void DataManager::saveUserDataOnExit()
{
+ enum class Choice { YESTOALL, NOTOALL, ASK };
+ Choice c = Choice::ASK;
+
for (NameSequencePair& nsp : m_sequences) {
const QString seqName = nsp.first;
std::shared_ptr<Sequence> seq = nsp.second;
while (it != seq->end()) {
std::shared_ptr<SingleRunData> sr = it->second;
+
if (sr->userDataModified()) {
- const QString srName = QString::fromStdString(it->first);
- int ret = QMessageBox::question(nullptr, "Save changes?" , "User data in sequence " + seqName + ", signal " + srName + " have been modified. "
- "Would you like to save the changes?", QMessageBox::Yes, QMessageBox::No);
- if (ret == QMessageBox::Yes)
+ switch (c) {
+ case Choice::YESTOALL:
sr->saveUserDataToJSON();
+ break;
+ case Choice::NOTOALL:
+ return;
+ case Choice::ASK: {
+ const QString srName = QString::fromStdString(it->first);
+ int ret = QMessageBox::question(nullptr, "Save changes?" , "User data in sequence " + seqName + ", signal " + srName + " have been modified. "
+ "Would you like to save the changes?",
+ QMessageBox::YesToAll | QMessageBox::Yes | QMessageBox::No | QMessageBox::NoToAll,
+ QMessageBox::Yes);
+ switch (ret) {
+ case QMessageBox::YesToAll:
+ c = Choice::YESTOALL;
+ case QMessageBox::Yes:
+ sr->saveUserDataToJSON();
+ break;
+ case QMessageBox::NoToAll:
+ c = Choice::NOTOALL;
+ break;
+ default:
+ break;
+ }
+ }
}
- ++it;
+ }
+
+ ++it;
}
}
}