Cute Chess 0.1
threadedtask.h
1/*
2 This file is part of Cute Chess.
3
4 Cute Chess is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
8
9 Cute Chess is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with Cute Chess. If not, see <http://www.gnu.org/licenses/>.
16*/
17
18#ifndef THREADEDTASK_H
19#define THREADEDTASK_H
20
21#include <QThread>
22#include <QTime>
23class QWidget;
24class QProgressDialog;
25
42class ThreadedTask : public QThread
43{
44 Q_OBJECT
45
46 public:
56 explicit ThreadedTask(const QString& title,
57 const QString& labelText,
58 int minimum,
59 int maximum,
60 QWidget* parent);
62 virtual ~ThreadedTask();
63
64 signals:
70 void progressValueChanged(int value);
75 void statusMessageChanged(const QString& message);
76
77 protected:
85 bool cancelRequested() const;
86
91 QString humaniseTime(int sec) const;
92
93 private slots:
94 // Yes, QThread subclasses shouldn't normally have slots
95 // because they're executed in the wrong thread. But in this
96 // case it doesn't matter because we're just setting a flag.
97 void cancel();
98
99 void updateProgress(int value);
100 void setStatusMessage(const QString& msg);
101
102 private:
103 bool m_cancel;
104 QString m_statusMessage;
105 QTime m_taskStart;
106 int m_lastUpdate;
107 QProgressDialog* m_dlg;
108};
109
110#endif // THREADEDTASK_H
ThreadedTask(const QString &title, const QString &labelText, int minimum, int maximum, QWidget *parent)
Definition threadedtask.cpp:21
virtual ~ThreadedTask()
Definition threadedtask.cpp:52
void statusMessageChanged(const QString &message)
QString humaniseTime(int sec) const
Definition threadedtask.cpp:87
bool cancelRequested() const
Definition threadedtask.cpp:61
void progressValueChanged(int value)