]> Devoid-pointer.net GitWeb - anyanka.git/commitdiff
- Adapt to new libHPCS API
authorMichal Malý <madcatxster@devoid-pointer.net>
Sun, 29 Mar 2015 13:19:09 +0000 (15:19 +0200)
committerMichal Malý <madcatxster@devoid-pointer.net>
Sun, 29 Mar 2015 13:19:09 +0000 (15:19 +0200)
- Add support for displaying raw method information

21 files changed:
Anyanka.pro
datafilesloader.cpp
datafilesloader.h
datamanager.cpp
datamanager.h
gui/mainwindow.cpp
gui/mainwindow.h
gui/mainwindow.ui
gui/methodinfodialog.cpp [new file with mode: 0644]
gui/methodinfodialog.h [new file with mode: 0644]
gui/methodinfodialog.ui [new file with mode: 0644]
gui/methodinfolistingwidget.cpp [new file with mode: 0644]
gui/methodinfolistingwidget.h [new file with mode: 0644]
gui/methodinfolistingwidget.ui [new file with mode: 0644]
main.cpp
methodinfo.cpp [new file with mode: 0644]
methodinfo.h [new file with mode: 0644]
methodinfolistingtablemodel.cpp [new file with mode: 0644]
methodinfolistingtablemodel.h [new file with mode: 0644]
singlerundata.cpp
singlerundata.h

