Fixed issues pointed out by Reijo.
The number of threads is now atleast 1. Added a very simple about dialog with version number and license. Replaced all CppCheck's with Cppcheck. Renamed "show more errors" to "show possible false positives" in the menu. User created application now has to have a name and a path.
This commit is contained in:
parent
2d8b08d4ab
commit
de0dd0a2bb
|
@ -24,6 +24,7 @@
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QMessageBox>
|
||||||
|
|
||||||
|
|
||||||
ApplicationDialog::ApplicationDialog(const QString &name,
|
ApplicationDialog::ApplicationDialog(const QString &name,
|
||||||
|
@ -66,7 +67,7 @@ ApplicationDialog::ApplicationDialog(const QString &name,
|
||||||
|
|
||||||
//Connect OK buttons
|
//Connect OK buttons
|
||||||
connect(ok, SIGNAL(clicked()),
|
connect(ok, SIGNAL(clicked()),
|
||||||
this, SLOT(accept()));
|
this, SLOT(Ok()));
|
||||||
connect(cancel, SIGNAL(clicked()),
|
connect(cancel, SIGNAL(clicked()),
|
||||||
this, SLOT(reject()));
|
this, SLOT(reject()));
|
||||||
setLayout(layout);
|
setLayout(layout);
|
||||||
|
@ -105,3 +106,15 @@ QString ApplicationDialog::GetPath()
|
||||||
{
|
{
|
||||||
return mPath->text();
|
return mPath->text();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ApplicationDialog::Ok()
|
||||||
|
{
|
||||||
|
if (mName->text().isEmpty() || mPath->text().isEmpty()) {
|
||||||
|
QMessageBox msgBox;
|
||||||
|
msgBox.setText("You must specify a name and a path for the application!");
|
||||||
|
msgBox.exec();
|
||||||
|
} else {
|
||||||
|
accept();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,6 +61,7 @@ public:
|
||||||
*/
|
*/
|
||||||
QString GetPath();
|
QString GetPath();
|
||||||
protected slots:
|
protected slots:
|
||||||
|
void Ok();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Slot to browse for an application
|
* @brief Slot to browse for an application
|
||||||
|
|
|
@ -100,6 +100,10 @@ void ApplicationList::SetApplicationType(const int index,
|
||||||
|
|
||||||
void ApplicationList::AddApplicationType(const QString &name, const QString &path)
|
void ApplicationList::AddApplicationType(const QString &name, const QString &path)
|
||||||
{
|
{
|
||||||
|
if (name.isEmpty() || path.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ApplicationType type;
|
ApplicationType type;
|
||||||
type.Name = name;
|
type.Name = name;
|
||||||
type.Path = path;
|
type.Path = path;
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
CheckThread::CheckThread(ThreadResult &result) :
|
CheckThread::CheckThread(ThreadResult &result) :
|
||||||
mResult(result),
|
mResult(result),
|
||||||
mCppCheck(result)
|
mCppcheck(result)
|
||||||
{
|
{
|
||||||
//ctor
|
//ctor
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ CheckThread::~CheckThread()
|
||||||
|
|
||||||
void CheckThread::Check(Settings settings)
|
void CheckThread::Check(Settings settings)
|
||||||
{
|
{
|
||||||
mCppCheck.settings(settings);
|
mCppcheck.settings(settings);
|
||||||
start();
|
start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,9 +47,9 @@ void CheckThread::run()
|
||||||
while (!file.isEmpty())
|
while (!file.isEmpty())
|
||||||
{
|
{
|
||||||
qDebug() << "Checking file" << file;
|
qDebug() << "Checking file" << file;
|
||||||
mCppCheck.addFile(file.toStdString());
|
mCppcheck.addFile(file.toStdString());
|
||||||
mCppCheck.check();
|
mCppcheck.check();
|
||||||
mCppCheck.clearFiles();
|
mCppcheck.clearFiles();
|
||||||
emit FileChecked(file);
|
emit FileChecked(file);
|
||||||
|
|
||||||
file = mResult.GetNextFile();
|
file = mResult.GetNextFile();
|
||||||
|
|
|
@ -63,10 +63,10 @@ signals:
|
||||||
protected:
|
protected:
|
||||||
ThreadResult &mResult;
|
ThreadResult &mResult;
|
||||||
/**
|
/**
|
||||||
* @brief CppCheck itself
|
* @brief Cppcheck itself
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
CppCheck mCppCheck;
|
CppCheck mCppcheck;
|
||||||
private:
|
private:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -23,24 +23,26 @@
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QDirIterator>
|
#include <QDirIterator>
|
||||||
#include <QMenuBar>
|
#include <QMenuBar>
|
||||||
|
#include <QMessageBox>
|
||||||
#include "../src/filelister.h"
|
#include "../src/filelister.h"
|
||||||
|
#include "../src/cppcheckexecutor.h"
|
||||||
|
|
||||||
MainWindow::MainWindow() :
|
MainWindow::MainWindow() :
|
||||||
mSettings(tr("CppCheck"), tr("CppCheck-GUI")),
|
mSettings(tr("Cppcheck"), tr("Cppcheck-GUI")),
|
||||||
mActionExit(tr("E&xit"), this),
|
mActionExit(tr("E&xit"), this),
|
||||||
mActionCheckFiles(tr("&Check files(s)"), this),
|
mActionCheckFiles(tr("&Check files(s)"), this),
|
||||||
mActionClearResults(tr("Clear &results"), this),
|
mActionClearResults(tr("Clear &results"), this),
|
||||||
mActionReCheck(tr("Recheck files"), this),
|
mActionReCheck(tr("Recheck files"), this),
|
||||||
mActionCheckDirectory(tr("Check &directory"), this),
|
mActionCheckDirectory(tr("Check &directory"), this),
|
||||||
mActionSettings(tr("&Settings"), this),
|
mActionSettings(tr("&Settings"), this),
|
||||||
mActionShowAll(tr("Show &more errors"), this),
|
mActionShowAll(tr("show possible false positives"), this),
|
||||||
mActionShowSecurity(tr("Show &security errors"), this),
|
mActionShowSecurity(tr("Show &security errors"), this),
|
||||||
mActionShowStyle(tr("Show s&tyle errors"), this),
|
mActionShowStyle(tr("Show s&tyle errors"), this),
|
||||||
mActionShowUnused(tr("Show errors on &unused functions"), this),
|
mActionShowUnused(tr("Show errors on &unused functions"), this),
|
||||||
mActionShowErrors(tr("Show &common errors"), this),
|
mActionShowErrors(tr("Show &common errors"), this),
|
||||||
mActionShowCheckAll(tr("Check all"), this),
|
mActionShowCheckAll(tr("Check all"), this),
|
||||||
mActionShowUncheckAll(tr("Uncheck all"), this),
|
mActionShowUncheckAll(tr("Uncheck all"), this),
|
||||||
|
mActionAbout(tr("About"), this),
|
||||||
mResults(mSettings, mApplications)
|
mResults(mSettings, mApplications)
|
||||||
{
|
{
|
||||||
QMenu *menu = menuBar()->addMenu(tr("&File"));
|
QMenu *menu = menuBar()->addMenu(tr("&File"));
|
||||||
|
@ -69,6 +71,9 @@ MainWindow::MainWindow() :
|
||||||
QMenu *menuprogram = menuBar()->addMenu(tr("&Program"));
|
QMenu *menuprogram = menuBar()->addMenu(tr("&Program"));
|
||||||
menuprogram->addAction(&mActionSettings);
|
menuprogram->addAction(&mActionSettings);
|
||||||
|
|
||||||
|
QMenu *menuHelp = menuBar()->addMenu(tr("&Help"));
|
||||||
|
menuHelp->addAction(&mActionAbout);
|
||||||
|
|
||||||
setCentralWidget(&mResults);
|
setCentralWidget(&mResults);
|
||||||
|
|
||||||
|
|
||||||
|
@ -87,10 +92,13 @@ MainWindow::MainWindow() :
|
||||||
connect(&mActionShowUncheckAll, SIGNAL(triggered()), this, SLOT(UncheckAll()));
|
connect(&mActionShowUncheckAll, SIGNAL(triggered()), this, SLOT(UncheckAll()));
|
||||||
|
|
||||||
connect(&mActionReCheck, SIGNAL(triggered()), this, SLOT(ReCheck()));
|
connect(&mActionReCheck, SIGNAL(triggered()), this, SLOT(ReCheck()));
|
||||||
|
|
||||||
|
connect(&mActionAbout, SIGNAL(triggered()), this, SLOT(About()));
|
||||||
|
|
||||||
connect(&mThread, SIGNAL(Done()), this, SLOT(CheckDone()));
|
connect(&mThread, SIGNAL(Done()), this, SLOT(CheckDone()));
|
||||||
LoadSettings();
|
LoadSettings();
|
||||||
mThread.Initialize(&mResults);
|
mThread.Initialize(&mResults);
|
||||||
setWindowTitle(tr("CppCheck"));
|
setWindowTitle(tr("Cppcheck"));
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
|
@ -161,7 +169,7 @@ void MainWindow::DoCheckFiles(QFileDialog::FileMode mode)
|
||||||
mThread.SetFiles(RemoveUnacceptedFiles(fileNames));
|
mThread.SetFiles(RemoveUnacceptedFiles(fileNames));
|
||||||
mSettings.setValue(tr("Check path"), dialog.directory().absolutePath());
|
mSettings.setValue(tr("Check path"), dialog.directory().absolutePath());
|
||||||
EnableCheckButtons(false);
|
EnableCheckButtons(false);
|
||||||
mThread.Check(GetCppCheckSettings(), false);
|
mThread.Check(GetCppcheckSettings(), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,7 +183,7 @@ void MainWindow::CheckDirectory()
|
||||||
DoCheckFiles(QFileDialog::DirectoryOnly);
|
DoCheckFiles(QFileDialog::DirectoryOnly);
|
||||||
}
|
}
|
||||||
|
|
||||||
Settings MainWindow::GetCppCheckSettings()
|
Settings MainWindow::GetCppcheckSettings()
|
||||||
{
|
{
|
||||||
Settings result;
|
Settings result;
|
||||||
result._debug = false;
|
result._debug = false;
|
||||||
|
@ -188,6 +196,11 @@ Settings MainWindow::GetCppCheckSettings()
|
||||||
result._unusedFunctions = true;
|
result._unusedFunctions = true;
|
||||||
result._security = true;
|
result._security = true;
|
||||||
result._jobs = mSettings.value(tr("Check threads"), 1).toInt();
|
result._jobs = mSettings.value(tr("Check threads"), 1).toInt();
|
||||||
|
|
||||||
|
if (result._jobs <= 0) {
|
||||||
|
result._jobs = 1;
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -248,7 +261,7 @@ void MainWindow::ReCheck()
|
||||||
{
|
{
|
||||||
ClearResults();
|
ClearResults();
|
||||||
EnableCheckButtons(false);
|
EnableCheckButtons(false);
|
||||||
mThread.Check(GetCppCheckSettings(), true);
|
mThread.Check(GetCppcheckSettings(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::ClearResults()
|
void MainWindow::ClearResults()
|
||||||
|
@ -316,3 +329,23 @@ void MainWindow::ToggleAllChecked(bool checked)
|
||||||
mActionShowErrors.setChecked(checked);
|
mActionShowErrors.setChecked(checked);
|
||||||
ShowErrors(checked);
|
ShowErrors(checked);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::About()
|
||||||
|
{
|
||||||
|
//TODO make a "GetVersionNumber" function to core cppcheck
|
||||||
|
CppCheckExecutor exec;
|
||||||
|
CppCheck check(exec);
|
||||||
|
const char *argv[] = {"","--version"};
|
||||||
|
QString version = check.parseFromArgs(2, argv).c_str();
|
||||||
|
version.replace("Cppcheck ","");
|
||||||
|
|
||||||
|
QMessageBox msgBox;
|
||||||
|
msgBox.setWindowTitle(tr("About..."));
|
||||||
|
msgBox.setText(QString("Cppcheck - A tool for static C/C++ code analysis.\nVersion %1\n\n" \
|
||||||
|
"This program is licensed under the terms\n" \
|
||||||
|
"of the GNU General Public License version 3\n" \
|
||||||
|
"Available online under:\n" \
|
||||||
|
"http://www.gnu.org/licenses/gpl-3.0.html\n\nSee AUTHORS file for the list of developers." \
|
||||||
|
).arg(version));
|
||||||
|
msgBox.exec();
|
||||||
|
}
|
||||||
|
|
|
@ -114,6 +114,12 @@ public slots:
|
||||||
*/
|
*/
|
||||||
void ProgramSettings();
|
void ProgramSettings();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Slot to open program's about dialog
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void About();
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -155,7 +161,7 @@ protected:
|
||||||
*
|
*
|
||||||
* @return Default cppcheck settings
|
* @return Default cppcheck settings
|
||||||
*/
|
*/
|
||||||
Settings GetCppCheckSettings();
|
Settings GetCppcheckSettings();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Removes all unaccepted (by cppcheck core) files from the list
|
* @brief Removes all unaccepted (by cppcheck core) files from the list
|
||||||
|
@ -262,6 +268,12 @@ protected:
|
||||||
*/
|
*/
|
||||||
QAction mActionShowUncheckAll;
|
QAction mActionShowUncheckAll;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Action show about dialog
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
QAction mActionAbout;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -348,7 +348,7 @@ void ResultsTree::contextMenuEvent(QContextMenuEvent * e)
|
||||||
|
|
||||||
void ResultsTree::StartApplication(QStandardItem *target, int application)
|
void ResultsTree::StartApplication(QStandardItem *target, int application)
|
||||||
{
|
{
|
||||||
if (target && application >= 0 && application < mApplications.GetApplicationCount())
|
if (target && application >= 0 && application < mApplications.GetApplicationCount() && target->parent())
|
||||||
{
|
{
|
||||||
QVariantMap data = target->data().toMap();
|
QVariantMap data = target->data().toMap();
|
||||||
|
|
||||||
|
|
|
@ -68,9 +68,13 @@ SettingsDialog::SettingsDialog(QSettings &programSettings, ApplicationList &list
|
||||||
//Number of jobs
|
//Number of jobs
|
||||||
QHBoxLayout *jobsLayout = new QHBoxLayout();
|
QHBoxLayout *jobsLayout = new QHBoxLayout();
|
||||||
mJobs = new QLineEdit(programSettings.value(tr("Check threads"), 1).toString());
|
mJobs = new QLineEdit(programSettings.value(tr("Check threads"), 1).toString());
|
||||||
|
mJobs->setValidator(new QIntValidator(1,9999,this));
|
||||||
|
|
||||||
jobsLayout->addWidget(new QLabel(tr("Number of threads: ")));
|
jobsLayout->addWidget(new QLabel(tr("Number of threads: ")));
|
||||||
jobsLayout->addWidget(mJobs);
|
jobsLayout->addWidget(mJobs);
|
||||||
mJobs->setValidator(new QIntValidator(this));
|
|
||||||
|
|
||||||
|
|
||||||
layout->addLayout(jobsLayout);
|
layout->addLayout(jobsLayout);
|
||||||
|
|
||||||
//Force
|
//Force
|
||||||
|
@ -169,7 +173,12 @@ void SettingsDialog::SaveSettings()
|
||||||
|
|
||||||
void SettingsDialog::SaveCheckboxValues()
|
void SettingsDialog::SaveCheckboxValues()
|
||||||
{
|
{
|
||||||
mSettings.setValue(tr("Check threads"), mJobs->text().toInt());
|
int jobs = mJobs->text().toInt();
|
||||||
|
if (jobs <= 0) {
|
||||||
|
jobs = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
mSettings.setValue(tr("Check threads"), jobs);
|
||||||
SaveCheckboxValue(mForce, tr("Check force"));
|
SaveCheckboxValue(mForce, tr("Check force"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -197,7 +206,6 @@ void SettingsDialog::DeleteApplication()
|
||||||
|
|
||||||
foreach(item, selected)
|
foreach(item, selected)
|
||||||
{
|
{
|
||||||
qDebug() << item;
|
|
||||||
mApplications.RemoveApplication(mListWidget->row(item));
|
mApplications.RemoveApplication(mListWidget->row(item));
|
||||||
mListWidget->clear();
|
mListWidget->clear();
|
||||||
PopulateListWidget();
|
PopulateListWidget();
|
||||||
|
|
Loading…
Reference in New Issue