MCPcopy Create free account
hub / github.com/MiniZinc/MiniZincIDE / promptSaveModified

Method promptSaveModified

MiniZincIDE/mainwindow.cpp:957–998  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

955}
956
957bool MainWindow::promptSaveModified()
958{
959 QVector<CodeEditor*> modifiedDocs;
960 for (int i=0; i<ui->tabWidget->count(); i++) {
961 CodeEditor* ce = qobject_cast<CodeEditor*>(ui->tabWidget->widget(i));
962 if (ce && !ce->filepath.isEmpty() && ce->document()->isModified()) {
963 modifiedDocs << ce;
964 }
965 }
966
967 // Prompt for saving modified files
968 if (!modifiedDocs.empty()) {
969 if (!saveBeforeRunning) {
970 QMessageBox msgBox;
971 if (modifiedDocs.size()==1) {
972 msgBox.setText("One of the files is modified. You have to save it before running.");
973 } else {
974 msgBox.setText("Several files have been modified. You have to save them before running.");
975 }
976 msgBox.setInformativeText("Do you want to save now and then run?");
977 QAbstractButton *saveButton = msgBox.addButton(QMessageBox::Save);
978 msgBox.addButton(QMessageBox::Cancel);
979 QAbstractButton *alwaysButton = msgBox.addButton("Always save", QMessageBox::AcceptRole);
980 msgBox.setDefaultButton(QMessageBox::Save);
981 msgBox.exec();
982 if (msgBox.clickedButton()==alwaysButton) {
983 saveBeforeRunning = true;
984 }
985 if (msgBox.clickedButton()!=saveButton && msgBox.clickedButton()!=alwaysButton) {
986 return false;
987 }
988 }
989 for (auto ce : modifiedDocs) {
990 saveFile(ce,ce->filepath);
991 if (ce->document()->isModified()) {
992 return false;
993 }
994 }
995 }
996
997 return true;
998}
999
1000QString MainWindow::setElapsedTime(qint64 elapsed_t)
1001{

Callers

nothing calls this directly

Calls 4

countMethod · 0.80
isModifiedMethod · 0.80
widgetMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected