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 <QFileDialog>
|
||||
#include <QDebug>
|
||||
#include <QMessageBox>
|
||||
|
||||
|
||||
ApplicationDialog::ApplicationDialog(const QString &name,
|
||||
|
@ -66,7 +67,7 @@ ApplicationDialog::ApplicationDialog(const QString &name,
|
|||
|
||||
//Connect OK buttons
|
||||
connect(ok, SIGNAL(clicked()),
|
||||
this, SLOT(accept()));
|
||||
this, SLOT(Ok()));
|
||||
connect(cancel, SIGNAL(clicked()),
|
||||
this, SLOT(reject()));
|
||||
setLayout(layout);
|
||||
|
@ -105,3 +106,15 @@ QString ApplicationDialog::GetPath()
|
|||
{
|
||||
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();
|
||||
protected slots:
|
||||
void Ok();
|
||||
|
||||
/**
|
||||
* @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)
|
||||
{
|
||||
if (name.isEmpty() || path.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
ApplicationType type;
|
||||
type.Name = name;
|
||||
type.Path = path;
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
CheckThread::CheckThread(ThreadResult &result) :
|
||||
mResult(result),
|
||||
mCppCheck(result)
|
||||
mCppcheck(result)
|
||||
{
|
||||
//ctor
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ CheckThread::~CheckThread()
|
|||
|
||||
void CheckThread::Check(Settings settings)
|
||||
{
|
||||
mCppCheck.settings(settings);
|
||||
mCppcheck.settings(settings);
|
||||
start();
|
||||
}
|
||||
|
||||
|
@ -47,9 +47,9 @@ void CheckThread::run()
|
|||
while (!file.isEmpty())
|
||||
{
|
||||
qDebug() << "Checking file" << file;
|
||||
mCppCheck.addFile(file.toStdString());
|
||||
mCppCheck.check();
|
||||
mCppCheck.clearFiles();
|
||||
mCppcheck.addFile(file.toStdString());
|
||||
mCppcheck.check();
|
||||
mCppcheck.clearFiles();
|
||||
emit FileChecked(file);
|
||||
|
||||
file = mResult.GetNextFile();
|
||||
|
|
|
@ -63,10 +63,10 @@ signals:
|
|||
protected:
|
||||
ThreadResult &mResult;
|
||||
/**
|
||||
* @brief CppCheck itself
|
||||
* @brief Cppcheck itself
|
||||
*
|
||||
*/
|
||||
CppCheck mCppCheck;
|
||||
CppCheck mCppcheck;
|
||||
private:
|
||||
};
|
||||
|
||||
|
|
|
@ -23,24 +23,26 @@
|
|||
#include <QMenu>
|
||||
#include <QDirIterator>
|
||||
#include <QMenuBar>
|
||||
#include <QMessageBox>
|
||||
#include "../src/filelister.h"
|
||||
|
||||
#include "../src/cppcheckexecutor.h"
|
||||
|
||||
MainWindow::MainWindow() :
|
||||
mSettings(tr("CppCheck"), tr("CppCheck-GUI")),
|
||||
mSettings(tr("Cppcheck"), tr("Cppcheck-GUI")),
|
||||
mActionExit(tr("E&xit"), this),
|
||||
mActionCheckFiles(tr("&Check files(s)"), this),
|
||||
mActionClearResults(tr("Clear &results"), this),
|
||||
mActionReCheck(tr("Recheck files"), this),
|
||||
mActionCheckDirectory(tr("Check &directory"), this),
|
||||
mActionSettings(tr("&Settings"), this),
|
||||
mActionShowAll(tr("Show &more errors"), this),
|
||||
mActionShowAll(tr("show possible false positives"), this),
|
||||
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),
|
||||
mActionShowCheckAll(tr("Check all"), this),
|
||||
mActionShowUncheckAll(tr("Uncheck all"), this),
|
||||
mActionAbout(tr("About"), this),
|
||||
mResults(mSettings, mApplications)
|
||||
{
|
||||
QMenu *menu = menuBar()->addMenu(tr("&File"));
|
||||
|
@ -69,6 +71,9 @@ MainWindow::MainWindow() :
|
|||
QMenu *menuprogram = menuBar()->addMenu(tr("&Program"));
|
||||
menuprogram->addAction(&mActionSettings);
|
||||
|
||||
QMenu *menuHelp = menuBar()->addMenu(tr("&Help"));
|
||||
menuHelp->addAction(&mActionAbout);
|
||||
|
||||
setCentralWidget(&mResults);
|
||||
|
||||
|
||||
|
@ -87,10 +92,13 @@ MainWindow::MainWindow() :
|
|||
connect(&mActionShowUncheckAll, SIGNAL(triggered()), this, SLOT(UncheckAll()));
|
||||
|
||||
connect(&mActionReCheck, SIGNAL(triggered()), this, SLOT(ReCheck()));
|
||||
|
||||
connect(&mActionAbout, SIGNAL(triggered()), this, SLOT(About()));
|
||||
|
||||
connect(&mThread, SIGNAL(Done()), this, SLOT(CheckDone()));
|
||||
LoadSettings();
|
||||
mThread.Initialize(&mResults);
|
||||
setWindowTitle(tr("CppCheck"));
|
||||
setWindowTitle(tr("Cppcheck"));
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
|
@ -161,7 +169,7 @@ void MainWindow::DoCheckFiles(QFileDialog::FileMode mode)
|
|||
mThread.SetFiles(RemoveUnacceptedFiles(fileNames));
|
||||
mSettings.setValue(tr("Check path"), dialog.directory().absolutePath());
|
||||
EnableCheckButtons(false);
|
||||
mThread.Check(GetCppCheckSettings(), false);
|
||||
mThread.Check(GetCppcheckSettings(), false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -175,7 +183,7 @@ void MainWindow::CheckDirectory()
|
|||
DoCheckFiles(QFileDialog::DirectoryOnly);
|
||||
}
|
||||
|
||||
Settings MainWindow::GetCppCheckSettings()
|
||||
Settings MainWindow::GetCppcheckSettings()
|
||||
{
|
||||
Settings result;
|
||||
result._debug = false;
|
||||
|
@ -188,6 +196,11 @@ Settings MainWindow::GetCppCheckSettings()
|
|||
result._unusedFunctions = true;
|
||||
result._security = true;
|
||||
result._jobs = mSettings.value(tr("Check threads"), 1).toInt();
|
||||
|
||||
if (result._jobs <= 0) {
|
||||
result._jobs = 1;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -248,7 +261,7 @@ void MainWindow::ReCheck()
|
|||
{
|
||||
ClearResults();
|
||||
EnableCheckButtons(false);
|
||||
mThread.Check(GetCppCheckSettings(), true);
|
||||
mThread.Check(GetCppcheckSettings(), true);
|
||||
}
|
||||
|
||||
void MainWindow::ClearResults()
|
||||
|
@ -316,3 +329,23 @@ void MainWindow::ToggleAllChecked(bool checked)
|
|||
mActionShowErrors.setChecked(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();
|
||||
|
||||
/**
|
||||
* @brief Slot to open program's about dialog
|
||||
*
|
||||
*/
|
||||
void About();
|
||||
|
||||
protected slots:
|
||||
|
||||
/**
|
||||
|
@ -155,7 +161,7 @@ protected:
|
|||
*
|
||||
* @return Default cppcheck settings
|
||||
*/
|
||||
Settings GetCppCheckSettings();
|
||||
Settings GetCppcheckSettings();
|
||||
|
||||
/**
|
||||
* @brief Removes all unaccepted (by cppcheck core) files from the list
|
||||
|
@ -262,6 +268,12 @@ protected:
|
|||
*/
|
||||
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)
|
||||
{
|
||||
if (target && application >= 0 && application < mApplications.GetApplicationCount())
|
||||
if (target && application >= 0 && application < mApplications.GetApplicationCount() && target->parent())
|
||||
{
|
||||
QVariantMap data = target->data().toMap();
|
||||
|
||||
|
|
|
@ -68,9 +68,13 @@ SettingsDialog::SettingsDialog(QSettings &programSettings, ApplicationList &list
|
|||
//Number of jobs
|
||||
QHBoxLayout *jobsLayout = new QHBoxLayout();
|
||||
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(mJobs);
|
||||
mJobs->setValidator(new QIntValidator(this));
|
||||
|
||||
|
||||
|
||||
layout->addLayout(jobsLayout);
|
||||
|
||||
//Force
|
||||
|
@ -169,7 +173,12 @@ void SettingsDialog::SaveSettings()
|
|||
|
||||
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"));
|
||||
}
|
||||
|
||||
|
@ -197,7 +206,6 @@ void SettingsDialog::DeleteApplication()
|
|||
|
||||
foreach(item, selected)
|
||||
{
|
||||
qDebug() << item;
|
||||
mApplications.RemoveApplication(mListWidget->row(item));
|
||||
mListWidget->clear();
|
||||
PopulateListWidget();
|
||||
|
|
Loading…
Reference in New Issue