2009-03-01 08:38:21 +01:00
|
|
|
/*
|
|
|
|
* Cppcheck - A tool for static C/C++ code analysis
|
2009-05-30 07:48:12 +02:00
|
|
|
* Copyright (C) 2007-2009 Daniel Marjamäki and Cppcheck team.
|
2009-03-01 08:38:21 +01:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include "mainwindow.h"
|
|
|
|
#include <QDebug>
|
|
|
|
#include <QMenu>
|
2009-03-22 13:32:07 +01:00
|
|
|
#include <QDirIterator>
|
2009-03-01 08:38:21 +01:00
|
|
|
#include <QMenuBar>
|
2009-05-24 10:53:29 +02:00
|
|
|
#include <QMessageBox>
|
2009-05-26 17:21:39 +02:00
|
|
|
#include <QToolBar>
|
2009-06-04 14:35:41 +02:00
|
|
|
#include "aboutdialog.h"
|
2009-03-22 13:32:07 +01:00
|
|
|
#include "../src/filelister.h"
|
2009-05-24 10:53:29 +02:00
|
|
|
#include "../src/cppcheckexecutor.h"
|
2009-03-01 08:38:21 +01:00
|
|
|
|
|
|
|
MainWindow::MainWindow() :
|
2009-05-24 10:53:29 +02:00
|
|
|
mSettings(tr("Cppcheck"), tr("Cppcheck-GUI")),
|
2009-03-22 13:32:07 +01:00
|
|
|
mActionExit(tr("E&xit"), this),
|
|
|
|
mActionCheckFiles(tr("&Check files(s)"), this),
|
2009-03-22 16:42:00 +01:00
|
|
|
mActionClearResults(tr("Clear &results"), this),
|
|
|
|
mActionReCheck(tr("Recheck files"), this),
|
|
|
|
mActionCheckDirectory(tr("Check &directory"), this),
|
2009-03-22 13:32:07 +01:00
|
|
|
mActionSettings(tr("&Settings"), this),
|
2009-05-24 10:53:29 +02:00
|
|
|
mActionShowAll(tr("show possible false positives"), this),
|
2009-03-22 18:39:44 +01:00
|
|
|
mActionShowSecurity(tr("Show &security errors"), this),
|
|
|
|
mActionShowStyle(tr("Show s&tyle errors"), this),
|
|
|
|
mActionShowUnused(tr("Show errors on &unused functions"), this),
|
|
|
|
mActionShowErrors(tr("Show &common errors"), this),
|
2009-05-23 10:17:27 +02:00
|
|
|
mActionShowCheckAll(tr("Check all"), this),
|
|
|
|
mActionShowUncheckAll(tr("Uncheck all"), this),
|
2009-06-02 00:26:44 +02:00
|
|
|
mActionShowCollapseAll(tr("Collapse all"), this),
|
|
|
|
mActionShowExpandAll(tr("Expand all"), this),
|
2009-05-24 10:53:29 +02:00
|
|
|
mActionAbout(tr("About"), this),
|
2009-05-26 17:21:39 +02:00
|
|
|
mActionStop(tr("Stop checking"), this),
|
|
|
|
mActionSave(tr("Save results to a file"), this),
|
2009-05-23 13:26:04 +02:00
|
|
|
mResults(mSettings, mApplications)
|
2009-03-01 08:38:21 +01:00
|
|
|
{
|
|
|
|
QMenu *menu = menuBar()->addMenu(tr("&File"));
|
2009-03-22 13:32:07 +01:00
|
|
|
menu->addAction(&mActionCheckFiles);
|
|
|
|
menu->addAction(&mActionCheckDirectory);
|
2009-03-22 16:42:00 +01:00
|
|
|
menu->addAction(&mActionReCheck);
|
2009-05-26 17:21:39 +02:00
|
|
|
menu->addAction(&mActionStop);
|
2009-03-22 16:42:00 +01:00
|
|
|
menu->addAction(&mActionClearResults);
|
2009-05-26 17:21:39 +02:00
|
|
|
menu->addAction(&mActionSave);
|
2009-03-01 08:38:21 +01:00
|
|
|
menu->addSeparator();
|
2009-03-22 13:32:07 +01:00
|
|
|
menu->addAction(&mActionExit);
|
|
|
|
|
2009-03-22 18:39:44 +01:00
|
|
|
QMenu *menuview = menuBar()->addMenu(tr("&View"));
|
|
|
|
mActionShowAll.setCheckable(true);
|
|
|
|
mActionShowSecurity.setCheckable(true);
|
|
|
|
mActionShowStyle.setCheckable(true);
|
|
|
|
mActionShowUnused.setCheckable(true);
|
|
|
|
mActionShowErrors.setCheckable(true);
|
|
|
|
|
|
|
|
menuview->addAction(&mActionShowAll);
|
|
|
|
menuview->addAction(&mActionShowSecurity);
|
|
|
|
menuview->addAction(&mActionShowStyle);
|
|
|
|
menuview->addAction(&mActionShowUnused);
|
|
|
|
menuview->addAction(&mActionShowErrors);
|
2009-05-28 17:10:09 +02:00
|
|
|
menuview->addSeparator();
|
2009-05-23 10:17:27 +02:00
|
|
|
menuview->addAction(&mActionShowCheckAll);
|
|
|
|
menuview->addAction(&mActionShowUncheckAll);
|
2009-06-02 00:26:44 +02:00
|
|
|
menuview->addSeparator();
|
|
|
|
menuview->addAction(&mActionShowCollapseAll);
|
|
|
|
menuview->addAction(&mActionShowExpandAll);
|
2009-03-22 18:39:44 +01:00
|
|
|
|
2009-03-22 13:32:07 +01:00
|
|
|
QMenu *menuprogram = menuBar()->addMenu(tr("&Program"));
|
|
|
|
menuprogram->addAction(&mActionSettings);
|
2009-03-01 08:38:21 +01:00
|
|
|
|
2009-05-24 10:53:29 +02:00
|
|
|
QMenu *menuHelp = menuBar()->addMenu(tr("&Help"));
|
|
|
|
menuHelp->addAction(&mActionAbout);
|
|
|
|
|
2009-03-01 08:38:21 +01:00
|
|
|
setCentralWidget(&mResults);
|
|
|
|
|
2009-03-22 13:32:07 +01:00
|
|
|
connect(&mActionExit, SIGNAL(triggered()), this, SLOT(close()));
|
|
|
|
connect(&mActionCheckFiles, SIGNAL(triggered()), this, SLOT(CheckFiles()));
|
|
|
|
connect(&mActionCheckDirectory, SIGNAL(triggered()), this, SLOT(CheckDirectory()));
|
|
|
|
connect(&mActionSettings, SIGNAL(triggered()), this, SLOT(ProgramSettings()));
|
2009-03-22 16:42:00 +01:00
|
|
|
connect(&mActionClearResults, SIGNAL(triggered()), this, SLOT(ClearResults()));
|
2009-03-22 18:39:44 +01:00
|
|
|
|
|
|
|
connect(&mActionShowAll, SIGNAL(toggled(bool)), this, SLOT(ShowAll(bool)));
|
|
|
|
connect(&mActionShowSecurity, SIGNAL(toggled(bool)), this, SLOT(ShowSecurity(bool)));
|
|
|
|
connect(&mActionShowStyle, SIGNAL(toggled(bool)), this, SLOT(ShowStyle(bool)));
|
|
|
|
connect(&mActionShowUnused, SIGNAL(toggled(bool)), this, SLOT(ShowUnused(bool)));
|
|
|
|
connect(&mActionShowErrors, SIGNAL(toggled(bool)), this, SLOT(ShowErrors(bool)));
|
2009-05-23 10:17:27 +02:00
|
|
|
connect(&mActionShowCheckAll, SIGNAL(triggered()), this, SLOT(CheckAll()));
|
|
|
|
connect(&mActionShowUncheckAll, SIGNAL(triggered()), this, SLOT(UncheckAll()));
|
2009-06-02 00:26:44 +02:00
|
|
|
connect(&mActionShowCollapseAll, SIGNAL(triggered()), &mResults, SLOT(CollapseAllResults()));
|
|
|
|
connect(&mActionShowExpandAll, SIGNAL(triggered()), &mResults, SLOT(ExpandAllResults()));
|
2009-03-22 18:39:44 +01:00
|
|
|
|
2009-03-22 16:42:00 +01:00
|
|
|
connect(&mActionReCheck, SIGNAL(triggered()), this, SLOT(ReCheck()));
|
2009-05-24 10:53:29 +02:00
|
|
|
|
2009-06-02 01:01:53 +02:00
|
|
|
connect(&mActionStop, SIGNAL(triggered()), &mThread, SLOT(Stop()));
|
2009-05-26 17:21:39 +02:00
|
|
|
connect(&mActionSave, SIGNAL(triggered()), this, SLOT(Save()));
|
2009-05-24 10:53:29 +02:00
|
|
|
|
2009-05-26 17:21:39 +02:00
|
|
|
connect(&mActionAbout, SIGNAL(triggered()), this, SLOT(About()));
|
2009-03-01 08:38:21 +01:00
|
|
|
connect(&mThread, SIGNAL(Done()), this, SLOT(CheckDone()));
|
2009-06-03 20:18:22 +02:00
|
|
|
connect(&mResults, SIGNAL(GotResults()), this, SLOT(ResultsAdded()));
|
2009-05-26 17:21:39 +02:00
|
|
|
|
|
|
|
//Toolbar
|
|
|
|
QToolBar *toolbar = addToolBar("Toolbar");
|
2009-05-26 17:23:06 +02:00
|
|
|
toolbar->setIconSize(QSize(22, 22));
|
2009-05-26 17:21:39 +02:00
|
|
|
|
2009-05-28 15:30:44 +02:00
|
|
|
mActionCheckDirectory.setIcon(QIcon(":icon.png"));
|
2009-05-28 10:32:32 +02:00
|
|
|
mActionReCheck.setIcon(QIcon(":images/view-refresh.png"));
|
|
|
|
mActionSettings.setIcon(QIcon(":images/preferences-system.png"));
|
|
|
|
mActionAbout.setIcon(QIcon(":images/help-browser.png"));
|
|
|
|
mActionStop.setIcon(QIcon(":images/process-stop.png"));
|
|
|
|
mActionSave.setIcon(QIcon(":images/media-floppy.png"));
|
|
|
|
mActionClearResults.setIcon(QIcon(":images/edit-clear.png"));
|
2009-05-26 17:21:39 +02:00
|
|
|
|
|
|
|
toolbar->addAction(&mActionCheckDirectory);
|
|
|
|
toolbar->addAction(&mActionSave);
|
|
|
|
toolbar->addAction(&mActionReCheck);
|
|
|
|
toolbar->addAction(&mActionStop);
|
|
|
|
toolbar->addAction(&mActionClearResults);
|
|
|
|
toolbar->addAction(&mActionSettings);
|
|
|
|
toolbar->addAction(&mActionAbout);
|
|
|
|
|
2009-03-01 08:38:21 +01:00
|
|
|
LoadSettings();
|
2009-03-01 21:44:42 +01:00
|
|
|
mThread.Initialize(&mResults);
|
2009-05-24 10:53:29 +02:00
|
|
|
setWindowTitle(tr("Cppcheck"));
|
2009-05-26 17:21:39 +02:00
|
|
|
|
|
|
|
EnableCheckButtons(true);
|
2009-06-03 20:18:22 +02:00
|
|
|
|
|
|
|
mActionClearResults.setEnabled(false);
|
|
|
|
mActionSave.setEnabled(false);
|
2009-03-01 08:38:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
MainWindow::~MainWindow()
|
|
|
|
{
|
2009-03-22 13:32:07 +01:00
|
|
|
SaveSettings();
|
2009-03-01 08:38:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::LoadSettings()
|
|
|
|
{
|
2009-03-01 21:44:42 +01:00
|
|
|
if (mSettings.value(tr("Window maximized"), false).toBool())
|
2009-03-01 08:38:21 +01:00
|
|
|
{
|
|
|
|
showMaximized();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-03-01 21:44:42 +01:00
|
|
|
resize(mSettings.value(tr("Window width"), 800).toInt(),
|
|
|
|
mSettings.value(tr("Window height"), 600).toInt());
|
2009-03-01 08:38:21 +01:00
|
|
|
}
|
2009-03-22 18:39:44 +01:00
|
|
|
|
|
|
|
mActionShowAll.setChecked(mSettings.value(tr("Show all"), true).toBool());
|
|
|
|
mActionShowSecurity.setChecked(mSettings.value(tr("Show security"), true).toBool());
|
|
|
|
mActionShowStyle.setChecked(mSettings.value(tr("Show style"), true).toBool());
|
|
|
|
mActionShowUnused.setChecked(mSettings.value(tr("Show unused"), true).toBool());
|
|
|
|
mActionShowErrors.setChecked(mSettings.value(tr("Show errors"), true).toBool());
|
|
|
|
|
|
|
|
mResults.ShowResults(SHOW_ALL, mActionShowAll.isChecked());
|
|
|
|
mResults.ShowResults(SHOW_ERRORS, mActionShowErrors.isChecked());
|
|
|
|
mResults.ShowResults(SHOW_SECURITY, mActionShowSecurity.isChecked());
|
|
|
|
mResults.ShowResults(SHOW_STYLE, mActionShowStyle.isChecked());
|
|
|
|
mResults.ShowResults(SHOW_UNUSED, mActionShowUnused.isChecked());
|
2009-05-23 12:37:30 +02:00
|
|
|
mApplications.LoadSettings(mSettings);
|
2009-03-01 08:38:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::SaveSettings()
|
|
|
|
{
|
2009-03-01 21:44:42 +01:00
|
|
|
mSettings.setValue(tr("Window width"), size().width());
|
|
|
|
mSettings.setValue(tr("Window height"), size().height());
|
|
|
|
mSettings.setValue(tr("Window maximized"), isMaximized());
|
2009-03-22 18:39:44 +01:00
|
|
|
|
|
|
|
mSettings.setValue(tr("Show all"), mActionShowAll.isChecked());
|
|
|
|
mSettings.setValue(tr("Show security"), mActionShowSecurity.isChecked());
|
|
|
|
mSettings.setValue(tr("Show style"), mActionShowStyle.isChecked());
|
|
|
|
mSettings.setValue(tr("Show unused"), mActionShowUnused.isChecked());
|
|
|
|
mSettings.setValue(tr("Show errors"), mActionShowErrors.isChecked());
|
2009-05-23 12:37:30 +02:00
|
|
|
mApplications.SaveSettings(mSettings);
|
2009-03-01 08:38:21 +01:00
|
|
|
}
|
|
|
|
|
2009-03-22 13:32:07 +01:00
|
|
|
void MainWindow::DoCheckFiles(QFileDialog::FileMode mode)
|
2009-03-01 08:38:21 +01:00
|
|
|
{
|
2009-03-22 13:32:07 +01:00
|
|
|
QFileDialog dialog(this);
|
2009-03-22 14:15:16 +01:00
|
|
|
dialog.setDirectory(QDir(mSettings.value(tr("Check path"), "").toString()));
|
2009-03-22 13:32:07 +01:00
|
|
|
dialog.setFileMode(mode);
|
|
|
|
|
|
|
|
if (dialog.exec())
|
2009-03-01 08:38:21 +01:00
|
|
|
{
|
2009-03-22 13:32:07 +01:00
|
|
|
QStringList selected = dialog.selectedFiles();
|
|
|
|
QStringList fileNames;
|
|
|
|
QString selection;
|
|
|
|
|
2009-03-22 14:15:16 +01:00
|
|
|
foreach(selection, selected)
|
2009-03-22 13:32:07 +01:00
|
|
|
{
|
|
|
|
fileNames << RemoveUnacceptedFiles(GetFilesRecursively(selection));
|
|
|
|
}
|
|
|
|
|
2009-03-01 08:38:21 +01:00
|
|
|
mResults.Clear();
|
|
|
|
mThread.ClearFiles();
|
2009-06-09 08:30:28 +02:00
|
|
|
|
|
|
|
if (fileNames.isEmpty())
|
|
|
|
{
|
|
|
|
QMessageBox msgBox;
|
|
|
|
msgBox.setText("No suitable files found to check!");
|
|
|
|
msgBox.exec();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-03-22 13:32:07 +01:00
|
|
|
mThread.SetFiles(RemoveUnacceptedFiles(fileNames));
|
|
|
|
mSettings.setValue(tr("Check path"), dialog.directory().absolutePath());
|
2009-03-22 16:42:00 +01:00
|
|
|
EnableCheckButtons(false);
|
2009-06-03 20:18:22 +02:00
|
|
|
mResults.SetCheckDirectory(dialog.directory().absolutePath());
|
2009-05-24 10:53:29 +02:00
|
|
|
mThread.Check(GetCppcheckSettings(), false);
|
2009-03-01 08:38:21 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-03-22 13:32:07 +01:00
|
|
|
void MainWindow::CheckFiles()
|
|
|
|
{
|
|
|
|
DoCheckFiles(QFileDialog::ExistingFiles);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::CheckDirectory()
|
|
|
|
{
|
|
|
|
DoCheckFiles(QFileDialog::DirectoryOnly);
|
|
|
|
}
|
|
|
|
|
2009-05-24 10:53:29 +02:00
|
|
|
Settings MainWindow::GetCppcheckSettings()
|
2009-03-22 13:32:07 +01:00
|
|
|
{
|
|
|
|
Settings result;
|
|
|
|
result._debug = false;
|
|
|
|
result._showAll = true;
|
|
|
|
result._checkCodingStyle = true;
|
|
|
|
result._errorsOnly = false;
|
|
|
|
result._verbose = true;
|
2009-03-22 16:42:00 +01:00
|
|
|
result._force = mSettings.value(tr("Check force"), 1).toBool();
|
2009-03-22 13:32:07 +01:00
|
|
|
result._xml = false;
|
|
|
|
result._unusedFunctions = true;
|
|
|
|
result._security = true;
|
|
|
|
result._jobs = mSettings.value(tr("Check threads"), 1).toInt();
|
2009-05-24 10:53:29 +02:00
|
|
|
|
2009-05-24 10:55:54 +02:00
|
|
|
if (result._jobs <= 0)
|
|
|
|
{
|
2009-05-24 10:53:29 +02:00
|
|
|
result._jobs = 1;
|
|
|
|
}
|
|
|
|
|
2009-03-22 13:32:07 +01:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
QStringList MainWindow::GetFilesRecursively(const QString &path)
|
|
|
|
{
|
|
|
|
QFileInfo info(path);
|
|
|
|
QStringList list;
|
|
|
|
|
|
|
|
if (info.isDir())
|
|
|
|
{
|
|
|
|
QDirIterator it(path, QDirIterator::Subdirectories);
|
|
|
|
|
|
|
|
while (it.hasNext())
|
|
|
|
{
|
|
|
|
list << it.next();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
list << path;
|
|
|
|
}
|
|
|
|
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
|
|
|
QStringList MainWindow::RemoveUnacceptedFiles(const QStringList &list)
|
|
|
|
{
|
|
|
|
QStringList result;
|
|
|
|
QString str;
|
|
|
|
foreach(str, list)
|
|
|
|
{
|
|
|
|
if (FileLister::AcceptFile(str.toStdString()))
|
|
|
|
{
|
|
|
|
result << str;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-03-01 08:38:21 +01:00
|
|
|
void MainWindow::CheckDone()
|
|
|
|
{
|
2009-03-22 16:42:00 +01:00
|
|
|
EnableCheckButtons(true);
|
2009-03-22 13:32:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::ProgramSettings()
|
|
|
|
{
|
2009-06-06 11:51:14 +02:00
|
|
|
SettingsDialog dialog(mSettings, mApplications, this);
|
2009-03-22 13:32:07 +01:00
|
|
|
if (dialog.exec() == QDialog::Accepted)
|
|
|
|
{
|
|
|
|
dialog.SaveCheckboxValues();
|
2009-06-03 20:18:22 +02:00
|
|
|
mResults.UpdateSettings(dialog.ShowFullPath(),
|
|
|
|
dialog.SaveFullPath(),
|
|
|
|
dialog.SaveAllErrors());
|
2009-03-22 13:32:07 +01:00
|
|
|
}
|
2009-03-01 08:38:21 +01:00
|
|
|
}
|
2009-03-22 13:32:07 +01:00
|
|
|
|
2009-03-22 16:42:00 +01:00
|
|
|
void MainWindow::ReCheck()
|
|
|
|
{
|
|
|
|
ClearResults();
|
|
|
|
EnableCheckButtons(false);
|
2009-05-24 10:53:29 +02:00
|
|
|
mThread.Check(GetCppcheckSettings(), true);
|
2009-03-22 16:42:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::ClearResults()
|
|
|
|
{
|
|
|
|
mResults.Clear();
|
2009-06-03 20:18:22 +02:00
|
|
|
mActionClearResults.setEnabled(false);
|
|
|
|
mActionSave.setEnabled(false);
|
2009-03-22 16:42:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::EnableCheckButtons(bool enable)
|
|
|
|
{
|
2009-05-26 17:21:39 +02:00
|
|
|
mActionStop.setEnabled(!enable);
|
2009-03-22 16:42:00 +01:00
|
|
|
mActionCheckFiles.setEnabled(enable);
|
|
|
|
mActionReCheck.setEnabled(enable);
|
|
|
|
mActionCheckDirectory.setEnabled(enable);
|
|
|
|
}
|
|
|
|
|
2009-03-22 18:39:44 +01:00
|
|
|
|
|
|
|
void MainWindow::ShowAll(bool checked)
|
|
|
|
{
|
|
|
|
mResults.ShowResults(SHOW_ALL, checked);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::ShowSecurity(bool checked)
|
|
|
|
{
|
|
|
|
mResults.ShowResults(SHOW_SECURITY, checked);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::ShowStyle(bool checked)
|
|
|
|
{
|
|
|
|
mResults.ShowResults(SHOW_STYLE, checked);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::ShowUnused(bool checked)
|
|
|
|
{
|
|
|
|
mResults.ShowResults(SHOW_UNUSED, checked);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::ShowErrors(bool checked)
|
|
|
|
{
|
|
|
|
mResults.ShowResults(SHOW_ERRORS, checked);
|
|
|
|
}
|
2009-05-23 10:17:27 +02:00
|
|
|
|
|
|
|
void MainWindow::CheckAll()
|
|
|
|
{
|
|
|
|
ToggleAllChecked(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::UncheckAll()
|
|
|
|
{
|
|
|
|
ToggleAllChecked(false);
|
|
|
|
}
|
|
|
|
|
2009-06-04 16:02:35 +02:00
|
|
|
void MainWindow::closeEvent(QCloseEvent *event)
|
|
|
|
{
|
|
|
|
// Check that we aren't checking files
|
|
|
|
if (!mThread.IsChecking())
|
|
|
|
event->accept();
|
|
|
|
else
|
|
|
|
{
|
|
|
|
QString msg(tr("Cannot exit while checking.\n\n" \
|
|
|
|
"Stop the checking before exiting."));
|
|
|
|
QMessageBox *box = new QMessageBox(QMessageBox::Warning,
|
|
|
|
tr("cppcheck"), msg);
|
|
|
|
box->show();
|
|
|
|
event->ignore();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-23 10:17:27 +02:00
|
|
|
void MainWindow::ToggleAllChecked(bool checked)
|
|
|
|
{
|
|
|
|
mActionShowAll.setChecked(checked);
|
|
|
|
ShowAll(checked);
|
|
|
|
|
|
|
|
mActionShowSecurity.setChecked(checked);
|
|
|
|
ShowSecurity(checked);
|
|
|
|
|
|
|
|
mActionShowStyle.setChecked(checked);
|
|
|
|
ShowStyle(checked);
|
|
|
|
|
|
|
|
mActionShowUnused.setChecked(checked);
|
|
|
|
ShowUnused(checked);
|
|
|
|
|
|
|
|
mActionShowErrors.setChecked(checked);
|
|
|
|
ShowErrors(checked);
|
|
|
|
}
|
2009-05-24 10:53:29 +02:00
|
|
|
|
|
|
|
void MainWindow::About()
|
|
|
|
{
|
|
|
|
//TODO make a "GetVersionNumber" function to core cppcheck
|
|
|
|
CppCheckExecutor exec;
|
|
|
|
CppCheck check(exec);
|
2009-05-24 10:55:54 +02:00
|
|
|
const char *argv[] = {"", "--version"};
|
2009-05-24 10:53:29 +02:00
|
|
|
QString version = check.parseFromArgs(2, argv).c_str();
|
2009-05-24 10:55:54 +02:00
|
|
|
version.replace("Cppcheck ", "");
|
|
|
|
|
2009-06-04 14:35:41 +02:00
|
|
|
AboutDialog *dlg = new AboutDialog(version, this);
|
|
|
|
dlg->show();
|
2009-05-24 10:53:29 +02:00
|
|
|
}
|
2009-05-26 17:21:39 +02:00
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::Save()
|
|
|
|
{
|
2009-06-03 20:18:22 +02:00
|
|
|
QFileDialog dialog(this);
|
|
|
|
dialog.setFileMode(QFileDialog::AnyFile);
|
|
|
|
dialog.setAcceptMode(QFileDialog::AcceptSave);
|
|
|
|
|
|
|
|
QStringList filters;
|
|
|
|
filters << tr("XML files (*.xml)") << tr("Text files (*.txt)");
|
|
|
|
dialog.setNameFilters(filters);
|
|
|
|
|
|
|
|
if (dialog.exec())
|
|
|
|
{
|
|
|
|
QStringList list = dialog.selectedFiles();
|
|
|
|
|
|
|
|
if (list.size() > 0)
|
|
|
|
{
|
|
|
|
bool xml = (dialog.selectedNameFilter() == filters[0] && list[0].endsWith(".xml", Qt::CaseInsensitive));
|
|
|
|
mResults.Save(list[0], xml);
|
|
|
|
}
|
|
|
|
}
|
2009-05-26 17:21:39 +02:00
|
|
|
}
|
|
|
|
|
2009-06-03 20:18:22 +02:00
|
|
|
void MainWindow::ResultsAdded()
|
|
|
|
{
|
|
|
|
mActionClearResults.setEnabled(true);
|
|
|
|
mActionSave.setEnabled(true);
|
|
|
|
}
|