]> Devoid-pointer.net GitWeb - anyanka.git/commitdiff
Add option to close single runs
authorMichal Malý <madcatxster@devoid-pointer.net>
Thu, 12 Mar 2015 20:18:09 +0000 (21:18 +0100)
committerMichal Malý <madcatxster@devoid-pointer.net>
Thu, 12 Mar 2015 20:18:09 +0000 (21:18 +0100)
datamanager.cpp
datamanager.h
gui/mainwindow.cpp
gui/mainwindow.h
gui/mainwindow.ui
main.cpp

index 29f070f2acf5c7a841a4ff0a76825e16defe58a0..7e08414f505a5fc443be67fe48c0eadb1e11885e 100644 (file)
@@ -690,6 +690,46 @@ void DataManager::onSequenceSelected(const QString& key)
   emit setActiveSingleRunKey(m_activeSequence->selectedRunKey());
 }
 
+void DataManager::onSingleRunClose(const QString& key)
+{
+  std::string stdKey = key.toStdString();
+  QString newKey;
+
+  if (m_activeSequence == nullptr)
+    return;
+
+  stdKey = key.toStdString();
+
+  SingleRunsMap::const_iterator cit = m_activeSequence->cbegin();
+  while (cit != m_activeSequence->cend()) {
+    if (cit->first.compare(stdKey) == 0)
+      break;
+    cit++;
+  }
+  if (cit == m_activeSequence->cend()) {
+    Logger::log(Logger::Level::ERROR, ME_SENDER_STR, "[" + key + "]: No such single run.");
+    return;
+  }
+
+  if (m_activeSequence->count() > 1) {
+    /* Closed single run was the last in the sequence */
+    if (std::next(cit) == m_activeSequence->cend())
+      newKey = QString::fromStdString(std::prev(cit)->first);
+    else
+      newKey = QString::fromStdString(std::next(cit)->first);
+
+    onSingleRunSelected(newKey);
+  } else {
+    emit cleanDashboard();
+    emit setSingleRunInfo("", "", "", "");
+  }
+
+  m_activeSequence->remove(stdKey);
+  m_singleSelModel.setSingleRuns(m_activeSequence->allRunKeys());
+  if (!newKey.isEmpty())
+    emit setActiveSingleRunKey(newKey.toStdString());
+}
+
 void DataManager::onSingleRunSelected(const QString& key)
 {
   if (m_activeSequence == nullptr)
index 8361fccb405e6f54e80a23f5a6aa1391fcbc59e8..221c5dd1d81c173652efda4df5c380a7df93f03d 100644 (file)
@@ -108,6 +108,7 @@ public slots:
   void onSaveChanges();
   void onSaveAllChanges();
   void onSequenceSelected(const QString& key);
+  void onSingleRunClose(const QString& key);
   void onSingleRunSelected(const QString& key);
 
 
index e97b2c8c87c5cfd5281bcc33de9694dbb8b8f761..1a49029ed8cfa86b795cee87890bbe8e5e1fd258 100644 (file)
@@ -69,6 +69,7 @@ void MainWindow::connectActions()
   /* DATA menu */
   connect(ui->actionLoad_single_run, SIGNAL(triggered()), this, SLOT(onLoadSingleRun()));
   connect(ui->actionLoad_sequence, SIGNAL(triggered()), this, SLOT(onLoadSequence()));
+  connect(ui->actionClose_single_run, SIGNAL(triggered()), this, SLOT(onCloseSingleRun()));
   connect(ui->actionSave_changes, SIGNAL(triggered()), this, SLOT(onSaveChanges()));
   connect(ui->actionSave_all_changes, SIGNAL(triggered()), this, SLOT(onSaveAllChanges()));
   /* EXPORT menu */
@@ -118,6 +119,11 @@ void MainWindow::onCleanDashboard()
     delete m_dashboard->widget(0);
 }
 
+void MainWindow::onCloseSingleRun()
+{
+  emit singleRunClose(ui->qcbox_singleRun->currentText());
+}
+
 void MainWindow::onSetActiveSequenceIndex(const int idx)
 {
   if (ui->qcbox_sequence->currentIndex() == idx)
index a02bd91ce89b2bce9750abbd9b5b819102fa2845..912586d255bd22dd893f3f128ee2ca4ca636e58c 100644 (file)
@@ -69,6 +69,7 @@ public slots:
 
 private slots:
   void onAboutAnyanka();
+  void onCloseSingleRun();
   void onExportGraphToImage() { emit exportGraphToImage(); }
   void onExportPeaks() { emit exportPeaks(); }
   void onExportRawData() { emit exportRawData(); }
@@ -94,6 +95,7 @@ signals:
   void saveChanges();
   void saveAllChanges();
   void sequenceSelected(const QString& str);
+  void singleRunClose(const QString& key);
   void singleRunSelected(const QString& str);
   void zoomMode();
 };
index b994eaed4de370c99d6fd085669167a38ccb2c91..23cf885625d1849328b5a37d07668bc0a8acce79 100644 (file)
     <addaction name="actionLoad_single_run"/>
     <addaction name="actionLoad_sequence"/>
     <addaction name="separator"/>
+    <addaction name="actionClose_single_run"/>
+    <addaction name="separator"/>
     <addaction name="actionSave_changes"/>
     <addaction name="actionSave_all_changes"/>
    </widget>
     <string>Ctrl+Shift+S</string>
    </property>
   </action>
+  <action name="actionClose_single_run">
+   <property name="text">
+    <string>Close single run</string>
+   </property>
+  </action>
  </widget>
  <resources/>
  <connections/>
index f44d9627bf1c8b4116d85dd4307aa1552ccffe7a..f141a3303f76c975e68b9a175f47f7214fd6c81f 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -65,6 +65,7 @@ int main(int argc, char *argv[])
   QObject::connect(mWin.get(), SIGNAL(loadSingleRun(QString)), dMgr.get(), SLOT(onLoadSingleRun(QString)));
   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(singleRunClose(QString)), dMgr.get(), SLOT(onSingleRunClose(QString)));
   QObject::connect(mWin.get(), SIGNAL(singleRunSelected(QString)), dMgr.get(), SLOT(onSingleRunSelected(QString)));
 
   mWin->show();