]> Devoid-pointer.net GitWeb - anyanka.git/commitdiff
Fix build on VC11
authorMichal Malý <madcatxster@devoid-pointer.net>
Fri, 1 Aug 2014 17:08:06 +0000 (19:08 +0200)
committerMichal Malý <madcatxster@devoid-pointer.net>
Fri, 1 Aug 2014 17:08:06 +0000 (19:08 +0200)
datafileexporter.cpp
datafileexporter.h
datafilesloader.h
datamanager.cpp
datamanager.h
gui/exportgraphtoimagedialog.cpp
integratedpeak.cpp
integratedpeak.h
logger.h
signalcontroller.cpp

index 54513f5313710bde99d7cda3c5e44144a62f2b2e..7a84d22625163ffb837fa0193c44167250f402d3 100644 (file)
@@ -30,7 +30,7 @@
 
 #include <QDebug>
 
-const std::vector<OutputFormat> DataFileExporter::SUPPORTED_FORMATS = { OutputFormat("Comma separated values", "csv") };
+const OutputFormat DataFileExporter::SUPPORTED_FORMATS[] = { OutputFormat("Comma separated values", "csv") };
 
 /* Static methods */
 QStringList DataFileExporter::supportedFormats()
@@ -61,7 +61,7 @@ exportData(const WriteList& list, const QString& path, const int formatIdx)
   DataFileExporter::ReturnCode ret;
   DataWriterBackend* backend;
 
-  if (formatIdx < 0 || formatIdx >= SUPPORTED_FORMATS.size()) {
+  if (formatIdx < 0 || formatIdx >= sizeof(SUPPORTED_FORMATS)) {
     return ReturnCode::E_INVAL_FORMAT;
   }
 
@@ -133,6 +133,8 @@ DataFileExporter::OutputFormats DataFileExporter::formatIdxToFormat(const int id
   switch (idx) {
     case 0:
       return OutputFormats::CSV;
+    default:
+      return OutputFormats::INVALID;
   }
 }
 
@@ -168,8 +170,8 @@ void DataFileExporter::guessFormatFromSuffix(const QString& name)
   if (suffix.length() == 0)
     return;
 
-  for (size_t i = 0; i < SUPPORTED_FORMATS.size(); i++) {
-    const OutputFormat& of = SUPPORTED_FORMATS.at(i);
+  for (size_t i = 0; i < sizeof(SUPPORTED_FORMATS); i++) {
+    const OutputFormat& of = SUPPORTED_FORMATS[i];
     if (suffix.compare(of.second) == 0) {
       emit formatChanged(i);
       return;
index c76657734cf14c9ff4210b390880624ef4a91e04..136000e542e23186fe2df529cb4d44862ffbb2f0 100644 (file)
@@ -53,14 +53,15 @@ public:
   static QStringList supportedFormats();
 private:
   enum class OutputFormats {
-    CSV
+    CSV,
+    INVALID
   };
 
   OutputFormats formatIdxToFormat(const int idx);
   QString toCSVLine(double time, double value);
   ReturnCode writeToFile(QFile& file, const DataWriterBackend* writer, const std::pair<QVariantList, std::vector<QVariantList>>& data);
 
-  static const std::vector<OutputFormat> SUPPORTED_FORMATS;
+  static const OutputFormat SUPPORTED_FORMATS[];
 
 signals:
   void formatChanged(const int idx);
index 19261a1e2656f3bff14e78a5a11c0ef0583f4126..9f4852bbd81267abff03b47a1e84a5c62f6f0d26 100644 (file)
@@ -27,6 +27,7 @@
 #include "libHPCS/libhpcs.h"
 #include <QtCore/QDir>
 #include <QtCore/QObject>
+#include <vector>
 
 class DataFilesLoader : public QObject
 {
index 5f3e4f58596a4cabc2dc737958ca03c748cbf875..aa955883059ed8234282b4a6e715ad3a07e03a46 100644 (file)
 #include <QDebug>
 
 const QString DataManager::ME_SENDER_STR("DataManager");
-const QString DataManager::UNIT_DEGREES_CELSIUS_TEXT = QString::fromLatin1((const char[]){static_cast<char>(0xB0), 0x43, 0x00});
-const QString DataManager::UNIT_KILOVOLTS_TEXT = QString::fromLatin1((const char[]){0x4B, 0x56, 0x00});
-const QString DataManager::UNIT_KILOVOLTS_ALT1_TEXT = QString::fromLatin1((const char[]){0x6B, 0x56, 0x00});
-const QString DataManager::UNIT_MICROAMPERES_TEXT = QString::fromLatin1((const char[]){static_cast<char>(0xB5), 0x41, 0x00});
-const QString DataManager::UNIT_MICROAMPERES_ALT1_TEXT = QString::fromLatin1((const char[]){0x75, 0x41, 0x00});
-const QString DataManager::UNIT_MILLIAU_TEXT = QString::fromLatin1((const char[]){0x6D, 0x41, 0x55, 0x00});
-const QString DataManager::UNIT_MILLIBARS_TEXT = QString::fromLatin1((const char[]){0x6D, 0x62, 0x61, 0x72, 0x00});
-const QString DataManager::UNIT_MILLIVOLTS_TEXT = QString::fromLatin1((const char[]){0x6D, 0x56, 0x00});
-const QString DataManager::UNIT_WATTS_TEXT = QString::fromLatin1((const char[]){0x57, 0x00});
+const char DataManager::UNIT_DEGREES_CELSIUS_TEXT[] = {static_cast<char>(0xB0), 0x43, 0x00};
+const char DataManager::UNIT_KILOVOLTS_TEXT[] = {0x4B, 0x56, 0x00};
+const char DataManager::UNIT_KILOVOLTS_ALT1_TEXT[] = {0x6B, 0x56, 0x00};
+const char DataManager::UNIT_MICROAMPERES_TEXT[] = {static_cast<char>(0xB5), 0x41, 0x00};
+const char DataManager::UNIT_MICROAMPERES_ALT1_TEXT[] = {0x75, 0x41, 0x00};
+const char DataManager::UNIT_MILLIAU_TEXT[] = {0x6D, 0x41, 0x55, 0x00};
+const char DataManager::UNIT_MILLIBARS_TEXT[] = {0x6D, 0x62, 0x61, 0x72, 0x00};
+const char DataManager::UNIT_MILLIVOLTS_TEXT[] = {0x6D, 0x56, 0x00};
+const char DataManager::UNIT_WATTS_TEXT[] = {0x57, 0x00};
 const QStringList DataManager::DATA_DIR_SUFFIX = QStringList() << "*.D";
 const QString DataManager::S_RES_DATAEXPORT("Error while exporting data to file");
 const QString DataManager::S_RES_IMGEXPORT("Error while exporting graph to image");
@@ -270,28 +270,26 @@ std::string DataManager::signalControllerKey(const QString& main, const QString&
   return std::string(main.toStdString() + "_" + resource.toStdString());
 }
 
-Signal::YUnit DataManager::yunitFromUnitStr(const char* unit_str)
+Signal::YUnit DataManager::yunitFromUnitStr(const char* str)
 {
-  QString str = m_sigNameCodec->toUnicode(unit_str);
-
-  if (QString::compare(str, UNIT_DEGREES_CELSIUS_TEXT) == 0)
+  if (strcmp(str, UNIT_DEGREES_CELSIUS_TEXT) == 0)
     return Signal::YUnit::DEGREES_CELSIUS;
-  else if (QString::compare(str, UNIT_KILOVOLTS_TEXT) == 0 ||
-           QString::compare(str, UNIT_KILOVOLTS_ALT1_TEXT) == 0)
+  else if (strcmp(str, UNIT_KILOVOLTS_TEXT) == 0 ||
+           strcmp(str, UNIT_KILOVOLTS_ALT1_TEXT) == 0)
     return Signal::YUnit::KILOVOLTS;
-  else if (QString::compare(str, UNIT_MICROAMPERES_TEXT) == 0 ||
-           QString::compare(str, UNIT_MICROAMPERES_ALT1_TEXT) == 0)
+  else if (strcmp(str, UNIT_MICROAMPERES_TEXT) == 0 ||
+           strcmp(str, UNIT_MICROAMPERES_ALT1_TEXT) == 0)
     return Signal::YUnit::MICROAMPERES;
-  else if (QString::compare(str, UNIT_MILLIAU_TEXT) == 0)
+  else if (strcmp(str, UNIT_MILLIAU_TEXT) == 0)
     return Signal::YUnit::MILLIAU;
-  else if (QString::compare(str, UNIT_MILLIBARS_TEXT) == 0)
+  else if (strcmp(str, UNIT_MILLIBARS_TEXT) == 0)
     return Signal::YUnit::MILLIBARS;
-  else if (QString::compare(str, UNIT_MILLIVOLTS_TEXT) == 0)
+  else if (strcmp(str, UNIT_MILLIVOLTS_TEXT) == 0)
     return Signal::YUnit::MILLIVOLTS;
-  else if (QString::compare(str, UNIT_WATTS_TEXT) == 0)
+  else if (strcmp(str, UNIT_WATTS_TEXT) == 0)
     return Signal::YUnit::WATTS;
   else
-    throw std::invalid_argument(str.toStdString());
+    throw std::invalid_argument(std::string(str));
 }
 
 std::shared_ptr<SingleRunData> DataManager::loadSingleRun(QDir& dir)
index 020f85871ce5de1b6f8a66b0a2787d3e5dfd1a6a..250acea2d9efe3d0e76e61e0bf98f65eda5f1dc5 100644 (file)
@@ -62,7 +62,7 @@ private:
   bool saveSingleRunUserData(std::shared_ptr<SingleRunData> sr);
   std::string signalControllerKey(const QString& main, const QString& resource);
   void showOneSignal(std::shared_ptr<SignalController> ctrl);
-  Signal::YUnit yunitFromUnitStr(const char* unit_str);
+  Signal::YUnit yunitFromUnitStr(const char* str);
 
   std::shared_ptr<Sequence> m_activeSequence;
   QString m_prevSequenceKey;
@@ -77,15 +77,15 @@ private:
   ExportGraphToImageDialog m_graphToImageExportDialog;
 
   static const QString ME_SENDER_STR;
-  static const QString UNIT_DEGREES_CELSIUS_TEXT;
-  static const QString UNIT_KILOVOLTS_TEXT;
-  static const QString UNIT_KILOVOLTS_ALT1_TEXT;
-  static const QString UNIT_MICROAMPERES_TEXT;
-  static const QString UNIT_MICROAMPERES_ALT1_TEXT;
-  static const QString UNIT_MILLIAU_TEXT;
-  static const QString UNIT_MILLIBARS_TEXT;
-  static const QString UNIT_MILLIVOLTS_TEXT;
-  static const QString UNIT_WATTS_TEXT;
+  static const char UNIT_DEGREES_CELSIUS_TEXT[];
+  static const char UNIT_KILOVOLTS_TEXT[];
+  static const char UNIT_KILOVOLTS_ALT1_TEXT[];
+  static const char UNIT_MICROAMPERES_TEXT[];
+  static const char UNIT_MICROAMPERES_ALT1_TEXT[];
+  static const char UNIT_MILLIAU_TEXT[];
+  static const char UNIT_MILLIBARS_TEXT[];
+  static const char UNIT_MILLIVOLTS_TEXT[];
+  static const char UNIT_WATTS_TEXT[];
 
   static const QStringList DATA_DIR_SUFFIX;
 
index 58e7f25cebb53a19d600d867aa7cde1b8bcf1553..35f545255c1ce4c35e40df1c350d5f8dd190df9c 100644 (file)
@@ -25,6 +25,7 @@
 #include "ui_exportgraphtoimagedialog.h"
 #include <QtCore/QLocale>
 #include <QtWidgets/QFileDialog>
+#include <tuple>
 
 /* Public functions */
 
index d4b17562fc05278ad67ea4464007eb4a8d1a8eee..66b684b213a4e0fbeb97777cd723914ada7e2b26 100644 (file)
@@ -21,6 +21,7 @@
 */
 
 #include "integratedpeak.h"
+#include <QtCore/QVariant>
 #include <QtCore/QJsonObject>
 
 const QString IntegratedPeak::KEY_AUC("auc");
@@ -129,6 +130,11 @@ bool IntegratedPeak::deserialize(const QJsonValue& value)
   return true;
 }
 
+template <typename T> QJsonValue IntegratedPeak::fromQVariant(T value) const
+{
+  return QJsonValue::fromVariant(QVariant(value));
+}
+
 double IntegratedPeak::height() const
 {
   return fabs(m_peakY - (baselineSlope() * (m_peakIdx - m_fromIdx) + m_fromY));
@@ -140,14 +146,14 @@ QJsonValue IntegratedPeak::serialize() const
   QString type = (m_type == Type::PEAK) ? "PEAK" : "VALLEY";
 
   jso.insert(KEY_AUC, QJsonValue(m_auc));
-  jso.insert(KEY_FROMIDX, QJsonValue(static_cast<qint64>(m_fromIdx)));
+  jso.insert(KEY_FROMIDX, QJsonValue(fromQVariant(static_cast<quint64>(m_fromIdx))));
   jso.insert(KEY_FROMTIME, QJsonValue(m_fromTime));
   jso.insert(KEY_FROMY, QJsonValue(m_fromY));
   jso.insert(KEY_ITYPE, QJsonValue( (m_itype == IntegrationType::BASELINE) ? true : false) );
-  jso.insert(KEY_PEAKIDX, QJsonValue(static_cast<qint64>(m_peakIdx)));
+  jso.insert(KEY_PEAKIDX, QJsonValue(fromQVariant(static_cast<quint64>(m_peakIdx))));
   jso.insert(KEY_PEAKTIME, QJsonValue(m_peakTime));
   jso.insert(KEY_PEAKY, QJsonValue(m_peakY));
-  jso.insert(KEY_TOIDX, QJsonValue(static_cast<qint64>(m_toIdx)));
+  jso.insert(KEY_TOIDX, QJsonValue(fromQVariant(static_cast<quint64>(m_toIdx))));
   jso.insert(KEY_TOTIME, QJsonValue(m_toTime));
   jso.insert(KEY_TOY, QJsonValue(m_toY));
   jso.insert(KEY_TYPE, QJsonValue(type));
index 1e1e2db05826896a5665d4d0d75a6c0ec3e89257..60e31d883ce2587241be8dbe4aff8d30a60f2fcc 100644 (file)
@@ -68,6 +68,8 @@ public:
   virtual QJsonValue serialize() const;
 
 private:
+  template <typename T> QJsonValue fromQVariant(T val) const;
+
   double m_auc;
   size_t m_fromIdx;
   double m_fromTime;
index c9e3bf004f2e0ebae14eae9d73584383a31b9096..2f308b858a5b493b7476168a7a70977d5cff4b54 100644 (file)
--- a/logger.h
+++ b/logger.h
 #include <QtCore/QObject>
 #include <QtCore/QDateTime>
 
+#ifdef WIN32
+#define __func__ __FUNCTION__
+#endif
+
 #define __QFUNC__ QString(__func__) + QString("()")
 
 class LocalLogger;
index ed1ebbcf853da74aedf440bb504d0bb33b2c576d..c2a19424ca42aea839c828cc4fed6e70e3e1fff2 100644 (file)
@@ -176,14 +176,16 @@ RulerDrawData SignalController::getRulerDrawData(const double from, const double
   diffRel = to - from;
 
   switch (axis) {
-    case Axis::TIME:
-      fromAbs = m_signal->timeAt(relToIdx(from));
-      toAbs = m_signal->timeAt(relToIdx(to));
-      break;
-    case Axis::VALUE:
-      fromAbs = relToValue(from);
-      toAbs = relToValue(to);
-      break;
+  case Axis::TIME:
+    fromAbs = m_signal->timeAt(relToIdx(from));
+    toAbs = m_signal->timeAt(relToIdx(to));
+    break;
+  case Axis::VALUE:
+    fromAbs = relToValue(from);
+    toAbs = relToValue(to);
+    break;
+  default:
+    return RulerDrawData();
   }
 
   /* Calculate step */