]> Devoid-pointer.net GitWeb - anyanka.git/commitdiff
Use QString instead of std::string in Signal class
authorMichal Malý <madcatxster@devoid-pointer.net>
Wed, 2 Jul 2014 21:03:30 +0000 (23:03 +0200)
committerMichal Malý <madcatxster@devoid-pointer.net>
Wed, 2 Jul 2014 21:03:30 +0000 (23:03 +0200)
Rename methods that return values as string to <value>AsString() from
<value>ToString()

datamanager.cpp
signal.cpp
signal.h
signaldatatablemodel.cpp
signaldrawer.cpp
singlerundata.cpp

index 3f46f2a44acd52a5218cf7c95d5c414fb2164579..f80786df38ab0bf54cde10865100ccebd237964d 100644 (file)
@@ -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<size_t, std::shared_ptr<IntegratedPeak>>::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<SingleRunData> DataManager::loadSingleRun(QDir& dir)
 
     _c = std::shared_ptr<SignalController>(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<SignalController> 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);
 
index 3ef5e0fe239225311ab8890217057c9c3f80732b..25ed6b5b3d3852d6291766e7b9d7cef083132361 100644 (file)
 #include "signal.h"
 #include <cfloat>
 
-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<TimeValuePair>& 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:
index b4944c28b941bbaf267ec10a69388054391cd26a..c18abc7af9bcf9a60d4728f2cf85e777467e55bd 100644 (file)
--- 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<TimeValuePair>& 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<TimeValuePair>::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:
 
index 46863e3d1ae11daf446d99c324e232300f1666dd..a7f8f364ee100759c857c40568eb55fd818ea04a 100644 (file)
@@ -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();
     }
index 21eb97cd495e00837f6e48d4d4c11e943984d2cd..a709ba425681025d404e86a83e78f19948dcabb8 100644 (file)
@@ -41,8 +41,8 @@ SignalDrawer::SignalDrawer(std::shared_ptr<SignalController> 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() + "]")
 {
 }
 
index 276cb9a0bec0940a5d5cd92141d63594dd91fb26..6cee8191b7068df792fe4111444f8b588efa5490 100644 (file)
@@ -79,7 +79,7 @@ void SingleRunData::readUserDataFromJSON()
 
   while (it != m_ctrls.end()) {
     std::shared_ptr<SignalController> 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);