From dce41a864f5d82c31d72829a66fac2b2a9c0f71d Mon Sep 17 00:00:00 2001 From: dismine Date: Fri, 30 May 2014 12:52:19 +0300 Subject: [PATCH] The C++11 initializer list feature. --HG-- branch : feature --- .../app/dialogstandardmeasurements.cpp | 3 +- src/app/mainwindow.cpp | 5 +-- src/app/tablewindow.cpp | 13 ++---- src/app/tools/vabstracttool.cpp | 5 +-- src/app/xml/vdomdocument.cpp | 3 +- src/app/xml/vindividualmeasurements.cpp | 3 +- src/app/xml/vpattern.cpp | 43 ++++++++----------- src/libs/qmuparser/qmuparserbase.cpp | 5 +-- 8 files changed, 29 insertions(+), 51 deletions(-) diff --git a/src/app/dialogs/app/dialogstandardmeasurements.cpp b/src/app/dialogs/app/dialogstandardmeasurements.cpp index bc8a538c4..01d2b10dd 100644 --- a/src/app/dialogs/app/dialogstandardmeasurements.cpp +++ b/src/app/dialogs/app/dialogstandardmeasurements.cpp @@ -136,8 +136,7 @@ void DialogStandardMeasurements::CheckState() //--------------------------------------------------------------------------------------------------------------------- void DialogStandardMeasurements::LoadStandardTables() { - QStringList filters; - filters << "*.vst"; + QStringList filters{"*.vst"}; QDir tablesDir(qApp->pathToTables()); tablesDir.setNameFilters(filters); tablesDir.setCurrent(qApp->pathToTables()); diff --git a/src/app/mainwindow.cpp b/src/app/mainwindow.cpp index 85010b170..e0ed7f41f 100644 --- a/src/app/mainwindow.cpp +++ b/src/app/mainwindow.cpp @@ -784,9 +784,8 @@ void MainWindow::ToolBarOption() { ui->toolBarOption->addWidget(new QLabel(tr("Height: "))); - QStringList list; - list <<"92"<<"98"<<"104"<<"110"<<"116"<<"122"<<"128"<<"134"<<"140"<<"146"<<"152"<<"158"<<"164"<<"170"<<"176" - <<"182"<<"188"; + QStringList list{"92", "98", "104", "110", "116", "122", "128", "134", "140", "146", "152", "158", "164", "170", + "176", "182", "188"}; QComboBox *comboBoxHeight = new QComboBox; comboBoxHeight->addItems(list); comboBoxHeight->setCurrentIndex(14);//176 diff --git a/src/app/tablewindow.cpp b/src/app/tablewindow.cpp index 87c4801f0..64e5af6eb 100644 --- a/src/app/tablewindow.cpp +++ b/src/app/tablewindow.cpp @@ -228,8 +228,7 @@ void TableWindow::saveScene() shadowPaper->setVisible(false); paper->setPen(QPen(Qt::white, 0.1, Qt::NoPen)); QFileInfo fi( name ); - QStringList suffix; - suffix << "svg" << "png" << "pdf" << "eps" << "ps"; + QStringList suffix{"svg", "png", "pdf", "eps", "ps"}; switch (suffix.indexOf(fi.suffix())) { case 0: //svg @@ -510,10 +509,7 @@ void TableWindow::EpsFile(const QString &name) const if (tmp.open()) { PdfFile(tmp.fileName()); - - QStringList params; - params << "-eps" << tmp.fileName() << name; - + QStringList params{"-eps", tmp.fileName(), name}; PdfToPs(params); } } @@ -525,10 +521,7 @@ void TableWindow::PsFile(const QString &name) const if (tmp.open()) { PdfFile(tmp.fileName()); - - QStringList params; - params << tmp.fileName() << name; - + QStringList params{tmp.fileName(), name}; PdfToPs(params); } } diff --git a/src/app/tools/vabstracttool.cpp b/src/app/tools/vabstracttool.cpp index 523d702fe..ce800920d 100644 --- a/src/app/tools/vabstracttool.cpp +++ b/src/app/tools/vabstracttool.cpp @@ -309,9 +309,8 @@ void VAbstractTool::LineCoefficients(const QLineF &line, qreal *a, qreal *b, qre const QStringList VAbstractTool::Styles() { //Keep synchronize with DialogTool lineStyles list!!! - QStringList styles; - styles << TypeLineNone << TypeLineLine << TypeLineDashLine << TypeLineDotLine << TypeLineDashDotLine - << TypeLineDashDotDotLine; + QStringList styles{TypeLineNone, TypeLineLine, TypeLineDashLine, TypeLineDotLine, TypeLineDashDotLine, + TypeLineDashDotDotLine}; return styles; } diff --git a/src/app/xml/vdomdocument.cpp b/src/app/xml/vdomdocument.cpp index c65e1b50c..28bed1d6b 100644 --- a/src/app/xml/vdomdocument.cpp +++ b/src/app/xml/vdomdocument.cpp @@ -338,8 +338,7 @@ void VDomDocument::setContent(const QString &fileName) //--------------------------------------------------------------------------------------------------------------------- Valentina::Units VDomDocument::StrToUnits(const QString &unit) { - QStringList units; - units << UnitMM << UnitCM << UnitINCH; + QStringList units{UnitMM, UnitCM, UnitINCH}; Valentina::Units result = Valentina::Cm; switch (units.indexOf(unit)) { diff --git a/src/app/xml/vindividualmeasurements.cpp b/src/app/xml/vindividualmeasurements.cpp index 3ea2f8149..107784f50 100644 --- a/src/app/xml/vindividualmeasurements.cpp +++ b/src/app/xml/vindividualmeasurements.cpp @@ -305,8 +305,7 @@ QString VIndividualMeasurements::GenderToStr(const VIndividualMeasurements::Gend //--------------------------------------------------------------------------------------------------------------------- VIndividualMeasurements::Genders VIndividualMeasurements::StrToGender(const QString &sex) { - QStringList genders; - genders << SexMale << SexFemale; + QStringList genders{SexMale, SexFemale}; switch (genders.indexOf(sex)) { case 0: // SexMale diff --git a/src/app/xml/vpattern.cpp b/src/app/xml/vpattern.cpp index 2f09edae4..8a885a141 100644 --- a/src/app/xml/vpattern.cpp +++ b/src/app/xml/vpattern.cpp @@ -214,9 +214,8 @@ void VPattern::Parse(const Document::Documents &parse, VMainGraphicsScene *scene const QDomElement domElement = domNode.toElement(); if (domElement.isNull() == false) { - QStringList tags; - tags << TagDraw << TagIncrements << TagAuthor << TagDescription << TagNotes << TagMeasurements - << TagVersion; + QStringList tags{TagDraw, TagIncrements, TagAuthor, TagDescription, TagNotes, TagMeasurements, + TagVersion}; switch (tags.indexOf(domElement.tagName())) { case 0: // TagDraw @@ -487,8 +486,7 @@ Valentina::Units VPattern::MUnit() const QDomElement element = list.at(0).toElement(); if (element.isElement()) { - QStringList units; - units << "mm" << "cm" << "inch"; + QStringList units{"mm", "cm", "inch"}; QString unit = GetParametrString(element, AttrUnit); switch (units.indexOf(unit)) { @@ -520,8 +518,7 @@ Pattern::Measurements VPattern::MType() const if (element.isElement()) { QString type = GetParametrString(element, AttrType); - QStringList types; - types << "standard" << "individual"; + QStringList types{"standard", "individual"}; switch (types.indexOf(type)) { case 0:// standard @@ -613,8 +610,7 @@ void VPattern::ParseDrawElement(VMainGraphicsScene *sceneDraw, VMainGraphicsScen const QDomElement domElement = domNode.toElement(); if (domElement.isNull() == false) { - QStringList tags; - tags << TagCalculation << TagModeling << TagDetails; + QStringList tags{TagCalculation, TagModeling, TagDetails}; switch (tags.indexOf(domElement.tagName())) { case 0: // TagCalculation @@ -659,8 +655,7 @@ void VPattern::ParseDrawMode(VMainGraphicsScene *sceneDraw, VMainGraphicsScene * QDomElement domElement = nodeList.at(i).toElement(); if (domElement.isNull() == false) { - QStringList tags; - tags << TagPoint << TagLine << TagSpline << TagArc << TagTools; + QStringList tags{TagPoint, TagLine, TagSpline, TagArc, TagTools}; switch (tags.indexOf(domElement.tagName())) { case 0: // TagPoint @@ -719,9 +714,8 @@ void VPattern::ParseDetailElement(VMainGraphicsScene *sceneDetail, const QDomEle const QString t = GetParametrString(element, AttrType, "NodePoint"); Valentina::Tools tool; - QStringList types; - types << VToolDetail::NodePoint << VToolDetail::NodeArc << VToolDetail::NodeSpline << - VToolDetail::NodeSplinePath; + QStringList types{VToolDetail::NodePoint, VToolDetail::NodeArc, VToolDetail::NodeSpline, + VToolDetail::NodeSplinePath}; switch (types.indexOf(t)) { 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"); - QStringList points; - points << VToolSinglePoint::ToolType << VToolEndLine::ToolType << VToolAlongLine::ToolType - << VToolShoulderPoint::ToolType << VToolNormal::ToolType << VToolBisector::ToolType - << VToolLineIntersect::ToolType << VToolPointOfContact::ToolType << VNodePoint::ToolType - << VToolHeight::ToolType << VToolTriangle::ToolType << VToolPointOfIntersection::ToolType - << VToolCutSpline::ToolType << VToolCutSplinePath::ToolType << VToolCutArc::ToolType; + QStringList points{VToolSinglePoint::ToolType, VToolEndLine::ToolType, VToolAlongLine::ToolType, + VToolShoulderPoint::ToolType, VToolNormal::ToolType, VToolBisector::ToolType, + VToolLineIntersect::ToolType, VToolPointOfContact::ToolType, VNodePoint::ToolType, + VToolHeight::ToolType, VToolTriangle::ToolType, VToolPointOfIntersection::ToolType, + VToolCutSpline::ToolType, VToolCutSplinePath::ToolType, VToolCutArc::ToolType}; switch (points.indexOf(type)) { 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(type.isEmpty() == false, Q_FUNC_INFO, "type of spline is empty"); - QStringList splines; - splines << VToolSpline::ToolType << VToolSplinePath::ToolType << VNodeSpline::ToolType << VNodeSplinePath::ToolType; + QStringList splines{VToolSpline::ToolType, VToolSplinePath::ToolType, VNodeSpline::ToolType, + VNodeSplinePath::ToolType}; switch (splines.indexOf(type)) { 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(type.isEmpty() == false, Q_FUNC_INFO, "type of spline is empty"); - QStringList arcs; - arcs << VToolArc::ToolType << VNodeArc::ToolType; + QStringList arcs{VToolArc::ToolType, VNodeArc::ToolType}; 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(type.isEmpty() == false, Q_FUNC_INFO, "type of spline is empty"); - QStringList tools; - tools << VToolUnionDetails::ToolType; + QStringList tools{VToolUnionDetails::ToolType}; switch (tools.indexOf(type)) { diff --git a/src/libs/qmuparser/qmuparserbase.cpp b/src/libs/qmuparser/qmuparserbase.cpp index 21ff321df..6354c8b03 100644 --- a/src/libs/qmuparser/qmuparserbase.cpp +++ b/src/libs/qmuparser/qmuparserbase.cpp @@ -50,9 +50,8 @@ bool QmuParserBase::g_DbgDumpStack = false; * When defining custom binary operators with #AddOprt(...) make sure not to choose * names conflicting with these definitions. */ -const QStringList QmuParserBase::c_DefaultOprt = QStringList() << "<=" << ">=" << "!=" << "==" << "<" << ">" - << "+" << "-" << "*" << "/" << "^" << "&&" - << "||" << "=" << "(" << ")" << "?" << ":"; +const QStringList QmuParserBase::c_DefaultOprt{"<=", ">=", "!=", "==", "<", ">", "+", "-", "*", "/", "^", "&&", "||", + "=", "(", ")", "?", ":"}; //--------------------------------------------------------------------------------------------------------------------- /**