diff --git a/gui/main.cpp b/gui/main.cpp index 9db0ebd5c..50a1d7407 100644 --- a/gui/main.cpp +++ b/gui/main.cpp @@ -76,7 +76,9 @@ void ShowUsage() " cppcheck-gui [OPTIONS] [files or paths]\n\n" "Options:\n" " -h, --help Print this help\n" - " -p Open given project file and start checking it\n"; + " -p Open given project file and start checking it\n" + " -l Open given results xml file\n" + " -d Specify the directory that was checked to generate the results xml specified with -l\n"; #if defined(_WIN32) QMessageBox msgBox(QMessageBox::Information, "Cppcheck GUI", diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index d58165a0d..94b416f1b 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -79,7 +79,7 @@ MainWindow::MainWindow() : connect(mUI.mActionCheckDirectory, SIGNAL(triggered()), this, SLOT(CheckDirectory())); connect(mUI.mActionSettings, SIGNAL(triggered()), this, SLOT(ProgramSettings())); connect(mUI.mActionClearResults, SIGNAL(triggered()), this, SLOT(ClearResults())); - connect(mUI.mActionOpenXML, SIGNAL(triggered()), this, SLOT(OpenXML())); + connect(mUI.mActionOpenXML, SIGNAL(triggered()), this, SLOT(OpenResults())); connect(mUI.mActionShowStyle, SIGNAL(toggled(bool)), this, SLOT(ShowStyle(bool))); connect(mUI.mActionShowErrors, SIGNAL(toggled(bool)), this, SLOT(ShowErrors(bool))); @@ -194,6 +194,24 @@ void MainWindow::HandleCLIParams(const QStringList ¶ms) const int ind = params.indexOf("-p"); if ((ind + 1) < params.length()) LoadProjectFile(params[ind + 1]); + } else if (params.contains("-l")) { + QString logFile; + const int ind = params.indexOf("-l"); + if ((ind + 1) < params.length()) + logFile = params[ind + 1]; + + if (params.contains("-d")) { + QString checkedDir; + const int ind = params.indexOf("-d"); + if ((ind + 1) < params.length()) + checkedDir = params[ind + 1]; + + LoadResults(logFile, checkedDir); + } + else + { + LoadResults(logFile); + } } else DoCheckFiles(params); } @@ -631,7 +649,7 @@ void MainWindow::ClearResults() mUI.mActionSave->setEnabled(false); } -void MainWindow::OpenXML() +void MainWindow::OpenResults() { if (mUI.mResults->HasResults()) { QMessageBox msgBox(this); @@ -658,6 +676,13 @@ void MainWindow::OpenXML() filter, &selectedFilter); + if (!selectedFile.isEmpty()) { + LoadResults(selectedFile); + } +} + +void MainWindow::LoadResults(const QString selectedFile) +{ if (!selectedFile.isEmpty()) { mUI.mResults->Clear(true); mUI.mResults->ReadErrorsXml(selectedFile); @@ -665,6 +690,12 @@ void MainWindow::OpenXML() } } +void MainWindow::LoadResults(const QString selectedFile, const QString sourceDirectory) +{ + LoadResults(selectedFile); + mUI.mResults->SetCheckDirectory(sourceDirectory); +} + void MainWindow::EnableCheckButtons(bool enable) { mUI.mActionStop->setEnabled(!enable); diff --git a/gui/mainwindow.h b/gui/mainwindow.h index 7dc84f925..774157823 100644 --- a/gui/mainwindow.h +++ b/gui/mainwindow.h @@ -94,7 +94,7 @@ public slots: * @brief Slot to open XML report file * */ - void OpenXML(); + void OpenResults(); /** * @brief Show errors with type "style" @@ -404,6 +404,19 @@ private: * @param params List of string given to command line. */ void HandleCLIParams(const QStringList ¶ms); + + /** + * @brief Load XML file to the GUI. + * @param file Filename (inc. path) of XML file to load. + */ + void LoadResults(const QString file); + + /** + * @brief Load XML file to the GUI. + * @param file Filename (inc. path) of XML file to load. + * @param checkedDirectory Path to the directory that the results were generated for. + */ + void LoadResults(const QString file, const QString checkedDirectory); /** * @brief Load project file to the GUI.