From 7d3fc45724b25eb616481a38002d82c83ec3b48e Mon Sep 17 00:00:00 2001 From: Tristan Youngs Date: Wed, 22 Jan 2025 10:11:16 +0000 Subject: [PATCH] Use QString. --- examples/groups/mainwindow_funcs.cpp | 2 +- src/entities/data.h | 4 ++-- src/version.h | 6 +++--- src/widget.cpp | 6 +++--- src/widget.h | 6 +++--- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/examples/groups/mainwindow_funcs.cpp b/examples/groups/mainwindow_funcs.cpp index e8d7b8f..339586b 100644 --- a/examples/groups/mainwindow_funcs.cpp +++ b/examples/groups/mainwindow_funcs.cpp @@ -39,7 +39,7 @@ MainWindow::MainWindow() : QMainWindow() [a, b, c](const auto x) { return 5.0 + a * sin(x) + b * sin(2.0 * x) - c * sin(3.0 * x); }); // Create a renderable and add it to the group - auto *renderable = ui_.TestingWidget->addData1D(std::string("Sines") + std::to_string(n)); + auto *renderable = ui_.TestingWidget->addData1D(QString("Sines%1").arg(n)); renderable->setData(xValues, y); renderable->colour().set({int(255 * dist(gen)), int(255 * dist(gen)), int(255 * dist(gen)), 255}); diff --git a/src/entities/data.h b/src/entities/data.h index ea34427..6169ed5 100644 --- a/src/entities/data.h +++ b/src/entities/data.h @@ -31,7 +31,7 @@ class DataEntity : public Qt3DCore::QEntity */ protected: // Display name for entity - std::string displayName_; + QString displayName_; // Extrema of data points in three-dimensional space Cuboid extrema_; // Extrema of data points in three-dimensional logarithmic space @@ -112,4 +112,4 @@ class DataEntity : public Qt3DCore::QEntity // Recreate renderables following metric / axis change void updateRenderables(); }; -} // namespace Mildred \ No newline at end of file +} // namespace Mildred diff --git a/src/version.h b/src/version.h index 021f74b..2b1bbed 100644 --- a/src/version.h +++ b/src/version.h @@ -11,10 +11,10 @@ namespace Mildred namespace Version { // Return version -std::string_view version() { return MILDREDVERSION; } +QString version() { return MILDREDVERSION; } // Return short hash -std::string_view shortHash() { return MILDREDSHORTHASH; } +QString shortHash() { return MILDREDSHORTHASH; } // Return repo url -std::string_view repoUrl() { return MILDREDREPO; } +QString repoUrl() { return MILDREDREPO; } }; // namespace Version }; // namespace Mildred diff --git a/src/widget.cpp b/src/widget.cpp index bde20f9..5111a3a 100644 --- a/src/widget.cpp +++ b/src/widget.cpp @@ -178,13 +178,13 @@ RenderableMaterial *MildredWidget::createMaterial(Qt3DCore::QEntity *parent, Ren } // Add new 1-dimensional data entity for supplied data -Data1DEntity *MildredWidget::addData1D(std::string_view tag) +Data1DEntity *MildredWidget::addData1D(const QString &tag) { // Check for existing tag auto it = std::find_if(dataEntities_.begin(), dataEntities_.end(), [tag](const auto &d) { return tag == d.first; }); if (it != dataEntities_.end()) { - printf("Data with tag '%s' already exists, so can't add it again.\n", it->first.c_str()); + qDebug() << QString("Data with tag '%1' already exists, so can't add it again.\n").arg(it->first); throw(std::runtime_error("Duplicate DataEntity tag created.\n")); } @@ -214,4 +214,4 @@ DisplayGroup *MildredWidget::addDisplayGroup() auto newGroup = displayGroups_.emplace_back(std::make_shared()); return newGroup.get(); -} \ No newline at end of file +} diff --git a/src/widget.h b/src/widget.h index 07b1d22..44a063e 100644 --- a/src/widget.h +++ b/src/widget.h @@ -193,7 +193,7 @@ class MildredWidget : public QWidget */ private: // Associated data entities (with identifying tag) - std::vector> dataEntities_; + std::vector> dataEntities_; private: // Create material for specified entity @@ -205,7 +205,7 @@ class MildredWidget : public QWidget public: // Add new data entity for supplied data - Data1DEntity *addData1D(std::string_view tag); + Data1DEntity *addData1D(const QString &tag); /* * Grouping @@ -218,4 +218,4 @@ class MildredWidget : public QWidget // Create new display group DisplayGroup *addDisplayGroup(); }; -} // namespace Mildred \ No newline at end of file +} // namespace Mildred