The C++11 initializer list feature.

--HG--
branch : feature
This commit is contained in:
dismine 2014-05-30 12:52:19 +03:00
parent 18307e0a14
commit dce41a864f
8 changed files with 29 additions and 51 deletions

View File

@ -136,8 +136,7 @@ void DialogStandardMeasurements::CheckState()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogStandardMeasurements::LoadStandardTables() void DialogStandardMeasurements::LoadStandardTables()
{ {
QStringList filters; QStringList filters{"*.vst"};
filters << "*.vst";
QDir tablesDir(qApp->pathToTables()); QDir tablesDir(qApp->pathToTables());
tablesDir.setNameFilters(filters); tablesDir.setNameFilters(filters);
tablesDir.setCurrent(qApp->pathToTables()); tablesDir.setCurrent(qApp->pathToTables());

View File

@ -784,9 +784,8 @@ void MainWindow::ToolBarOption()
{ {
ui->toolBarOption->addWidget(new QLabel(tr("Height: "))); ui->toolBarOption->addWidget(new QLabel(tr("Height: ")));
QStringList list; QStringList list{"92", "98", "104", "110", "116", "122", "128", "134", "140", "146", "152", "158", "164", "170",
list <<"92"<<"98"<<"104"<<"110"<<"116"<<"122"<<"128"<<"134"<<"140"<<"146"<<"152"<<"158"<<"164"<<"170"<<"176" "176", "182", "188"};
<<"182"<<"188";
QComboBox *comboBoxHeight = new QComboBox; QComboBox *comboBoxHeight = new QComboBox;
comboBoxHeight->addItems(list); comboBoxHeight->addItems(list);
comboBoxHeight->setCurrentIndex(14);//176 comboBoxHeight->setCurrentIndex(14);//176

View File

@ -228,8 +228,7 @@ void TableWindow::saveScene()
shadowPaper->setVisible(false); shadowPaper->setVisible(false);
paper->setPen(QPen(Qt::white, 0.1, Qt::NoPen)); paper->setPen(QPen(Qt::white, 0.1, Qt::NoPen));
QFileInfo fi( name ); QFileInfo fi( name );
QStringList suffix; QStringList suffix{"svg", "png", "pdf", "eps", "ps"};
suffix << "svg" << "png" << "pdf" << "eps" << "ps";
switch (suffix.indexOf(fi.suffix())) switch (suffix.indexOf(fi.suffix()))
{ {
case 0: //svg case 0: //svg
@ -510,10 +509,7 @@ void TableWindow::EpsFile(const QString &name) const
if (tmp.open()) if (tmp.open())
{ {
PdfFile(tmp.fileName()); PdfFile(tmp.fileName());
QStringList params{"-eps", tmp.fileName(), name};
QStringList params;
params << "-eps" << tmp.fileName() << name;
PdfToPs(params); PdfToPs(params);
} }
} }
@ -525,10 +521,7 @@ void TableWindow::PsFile(const QString &name) const
if (tmp.open()) if (tmp.open())
{ {
PdfFile(tmp.fileName()); PdfFile(tmp.fileName());
QStringList params{tmp.fileName(), name};
QStringList params;
params << tmp.fileName() << name;
PdfToPs(params); PdfToPs(params);
} }
} }

View File

@ -309,9 +309,8 @@ void VAbstractTool::LineCoefficients(const QLineF &line, qreal *a, qreal *b, qre
const QStringList VAbstractTool::Styles() const QStringList VAbstractTool::Styles()
{ {
//Keep synchronize with DialogTool lineStyles list!!! //Keep synchronize with DialogTool lineStyles list!!!
QStringList styles; QStringList styles{TypeLineNone, TypeLineLine, TypeLineDashLine, TypeLineDotLine, TypeLineDashDotLine,
styles << TypeLineNone << TypeLineLine << TypeLineDashLine << TypeLineDotLine << TypeLineDashDotLine TypeLineDashDotDotLine};
<< TypeLineDashDotDotLine;
return styles; return styles;
} }

View File

@ -338,8 +338,7 @@ void VDomDocument::setContent(const QString &fileName)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
Valentina::Units VDomDocument::StrToUnits(const QString &unit) Valentina::Units VDomDocument::StrToUnits(const QString &unit)
{ {
QStringList units; QStringList units{UnitMM, UnitCM, UnitINCH};
units << UnitMM << UnitCM << UnitINCH;
Valentina::Units result = Valentina::Cm; Valentina::Units result = Valentina::Cm;
switch (units.indexOf(unit)) switch (units.indexOf(unit))
{ {

View File

@ -305,8 +305,7 @@ QString VIndividualMeasurements::GenderToStr(const VIndividualMeasurements::Gend
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VIndividualMeasurements::Genders VIndividualMeasurements::StrToGender(const QString &sex) VIndividualMeasurements::Genders VIndividualMeasurements::StrToGender(const QString &sex)
{ {
QStringList genders; QStringList genders{SexMale, SexFemale};
genders << SexMale << SexFemale;
switch (genders.indexOf(sex)) switch (genders.indexOf(sex))
{ {
case 0: // SexMale case 0: // SexMale

View File

@ -214,9 +214,8 @@ void VPattern::Parse(const Document::Documents &parse, VMainGraphicsScene *scene
const QDomElement domElement = domNode.toElement(); const QDomElement domElement = domNode.toElement();
if (domElement.isNull() == false) if (domElement.isNull() == false)
{ {
QStringList tags; QStringList tags{TagDraw, TagIncrements, TagAuthor, TagDescription, TagNotes, TagMeasurements,
tags << TagDraw << TagIncrements << TagAuthor << TagDescription << TagNotes << TagMeasurements TagVersion};
<< TagVersion;
switch (tags.indexOf(domElement.tagName())) switch (tags.indexOf(domElement.tagName()))
{ {
case 0: // TagDraw case 0: // TagDraw
@ -487,8 +486,7 @@ Valentina::Units VPattern::MUnit() const
QDomElement element = list.at(0).toElement(); QDomElement element = list.at(0).toElement();
if (element.isElement()) if (element.isElement())
{ {
QStringList units; QStringList units{"mm", "cm", "inch"};
units << "mm" << "cm" << "inch";
QString unit = GetParametrString(element, AttrUnit); QString unit = GetParametrString(element, AttrUnit);
switch (units.indexOf(unit)) switch (units.indexOf(unit))
{ {
@ -520,8 +518,7 @@ Pattern::Measurements VPattern::MType() const
if (element.isElement()) if (element.isElement())
{ {
QString type = GetParametrString(element, AttrType); QString type = GetParametrString(element, AttrType);
QStringList types; QStringList types{"standard", "individual"};
types << "standard" << "individual";
switch (types.indexOf(type)) switch (types.indexOf(type))
{ {
case 0:// standard case 0:// standard
@ -613,8 +610,7 @@ void VPattern::ParseDrawElement(VMainGraphicsScene *sceneDraw, VMainGraphicsScen
const QDomElement domElement = domNode.toElement(); const QDomElement domElement = domNode.toElement();
if (domElement.isNull() == false) if (domElement.isNull() == false)
{ {
QStringList tags; QStringList tags{TagCalculation, TagModeling, TagDetails};
tags << TagCalculation << TagModeling << TagDetails;
switch (tags.indexOf(domElement.tagName())) switch (tags.indexOf(domElement.tagName()))
{ {
case 0: // TagCalculation case 0: // TagCalculation
@ -659,8 +655,7 @@ void VPattern::ParseDrawMode(VMainGraphicsScene *sceneDraw, VMainGraphicsScene *
QDomElement domElement = nodeList.at(i).toElement(); QDomElement domElement = nodeList.at(i).toElement();
if (domElement.isNull() == false) if (domElement.isNull() == false)
{ {
QStringList tags; QStringList tags{TagPoint, TagLine, TagSpline, TagArc, TagTools};
tags << TagPoint << TagLine << TagSpline << TagArc << TagTools;
switch (tags.indexOf(domElement.tagName())) switch (tags.indexOf(domElement.tagName()))
{ {
case 0: // TagPoint case 0: // TagPoint
@ -719,9 +714,8 @@ void VPattern::ParseDetailElement(VMainGraphicsScene *sceneDetail, const QDomEle
const QString t = GetParametrString(element, AttrType, "NodePoint"); const QString t = GetParametrString(element, AttrType, "NodePoint");
Valentina::Tools tool; Valentina::Tools tool;
QStringList types; QStringList types{VToolDetail::NodePoint, VToolDetail::NodeArc, VToolDetail::NodeSpline,
types << VToolDetail::NodePoint << VToolDetail::NodeArc << VToolDetail::NodeSpline << VToolDetail::NodeSplinePath};
VToolDetail::NodeSplinePath;
switch (types.indexOf(t)) switch (types.indexOf(t))
{ {
case 0: // VToolDetail::NodePoint case 0: // VToolDetail::NodePoint
@ -787,12 +781,11 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem
Q_ASSERT_X(type.isEmpty() == false, Q_FUNC_INFO, "type of point is empty"); Q_ASSERT_X(type.isEmpty() == false, Q_FUNC_INFO, "type of point is empty");
QStringList points; QStringList points{VToolSinglePoint::ToolType, VToolEndLine::ToolType, VToolAlongLine::ToolType,
points << VToolSinglePoint::ToolType << VToolEndLine::ToolType << VToolAlongLine::ToolType VToolShoulderPoint::ToolType, VToolNormal::ToolType, VToolBisector::ToolType,
<< VToolShoulderPoint::ToolType << VToolNormal::ToolType << VToolBisector::ToolType VToolLineIntersect::ToolType, VToolPointOfContact::ToolType, VNodePoint::ToolType,
<< VToolLineIntersect::ToolType << VToolPointOfContact::ToolType << VNodePoint::ToolType VToolHeight::ToolType, VToolTriangle::ToolType, VToolPointOfIntersection::ToolType,
<< VToolHeight::ToolType << VToolTriangle::ToolType << VToolPointOfIntersection::ToolType VToolCutSpline::ToolType, VToolCutSplinePath::ToolType, VToolCutArc::ToolType};
<< VToolCutSpline::ToolType << VToolCutSplinePath::ToolType << VToolCutArc::ToolType;
switch (points.indexOf(type)) switch (points.indexOf(type))
{ {
case 0: //VToolSinglePoint::ToolType case 0: //VToolSinglePoint::ToolType
@ -1256,8 +1249,8 @@ void VPattern::ParseSplineElement(VMainGraphicsScene *scene, const QDomElement &
Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null"); Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null");
Q_ASSERT_X(type.isEmpty() == false, Q_FUNC_INFO, "type of spline is empty"); Q_ASSERT_X(type.isEmpty() == false, Q_FUNC_INFO, "type of spline is empty");
QStringList splines; QStringList splines{VToolSpline::ToolType, VToolSplinePath::ToolType, VNodeSpline::ToolType,
splines << VToolSpline::ToolType << VToolSplinePath::ToolType << VNodeSpline::ToolType << VNodeSplinePath::ToolType; VNodeSplinePath::ToolType};
switch (splines.indexOf(type)) switch (splines.indexOf(type))
{ {
case 0: //VToolSpline::ToolType case 0: //VToolSpline::ToolType
@ -1378,8 +1371,7 @@ void VPattern::ParseArcElement(VMainGraphicsScene *scene, const QDomElement &dom
Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null"); Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null");
Q_ASSERT_X(type.isEmpty() == false, Q_FUNC_INFO, "type of spline is empty"); Q_ASSERT_X(type.isEmpty() == false, Q_FUNC_INFO, "type of spline is empty");
QStringList arcs; QStringList arcs{VToolArc::ToolType, VNodeArc::ToolType};
arcs << VToolArc::ToolType << VNodeArc::ToolType;
switch (arcs.indexOf(type)) switch (arcs.indexOf(type))
{ {
@ -1442,8 +1434,7 @@ void VPattern::ParseToolsElement(VMainGraphicsScene *scene, const QDomElement &d
Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null"); Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null");
Q_ASSERT_X(type.isEmpty() == false, Q_FUNC_INFO, "type of spline is empty"); Q_ASSERT_X(type.isEmpty() == false, Q_FUNC_INFO, "type of spline is empty");
QStringList tools; QStringList tools{VToolUnionDetails::ToolType};
tools << VToolUnionDetails::ToolType;
switch (tools.indexOf(type)) switch (tools.indexOf(type))
{ {

View File

@ -50,9 +50,8 @@ bool QmuParserBase::g_DbgDumpStack = false;
* When defining custom binary operators with #AddOprt(...) make sure not to choose * When defining custom binary operators with #AddOprt(...) make sure not to choose
* names conflicting with these definitions. * names conflicting with these definitions.
*/ */
const QStringList QmuParserBase::c_DefaultOprt = QStringList() << "<=" << ">=" << "!=" << "==" << "<" << ">" const QStringList QmuParserBase::c_DefaultOprt{"<=", ">=", "!=", "==", "<", ">", "+", "-", "*", "/", "^", "&&", "||",
<< "+" << "-" << "*" << "/" << "^" << "&&" "=", "(", ")", "?", ":"};
<< "||" << "=" << "(" << ")" << "?" << ":";
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**