From 5000c6a7416c628f2bab791209a29b9ee97b17bb Mon Sep 17 00:00:00 2001 From: =?utf8?q?Michal=20Mal=C3=BD?= Date: Wed, 2 Jul 2014 23:03:30 +0200 Subject: [PATCH] Use QString instead of std::string in Signal class Rename methods that return values as string to AsString() from ToString() --- datamanager.cpp | 20 ++++++++++---------- signal.cpp | 32 ++++++++++++++++---------------- signal.h | 30 +++++++++++++++--------------- signaldatatablemodel.cpp | 4 ++-- signaldrawer.cpp | 4 ++-- singlerundata.cpp | 2 +- 6 files changed, 46 insertions(+), 46 deletions(-) diff --git a/datamanager.cpp b/datamanager.cpp index 3f46f2a..f80786d 100644 --- a/datamanager.cpp +++ b/datamanager.cpp @@ -110,9 +110,9 @@ void DataManager::generateIntegDataWriteList(DataFileExporter::WriteList& writeL if (ctrl == nullptr) continue; - header << "time [" + QString::fromStdString(ctrl->signal()->xunitToString()) + "]" << "area [" + QString::fromStdString(ctrl->signal()->xunitToString()) + " " - + QString::fromStdString(ctrl->signal()->yunitToString()) + "]" << "width [" + QString::fromStdString(ctrl->signal()->xunitToString()) + "]" - << "height [" + QString::fromStdString(ctrl->signal()->yunitToString()) + "]"; + header << "time [" + ctrl->signal()->xunitAsString() + "]" << "area [" + ctrl->signal()->xunitAsString() + " " + + ctrl->signal()->yunitAsString() + "]" << "width [" + ctrl->signal()->xunitAsString() + "]" + << "height [" + ctrl->signal()->yunitAsString() + "]"; integrator = ctrl->cIntegrator(); /*for (std::multimap>::const_iterator cit = integrator->peaksCBegin(); cit != integrator->peaksCEnd(); cit++) {*/ @@ -138,7 +138,7 @@ void DataManager::generateRawDataWriteList(DataFileExporter::WriteList& writeLis continue; /* Create header */ - header << QString("time [" + QString::fromStdString(sig->xunitToString()) + "]") << QString("value [" + QString::fromStdString(sig->yunitToString()) + "]"); + header << QString("time [" + sig->xunitAsString() + "]") << QString("value [" + sig->yunitAsString() + "]"); for (const Signal::TimeValuePair& tvp : sig->values()) { QVariantList line; line << tvp.first << tvp.second; @@ -366,8 +366,8 @@ std::shared_ptr DataManager::loadSingleRun(QDir& dir) _c = std::shared_ptr(new SignalController(_s)); - sigs[_s->descriptiveName()] = _s; - ctrls[_s->descriptiveName()] = _c; + sigs[_s->descriptiveName().toStdString()] = _s; + ctrls[_s->descriptiveName().toStdString()] = _c; hpcs_free(md); } @@ -424,12 +424,12 @@ void DataManager::showOneSignal(std::shared_ptr ctrl) swp->setDataTableModel(ctrl->dataTableModel()); swp->setIntegrationTableModel(ctrl->integrationTableModel()); if (ctrl->signal()->resource() == Signal::Resource::CE_DAD) - swp->setTypeText(QString::fromStdString(ctrl->signal()->resourceToString()) + QString(" Sig: ") + QString::number(ctrl->signal()->wavelengthAbsorbed()) + " nm, Ref: " + + swp->setTypeText(ctrl->signal()->resourceAsString() + " Sig: " + QString::number(ctrl->signal()->wavelengthAbsorbed()) + " nm, Ref: " + QString::number(ctrl->signal()->wavelengthReference()) + " nm"); else - swp->setTypeText(QString::fromStdString(ctrl->signal()->resourceToString())); - swp->setXUnits(QString::fromStdString(ctrl->signal()->xunitToString())); - swp->setYUnits(QString::fromStdString(ctrl->signal()->yunitToString())); + swp->setTypeText(ctrl->signal()->resourceAsString()); + swp->setXUnits(ctrl->signal()->xunitAsString()); + swp->setYUnits(ctrl->signal()->yunitAsString()); emit addToDashboard(swp); diff --git a/signal.cpp b/signal.cpp index 3ef5e0f..25ed6b5 100644 --- a/signal.cpp +++ b/signal.cpp @@ -23,16 +23,16 @@ #include "signal.h" #include -const std::string Signal::RES_CCD("CCD"); -const std::string Signal::RES_CURRENT("Current"); -const std::string Signal::RES_DAD("Absorbance"); -const std::string Signal::RES_POWER("Power"); -const std::string Signal::RES_VOLTAGE("Voltage"); -const std::string Signal::KILOVOTLS_SI("KV"); -const std::string Signal::MICROAMPERES_SI("\u03BCA"); -const std::string Signal::MILLIAU_SI("mAU"); -const std::string Signal::MILLIVOLTS_SI("mV"); -const std::string Signal::WATTS_SI("W"); +const QString Signal::RES_CCD("CCD"); +const QString Signal::RES_CURRENT("Current"); +const QString Signal::RES_DAD("Absorbance"); +const QString Signal::RES_POWER("Power"); +const QString Signal::RES_VOLTAGE("Voltage"); +const QString Signal::KILOVOTLS_SI("KV"); +const QString Signal::MICROAMPERES_SI("\u03BCA"); +const QString Signal::MILLIAU_SI("mAU"); +const QString Signal::MILLIVOLTS_SI("mV"); +const QString Signal::WATTS_SI("W"); Signal::Signal(const Equipment equipment, const Resource resource, const double samplingRate, const YUnit yunit, uint16_t wavelengthAbs, uint16_t wavelengthRef, const std::vector& values, QObject* parent) : @@ -54,11 +54,11 @@ Signal::Signal(const Equipment equipment, const Resource resource, const double } } -std::string Signal::descriptiveName() const +QString Signal::descriptiveName() const { - std::string name = resourceToString(); + QString name = resourceAsString(); if (m_resource == Resource::CE_DAD) - name += "_SIG" + std::to_string(m_wavelengthAbs) + "_REF" + std::to_string(m_wavelengthRef); + name += "_SIG" + QString::number(m_wavelengthAbs) + "_REF" + QString::number(m_wavelengthRef); return name; } @@ -75,7 +75,7 @@ Signal::TimeValuePair Signal::pairAt(const size_t idx) const return m_values.at(idx); } -std::string Signal::resourceToString() const { +QString Signal::resourceAsString() const { switch (m_resource) { case Resource::CE_CCD: return RES_CCD; @@ -113,7 +113,7 @@ double Signal::valueAt(const size_t idx) const return m_values.at(idx).second; } -std::string Signal::xunitToString() const +QString Signal::xunitAsString() const { switch (m_xunit) { case XUnit::MINUTE: @@ -123,7 +123,7 @@ std::string Signal::xunitToString() const } } -std::string Signal::yunitToString() const +QString Signal::yunitAsString() const { switch (m_yunit) { case YUnit::KILOVOLTS: diff --git a/signal.h b/signal.h index b4944c2..c18abc7 100644 --- a/signal.h +++ b/signal.h @@ -57,14 +57,14 @@ public: explicit Signal(const Equipment equipment, const Resource resource, const double samplingRate, const YUnit yunit, const uint16_t wavelengthAbs, const uint16_t wavelengthRef, const std::vector& values, QObject* parent = nullptr); uint count() const { return m_values.size(); } - std::string descriptiveName() const; + QString descriptiveName() const; Equipment equipment() const { return m_equipment; } std::vector::const_iterator iteratorFrom(const size_t idx) const; double maximum() const { return m_max; } double minimum() const { return m_min; } TimeValuePair pairAt(const size_t idx) const; Resource resource() const { return m_resource; } - std::string resourceToString() const; + QString resourceAsString() const; double timeAt(const size_t idx) const; double samplingRate() const { return m_samplingRate; } double valueAt(const size_t idx) const; @@ -75,9 +75,9 @@ public: uint16_t wavelengthAbsorbed() const { return m_wavelengthAbs; } uint16_t wavelengthReference() const { return m_wavelengthRef; } XUnit xunit() const { return m_xunit; } - std::string xunitToString() const; + QString xunitAsString() const; YUnit yunit() const { return m_yunit; } - std::string yunitToString() const; + QString yunitAsString() const; private: const Equipment m_equipment; @@ -91,17 +91,17 @@ private: const XUnit m_xunit; const YUnit m_yunit; - static const std::string RES_ABSORBANCE; - static const std::string RES_CCD; - static const std::string RES_CURRENT; - static const std::string RES_DAD; - static const std::string RES_POWER; - static const std::string RES_VOLTAGE; - static const std::string KILOVOTLS_SI; - static const std::string MICROAMPERES_SI; - static const std::string MILLIAU_SI; - static const std::string MILLIVOLTS_SI; - static const std::string WATTS_SI; + static const QString RES_ABSORBANCE; + static const QString RES_CCD; + static const QString RES_CURRENT; + static const QString RES_DAD; + static const QString RES_POWER; + static const QString RES_VOLTAGE; + static const QString KILOVOTLS_SI; + static const QString MICROAMPERES_SI; + static const QString MILLIAU_SI; + static const QString MILLIVOLTS_SI; + static const QString WATTS_SI; signals: diff --git a/signaldatatablemodel.cpp b/signaldatatablemodel.cpp index 46863e3..a7f8f36 100644 --- a/signaldatatablemodel.cpp +++ b/signaldatatablemodel.cpp @@ -57,9 +57,9 @@ QVariant SignalDataTableModel::headerData(int section, Qt::Orientation orientati if (role == Qt::DisplayRole && orientation == Qt::Horizontal) { switch (section) { case 0: - return QString("Time [") + QString::fromStdString(m_signal->xunitToString()) + QString("]"); + return "Time [" + m_signal->xunitAsString() + "]"; case 1: - return QString("Value [") + QString::fromStdString(m_signal->yunitToString()) + QString("]"); + return "Value [" + m_signal->yunitAsString() + "]"; default: return QVariant(); } diff --git a/signaldrawer.cpp b/signaldrawer.cpp index 21eb97c..a709ba4 100644 --- a/signaldrawer.cpp +++ b/signaldrawer.cpp @@ -41,8 +41,8 @@ SignalDrawer::SignalDrawer(std::shared_ptr controller, const C m_relYMin(constraints.fromY), m_axisLabelFont(QFont("arial", 10)), m_axisLabelFM(QFontMetrics(m_axisLabelFont)), - m_xAxisLabelText("[" + QString::fromStdString(controller->signal()->xunitToString()) + "]"), - m_yAxisLabelText("[" + QString::fromStdString(controller->signal()->yunitToString()) + "]") + m_xAxisLabelText("[" + controller->signal()->xunitAsString() + "]"), + m_yAxisLabelText("[" + controller->signal()->yunitAsString() + "]") { } diff --git a/singlerundata.cpp b/singlerundata.cpp index 276cb9a..6cee819 100644 --- a/singlerundata.cpp +++ b/singlerundata.cpp @@ -79,7 +79,7 @@ void SingleRunData::readUserDataFromJSON() while (it != m_ctrls.end()) { std::shared_ptr c = it->second; - QString descriptiveName = QString::fromStdString(c->signal()->descriptiveName()); + QString descriptiveName = c->signal()->descriptiveName(); QString filename = "ank_" + descriptiveName + ".json"; QFile jsonFile(m_absPath + "/" + filename); -- 2.43.5