diff options
-rwxr-xr-x | quitdialog.cpp | 8 | ||||
-rw-r--r-- | textedit.cpp | 43 |
2 files changed, 30 insertions, 21 deletions
diff --git a/quitdialog.cpp b/quitdialog.cpp index e599f6b..38cf14e 100755 --- a/quitdialog.cpp +++ b/quitdialog.cpp @@ -47,10 +47,10 @@ QuitDialog::QuitDialog(QWidget *parent, QHash<int, QString> unsavedDocs, QString mFileList->setEditTriggers(QAbstractItemView::NoEditTriggers); mFileList->setFocusPolicy(Qt::NoFocus); mFileList->horizontalHeader()->setStretchLastSection( true ); - // fill the table - while (i.hasNext()) { - i.next(); + i.toBack(); //jump to the end of list to fill the table backwards + while (i.hasPrevious()) { + i.previous(); mFileList->setRowCount(mFileList->rowCount()+1); // checkbox in front of filename @@ -119,7 +119,7 @@ QList <int> QuitDialog::getTabIdsToSave() QList <int> tabIdsToSave; for (int i = 0; i < mFileList->rowCount(); i++) { if (mFileList->item(i, 0)->checkState() == Qt::Checked) { - qDebug() << mFileList->item(i, 2)->text(); + qDebug() << "tabidtosave: " << mFileList->item(i, 2)->text(); tabIdsToSave << mFileList->item(i, 2)->text().toInt(); } } diff --git a/textedit.cpp b/textedit.cpp index 084da83..d34b035 100644 --- a/textedit.cpp +++ b/textedit.cpp @@ -333,8 +333,6 @@ bool TextEdit::saveTab(int i) { } else { return saveFile(filePath); } - - } /** * Checks if there are unsaved documents in any tab, @@ -359,6 +357,12 @@ bool TextEdit::maybeSaveAnyTab() } /* + * no unsaved documents + */ + if (unsavedDocs.size() == 1) { + return true; + } + /* * only 1 unsaved document -> set modified tab as current * and show normal unsaved doc dialog */ @@ -371,14 +375,12 @@ bool TextEdit::maybeSaveAnyTab() /* * more than one unsaved documents */ - } else if(unsavedDocs.size() > 1) { - - QString docList; + } + if(unsavedDocs.size() > 1) { QHashIterator<int, QString> i (unsavedDocs); while (i.hasNext()) { i.next(); qDebug() << "unsaved: " << i.key() << ": " << i.value(); - docList.append(i.value()).append("\n"); } QuitDialog *dialog; @@ -386,32 +388,39 @@ bool TextEdit::maybeSaveAnyTab() int result = dialog->exec(); - // return true, if app can be closed + // return true, if discard is clicked, so app can be closed if (result == QDialog::Rejected){ if (dialog->isDiscarded()){ return true; } else { return false; } + } else { + bool allsaved=true; QList <int> tabIdsToSave = dialog->getTabIdsToSave(); foreach (int tabId, tabIdsToSave){ - qDebug() << "handling for save" << tabId; - + qDebug() << "testtabid" << tabId; } - return true; + foreach (int tabId, tabIdsToSave){ + qDebug() << "tabIdtosave in quitdialog: " << tabId; + tabWidget->setCurrentIndex(tabId); + if (! maybeSaveCurrentTab()) { + allsaved=false; + } + qDebug() << "handling for save" << tabId; + if (allsaved) { + return true; + } else { + return false; + } + } } - - /* - * no unsaved documents - */ - } else { - return true; } - // code should never reach this statement return false; + } |