diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2023-02-24 14:51:41 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2023-02-28 11:24:56 +0000 |
commit | 91a5738af7f8f084292c979001dd7014cd42e796 (patch) | |
tree | a067f457b40892bd9cb40aaf52aae28421108fd0 | |
parent | 22023b770f6c20ef63e7b9824a76a1a605b93043 (diff) |
Use new string literals in graphgallery example
Task-number: QTBUG-110698
Change-Id: I110c297d08f6a24e402e514f36688b5bf4896c59
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
(cherry picked from commit 9c7c6e657ab848f5c252aa780a18e58ead3ee2f8)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
9 files changed, 169 insertions, 151 deletions
diff --git a/examples/datavisualization/graphgallery/bargraph.cpp b/examples/datavisualization/graphgallery/bargraph.cpp index 49269648..bdbd03a2 100644 --- a/examples/datavisualization/graphgallery/bargraph.cpp +++ b/examples/datavisualization/graphgallery/bargraph.cpp @@ -15,6 +15,8 @@ #include <QtWidgets/qbuttongroup.h> #include <QtGui/qfontdatabase.h> +using namespace Qt::StringLiterals; + BarGraph::BarGraph() { //! [0] @@ -52,92 +54,92 @@ bool BarGraph::initialize() //! [1] QComboBox *themeList = new QComboBox(m_barsWidget); - themeList->addItem(QStringLiteral("Qt")); - themeList->addItem(QStringLiteral("Primary Colors")); - themeList->addItem(QStringLiteral("Digia")); - themeList->addItem(QStringLiteral("Stone Moss")); - themeList->addItem(QStringLiteral("Army Blue")); - themeList->addItem(QStringLiteral("Retro")); - themeList->addItem(QStringLiteral("Ebony")); - themeList->addItem(QStringLiteral("Isabelle")); + themeList->addItem(u"Qt"_s); + themeList->addItem(u"Primary Colors"_s); + themeList->addItem(u"Digia"_s); + themeList->addItem(u"Stone Moss"_s); + themeList->addItem(u"Army Blue"_s); + themeList->addItem(u"Retro"_s); + themeList->addItem(u"Ebony"_s); + themeList->addItem(u"Isabelle"_s); themeList->setCurrentIndex(0); QPushButton *labelButton = new QPushButton(m_barsWidget); - labelButton->setText(QStringLiteral("Change label style")); + labelButton->setText(u"Change label style"_s); QCheckBox *smoothCheckBox = new QCheckBox(m_barsWidget); - smoothCheckBox->setText(QStringLiteral("Smooth bars")); + smoothCheckBox->setText(u"Smooth bars"_s); smoothCheckBox->setChecked(false); QComboBox *barStyleList = new QComboBox(m_barsWidget); - barStyleList->addItem(QStringLiteral("Bar"), int(QAbstract3DSeries::MeshBar)); - barStyleList->addItem(QStringLiteral("Pyramid"), int(QAbstract3DSeries::MeshPyramid)); - barStyleList->addItem(QStringLiteral("Cone"), int(QAbstract3DSeries::MeshCone)); - barStyleList->addItem(QStringLiteral("Cylinder"), int(QAbstract3DSeries::MeshCylinder)); - barStyleList->addItem(QStringLiteral("Bevel bar"), int(QAbstract3DSeries::MeshBevelBar)); - barStyleList->addItem(QStringLiteral("Sphere"), int(QAbstract3DSeries::MeshSphere)); + barStyleList->addItem(u"Bar"_s, int(QAbstract3DSeries::MeshBar)); + barStyleList->addItem(u"Pyramid"_s, int(QAbstract3DSeries::MeshPyramid)); + barStyleList->addItem(u"Cone"_s, int(QAbstract3DSeries::MeshCone)); + barStyleList->addItem(u"Cylinder"_s, int(QAbstract3DSeries::MeshCylinder)); + barStyleList->addItem(u"Bevel bar"_s, int(QAbstract3DSeries::MeshBevelBar)); + barStyleList->addItem(u"Sphere"_s, int(QAbstract3DSeries::MeshSphere)); barStyleList->setCurrentIndex(4); QPushButton *cameraButton = new QPushButton(m_barsWidget); - cameraButton->setText(QStringLiteral("Change camera preset")); + cameraButton->setText(u"Change camera preset"_s); QPushButton *zoomToSelectedButton = new QPushButton(m_barsWidget); - zoomToSelectedButton->setText(QStringLiteral("Zoom to selected bar")); + zoomToSelectedButton->setText(u"Zoom to selected bar"_s); QComboBox *selectionModeList = new QComboBox(m_barsWidget); - selectionModeList->addItem(QStringLiteral("None"), + selectionModeList->addItem(u"None"_s, int(QAbstract3DGraph::SelectionNone)); - selectionModeList->addItem(QStringLiteral("Bar"), + selectionModeList->addItem(u"Bar"_s, int(QAbstract3DGraph::SelectionItem)); - selectionModeList->addItem(QStringLiteral("Row"), + selectionModeList->addItem(u"Row"_s, int(QAbstract3DGraph::SelectionRow)); - selectionModeList->addItem(QStringLiteral("Bar and Row"), + selectionModeList->addItem(u"Bar and Row"_s, int(QAbstract3DGraph::SelectionItemAndRow)); - selectionModeList->addItem(QStringLiteral("Column"), + selectionModeList->addItem(u"Column"_s, int(QAbstract3DGraph::SelectionColumn)); - selectionModeList->addItem(QStringLiteral("Bar and Column"), + selectionModeList->addItem(u"Bar and Column"_s, int(QAbstract3DGraph::SelectionItemAndColumn)); - selectionModeList->addItem(QStringLiteral("Row and Column"), + selectionModeList->addItem(u"Row and Column"_s, int(QAbstract3DGraph::SelectionRowAndColumn)); - selectionModeList->addItem(QStringLiteral("Bar, Row and Column"), + selectionModeList->addItem(u"Bar, Row and Column"_s, int(QAbstract3DGraph::SelectionItemRowAndColumn)); - selectionModeList->addItem(QStringLiteral("Slice into Row"), + selectionModeList->addItem(u"Slice into Row"_s, int(QAbstract3DGraph::SelectionSlice | QAbstract3DGraph::SelectionRow)); - selectionModeList->addItem(QStringLiteral("Slice into Row and Item"), + selectionModeList->addItem(u"Slice into Row and Item"_s, int(QAbstract3DGraph::SelectionSlice | QAbstract3DGraph::SelectionItemAndRow)); - selectionModeList->addItem(QStringLiteral("Slice into Column"), + selectionModeList->addItem(u"Slice into Column"_s, int(QAbstract3DGraph::SelectionSlice | QAbstract3DGraph::SelectionColumn)); - selectionModeList->addItem(QStringLiteral("Slice into Column and Item"), + selectionModeList->addItem(u"Slice into Column and Item"_s, int(QAbstract3DGraph::SelectionSlice | QAbstract3DGraph::SelectionItemAndColumn)); - selectionModeList->addItem(QStringLiteral("Multi: Bar, Row, Col"), + selectionModeList->addItem(u"Multi: Bar, Row, Col"_s, int(QAbstract3DGraph::SelectionItemRowAndColumn | QAbstract3DGraph::SelectionMultiSeries)); - selectionModeList->addItem(QStringLiteral("Multi, Slice: Row, Item"), + selectionModeList->addItem(u"Multi, Slice: Row, Item"_s, int(QAbstract3DGraph::SelectionSlice | QAbstract3DGraph::SelectionItemAndRow | QAbstract3DGraph::SelectionMultiSeries)); - selectionModeList->addItem(QStringLiteral("Multi, Slice: Col, Item"), + selectionModeList->addItem(u"Multi, Slice: Col, Item"_s, int(QAbstract3DGraph::SelectionSlice | QAbstract3DGraph::SelectionItemAndColumn | QAbstract3DGraph::SelectionMultiSeries)); selectionModeList->setCurrentIndex(1); QCheckBox *backgroundCheckBox = new QCheckBox(m_barsWidget); - backgroundCheckBox->setText(QStringLiteral("Show background")); + backgroundCheckBox->setText(u"Show background"_s); backgroundCheckBox->setChecked(false); QCheckBox *gridCheckBox = new QCheckBox(m_barsWidget); - gridCheckBox->setText(QStringLiteral("Show grid")); + gridCheckBox->setText(u"Show grid"_s); gridCheckBox->setChecked(true); QCheckBox *seriesCheckBox = new QCheckBox(m_barsWidget); - seriesCheckBox->setText(QStringLiteral("Show second series")); + seriesCheckBox->setText(u"Show second series"_s); seriesCheckBox->setChecked(false); QCheckBox *reverseValueAxisCheckBox = new QCheckBox(m_barsWidget); - reverseValueAxisCheckBox->setText(QStringLiteral("Reverse value axis")); + reverseValueAxisCheckBox->setText(u"Reverse value axis"_s); reverseValueAxisCheckBox->setChecked(false); QCheckBox *reflectionCheckBox = new QCheckBox(m_barsWidget); - reflectionCheckBox->setText(QStringLiteral("Show reflections")); + reflectionCheckBox->setText(u"Show reflections"_s); reflectionCheckBox->setChecked(false); //! [3] @@ -166,33 +168,33 @@ bool BarGraph::initialize() fontList->setCurrentFont(QFont("Times New Roman")); QComboBox *shadowQuality = new QComboBox(m_barsWidget); - shadowQuality->addItem(QStringLiteral("None")); - shadowQuality->addItem(QStringLiteral("Low")); - shadowQuality->addItem(QStringLiteral("Medium")); - shadowQuality->addItem(QStringLiteral("High")); - shadowQuality->addItem(QStringLiteral("Low Soft")); - shadowQuality->addItem(QStringLiteral("Medium Soft")); - shadowQuality->addItem(QStringLiteral("High Soft")); + shadowQuality->addItem(u"None"_s); + shadowQuality->addItem(u"Low"_s); + shadowQuality->addItem(u"Medium"_s); + shadowQuality->addItem(u"High"_s); + shadowQuality->addItem(u"Low Soft"_s); + shadowQuality->addItem(u"Medium Soft"_s); + shadowQuality->addItem(u"High Soft"_s); shadowQuality->setCurrentIndex(5); QComboBox *rangeList = new QComboBox(m_barsWidget); - rangeList->addItem(QStringLiteral("2015")); - rangeList->addItem(QStringLiteral("2016")); - rangeList->addItem(QStringLiteral("2017")); - rangeList->addItem(QStringLiteral("2018")); - rangeList->addItem(QStringLiteral("2019")); - rangeList->addItem(QStringLiteral("2020")); - rangeList->addItem(QStringLiteral("2021")); - rangeList->addItem(QStringLiteral("2022")); - rangeList->addItem(QStringLiteral("All")); + rangeList->addItem(u"2015"_s); + rangeList->addItem(u"2016"_s); + rangeList->addItem(u"2017"_s); + rangeList->addItem(u"2018"_s); + rangeList->addItem(u"2019"_s); + rangeList->addItem(u"2020"_s); + rangeList->addItem(u"2021"_s); + rangeList->addItem(u"2022"_s); + rangeList->addItem(u"All"_s); rangeList->setCurrentIndex(8); QCheckBox *axisTitlesVisibleCB = new QCheckBox(m_barsWidget); - axisTitlesVisibleCB->setText(QStringLiteral("Axis titles visible")); + axisTitlesVisibleCB->setText(u"Axis titles visible"_s); axisTitlesVisibleCB->setChecked(true); QCheckBox *axisTitlesFixedCB = new QCheckBox(m_barsWidget); - axisTitlesFixedCB->setText(QStringLiteral("Axis titles fixed")); + axisTitlesFixedCB->setText(u"Axis titles fixed"_s); axisTitlesFixedCB->setChecked(true); QSlider *axisLabelRotationSlider = new QSlider(Qt::Horizontal, m_barsWidget); @@ -203,17 +205,17 @@ bool BarGraph::initialize() axisLabelRotationSlider->setMaximum(90); QButtonGroup *modeGroup = new QButtonGroup(m_barsWidget); - QRadioButton *modeWeather = new QRadioButton(QStringLiteral("Temperature Data"), m_barsWidget); + QRadioButton *modeWeather = new QRadioButton(u"Temperature Data"_s, m_barsWidget); modeWeather->setChecked(true); - QRadioButton *modeCustomProxy = new QRadioButton(QStringLiteral("Custom Proxy Data"), m_barsWidget); + QRadioButton *modeCustomProxy = new QRadioButton(u"Custom Proxy Data"_s, m_barsWidget); modeGroup->addButton(modeWeather); modeGroup->addButton(modeCustomProxy); //! [4] - vLayout->addWidget(new QLabel(QStringLiteral("Rotate horizontally"))); + vLayout->addWidget(new QLabel(u"Rotate horizontally"_s)); vLayout->addWidget(rotationSliderX, 0, Qt::AlignTop); //! [4] - vLayout->addWidget(new QLabel(QStringLiteral("Rotate vertically"))); + vLayout->addWidget(new QLabel(u"Rotate vertically"_s)); vLayout->addWidget(rotationSliderY, 0, Qt::AlignTop); vLayout->addWidget(labelButton, 0, Qt::AlignTop); vLayout->addWidget(cameraButton, 0, Qt::AlignTop); @@ -226,21 +228,21 @@ bool BarGraph::initialize() vLayout->addWidget(reverseValueAxisCheckBox); vLayout->addWidget(axisTitlesVisibleCB); vLayout->addWidget(axisTitlesFixedCB); - vLayout->addWidget(new QLabel(QStringLiteral("Show year"))); + vLayout->addWidget(new QLabel(u"Show year"_s)); vLayout->addWidget(rangeList); - vLayout->addWidget(new QLabel(QStringLiteral("Change bar style"))); + vLayout->addWidget(new QLabel(u"Change bar style"_s)); vLayout->addWidget(barStyleList); - vLayout->addWidget(new QLabel(QStringLiteral("Change selection mode"))); + vLayout->addWidget(new QLabel(u"Change selection mode"_s)); vLayout->addWidget(selectionModeList); - vLayout->addWidget(new QLabel(QStringLiteral("Change theme"))); + vLayout->addWidget(new QLabel(u"Change theme"_s)); vLayout->addWidget(themeList); - vLayout->addWidget(new QLabel(QStringLiteral("Adjust shadow quality"))); + vLayout->addWidget(new QLabel(u"Adjust shadow quality"_s)); vLayout->addWidget(shadowQuality); - vLayout->addWidget(new QLabel(QStringLiteral("Change font"))); + vLayout->addWidget(new QLabel(u"Change font"_s)); vLayout->addWidget(fontList); - vLayout->addWidget(new QLabel(QStringLiteral("Adjust font size"))); + vLayout->addWidget(new QLabel(u"Adjust font size"_s)); vLayout->addWidget(fontSizeSlider); - vLayout->addWidget(new QLabel(QStringLiteral("Axis label rotation"))); + vLayout->addWidget(new QLabel(u"Axis label rotation"_s)); vLayout->addWidget(axisLabelRotationSlider, 0, Qt::AlignTop); vLayout->addWidget(modeWeather, 0, Qt::AlignTop); vLayout->addWidget(modeCustomProxy, 1, Qt::AlignTop); diff --git a/examples/datavisualization/graphgallery/graphmodifier.cpp b/examples/datavisualization/graphgallery/graphmodifier.cpp index 2f79fa7a..19863889 100644 --- a/examples/datavisualization/graphgallery/graphmodifier.cpp +++ b/examples/datavisualization/graphgallery/graphmodifier.cpp @@ -14,18 +14,21 @@ #include <QtCore/qmath.h> #include <QtWidgets/qcombobox.h> +using namespace Qt::StringLiterals; + // TODO: Many of the values do not affect custom proxy series now - should be fixed //! [0] -GraphModifier::GraphModifier(Q3DBars *bargraph) - : m_graph(bargraph), +GraphModifier::GraphModifier(Q3DBars *bargraph) : + m_graph(bargraph), //! [0] //! [1] m_temperatureAxis(new QValue3DAxis), m_yearAxis(new QCategory3DAxis), m_monthAxis(new QCategory3DAxis), m_primarySeries(new QBar3DSeries), - m_secondarySeries(new QBar3DSeries) + m_secondarySeries(new QBar3DSeries), + m_celsiusString(u"°C"_s) //! [1] { //! [2] @@ -45,7 +48,7 @@ GraphModifier::GraphModifier(Q3DBars *bargraph) m_temperatureAxis->setSegmentCount(m_segments); m_temperatureAxis->setSubSegmentCount(m_subSegments); m_temperatureAxis->setRange(m_minval, m_maxval); - m_temperatureAxis->setLabelFormat(QString(QStringLiteral("%.1f ") + m_celsiusString)); + m_temperatureAxis->setLabelFormat(u"%.1f "_s + m_celsiusString); m_temperatureAxis->setLabelAutoRotation(30.0f); m_temperatureAxis->setTitleVisible(true); @@ -62,11 +65,11 @@ GraphModifier::GraphModifier(Q3DBars *bargraph) //! [3] //! [4] - m_primarySeries->setItemLabelFormat(QStringLiteral("Oulu - @colLabel @rowLabel: @valueLabel")); + m_primarySeries->setItemLabelFormat(u"Oulu - @colLabel @rowLabel: @valueLabel"_s); m_primarySeries->setMesh(QAbstract3DSeries::MeshBevelBar); m_primarySeries->setMeshSmooth(false); - m_secondarySeries->setItemLabelFormat(QStringLiteral("Helsinki - @colLabel @rowLabel: @valueLabel")); + m_secondarySeries->setItemLabelFormat(u"Helsinki - @colLabel @rowLabel: @valueLabel"_s); m_secondarySeries->setMesh(QAbstract3DSeries::MeshBevelBar); m_secondarySeries->setMeshSmooth(false); m_secondarySeries->setVisible(false); diff --git a/examples/datavisualization/graphgallery/graphmodifier.h b/examples/datavisualization/graphgallery/graphmodifier.h index 09110768..deba00c5 100644 --- a/examples/datavisualization/graphgallery/graphmodifier.h +++ b/examples/datavisualization/graphgallery/graphmodifier.h @@ -80,7 +80,7 @@ private: float m_defaultAngleY = 0.f; float m_defaultZoom = 0.f; QVector3D m_defaultTarget = {}; - const QString m_celsiusString = QString(QChar(0xB0)) + QLatin1String("C"); + const QString m_celsiusString; RainfallData *m_customData = nullptr; }; diff --git a/examples/datavisualization/graphgallery/main.cpp b/examples/datavisualization/graphgallery/main.cpp index 88000d28..efe8ecbd 100644 --- a/examples/datavisualization/graphgallery/main.cpp +++ b/examples/datavisualization/graphgallery/main.cpp @@ -9,6 +9,8 @@ #include <QtWidgets/qwidget.h> #include <QtWidgets/qtabwidget.h> +using namespace Qt::StringLiterals; + int main(int argc, char **argv) { qputenv("QSG_RHI_BACKEND", "opengl"); @@ -32,14 +34,14 @@ int main(int argc, char **argv) // Create a tab widget for creating own tabs for Q3DBars, Q3DScatter, and Q3DSurface QTabWidget tabWidget; - tabWidget.setWindowTitle(QLatin1String("Graph Gallery")); + tabWidget.setWindowTitle(u"Graph Gallery"_s); // Add bars widget - tabWidget.addTab(bars.barsWidget(), QLatin1String("Bar Graph")); + tabWidget.addTab(bars.barsWidget(), u"Bar Graph"_s); // Add scatter widget - tabWidget.addTab(scatter.scatterWidget(), QLatin1String("Scatter Graph")); + tabWidget.addTab(scatter.scatterWidget(), u"Scatter Graph"_s); // Add surface widget - tabWidget.addTab(surface.surfaceWidget(), QLatin1String("Surface Graph")); + tabWidget.addTab(surface.surfaceWidget(), u"Surface Graph"_s); tabWidget.show(); return app.exec(); diff --git a/examples/datavisualization/graphgallery/rainfalldata.cpp b/examples/datavisualization/graphgallery/rainfalldata.cpp index 498e09ae..8765db2c 100644 --- a/examples/datavisualization/graphgallery/rainfalldata.cpp +++ b/examples/datavisualization/graphgallery/rainfalldata.cpp @@ -9,6 +9,8 @@ #include <QtCore/qtextstream.h> #include <QtCore/qfile.h> +using namespace Qt::StringLiterals; + RainfallData::RainfallData() { // In data file the months are in numeric format, so create custom list @@ -25,7 +27,7 @@ RainfallData::RainfallData() m_series = new QBar3DSeries(m_proxy); //! [0] - m_series->setItemLabelFormat(QString(QStringLiteral("%.1f mm"))); + m_series->setItemLabelFormat(u"%.1f mm"_s); // Create the axes m_rowAxis = new QCategory3DAxis(this); diff --git a/examples/datavisualization/graphgallery/scatterdatamodifier.cpp b/examples/datavisualization/graphgallery/scatterdatamodifier.cpp index 9b61ab24..edb4cbd4 100644 --- a/examples/datavisualization/graphgallery/scatterdatamodifier.cpp +++ b/examples/datavisualization/graphgallery/scatterdatamodifier.cpp @@ -12,6 +12,8 @@ #include <QtCore/qrandom.h> #include <QtWidgets/qcombobox.h> +using namespace Qt::StringLiterals; + //#define RANDOM_SCATTER // Uncomment this to switch to random scatter const int numberOfItems = 10000; @@ -37,7 +39,7 @@ ScatterDataModifier::ScatterDataModifier(Q3DScatter *scatter) //! [1] QScatterDataProxy *proxy = new QScatterDataProxy; QScatter3DSeries *series = new QScatter3DSeries(proxy); - series->setItemLabelFormat(QStringLiteral("@xTitle: @xLabel @yTitle: @yLabel @zTitle: @zLabel")); + series->setItemLabelFormat(u"@xTitle: @xLabel @yTitle: @yLabel @zTitle: @zLabel"_s); series->setMeshSmooth(m_smooth); m_graph->addSeries(series); //! [1] diff --git a/examples/datavisualization/graphgallery/scattergraph.cpp b/examples/datavisualization/graphgallery/scattergraph.cpp index b841a585..baab4663 100644 --- a/examples/datavisualization/graphgallery/scattergraph.cpp +++ b/examples/datavisualization/graphgallery/scattergraph.cpp @@ -11,6 +11,8 @@ #include <QtWidgets/qmessagebox.h> #include <QtWidgets/qcommandlinkbutton.h> +using namespace Qt::StringLiterals; + ScatterGraph::ScatterGraph() { m_scatterGraph = new Q3DScatter(); @@ -44,58 +46,58 @@ bool ScatterGraph::initialize() hLayout->addLayout(vLayout); QCommandLinkButton *cameraButton = new QCommandLinkButton(m_scatterWidget); - cameraButton->setText(QStringLiteral("Change camera preset")); - cameraButton->setDescription(QStringLiteral("Switch between a number of preset camera positions")); + cameraButton->setText(u"Change camera preset"_s); + cameraButton->setDescription(u"Switch between a number of preset camera positions"_s); cameraButton->setIconSize(QSize(0, 0)); QCommandLinkButton *itemCountButton = new QCommandLinkButton(m_scatterWidget); - itemCountButton->setText(QStringLiteral("Toggle item count")); - itemCountButton->setDescription(QStringLiteral("Switch between 900 and 10000 data points")); + itemCountButton->setText(u"Toggle item count"_s); + itemCountButton->setDescription(u"Switch between 900 and 10000 data points"_s); itemCountButton->setIconSize(QSize(0, 0)); QCommandLinkButton *rangeButton = new QCommandLinkButton(m_scatterWidget); - rangeButton->setText(QStringLiteral("Toggle axis ranges")); - rangeButton->setDescription(QStringLiteral("Switch between automatic axis ranges and preset ranges")); + rangeButton->setText(u"Toggle axis ranges"_s); + rangeButton->setDescription(u"Switch between automatic axis ranges and preset ranges"_s); rangeButton->setIconSize(QSize(0, 0)); QCheckBox *backgroundCheckBox = new QCheckBox(m_scatterWidget); - backgroundCheckBox->setText(QStringLiteral("Show background")); + backgroundCheckBox->setText(u"Show background"_s); backgroundCheckBox->setChecked(true); QCheckBox *gridCheckBox = new QCheckBox(m_scatterWidget); - gridCheckBox->setText(QStringLiteral("Show grid")); + gridCheckBox->setText(u"Show grid"_s); gridCheckBox->setChecked(true); QCheckBox *smoothCheckBox = new QCheckBox(m_scatterWidget); - smoothCheckBox->setText(QStringLiteral("Smooth dots")); + smoothCheckBox->setText(u"Smooth dots"_s); smoothCheckBox->setChecked(true); QComboBox *itemStyleList = new QComboBox(m_scatterWidget); - itemStyleList->addItem(QStringLiteral("Sphere"), int(QAbstract3DSeries::MeshSphere)); - itemStyleList->addItem(QStringLiteral("Cube"), int(QAbstract3DSeries::MeshCube)); - itemStyleList->addItem(QStringLiteral("Minimal"), int(QAbstract3DSeries::MeshMinimal)); - itemStyleList->addItem(QStringLiteral("Point"), int(QAbstract3DSeries::MeshPoint)); + itemStyleList->addItem(u"Sphere"_s, int(QAbstract3DSeries::MeshSphere)); + itemStyleList->addItem(u"Cube"_s, int(QAbstract3DSeries::MeshCube)); + itemStyleList->addItem(u"Minimal"_s, int(QAbstract3DSeries::MeshMinimal)); + itemStyleList->addItem(u"Point"_s, int(QAbstract3DSeries::MeshPoint)); itemStyleList->setCurrentIndex(0); QComboBox *themeList = new QComboBox(m_scatterWidget); - themeList->addItem(QStringLiteral("Qt")); - themeList->addItem(QStringLiteral("Primary Colors")); - themeList->addItem(QStringLiteral("Digia")); - themeList->addItem(QStringLiteral("Stone Moss")); - themeList->addItem(QStringLiteral("Army Blue")); - themeList->addItem(QStringLiteral("Retro")); - themeList->addItem(QStringLiteral("Ebony")); - themeList->addItem(QStringLiteral("Isabelle")); + themeList->addItem(u"Qt"_s); + themeList->addItem(u"Primary Colors"_s); + themeList->addItem(u"Digia"_s); + themeList->addItem(u"Stone Moss"_s); + themeList->addItem(u"Army Blue"_s); + themeList->addItem(u"Retro"_s); + themeList->addItem(u"Ebony"_s); + themeList->addItem(u"Isabelle"_s); themeList->setCurrentIndex(3); QComboBox *shadowQuality = new QComboBox(m_scatterWidget); - shadowQuality->addItem(QStringLiteral("None")); - shadowQuality->addItem(QStringLiteral("Low")); - shadowQuality->addItem(QStringLiteral("Medium")); - shadowQuality->addItem(QStringLiteral("High")); - shadowQuality->addItem(QStringLiteral("Low Soft")); - shadowQuality->addItem(QStringLiteral("Medium Soft")); - shadowQuality->addItem(QStringLiteral("High Soft")); + shadowQuality->addItem(u"None"_s); + shadowQuality->addItem(u"Low"_s); + shadowQuality->addItem(u"Medium"_s); + shadowQuality->addItem(u"High"_s); + shadowQuality->addItem(u"Low Soft"_s); + shadowQuality->addItem(u"Medium Soft"_s); + shadowQuality->addItem(u"High Soft"_s); shadowQuality->setCurrentIndex(6); vLayout->addWidget(cameraButton); @@ -104,11 +106,11 @@ bool ScatterGraph::initialize() vLayout->addWidget(backgroundCheckBox); vLayout->addWidget(gridCheckBox); vLayout->addWidget(smoothCheckBox); - vLayout->addWidget(new QLabel(QStringLiteral("Change dot style"))); + vLayout->addWidget(new QLabel(u"Change dot style"_s)); vLayout->addWidget(itemStyleList); - vLayout->addWidget(new QLabel(QStringLiteral("Change theme"))); + vLayout->addWidget(new QLabel(u"Change theme"_s)); vLayout->addWidget(themeList); - vLayout->addWidget(new QLabel(QStringLiteral("Adjust shadow quality"))); + vLayout->addWidget(new QLabel(u"Adjust shadow quality"_s)); vLayout->addWidget(shadowQuality, 1, Qt::AlignTop); ScatterDataModifier *modifier = new ScatterDataModifier(m_scatterGraph); diff --git a/examples/datavisualization/graphgallery/surfacegraph.cpp b/examples/datavisualization/graphgallery/surfacegraph.cpp index 5731e5a2..6caf49e1 100644 --- a/examples/datavisualization/graphgallery/surfacegraph.cpp +++ b/examples/datavisualization/graphgallery/surfacegraph.cpp @@ -14,6 +14,8 @@ #include <QtWidgets/qcommandlinkbutton.h> #include <QtGui/qpainter.h> +using namespace Qt::StringLiterals; + SurfaceGraph::SurfaceGraph() { m_surfaceGraph = new Q3DSurface(); @@ -48,18 +50,18 @@ bool SurfaceGraph::initialize() vLayout->setAlignment(Qt::AlignTop); // Create control widgets - QGroupBox *modelGroupBox = new QGroupBox(QLatin1String("Model")); + QGroupBox *modelGroupBox = new QGroupBox(u"Model"_s); QRadioButton *sqrtSinModelRB = new QRadioButton(m_surfaceWidget); - sqrtSinModelRB->setText(QLatin1String("Sqrt && Sin")); + sqrtSinModelRB->setText(u"_sqrt && Sin"_s); sqrtSinModelRB->setChecked(false); QRadioButton *heightMapModelRB = new QRadioButton(m_surfaceWidget); - heightMapModelRB->setText(QLatin1String("Multiseries\nHeight Map")); + heightMapModelRB->setText(u"Multiseries\nHeight Map"_s); heightMapModelRB->setChecked(false); QRadioButton *texturedModelRB = new QRadioButton(m_surfaceWidget); - texturedModelRB->setText(QLatin1String("Textured\nTopography")); + texturedModelRB->setText(u"Textured\nTopography"_s); texturedModelRB->setChecked(false); QVBoxLayout *modelVBox = new QVBoxLayout; @@ -68,22 +70,22 @@ bool SurfaceGraph::initialize() modelVBox->addWidget(texturedModelRB); modelGroupBox->setLayout(modelVBox); - QGroupBox *selectionGroupBox = new QGroupBox(QLatin1String("Graph Selection Mode")); + QGroupBox *selectionGroupBox = new QGroupBox(u"Graph Selection Mode"_s); QRadioButton *modeNoneRB = new QRadioButton(m_surfaceWidget); - modeNoneRB->setText(QLatin1String("No selection")); + modeNoneRB->setText(u"No selection"_s); modeNoneRB->setChecked(false); QRadioButton *modeItemRB = new QRadioButton(m_surfaceWidget); - modeItemRB->setText(QLatin1String("Item")); + modeItemRB->setText(u"Item"_s); modeItemRB->setChecked(false); QRadioButton *modeSliceRowRB = new QRadioButton(m_surfaceWidget); - modeSliceRowRB->setText(QLatin1String("Row Slice")); + modeSliceRowRB->setText(u"Row Slice"_s); modeSliceRowRB->setChecked(false); QRadioButton *modeSliceColumnRB = new QRadioButton(m_surfaceWidget); - modeSliceColumnRB->setText(QLatin1String("Column Slice")); + modeSliceColumnRB->setText(u"Column Slice"_s); modeSliceColumnRB->setChecked(false); QVBoxLayout *selectionVBox = new QVBoxLayout; @@ -93,7 +95,7 @@ bool SurfaceGraph::initialize() selectionVBox->addWidget(modeSliceColumnRB); selectionGroupBox->setLayout(selectionVBox); - QGroupBox *axisGroupBox = new QGroupBox(QLatin1String("Axis ranges")); + QGroupBox *axisGroupBox = new QGroupBox(u"Axis ranges"_s); QSlider *axisMinSliderX = new QSlider(Qt::Horizontal); axisMinSliderX->setMinimum(0); @@ -113,17 +115,17 @@ bool SurfaceGraph::initialize() axisMaxSliderZ->setEnabled(true); QVBoxLayout *axisVBox = new QVBoxLayout; - axisVBox->addWidget(new QLabel(QLatin1String("Column range"))); + axisVBox->addWidget(new QLabel(u"Column range"_s)); axisVBox->addWidget(axisMinSliderX); axisVBox->addWidget(axisMaxSliderX); - axisVBox->addWidget(new QLabel(QLatin1String("Row range"))); + axisVBox->addWidget(new QLabel(u"Row range"_s)); axisVBox->addWidget(axisMinSliderZ); axisVBox->addWidget(axisMaxSliderZ); axisGroupBox->setLayout(axisVBox); // Mode-dependent controls // sqrt-sin - QGroupBox *colorGroupBox = new QGroupBox(QLatin1String("Custom gradient")); + QGroupBox *colorGroupBox = new QGroupBox(u"Custom gradient"_s); QLinearGradient grBtoY(0, 0, 1, 100); grBtoY.setColorAt(1.f, Qt::black); @@ -156,16 +158,16 @@ bool SurfaceGraph::initialize() colorGroupBox->setLayout(colorHBox); // Multiseries heightmap - QGroupBox *showGroupBox = new QGroupBox(QLatin1String("Show Object")); + QGroupBox *showGroupBox = new QGroupBox(u"_show Object"_s); showGroupBox->setVisible(false); - QCheckBox *checkboxShowOilRigOne = new QCheckBox(QLatin1String("Oil Rig 1")); + QCheckBox *checkboxShowOilRigOne = new QCheckBox(u"Oil Rig 1"_s); checkboxShowOilRigOne->setChecked(true); - QCheckBox *checkboxShowOilRigTwo = new QCheckBox(QLatin1String("Oil Rig 2")); + QCheckBox *checkboxShowOilRigTwo = new QCheckBox(u"Oil Rig 2"_s); checkboxShowOilRigTwo->setChecked(true); - QCheckBox *checkboxShowRefinery = new QCheckBox(QLatin1String("Refinery")); + QCheckBox *checkboxShowRefinery = new QCheckBox(u"Refinery"_s); QVBoxLayout *showVBox = new QVBoxLayout; showVBox->addWidget(checkboxShowOilRigOne); @@ -173,14 +175,14 @@ bool SurfaceGraph::initialize() showVBox->addWidget(checkboxShowRefinery); showGroupBox->setLayout(showVBox); - QGroupBox *visualsGroupBox = new QGroupBox(QLatin1String("Visuals")); + QGroupBox *visualsGroupBox = new QGroupBox(u"Visuals"_s); visualsGroupBox->setVisible(false); - QCheckBox *checkboxVisualsSeeThrough = new QCheckBox(QLatin1String("See-Through")); + QCheckBox *checkboxVisualsSeeThrough = new QCheckBox(u"_see-Through"_s); - QCheckBox *checkboxHighlightOil = new QCheckBox(QLatin1String("Highlight Oil")); + QCheckBox *checkboxHighlightOil = new QCheckBox(u"Highlight Oil"_s); - QCheckBox *checkboxShowShadows = new QCheckBox(QLatin1String("Shadows")); + QCheckBox *checkboxShowShadows = new QCheckBox(u"_shadows"_s); checkboxShowShadows->setChecked(true); QVBoxLayout *visualVBox = new QVBoxLayout; @@ -189,14 +191,14 @@ bool SurfaceGraph::initialize() visualVBox->addWidget(checkboxShowShadows); visualsGroupBox->setLayout(visualVBox); - QLabel *labelSelection = new QLabel(QLatin1String("Selection:")); + QLabel *labelSelection = new QLabel(u"_selection:"_s); labelSelection->setVisible(false); - QLabel *labelSelectedItem = new QLabel(QLatin1String("Nothing")); + QLabel *labelSelectedItem = new QLabel(u"Nothing"_s); labelSelectedItem->setVisible(false); // Textured topography heightmap - QCheckBox *enableTexture = new QCheckBox(QLatin1String("Surface texture")); + QCheckBox *enableTexture = new QCheckBox(u"_surface texture"_s); enableTexture->setVisible(false); int height = 400; @@ -221,13 +223,14 @@ bool SurfaceGraph::initialize() for (int i = 0; i < 6; i++) { int yPos = i * step + border; pmpHighlight.drawLine(border, yPos, 55, yPos); - pmpHighlight.drawText(60, yPos + 2, QString("%1 m").arg(550 - (i * 110))); + const int height = 550 - (i * 110); + pmpHighlight.drawText(60, yPos + 2, QString::number(height) + u" m"_s); } QLabel *label = new QLabel(m_surfaceWidget); label->setPixmap(pmHighlight); - QGroupBox *heightMapGroupBox = new QGroupBox(QLatin1String("Highlight color map")); + QGroupBox *heightMapGroupBox = new QGroupBox(u"Highlight color map"_s); QVBoxLayout *colorMapVBox = new QVBoxLayout; colorMapVBox->addWidget(label); heightMapGroupBox->setLayout(colorMapVBox); diff --git a/examples/datavisualization/graphgallery/surfacegraphmodifier.cpp b/examples/datavisualization/graphgallery/surfacegraphmodifier.cpp index 8e301e73..005c27fc 100644 --- a/examples/datavisualization/graphgallery/surfacegraphmodifier.cpp +++ b/examples/datavisualization/graphgallery/surfacegraphmodifier.cpp @@ -11,6 +11,8 @@ #include <QtGui/qimage.h> #include <QtCore/qmath.h> +using namespace Qt::StringLiterals; + const int sampleCountX = 150; const int sampleCountZ = 150; const int heightMapGridStepX = 6; @@ -52,7 +54,7 @@ SurfaceGraphModifier::SurfaceGraphModifier(Q3DSurface *surface, QLabel *label) QImage heightMapImageOne(":/data/layer_1.png"); m_heightMapProxyOne = new QHeightMapSurfaceDataProxy(heightMapImageOne); m_heightMapSeriesOne = new QSurface3DSeries(m_heightMapProxyOne); - m_heightMapSeriesOne->setItemLabelFormat(QStringLiteral("(@xLabel, @zLabel): @yLabel")); + m_heightMapSeriesOne->setItemLabelFormat(u"(@xLabel, @zLabel): @yLabel"_s); m_heightMapProxyOne->setValueRanges(34.f, 40.f, 18.f, 24.f); //! [2] @@ -60,13 +62,13 @@ SurfaceGraphModifier::SurfaceGraphModifier(Q3DSurface *surface, QLabel *label) QImage heightMapImageTwo(":/data/layer_2.png"); m_heightMapProxyTwo = new QHeightMapSurfaceDataProxy(heightMapImageTwo); m_heightMapSeriesTwo = new QSurface3DSeries(m_heightMapProxyTwo); - m_heightMapSeriesTwo->setItemLabelFormat(QStringLiteral("(@xLabel, @zLabel): @yLabel")); + m_heightMapSeriesTwo->setItemLabelFormat(u"(@xLabel, @zLabel): @yLabel"_s); m_heightMapProxyTwo->setValueRanges(34.f, 40.f, 18.f, 24.f); QImage heightMapImageThree(":/data/layer_3.png"); m_heightMapProxyThree = new QHeightMapSurfaceDataProxy(heightMapImageThree); m_heightMapSeriesThree = new QSurface3DSeries(m_heightMapProxyThree); - m_heightMapSeriesThree->setItemLabelFormat(QStringLiteral("(@xLabel, @zLabel): @yLabel")); + m_heightMapSeriesThree->setItemLabelFormat(u"(@xLabel, @zLabel): @yLabel"_s); m_heightMapProxyThree->setValueRanges(34.f, 40.f, 18.f, 24.f); // The images are the same size, so it's enough to get the dimensions from one @@ -125,7 +127,7 @@ SurfaceGraphModifier::SurfaceGraphModifier(Q3DSurface *surface, QLabel *label) // m_topography = new TopographicSeries(); m_topography->setTopographyFile(":/data/topography.png", areaWidth, areaHeight); - m_topography->setItemLabelFormat(QStringLiteral("@yLabel m")); + m_topography->setItemLabelFormat(u"@yLabel m"_s); m_highlight = new HighlightSeries(); m_highlight->setTopographicSeries(m_topography); @@ -205,9 +207,9 @@ void SurfaceGraphModifier::enableSqrtSinModel(bool enable) m_graph->axisY()->setTitleVisible(false); m_graph->axisZ()->setTitleVisible(false); - m_graph->axisX()->setTitle(QStringLiteral("")); - m_graph->axisY()->setTitle(QStringLiteral("")); - m_graph->axisZ()->setTitle(QStringLiteral("")); + m_graph->axisX()->setTitle({}); + m_graph->axisY()->setTitle({}); + m_graph->axisZ()->setTitle({}); m_graph->setActiveInputHandler(m_defaultInputHandler); @@ -251,9 +253,9 @@ void SurfaceGraphModifier::enableHeightMapModel(bool enable) //! [4] m_graph->axisZ()->setRange(18.f, 24.f); - m_graph->axisX()->setTitle(QStringLiteral("Latitude")); - m_graph->axisY()->setTitle(QStringLiteral("Height")); - m_graph->axisZ()->setTitle(QStringLiteral("Longitude")); + m_graph->axisX()->setTitle(u"Latitude"_s); + m_graph->axisY()->setTitle(u"Height"_s); + m_graph->axisZ()->setTitle(u"Longitude"_s); m_graph->removeSeries(m_sqrtSinSeries); m_graph->removeSeries(m_topography); @@ -314,9 +316,9 @@ void SurfaceGraphModifier::enableTopographyModel(bool enable) m_graph->axisY()->setTitleVisible(false); m_graph->axisZ()->setTitleVisible(false); - m_graph->axisX()->setTitle(QStringLiteral("")); - m_graph->axisY()->setTitle(QStringLiteral("")); - m_graph->axisZ()->setTitle(QStringLiteral("")); + m_graph->axisX()->setTitle({}); + m_graph->axisY()->setTitle({}); + m_graph->axisZ()->setTitle({}); //! [5] m_graph->setActiveInputHandler(m_customInputHandler); |