From: Michal MalĂ˝ Date: Thu, 12 Mar 2015 20:18:09 +0000 (+0100) Subject: Add option to close single runs X-Git-Tag: 0.4b~10 X-Git-Url: https://gitweb.devoid-pointer.net/?a=commitdiff_plain;h=ed9734f7797cbbefdfd0f888c7c85aa795a7f999;p=anyanka.git Add option to close single runs --- diff --git a/datamanager.cpp b/datamanager.cpp index 29f070f..7e08414 100644 --- a/datamanager.cpp +++ b/datamanager.cpp @@ -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) diff --git a/datamanager.h b/datamanager.h index 8361fcc..221c5dd 100644 --- a/datamanager.h +++ b/datamanager.h @@ -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); diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index e97b2c8..1a49029 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -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) diff --git a/gui/mainwindow.h b/gui/mainwindow.h index a02bd91..912586d 100644 --- a/gui/mainwindow.h +++ b/gui/mainwindow.h @@ -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(); }; diff --git a/gui/mainwindow.ui b/gui/mainwindow.ui index b994eae..23cf885 100644 --- a/gui/mainwindow.ui +++ b/gui/mainwindow.ui @@ -229,6 +229,8 @@ + + @@ -302,6 +304,11 @@ Ctrl+Shift+S + + + Close single run + + diff --git a/main.cpp b/main.cpp index f44d962..f141a33 100644 --- 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();