GUI: Added extra command line parameters for opening a results file and for specifying which folder the results apply to

This commit is contained in:
unknown 2013-02-10 07:48:09 +01:00 committed by Daniel Marjamäki
parent ff89997d89
commit 6fdb24b7e7
3 changed files with 50 additions and 4 deletions

View File

@ -76,7 +76,9 @@ void ShowUsage()
" cppcheck-gui [OPTIONS] [files or paths]\n\n"
"Options:\n"
" -h, --help Print this help\n"
" -p <file> Open given project file and start checking it\n";
" -p <file> Open given project file and start checking it\n"
" -l <file> Open given results xml file\n"
" -d <directory> Specify the directory that was checked to generate the results xml specified with -l\n";
#if defined(_WIN32)
QMessageBox msgBox(QMessageBox::Information,
"Cppcheck GUI",

View File

@ -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 &params)
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);

View File

@ -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 &params);
/**
* @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.