GUI: Make ThreadHandler class part of object tree.

This commit is contained in:
Kimmo Varis 2009-06-20 19:55:23 +03:00
parent d1d9c9a9c9
commit 2eff269e60
4 changed files with 18 additions and 14 deletions

View File

@ -27,6 +27,7 @@
#include <QKeySequence>
#include <QFileInfo>
#include "aboutdialog.h"
#include "threadhandler.h"
#include "fileviewdialog.h"
#include "../src/filelister.h"
#include "../src/cppcheckexecutor.h"
@ -57,6 +58,7 @@ MainWindow::MainWindow() :
{
CreateMenus();
CreateToolbar();
mThread = new ThreadHandler(this);
setCentralWidget(&mResults);
@ -78,14 +80,14 @@ MainWindow::MainWindow() :
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(&mActionAbout, SIGNAL(triggered()), this, SLOT(About()));
connect(&mActionShowLicense, SIGNAL(triggered()), this, SLOT(ShowLicense()));
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()));
mActionCheckDirectory.setIcon(QIcon(":icon.png"));
@ -102,7 +104,7 @@ MainWindow::MainWindow() :
mActionAbout.setShortcut(QKeySequence(Qt::Key_F1));
LoadSettings();
mThread.Initialize(&mResults);
mThread->Initialize(&mResults);
setWindowTitle(tr("Cppcheck"));
EnableCheckButtons(true);
@ -248,7 +250,7 @@ void MainWindow::DoCheckFiles(QFileDialog::FileMode mode)
}
mResults.Clear();
mThread.ClearFiles();
mThread->ClearFiles();
if (fileNames.isEmpty())
{
@ -263,13 +265,13 @@ void MainWindow::DoCheckFiles(QFileDialog::FileMode mode)
mResults.CheckingStarted();
mThread.SetFiles(RemoveUnacceptedFiles(fileNames));
mThread->SetFiles(RemoveUnacceptedFiles(fileNames));
QFileInfo inf(fileNames[0]);
QString absDirectory = inf.absoluteDir().path();
mSettings.setValue(tr("Check path"), absDirectory);
EnableCheckButtons(false);
mResults.SetCheckDirectory(absDirectory);
mThread.Check(GetCppcheckSettings(), false);
mThread->Check(GetCppcheckSettings(), false);
}
}
@ -365,7 +367,7 @@ void MainWindow::ReCheck()
{
ClearResults();
EnableCheckButtons(false);
mThread.Check(GetCppcheckSettings(), true);
mThread->Check(GetCppcheckSettings(), true);
}
void MainWindow::ClearResults()
@ -422,7 +424,7 @@ void MainWindow::UncheckAll()
void MainWindow::closeEvent(QCloseEvent *event)
{
// Check that we aren't checking files
if (!mThread.IsChecking())
if (!mThread->IsChecking())
event->accept();
else
{

View File

@ -21,15 +21,15 @@
#define MAINWINDOW_H
#include <QMainWindow>
#include "resultsview.h"
#include <QSettings>
#include <QAction>
#include <QFileDialog>
#include "threadhandler.h"
#include "resultsview.h"
#include "settingsdialog.h"
class ThreadHandler;
/**
* @brief Main window for cppcheck-gui
*
@ -359,7 +359,7 @@ protected:
* @brief Thread to check files
*
*/
ThreadHandler mThread;
ThreadHandler *mThread;
/**
* @brief List of user defined applications to open errors with

View File

@ -20,7 +20,9 @@
#include "threadhandler.h"
#include <QDebug>
ThreadHandler::ThreadHandler() : mRunningThreadCount(0)
ThreadHandler::ThreadHandler(QObject *parent) :
QObject(parent),
mRunningThreadCount(0)
{
SetThreadCount(1);
}

View File

@ -36,7 +36,7 @@ class ThreadHandler : public QObject
{
Q_OBJECT
public:
ThreadHandler();
ThreadHandler(QObject *parent = 0);
virtual ~ThreadHandler();
/**