index d820f229539bf614f0a92ecd4c81c1c3906bfa5e..ae6be7f19b5deb91fd3e26213f618e7a8f1d8f34 100644 (file)
@@ -13,8 +13,9 @@ TEMPLATE = app
 unix {
         QMAKE_CXXFLAGS += -std=c++11 -Wall -Wextra
         # You may want to adjust these paths based on the location of libHPCS on your system
-        INCLUDEPATH += $$PWD/libHPCS/include
-        LIBS += -L$$PWD/libHPCS/build -lHPCS
+        #INCLUDEPATH += $$PWD/libHPCS/include
+        INCLUDEPATH += /home/madcat/Devel/C/libHPCS/include
+        LIBS += -L/home/madcat/Devel/C/libHPCS/build -lHPCS
 }
 win32 {
         # Add project root directory to work around VC11 include path scheme
@@ -63,7 +64,11 @@ SOURCES += main.cpp\
     jsonserializable.cpp \
     gui/failedfilesdialog.cpp \
     helpers.cpp \
-    usersettings.cpp
+    usersettings.cpp \
+    methodinfo.cpp \
+    gui/methodinfolistingwidget.cpp \
+    methodinfolistingtablemodel.cpp \
+    gui/methodinfodialog.cpp
 
 HEADERS  += \
     datafilesloader.h \
@@ -97,7 +102,11 @@ HEADERS  += \
     jsonserializable.h \
     helpers.h \
     gui/failedfilesdialog.h \
-    usersettings.h
+    usersettings.h \
+    methodinfo.h \
+    gui/methodinfolistingwidget.h \
+    methodinfolistingtablemodel.h \
+    gui/methodinfodialog.h
 
 FORMS += \
     gui/mainwindow.ui \
@@ -105,7 +114,9 @@ FORMS += \
     gui/aboutanyanka.ui \
     gui/exportrawdatadialog.ui \
     gui/exportgraphtoimagedialog.ui \
-    gui/failedfilesdialog.ui
+    gui/failedfilesdialog.ui \
+    gui/methodinfolistingwidget.ui \
+    gui/methodinfodialog.ui
 
 RESOURCES += \
     imgresources.qrc
index ad730b9d6bccd2818bce0d4549e60625254da665..54505bb8b95c635090d266be8bc38c4aea9d95d7 100644 (file)
 #include "logger.h"
 #include "gui/failedfilesdialog.h"
 
-DataFilesLoader::DataFilesLoader(QObject *parent) :
-  QObject(parent)
+const QStringList DataFilesLoader::m_supportedMeasurementFileTypes = QStringList() << "*.ch";
+const QStringList DataFilesLoader::m_supportedMethodInfoFileTypes = QStringList() << "*.mth";
+
+DataFilesLoader::ReturnCode DataFilesLoader::loadSingleRun(const QDir& path, std::vector<struct HPCS_MeasuredData* >& measuredData, std::vector<std::pair<const QString, HPCS_MethodInfo*> >& methodInfo)
 {
-  m_supportedFileTypes << "*.ch";
+  QDir _path(path);
+
+  if (!loadMeasuredData(_path, measuredData))
+    return ReturnCode::E_FAILED;
+
+  if (!_path.cd("./ACQ.M"))
+    return ReturnCode::W_LIMITED;
+  if (!loadMethodInfo(_path, methodInfo))
+    return ReturnCode::W_LIMITED;
+
+  return ReturnCode::SUCCESS;
 }
 
-DataFilesLoader::ReturnCode DataFilesLoader::loadSingleRun(const QDir& path, std::vector<struct HPCS_MeasuredData* >& loadedData)
+void DataFilesLoader::displayFailedFiles(std::vector<std::pair<const QString, const QString> >& failedFiles)
 {
-  std::vector<CQStringPair> failedFiles;
+  if (failedFiles.size() > 0)
+    FailedFilesDialog::exec(failedFiles);
+}
 
-  for (const QString& s : path.entryList(m_supportedFileTypes, QDir::Files | QDir::NoDotAndDotDot)) {
-    struct HPCS_MeasuredData* mdata = hpcs_alloc();
-    if (mdata == nullptr) {
-      return ReturnCode::E_FATAL;
-      break;
-    }
+bool DataFilesLoader::loadMeasuredData(const QDir path, std::vector<HPCS_MeasuredData* >& measuredData)
+{
+  std::vector<std::pair<const QString, const QString>> failedFiles;
 
+  for (const QString s : path.entryList(m_supportedMeasurementFileTypes)) {
+    struct HPCS_MeasuredData* mdata;
+    HPCS_RetCode ret;
     QString absPath = path.absoluteFilePath(s);
 
-    HPCS_RetCode iret = hpcs_read_file(absPath.toStdString().c_str(), mdata);
-    if (iret == HPCS_OK)
-      loadedData.push_back(mdata);
-    else {
-      QString errDesc = hpcs_error_to_string(iret);
-      Logger::log(Logger::Level::DEBUG, ME_SENDER_STR, "Error reading file '" + s + "'" + errDesc);
-      failedFiles.push_back(CQStringPair(s, errDesc));
-
-      hpcs_free(mdata);
+    mdata = hpcs_alloc_mdata();
+    ret = hpcs_read_mdata(absPath.toLocal8Bit(), mdata);
+    if (ret != HPCS_OK) {
+      logFailedFile(s, hpcs_error_to_string(ret), failedFiles);
+      continue;
     }
+
+    measuredData.push_back(mdata);
   }
 
-  if (failedFiles.size() > 0) {
-    Logger::log(Logger::Level::DEBUG, ME_SENDER_STR, "Failed files count: " + QString::number(failedFiles.size()));
-    FailedFilesDialog::exec(failedFiles);
+  displayFailedFiles(failedFiles);
+  if (measuredData.size() < 1)
+    return false;
+  return true;
+}
+
+bool DataFilesLoader::loadMethodInfo(const QDir path, std::vector<std::pair<const QString, HPCS_MethodInfo* >>& methodInfo)
+{
+  std::vector<std::pair<const QString, const QString>> failedFiles;
+
+  for (const QString s : path.entryList(m_supportedMethodInfoFileTypes)) {
+    struct HPCS_MethodInfo* minfo;
+    HPCS_RetCode ret;
+    QString absPath = path.absoluteFilePath(s);
+
+    minfo = hpcs_alloc_minfo();
+    ret = hpcs_read_minfo(absPath.toUtf8(), minfo);
+    if (ret != HPCS_OK) {
+      logFailedFile(s, hpcs_error_to_string(ret), failedFiles);
+      continue;
+    }
+
+    methodInfo.push_back(std::pair<const QString, struct HPCS_MethodInfo* >(s, minfo));
   }
-  if (loadedData.size() == 0)
-    return ReturnCode::E_NO_FILES;
 
-  Logger::log(Logger::Level::DEBUG, ME_SENDER_STR, QString::number(loadedData.size()) + " files were found and successfully parsed");
+  displayFailedFiles(failedFiles);
+  if (methodInfo.size() < 1)
+    return false;
+  return true;
+}
 
-  return ReturnCode::SUCCESS;
+void DataFilesLoader::logFailedFile(const QString file, const char* msg, std::vector<std::pair<const QString, const QString>>& failedFiles)
+{
+  const QString errMsg = QString::fromUtf8(msg);
+  Logger::log(Logger::Level::DEBUG, ME_SENDER_STR, QString("Error reading file '%1' (%2)").arg(file).arg(errMsg));
+  failedFiles.push_back(std::pair<const QString, const QString>(file, errMsg));
 }
index f38f60465693d03ea95c484c56985ba26c20be2c..36430278d2531b8f21a3149f2e2512ecbe29f9c9 100644 (file)
@@ -34,16 +34,22 @@ class DataFilesLoader : public QObject
   Q_OBJECT
 public:
   enum class ReturnCode {
-    SUCCESS,
-    E_NO_FILES,
-    E_FATAL
+    SUCCESS,   /* All files loaded successfully */
+    E_FAILED,  /* Measurement data could not have been loaded */
+    W_LIMITED  /* Some non-essential data could not have been loaded */
   };
 
-  explicit DataFilesLoader(QObject* parent = nullptr);
-  ReturnCode loadSingleRun(const QDir& path, std::vector<struct HPCS_MeasuredData* >& loadedData);
+  ReturnCode loadSingleRun(const QDir& path, std::vector<struct HPCS_MeasuredData* >& measuredData,
+                           std::vector<std::pair<const QString, struct HPCS_MethodInfo* >>& methodInfo);
 
 private:
-  QStringList m_supportedFileTypes;
+  void displayFailedFiles(std::vector<std::pair<const QString, const QString>>& failedFiles);
+  bool loadMeasuredData(const QDir path, std::vector<struct HPCS_MeasuredData* >& measuredData);
+  bool loadMethodInfo(const QDir path, std::vector<std::pair<const QString, struct HPCS_MethodInfo* >>& methodInfo);
+  void logFailedFile(const QString file, const char* msg, std::vector<std::pair<const QString, const QString>>& failedFiles);
+
+  static const QStringList m_supportedMeasurementFileTypes;
+  static const QStringList m_supportedMethodInfoFileTypes;
 
 signals:
 
index d788cde2a3e855557b8b3aa4d78309ac2a08996e..ad738964382655acd78d5fbe579ce764474737c6 100644 (file)
 #include "datamanager.h"
 #include "imagedrawer.h"
 #include "logger.h"
+#include "methodinfolistingtablemodel.h"
+#include "gui/methodinfodialog.h"
 #include <QtWidgets/QMessageBox>
 
-const char DataManager::UNIT_DEGREES_CELSIUS_TEXT[] = {static_cast<char>(0xB0), 0x43, 0x00};
+const char DataManager::UNIT_DEGREES_CELSIUS_TEXT[] = {static_cast<char>(0xC2), 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};
@@ -293,6 +295,7 @@ Signal::YUnit DataManager::yunitFromUnitStr(const char* str)
 std::shared_ptr<SingleRunData> DataManager::loadSingleRun(QDir& dir)
 {
   std::vector<struct HPCS_MeasuredData* > measuredData;
+  std::vector<std::pair<const QString, struct HPCS_MethodInfo* >> methodInfo;
   std::shared_ptr<SingleRunData> singleRun;
   SignalsMap sigs;
   SignalControllersMap ctrls;
@@ -300,13 +303,18 @@ std::shared_ptr<SingleRunData> DataManager::loadSingleRun(QDir& dir)
   LocalLoggerPtr llog = Logger::createLocalLog();
   llog->setPrintLevel(Logger::Level::WARNING);
 
-  ret = m_dfl.loadSingleRun(dir, measuredData);
-  if (ret == DataFilesLoader::ReturnCode::E_NO_FILES) {
+  ret = m_dfl.loadSingleRun(dir, measuredData, methodInfo);
+  switch (ret) {
+  case DataFilesLoader::ReturnCode::E_FAILED:
     QMessageBox::warning(nullptr, "Data loading", "Directory '" + dir.path() + "' does not seem to contain ChemStation run data.");
     return nullptr;
+    break;
+  case DataFilesLoader::ReturnCode::W_LIMITED:
+    QMessageBox::warning(nullptr, "Data loading", "Some files could not have been loaded");
+    break;
+  default:
+    break;
   }
-  if (ret != DataFilesLoader::ReturnCode::SUCCESS)
-    return nullptr;
 
   QStringList operatorNames;
   QStringList methodNames;
@@ -334,14 +342,14 @@ std::shared_ptr<SingleRunData> DataManager::loadSingleRun(QDir& dir)
       eqp = equipmentFromFiletype(md->file_type);
     } catch (std::invalid_argument& ia) {
       llog->log(Logger::ERROR, ME_SENDER_STR, ia.what());
-      hpcs_free(md);
+      hpcs_free_mdata(md);
       continue;
     }
     try {
       res = resourceFromFiletype(md->file_type);
     } catch (std::invalid_argument& ia) {
       llog->log(Logger::ERROR, ME_SENDER_STR, ia.what());
-      hpcs_free(md);
+      hpcs_free_mdata(md);
       continue;
 
     }
@@ -349,7 +357,7 @@ std::shared_ptr<SingleRunData> DataManager::loadSingleRun(QDir& dir)
       yu = yunitFromUnitStr(md->y_units);
     } catch (std::invalid_argument& ia) {
       llog->log(Logger::ERROR, ME_SENDER_STR, QString("Invalid units ") + ia.what());
-      hpcs_free(md);
+      hpcs_free_mdata(md);
       continue;
     }
     samplingRate = md->sampling_rate;
@@ -380,7 +388,7 @@ std::shared_ptr<SingleRunData> DataManager::loadSingleRun(QDir& dir)
 
     sigs[_s->descriptiveName().toStdString()] = _s;
     ctrls[_s->descriptiveName().toStdString()] = _c;
-    hpcs_free(md);
+    hpcs_free_mdata(md);
   }
 
   /* We must have same number of signals and controllers */
@@ -428,8 +436,23 @@ std::shared_ptr<SingleRunData> DataManager::loadSingleRun(QDir& dir)
     }
   }
 
+  /* Now deal with the method information */
+  MethodInfoList methodInfoList;
+  for (std::pair<const QString, struct HPCS_MethodInfo* >& p : methodInfo) {
+    MethodParametersList mpList;
+    struct HPCS_MethodInfo* minfo = p.second;
+
+    for (size_t idx = 0; idx < minfo->count; idx++) {
+      struct HPCS_MethodInfoBlock* b = &minfo->blocks[idx];
+
+      mpList.push_back(MethodParameter(QString::fromUtf8(b->name), QString::fromUtf8(b->value)));
+    }
+    hpcs_free_minfo(minfo);
+    methodInfoList.push_back(MethodInfo(p.first, mpList));
+  }
+
   singleRun = std::shared_ptr<SingleRunData>(new SingleRunData(methodNames.at(0), operatorNames.at(0), sampleInfos.at(0), dates.at(0), times.at(0), sigs, ctrls,
-                                                               dir.dirName(), dir.absolutePath(), this));
+                                                               dir.dirName(), dir.absolutePath(), methodInfoList,this));
   singleRun->readUserDataFromJSON();
 
   Logger::log(Logger::DEBUG, ME_SENDER_STR, "Single run successfully parsed");
@@ -738,6 +761,41 @@ void DataManager::onSequenceSelected(const QString& key)
   emit setActiveSingleRunKey(m_activeSequence->selectedRunKey());
 }
 
+void DataManager::onShowMethodInfoClicked()
+{
+  MethodInfoDialog miWidget;
+  std::shared_ptr<SingleRunData> sr;
+  if (m_activeSequence == nullptr)
+    return;
+
+  sr = m_activeSequence->selectedRun();
+
+  const MethodInfoList& mil = sr->methodInfoList();
+  for (const MethodInfo& mi : mil) {
+    MethodInfoListingWidget* listingWidget = new MethodInfoListingWidget(&miWidget);
+    if (listingWidget == nullptr)
+      continue;
+    MethodInfoListingTableModel* model = new MethodInfoListingTableModel(listingWidget);
+    if (model == nullptr)
+      continue;
+
+    Logger::log(Logger::Level::DEBUG, ME_SENDER_STR, mi.filename());
+    std::vector<MethodInfoListingTableModel::ModelItem> model_data;
+    for (MethodParameter p : mi.parameters()) {
+      MethodInfoListingTableModel::ModelItem model_item(p.name, p.value);
+      model_data.push_back(model_item);
+      Logger::log(Logger::Level::DEBUG, ME_SENDER_STR, QString("Name %1, Value %2").arg(model_item.name()).arg(model_item.value()));
+    }
+
+    model->set(model_data);
+    listingWidget->setTableModel(model);
+    miWidget.addTab(listingWidget, mi.filename());
+  }
+
+  Logger::log(Logger::Level::DEBUG, ME_SENDER_STR, QString("Show method info: %1").arg(QString::fromStdString(m_activeSequence->selectedRunKey())));
+  miWidget.exec();
+}
+
 void DataManager::onSingleRunClose(const QString& key)
 {
   std::string stdKey = key.toStdString();
index 1d98f9b9aa9ca5641c7c33188e0dcbf0dd6931ed..3627382b7eb5e2b76039159001f01b5ad8ec4020 100644 (file)
@@ -109,10 +109,12 @@ public slots:
   void onSaveAllChanges();
   void onSequenceClose(const QString& key);
   void onSequenceSelected(const QString& key);
+  void onShowMethodInfoClicked();
   void onSingleRunClose(const QString& key);
   void onSingleRunSelected(const QString& key);
 
 
+
 };
 
 #endif // DATAMANAGER_H
