GUI: Make ThreadHandler class part of object tree.
This commit is contained in:
parent
d1d9c9a9c9
commit
2eff269e60
|
@ -27,6 +27,7 @@
|
||||||
#include <QKeySequence>
|
#include <QKeySequence>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include "aboutdialog.h"
|
#include "aboutdialog.h"
|
||||||
|
#include "threadhandler.h"
|
||||||
#include "fileviewdialog.h"
|
#include "fileviewdialog.h"
|
||||||
#include "../src/filelister.h"
|
#include "../src/filelister.h"
|
||||||
#include "../src/cppcheckexecutor.h"
|
#include "../src/cppcheckexecutor.h"
|
||||||
|
@ -57,6 +58,7 @@ MainWindow::MainWindow() :
|
||||||
{
|
{
|
||||||
CreateMenus();
|
CreateMenus();
|
||||||
CreateToolbar();
|
CreateToolbar();
|
||||||
|
mThread = new ThreadHandler(this);
|
||||||
|
|
||||||
setCentralWidget(&mResults);
|
setCentralWidget(&mResults);
|
||||||
|
|
||||||
|
@ -78,14 +80,14 @@ MainWindow::MainWindow() :
|
||||||
|
|
||||||
connect(&mActionReCheck, SIGNAL(triggered()), this, SLOT(ReCheck()));
|
connect(&mActionReCheck, SIGNAL(triggered()), this, SLOT(ReCheck()));
|
||||||
|
|
||||||
connect(&mActionStop, SIGNAL(triggered()), &mThread, SLOT(Stop()));
|
connect(&mActionStop, SIGNAL(triggered()), mThread, SLOT(Stop()));
|
||||||
connect(&mActionSave, SIGNAL(triggered()), this, SLOT(Save()));
|
connect(&mActionSave, SIGNAL(triggered()), this, SLOT(Save()));
|
||||||
|
|
||||||
connect(&mActionAbout, SIGNAL(triggered()), this, SLOT(About()));
|
connect(&mActionAbout, SIGNAL(triggered()), this, SLOT(About()));
|
||||||
connect(&mActionShowLicense, SIGNAL(triggered()), this, SLOT(ShowLicense()));
|
connect(&mActionShowLicense, SIGNAL(triggered()), this, SLOT(ShowLicense()));
|
||||||
connect(&mActionShowAuthors, SIGNAL(triggered()), this, SLOT(ShowAuthors()));
|
connect(&mActionShowAuthors, SIGNAL(triggered()), this, SLOT(ShowAuthors()));
|
||||||
|
|
||||||
connect(&mThread, SIGNAL(Done()), this, SLOT(CheckDone()));
|
connect(mThread, SIGNAL(Done()), this, SLOT(CheckDone()));
|
||||||
connect(&mResults, SIGNAL(GotResults()), this, SLOT(ResultsAdded()));
|
connect(&mResults, SIGNAL(GotResults()), this, SLOT(ResultsAdded()));
|
||||||
|
|
||||||
mActionCheckDirectory.setIcon(QIcon(":icon.png"));
|
mActionCheckDirectory.setIcon(QIcon(":icon.png"));
|
||||||
|
@ -102,7 +104,7 @@ MainWindow::MainWindow() :
|
||||||
mActionAbout.setShortcut(QKeySequence(Qt::Key_F1));
|
mActionAbout.setShortcut(QKeySequence(Qt::Key_F1));
|
||||||
|
|
||||||
LoadSettings();
|
LoadSettings();
|
||||||
mThread.Initialize(&mResults);
|
mThread->Initialize(&mResults);
|
||||||
setWindowTitle(tr("Cppcheck"));
|
setWindowTitle(tr("Cppcheck"));
|
||||||
|
|
||||||
EnableCheckButtons(true);
|
EnableCheckButtons(true);
|
||||||
|
@ -248,7 +250,7 @@ void MainWindow::DoCheckFiles(QFileDialog::FileMode mode)
|
||||||
}
|
}
|
||||||
|
|
||||||
mResults.Clear();
|
mResults.Clear();
|
||||||
mThread.ClearFiles();
|
mThread->ClearFiles();
|
||||||
|
|
||||||
if (fileNames.isEmpty())
|
if (fileNames.isEmpty())
|
||||||
{
|
{
|
||||||
|
@ -263,13 +265,13 @@ void MainWindow::DoCheckFiles(QFileDialog::FileMode mode)
|
||||||
|
|
||||||
mResults.CheckingStarted();
|
mResults.CheckingStarted();
|
||||||
|
|
||||||
mThread.SetFiles(RemoveUnacceptedFiles(fileNames));
|
mThread->SetFiles(RemoveUnacceptedFiles(fileNames));
|
||||||
QFileInfo inf(fileNames[0]);
|
QFileInfo inf(fileNames[0]);
|
||||||
QString absDirectory = inf.absoluteDir().path();
|
QString absDirectory = inf.absoluteDir().path();
|
||||||
mSettings.setValue(tr("Check path"), absDirectory);
|
mSettings.setValue(tr("Check path"), absDirectory);
|
||||||
EnableCheckButtons(false);
|
EnableCheckButtons(false);
|
||||||
mResults.SetCheckDirectory(absDirectory);
|
mResults.SetCheckDirectory(absDirectory);
|
||||||
mThread.Check(GetCppcheckSettings(), false);
|
mThread->Check(GetCppcheckSettings(), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -365,7 +367,7 @@ void MainWindow::ReCheck()
|
||||||
{
|
{
|
||||||
ClearResults();
|
ClearResults();
|
||||||
EnableCheckButtons(false);
|
EnableCheckButtons(false);
|
||||||
mThread.Check(GetCppcheckSettings(), true);
|
mThread->Check(GetCppcheckSettings(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::ClearResults()
|
void MainWindow::ClearResults()
|
||||||
|
@ -422,7 +424,7 @@ void MainWindow::UncheckAll()
|
||||||
void MainWindow::closeEvent(QCloseEvent *event)
|
void MainWindow::closeEvent(QCloseEvent *event)
|
||||||
{
|
{
|
||||||
// Check that we aren't checking files
|
// Check that we aren't checking files
|
||||||
if (!mThread.IsChecking())
|
if (!mThread->IsChecking())
|
||||||
event->accept();
|
event->accept();
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -21,15 +21,15 @@
|
||||||
#define MAINWINDOW_H
|
#define MAINWINDOW_H
|
||||||
|
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
#include "resultsview.h"
|
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
|
|
||||||
|
#include "resultsview.h"
|
||||||
#include "threadhandler.h"
|
|
||||||
#include "settingsdialog.h"
|
#include "settingsdialog.h"
|
||||||
|
|
||||||
|
class ThreadHandler;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Main window for cppcheck-gui
|
* @brief Main window for cppcheck-gui
|
||||||
*
|
*
|
||||||
|
@ -359,7 +359,7 @@ protected:
|
||||||
* @brief Thread to check files
|
* @brief Thread to check files
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
ThreadHandler mThread;
|
ThreadHandler *mThread;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief List of user defined applications to open errors with
|
* @brief List of user defined applications to open errors with
|
||||||
|
|
|
@ -20,7 +20,9 @@
|
||||||
#include "threadhandler.h"
|
#include "threadhandler.h"
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
ThreadHandler::ThreadHandler() : mRunningThreadCount(0)
|
ThreadHandler::ThreadHandler(QObject *parent) :
|
||||||
|
QObject(parent),
|
||||||
|
mRunningThreadCount(0)
|
||||||
{
|
{
|
||||||
SetThreadCount(1);
|
SetThreadCount(1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ class ThreadHandler : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
ThreadHandler();
|
ThreadHandler(QObject *parent = 0);
|
||||||
virtual ~ThreadHandler();
|
virtual ~ThreadHandler();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue