Added recheck and clear results buttons.
This commit is contained in:
parent
f04bdccee4
commit
84853aa7f9
|
@ -30,13 +30,17 @@ 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),
|
||||||
mActionCheckDirectory(tr("&Check directory"), this),
|
mActionClearResults(tr("Clear &results"), this),
|
||||||
|
mActionReCheck(tr("Recheck files"), this),
|
||||||
|
mActionCheckDirectory(tr("Check &directory"), this),
|
||||||
mActionSettings(tr("&Settings"), this),
|
mActionSettings(tr("&Settings"), this),
|
||||||
mResults(mSettings)
|
mResults(mSettings)
|
||||||
{
|
{
|
||||||
QMenu *menu = menuBar()->addMenu(tr("&File"));
|
QMenu *menu = menuBar()->addMenu(tr("&File"));
|
||||||
menu->addAction(&mActionCheckFiles);
|
menu->addAction(&mActionCheckFiles);
|
||||||
menu->addAction(&mActionCheckDirectory);
|
menu->addAction(&mActionCheckDirectory);
|
||||||
|
menu->addAction(&mActionReCheck);
|
||||||
|
menu->addAction(&mActionClearResults);
|
||||||
menu->addSeparator();
|
menu->addSeparator();
|
||||||
menu->addAction(&mActionExit);
|
menu->addAction(&mActionExit);
|
||||||
|
|
||||||
|
@ -50,6 +54,8 @@ MainWindow::MainWindow() :
|
||||||
connect(&mActionCheckFiles, SIGNAL(triggered()), this, SLOT(CheckFiles()));
|
connect(&mActionCheckFiles, SIGNAL(triggered()), this, SLOT(CheckFiles()));
|
||||||
connect(&mActionCheckDirectory, SIGNAL(triggered()), this, SLOT(CheckDirectory()));
|
connect(&mActionCheckDirectory, SIGNAL(triggered()), this, SLOT(CheckDirectory()));
|
||||||
connect(&mActionSettings, SIGNAL(triggered()), this, SLOT(ProgramSettings()));
|
connect(&mActionSettings, SIGNAL(triggered()), this, SLOT(ProgramSettings()));
|
||||||
|
connect(&mActionClearResults, SIGNAL(triggered()), this, SLOT(ClearResults()));
|
||||||
|
connect(&mActionReCheck, SIGNAL(triggered()), this, SLOT(ReCheck()));
|
||||||
connect(&mThread, SIGNAL(Done()), this, SLOT(CheckDone()));
|
connect(&mThread, SIGNAL(Done()), this, SLOT(CheckDone()));
|
||||||
LoadSettings();
|
LoadSettings();
|
||||||
mThread.Initialize(&mResults);
|
mThread.Initialize(&mResults);
|
||||||
|
@ -102,8 +108,8 @@ void MainWindow::DoCheckFiles(QFileDialog::FileMode mode)
|
||||||
mThread.ClearFiles();
|
mThread.ClearFiles();
|
||||||
mThread.SetFiles(RemoveUnacceptedFiles(fileNames));
|
mThread.SetFiles(RemoveUnacceptedFiles(fileNames));
|
||||||
mSettings.setValue(tr("Check path"), dialog.directory().absolutePath());
|
mSettings.setValue(tr("Check path"), dialog.directory().absolutePath());
|
||||||
mActionCheckFiles.setDisabled(true);
|
EnableCheckButtons(false);
|
||||||
mThread.Check(GetCppCheckSettings());
|
mThread.Check(GetCppCheckSettings(),false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,7 +131,7 @@ Settings MainWindow::GetCppCheckSettings()
|
||||||
result._checkCodingStyle = true;
|
result._checkCodingStyle = true;
|
||||||
result._errorsOnly = false;
|
result._errorsOnly = false;
|
||||||
result._verbose = true;
|
result._verbose = true;
|
||||||
result._force = true;
|
result._force = mSettings.value(tr("Check force"), 1).toBool();
|
||||||
result._xml = false;
|
result._xml = false;
|
||||||
result._unusedFunctions = true;
|
result._unusedFunctions = true;
|
||||||
result._security = true;
|
result._security = true;
|
||||||
|
@ -186,7 +192,7 @@ QStringList MainWindow::RemoveUnacceptedFiles(const QStringList &list)
|
||||||
|
|
||||||
void MainWindow::CheckDone()
|
void MainWindow::CheckDone()
|
||||||
{
|
{
|
||||||
mActionCheckFiles.setDisabled(false);
|
EnableCheckButtons(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::ProgramSettings()
|
void MainWindow::ProgramSettings()
|
||||||
|
@ -198,3 +204,23 @@ void MainWindow::ProgramSettings()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MainWindow::ReCheck()
|
||||||
|
{
|
||||||
|
ClearResults();
|
||||||
|
EnableCheckButtons(false);
|
||||||
|
mThread.Check(GetCppCheckSettings(),true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::ClearResults()
|
||||||
|
{
|
||||||
|
mResults.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::EnableCheckButtons(bool enable)
|
||||||
|
{
|
||||||
|
mActionCheckFiles.setEnabled(enable);
|
||||||
|
mActionReCheck.setEnabled(enable);
|
||||||
|
mActionCheckDirectory.setEnabled(enable);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,8 @@ public slots:
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void CheckFiles();
|
void CheckFiles();
|
||||||
|
void ReCheck();
|
||||||
|
void ClearResults();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Slot for check directory menu item
|
* @brief Slot for check directory menu item
|
||||||
|
@ -66,6 +68,7 @@ protected slots:
|
||||||
*/
|
*/
|
||||||
void CheckDone();
|
void CheckDone();
|
||||||
protected:
|
protected:
|
||||||
|
void EnableCheckButtons(bool enable);
|
||||||
void DoCheckFiles(QFileDialog::FileMode mode);
|
void DoCheckFiles(QFileDialog::FileMode mode);
|
||||||
QStringList GetFilesRecursively(const QString &path);
|
QStringList GetFilesRecursively(const QString &path);
|
||||||
QStringList RemoveDuplicates(const QStringList &list);
|
QStringList RemoveDuplicates(const QStringList &list);
|
||||||
|
@ -102,6 +105,19 @@ protected:
|
||||||
*/
|
*/
|
||||||
QAction mActionCheckFiles;
|
QAction mActionCheckFiles;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Menu action to clear results
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
QAction mActionClearResults;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Menu action to re check
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
QAction mActionReCheck;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Menu action to check a directory
|
* @brief Menu action to check a directory
|
||||||
*
|
*
|
||||||
|
|
|
@ -72,15 +72,11 @@ void ResultsTree::AddErrorItem(const QString &file,
|
||||||
mModel.appendRow(fileitem);
|
mModel.appendRow(fileitem);
|
||||||
}
|
}
|
||||||
|
|
||||||
//qDebug() << "Adding error for file" << realfile << ". Message is" << message;
|
|
||||||
|
|
||||||
QList<QStandardItem*> list;
|
QList<QStandardItem*> list;
|
||||||
list << CreateItem(severity);
|
list << CreateItem(severity);
|
||||||
list << CreateItem(QString("%1").arg(lines[0]));
|
list << CreateItem(QString("%1").arg(lines[0]));
|
||||||
list << CreateItem(message);
|
list << CreateItem(message);
|
||||||
fileitem->appendRow(list);
|
fileitem->appendRow(list);
|
||||||
|
|
||||||
//qDebug()<<"\n";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QStandardItem *ResultsTree::FindFileItem(const QString &name)
|
QStandardItem *ResultsTree::FindFileItem(const QString &name)
|
||||||
|
|
|
@ -33,22 +33,23 @@ ThreadHandler::~ThreadHandler()
|
||||||
|
|
||||||
void ThreadHandler::ClearFiles()
|
void ThreadHandler::ClearFiles()
|
||||||
{
|
{
|
||||||
|
mLastFiles.clear();
|
||||||
mResults.ClearFiles();
|
mResults.ClearFiles();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThreadHandler::SetFiles(const QStringList &files)
|
void ThreadHandler::SetFiles(const QStringList &files)
|
||||||
{
|
{
|
||||||
mResults.SetFiles(files);
|
mResults.SetFiles(files);
|
||||||
|
mLastFiles = files;
|
||||||
QString file;
|
QString file;
|
||||||
qDebug() << "Files to check:";
|
|
||||||
foreach(file, files)
|
|
||||||
{
|
|
||||||
qDebug() << file;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThreadHandler::Check(Settings settings)
|
void ThreadHandler::Check(Settings settings, bool recheck)
|
||||||
{
|
{
|
||||||
|
if (recheck && mRunningThreadCount == 0) {
|
||||||
|
mResults.SetFiles(mLastFiles);
|
||||||
|
}
|
||||||
|
|
||||||
if (mResults.GetFileCount() == 0 || mRunningThreadCount > 0 || settings._jobs <= 0)
|
if (mResults.GetFileCount() == 0 || mRunningThreadCount > 0 || settings._jobs <= 0)
|
||||||
{
|
{
|
||||||
qDebug() << "Can't start checking if there's no files to check or if check is in progress.";
|
qDebug() << "Can't start checking if there's no files to check or if check is in progress.";
|
||||||
|
@ -126,8 +127,6 @@ void ThreadHandler::Stop()
|
||||||
{
|
{
|
||||||
mThreads[i]->terminate();
|
mThreads[i]->terminate();
|
||||||
}
|
}
|
||||||
|
|
||||||
mResults.ClearFiles();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThreadHandler::Initialize(ResultsView *view)
|
void ThreadHandler::Initialize(ResultsView *view)
|
||||||
|
|
|
@ -57,7 +57,7 @@ public:
|
||||||
*/
|
*/
|
||||||
void SetFiles(const QStringList &files);
|
void SetFiles(const QStringList &files);
|
||||||
|
|
||||||
void Check(Settings settings);
|
void Check(Settings settings, bool recheck);
|
||||||
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
@ -66,6 +66,7 @@ protected slots:
|
||||||
void Stop();
|
void Stop();
|
||||||
void ThreadDone();
|
void ThreadDone();
|
||||||
protected:
|
protected:
|
||||||
|
QStringList mLastFiles;
|
||||||
void RemoveThreads();
|
void RemoveThreads();
|
||||||
ThreadResult mResults;
|
ThreadResult mResults;
|
||||||
QList<CheckThread *> mThreads;
|
QList<CheckThread *> mThreads;
|
||||||
|
|
Loading…
Reference in New Issue