index 5da3a9e146e975d67c71fdde9664b85de5ca4dd1..84a95abdeba77408a982d8a84b44e4cf9d071015 100644 (file)
@@ -78,6 +78,8 @@ void MainWindow::connectActions()
   /* RUN/SEQ cboxes*/
   connect(ui->qcbox_sequence, SIGNAL(activated(QString)), this, SLOT(onSequenceSelected(QString)));
   connect(ui->qcbox_singleRun, SIGNAL(activated(QString)), this, SLOT(onSingleRunSelected(QString)));
+  /* Method info */
+  connect(ui->qpb_showMethodInfo, SIGNAL(clicked()), this, SLOT(onShowMethodInfoClicked()));
 }
 
 /* Public slots */
@@ -200,6 +202,11 @@ void MainWindow::onSequenceSelected(const QString &str)
   emit sequenceSelected(str);
 }
 
+void MainWindow::onShowMethodInfoClicked()
+{
+  emit showMethodInfoClicked();
+}
+
 void MainWindow::onSingleRunSelected(const QString &str)
 {
   emit singleRunSelected(str);
index 5a3b4f334fd6728ea3f84fe3b3b6ff3a345befd5..32bce9313ae8f15256804b49c6b919beb66c0c76 100644 (file)
@@ -76,6 +76,7 @@ private slots:
   void onSaveChanges() { emit saveChanges(); }
   void onSaveAllChanges() { emit saveAllChanges(); }
   void onSequenceSelected(const QString& str);
+  void onShowMethodInfoClicked();
   void onSingleRunSelected(const QString& str);
   void onSWFullSizeToggle();
   void onZoomSelected();
@@ -92,6 +93,7 @@ signals:
   void saveAllChanges();
   void sequenceClose(const QString& str);
   void sequenceSelected(const QString& str);
+  void showMethodInfoClicked();
   void singleRunClose(const QString& key);
   void singleRunSelected(const QString& str);
   void zoomMode();
index f2fea0d72858a7dd8c313710db5a5969284ee79d..861d0af665d0e437ef5ddccea7dfb7a30241217d 100644 (file)
          </property>
         </widget>
        </item>
+       <item row="1" column="3">
+        <widget class="QLabel" name="ql_dateTime">
+         <property name="text">
+          <string>Date/Time:</string>
+         </property>
+        </widget>
+       </item>
        <item row="1" column="2">
         <widget class="QLineEdit" name="qle_sampleInfo">
          <property name="sizePolicy">
          </property>
         </widget>
        </item>
-       <item row="1" column="3">
-        <widget class="QLabel" name="ql_dateTime">
-         <property name="text">
-          <string>Date/Time:</string>
-         </property>
-        </widget>
-       </item>
        <item row="1" column="4">
         <widget class="QLineEdit" name="qle_dateTime">
          <property name="alignment">
          </property>
         </widget>
        </item>
+       <item row="2" column="4">
+        <widget class="QPushButton" name="qpb_showMethodInfo">
+         <property name="text">
+          <string>Show method info</string>
+         </property>
+        </widget>
+       </item>
       </layout>
      </widget>
     </item>
         <rect>
          <x>0</x>
          <y>0</y>
-         <width>782</width>
-         <height>309</height>
+         <width>780</width>
+         <height>292</height>
         </rect>
        </property>
        <property name="sizePolicy">
      <x>0</x>
      <y>0</y>
      <width>800</width>
-     <height>25</height>
+     <height>21</height>
     </rect>
    </property>
    <widget class="QMenu" name="menuData">
    </widget>
    <widget class="QMenu" name="menuHelp">
     <property name="title">
-     <string>Help</string>
+     <string>He&amp;lp</string>
     </property>
     <addaction name="actionAbout"/>
    </widget>
    <widget class="QMenu" name="menuExport">
     <property name="title">
-     <string>Export</string>
+     <string>E&amp;xport</string>
     </property>
     <addaction name="actionRaw_values"/>
     <addaction name="actionIntegration_results"/>
   </widget>
   <action name="actionLoad_single_run">
    <property name="text">
-    <string>Load single run</string>
+    <string>&amp;Load single run</string>
    </property>
   </action>
   <action name="actionLoad_sequence">
    <property name="text">
-    <string>Load sequence</string>
+    <string>L&amp;oad sequence</string>
    </property>
   </action>
   <action name="actionAbout">
    <property name="text">
-    <string>About</string>
+    <string>&amp;About</string>
    </property>
   </action>
   <action name="actionRaw_values">
    <property name="text">
-    <string>Raw data</string>
+    <string>&amp;Raw data</string>
    </property>
   </action>
   <action name="actionIntegration_results">
    <property name="text">
-    <string>Integration results</string>
+    <string>&amp;Integration results</string>
    </property>
   </action>
   <action name="actionGraph_as_image">
    <property name="text">
-    <string>Graph as image</string>
+    <string>&amp;Graph as image</string>
    </property>
   </action>
   <action name="actionSave_changes">
    <property name="text">
-    <string>Save changes</string>
+    <string>&amp;Save changes</string>
    </property>
    <property name="shortcut">
     <string>Ctrl+S</string>
   </action>
   <action name="actionSave_all_changes">
    <property name="text">
-    <string>Save all changes</string>
+    <string>Sa&amp;ve all changes</string>
    </property>
    <property name="shortcut">
     <string>Ctrl+Shift+S</string>
   </action>
   <action name="actionClose_single_run">
    <property name="text">
-    <string>Close single run</string>
+    <string>&amp;Close single run</string>
    </property>
   </action>
   <action name="actionClose_sequence">
    <property name="text">
-    <string>Close sequence</string>
+    <string>Clos&amp;e sequence</string>
    </property>
   </action>
  </widget>
diff --git a/gui/methodinfodialog.cpp b/gui/methodinfodialog.cpp
new file mode 100644 (file)
index 0000000..b9c4450
--- /dev/null
@@ -0,0 +1,28 @@
+#include "methodinfodialog.h"
+#include "ui_methodinfodialog.h"
+#include <QTabWidget>
+
+MethodInfoDialog::MethodInfoDialog(QWidget *parent) :
+  QDialog(parent),
+  ui(new Ui::MethodInfoDialog)
+{
+  ui->setupUi(this);
+  ui->verticalLayout->addWidget(&m_tabs);
+}
+
+MethodInfoDialog::~MethodInfoDialog()
+{
+  for (int idx = 0; idx < m_tabs.count(); idx++)
+    m_tabs.removeTab(0);
+
+  for (MethodInfoListingWidget* w : m_listWidgets)
+    delete w;
+
+  delete ui;
+}
+
+void MethodInfoDialog::addTab(MethodInfoListingWidget* w, const QString& label)
+{
+  m_listWidgets.push_back(w);
+  m_tabs.addTab(w, label);
+}
diff --git a/gui/methodinfodialog.h b/gui/methodinfodialog.h
new file mode 100644 (file)
index 0000000..42c6783
--- /dev/null
@@ -0,0 +1,28 @@
+#ifndef METHODINFODIALOG_H
+#define METHODINFODIALOG_H
+
+#include "methodinfolistingwidget.h"
+#include <QTabWidget>
+#include <QDialog>
+
+namespace Ui {
+class MethodInfoDialog;
+}
+
+class MethodInfoDialog : public QDialog
+{
+  Q_OBJECT
+
+public:
+  explicit MethodInfoDialog(QWidget* parent = nullptr);
+  ~MethodInfoDialog();
+
+  void addTab(MethodInfoListingWidget* w, const QString& label);
+
+private:
+  std::vector<MethodInfoListingWidget*> m_listWidgets;
+  QTabWidget m_tabs;
+  Ui::MethodInfoDialog *ui;
+};
+
+#endif // METHODINFOWIDGET_H
diff --git a/gui/methodinfodialog.ui b/gui/methodinfodialog.ui
new file mode 100644 (file)
index 0000000..187bf00
--- /dev/null
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>MethodInfoDialog</class>
+ <widget class="QWidget" name="MethodInfoDialog">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>295</width>
+    <height>348</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Form</string>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout"/>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/gui/methodinfolistingwidget.cpp b/gui/methodinfolistingwidget.cpp
new file mode 100644 (file)
index 0000000..2ccbaa8
--- /dev/null
@@ -0,0 +1,21 @@
+#include "methodinfolistingwidget.h"
+#include "ui_methodinfolistingwidget.h"
+
+MethodInfoListingWidget::MethodInfoListingWidget(QWidget *parent) :
+  QWidget(parent),
+  ui(new Ui::MethodInfoListingWidget)
+{
+  ui->setupUi(this);
+}
+
+MethodInfoListingWidget::~MethodInfoListingWidget()
+{
+  delete ui;
+  delete m_model;
+}
+
+void MethodInfoListingWidget::setTableModel(MethodInfoListingTableModel* model)
+{
+  m_model = model;
+  ui->qtabv_list->setModel(model);
+}
diff --git a/gui/methodinfolistingwidget.h b/gui/methodinfolistingwidget.h
new file mode 100644 (file)
index 0000000..0365126
--- /dev/null
@@ -0,0 +1,25 @@
+#ifndef METHODINFOLISTINGWIDGET_H
+#define METHODINFOLISTINGWIDGET_H
+
+#include "methodinfolistingtablemodel.h"
+#include <QWidget>
+
+namespace Ui {
+class MethodInfoListingWidget;
+}
+
+class MethodInfoListingWidget : public QWidget
+{
+  Q_OBJECT
+
+public:
+  explicit MethodInfoListingWidget(QWidget* parent = nullptr);
+  ~MethodInfoListingWidget();
+  void setTableModel(MethodInfoListingTableModel* model);
+
+private:
+  Ui::MethodInfoListingWidget* ui;
+  MethodInfoListingTableModel* m_model;
+};
+
+#endif // METHODINFOLISTINGWIDGET_H
diff --git a/gui/methodinfolistingwidget.ui b/gui/methodinfolistingwidget.ui
new file mode 100644 (file)
index 0000000..be93a5b
--- /dev/null
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>MethodInfoListingWidget</class>
+ <widget class="QWidget" name="MethodInfoListingWidget">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>400</width>
+    <height>300</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Form</string>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout">
+   <item>
+    <widget class="QTableView" name="qtabv_list">
+     <property name="editTriggers">
+      <set>QAbstractItemView::NoEditTriggers</set>
+     </property>
+     <property name="alternatingRowColors">
+      <bool>true</bool>
+     </property>
+     <attribute name="verticalHeaderVisible">
+      <bool>false</bool>
+     </attribute>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
index a201577c541a667cf2dd5a15a0059751900c8892..cc5a8e5d4ee07f093c0ee7ddbf02ffb2b3791e30 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -61,6 +61,7 @@ int main(int argc, char *argv[])
   QObject::connect(mWin.get(), SIGNAL(loadSequence(QString)), dMgr.get(), SLOT(onLoadSequence(QString)));
   QObject::connect(mWin.get(), SIGNAL(sequenceSelected(QString)), dMgr.get(), SLOT(onSequenceSelected(QString)));
   QObject::connect(mWin.get(), SIGNAL(sequenceClose(QString)), dMgr.get(), SLOT(onSequenceClose(QString)));
+  QObject::connect(mWin.get(), SIGNAL(showMethodInfoClicked()), dMgr.get(), SLOT(onShowMethodInfoClicked()));
   QObject::connect(mWin.get(), SIGNAL(singleRunClose(QString)), dMgr.get(), SLOT(onSingleRunClose(QString)));
   QObject::connect(mWin.get(), SIGNAL(singleRunSelected(QString)), dMgr.get(), SLOT(onSingleRunSelected(QString)));
 
diff --git a/methodinfo.cpp b/methodinfo.cpp
new file mode 100644 (file)
index 0000000..a496aba
--- /dev/null
@@ -0,0 +1,7 @@
+#include "methodinfo.h"
+
+MethodInfo::MethodInfo(const QString& filename, const MethodParametersList& params) :
+  m_filename(filename),
+  m_params(params)
+{}
+
diff --git a/methodinfo.h b/methodinfo.h
new file mode 100644 (file)
index 0000000..da05ed7
--- /dev/null
@@ -0,0 +1,31 @@
+#ifndef METHODINFO_H
+#define METHODINFO_H
+
+#include <QString>
+
+struct MethodParameter {
+  MethodParameter(const QString& _name, const QString& _value) :
+    name(_name),
+    value(_value)
+  {}
+
+  const QString name;
+  const QString value;
+};
+
+typedef std::vector<MethodParameter> MethodParametersList;
+
+class MethodInfo
+{
+public:
+  explicit MethodInfo(const QString& filename, const MethodParametersList& params);
+  inline QString filename() const { return m_filename; }
+  inline MethodParametersList parameters() const { return m_params; }
+
+private:
+  const QString m_filename;
+  const MethodParametersList m_params;
+
+};
+
+#endif // METHODINFO_H
diff --git a/methodinfolistingtablemodel.cpp b/methodinfolistingtablemodel.cpp
new file mode 100644 (file)
index 0000000..4239775
--- /dev/null
@@ -0,0 +1,73 @@
+#include "methodinfolistingtablemodel.h"
+
+MethodInfoListingTableModel::MethodInfoListingTableModel(QObject* parent) : QAbstractTableModel(parent)
+{}
+
+MethodInfoListingTableModel::~MethodInfoListingTableModel()
+{}
+
+int MethodInfoListingTableModel::columnCount(const QModelIndex& parent) const
+{
+  Q_UNUSED(parent);
+
+  if (m_data.size() < 1)
+    return 0;
+  return 2;
+}
+
+QVariant MethodInfoListingTableModel::data(const QModelIndex& index, int role) const
+{
+  if (m_data.size() < 1)
+    return QVariant();
+  if (index.column() > 1 || index.column() < 0)
+    return QVariant();
+  if (index.row() >= m_data.size() || index.row() < 0)
+    return QVariant();
+
+  switch (role) {
+  case Qt::DisplayRole:
+  {
+    const ModelItem& mi = m_data[index.row()];
+    switch (index.column()) {
+      case 0:
+        return mi.name();
+      case 1:
+        return mi.value();
+      default:
+        return QVariant();
+    }
+  }
+    break;
+  case Qt::TextAlignmentRole:
+    return Qt::AlignRight + Qt::AlignVCenter;
+  default:
+    return QVariant();
+  }
+}
+
+QVariant MethodInfoListingTableModel::headerData(int section, Qt::Orientation orientation, int role) const
+{
+  if (role == Qt::DisplayRole && orientation == Qt::Horizontal) {
+    switch (section) {
+    case 0:
+      return QString("Name");
+    case 1:
+      return QString("Value");
+    default:
+      return QVariant();
+    }
+  }
+  return QVariant();
+}
+
+int MethodInfoListingTableModel::rowCount(const QModelIndex& parent) const
+{
+  return m_data.size();
+}
+
+void MethodInfoListingTableModel::set(const std::vector<ModelItem>& data)
+{
+  beginResetModel();
+  m_data = data;
+  endResetModel();
+}
diff --git a/methodinfolistingtablemodel.h b/methodinfolistingtablemodel.h
new file mode 100644 (file)
index 0000000..cabc0b5
--- /dev/null
@@ -0,0 +1,35 @@
+#ifndef MODELINFOLISTINGTABLEMODEL_H
+#define MODELINFOLISTINGTABLEMODEL_H
+
+#include <QAbstractTableModel>
+
+class MethodInfoListingTableModel : public QAbstractTableModel
+{
+  Q_OBJECT
+public:
+  class ModelItem {
+  public:
+    ModelItem(const QString& name, const QString& value) :
+      m_name(name),
+      m_value(value) {}
+    QString name() const { return m_name; }
+    QString value() const { return m_value; }
+
+  private:
+    QString m_name;
+    QString m_value;
+  };
+
+  MethodInfoListingTableModel(QObject* parent = nullptr);
+  ~MethodInfoListingTableModel();
+  int columnCount(const QModelIndex& parent) const;
+  QVariant data(const QModelIndex& index, int role) const;
+  QVariant headerData(int section, Qt::Orientation orientation, int role) const;
+  int rowCount(const QModelIndex& parent) const;
+  void set(const std::vector<ModelItem>& data);
+
+private:
+  std::vector<ModelItem> m_data;
+};
+
+#endif // MODELINFOLISTINGTABLEMODEL_H
index 5d1d4720e7171b40b4fc2833788d058f73b381ab..14fc82844a94836103d24c22735d02fafac84950 100644 (file)
 
 SingleRunData::SingleRunData(const QString& methodName, const QString& operatorName, const QString& sampleInfo, const QDate date, const QTime time,
                              SignalsMap& sigs, SignalControllersMap& ctrls,
-                             const QString& dirname, const QString& absPath, QObject *parent) :
+                             const QString& dirname, const QString& absPath, MethodInfoList& methodInfoList, QObject *parent) :
   QObject(parent),
   m_absPath(absPath),
   m_date(date),
   m_dirName(dirname),
