From 8bfbf82bdc26c40767530b8954193929805bc754 Mon Sep 17 00:00:00 2001 From: Kimmo Varis Date: Tue, 7 Jun 2011 16:12:21 +0300 Subject: [PATCH] GUI: Suggest using project file if one is found. If we there is project file in the directory to check then ask user if one wants to use the project file instead. If there are multiple project files then just tell there are project files and ask if user wants to continue without using them. Ticket: #2816 (GUI regression: Interrupted checking because of too many #ifdef configurations.) --- gui/mainwindow.cpp | 59 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 58 insertions(+), 1 deletion(-) diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index 843b34a3d..3603e5d2b 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -359,7 +359,64 @@ void MainWindow::CheckFiles() void MainWindow::CheckDirectory() { - DoCheckFiles(SelectFilesToCheck(QFileDialog::DirectoryOnly)); + QStringList dir = SelectFilesToCheck(QFileDialog::DirectoryOnly); + if (dir.isEmpty()) + return; + + QDir checkDir(dir[0]); + QStringList filters; + filters << "*.cppcheck"; + checkDir.setNameFilters(filters); + QStringList projFiles = checkDir.entryList(); + if (!projFiles.empty()) + { + if (projFiles.size() == 1) + { + // If one project file found, suggest loading it + QMessageBox msgBox(this); + msgBox.setWindowTitle(tr("Cppcheck")); + const QString msg(tr("Found project file: %1\n\nDo you want to " + "load this project file instead?").arg(projFiles[0])); + msgBox.setText(msg); + msgBox.setIcon(QMessageBox::Warning); + msgBox.addButton(QMessageBox::Yes); + msgBox.addButton(QMessageBox::No); + msgBox.setDefaultButton(QMessageBox::Yes); + int dlgResult = msgBox.exec(); + if (dlgResult == QMessageBox::Yes) + { + LoadProjectFile(projFiles[0]); + } + else + { + DoCheckFiles(dir); + } + } + else + { + // If multiple project files found inform that there are project + // files also available. + QMessageBox msgBox(this); + msgBox.setWindowTitle(tr("Cppcheck")); + const QString msg(tr("Found project files from the directory.\n\n" + "Do you want to proceed checking without " + "using any of these project files?")); + msgBox.setText(msg); + msgBox.setIcon(QMessageBox::Warning); + msgBox.addButton(QMessageBox::Yes); + msgBox.addButton(QMessageBox::No); + msgBox.setDefaultButton(QMessageBox::Yes); + int dlgResult = msgBox.exec(); + if (dlgResult == QMessageBox::Yes) + { + DoCheckFiles(dir); + } + } + } + else + { + DoCheckFiles(dir); + } } void MainWindow::AddIncludeDirs(const QStringList &includeDirs, Settings &result)