+  m_methodInfoList(methodInfoList),
   m_methodName(methodName),
   m_operatorName(operatorName),
   m_sampleInfo(sampleInfo),
index c0717cc21c83436b5fe1018899e72074b579532a..47b73bee5de2c615e940b1b9df45c8ca197637f8 100644 (file)
 #ifndef SINGLERUNDATA_H
 #define SINGLERUNDATA_H
 
+#include "methodinfo.h"
 #include "signalcontroller.h"
 #include <memory>
 #include <QtCore/QDate>
 #include <QtCore/QObject>
 #include <QtCore/QTime>
 
+typedef std::vector<MethodInfo> MethodInfoList;
 typedef std::map<std::string, std::shared_ptr<SignalController>> SignalControllersMap;
 typedef std::map<std::string, std::shared_ptr<Signal>> SignalsMap;
 
@@ -39,7 +41,8 @@ class SingleRunData : public QObject
 public:
   explicit SingleRunData(const QString& methodName, const QString& operatorName, const QString& sampleInfo, const QDate date, const QTime time,
                          SignalsMap& sigs, SignalControllersMap& ctrls,
-                         const QString& dirname, const QString& absPath, QObject* parent = nullptr);
+                         const QString& dirname, const QString& absPath,
+                         MethodInfoList& methodInfoList, QObject* parent = nullptr);
   QString absPath() const { return m_absPath; }
   const SignalControllersMap& allControllers() const { return m_ctrls; }
   std::vector<std::string> allKeys() const;
@@ -49,6 +52,7 @@ public:
   QDate date() const { return m_date; }
   QString dirName() const { return m_dirName; }
   SignalControllersMap::iterator ctrls_end() { return m_ctrls.end(); }
+  const MethodInfoList& methodInfoList() const { return m_methodInfoList; }
   QString methodName() const { return m_methodName; }
   QString operatorName() const { return m_operatorName; }
   void readUserDataFromJSON();
@@ -63,6 +67,7 @@ private:
   const QString m_absPath;
   const QDate m_date;
   const QString m_dirName;
+  const MethodInfoList m_methodInfoList;
   const QString m_methodName;
   const QString m_operatorName;
   const QString m_sampleInfo;