DISPLACE  1.0
A spatial model of fisheries to help sustainable fishing and maritime spatial planning
backgroundworker.h
Go to the documentation of this file.
1 // --------------------------------------------------------------------------
2 // DISPLACE: DYNAMIC INDIVIDUAL VESSEL-BASED SPATIAL PLANNING
3 // AND EFFORT DISPLACEMENT
4 // Copyright (c) 2012-2019 Francois Bastardie <fba@aqua.dtu.dk>
5 
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2 of the License, or
9 // (at your option) any later version.
10 
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 
16 // You should have received a copy of the GNU General Public License along
17 // with this program; if not, write to the Free Software Foundation, Inc.,
18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 // --------------------------------------------------------------------------
20 
21 /* --------------------------------------------------------------------------
22  * DISPLACE: DYNAMIC INDIVIDUAL VESSEL-BASED SPATIAL PLANNING
23  * AND EFFORT DISPLACEMENT
24  * Copyright (c) 2012, 2013, 2014 Francois Bastardie <fba@aqua.dtu.dk>
25  *
26  * This program is free software; you can redistribute it and/or modify
27  * it under the terms of the GNU General Public License as published by
28  * the Free Software Foundation; either version 2 of the License, or
29  * (at your option) any later version.
30  *
31  * This program is distributed in the hope that it will be useful,
32  * but WITHOUT ANY WARRANTY; without even the implied warranty of
33  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
34  * GNU General Public License for more details.
35  *
36  * You should have received a copy of the GNU General Public License along
37  * with this program; if not, write to the Free Software Foundation, Inc.,
38  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
39  * --------------------------------------------------------------------------
40  */
41 #ifndef BACKGROUDWORKER_H
42 #define BACKGROUDWORKER_H
43 
44 #include <QObject>
45 #include <waitdialog.h>
46 
47 class MainWindow;
48 
49 class BackgroundWorker : public QObject
50 {
51  Q_OBJECT
52 public:
53  explicit BackgroundWorker(MainWindow *main);
54 
55  virtual void execute() = 0;
56 
57  QString getError() const { return mError; }
58  virtual bool success() const { return mResult; }
59 
60 signals:
61  void workStarted();
62  void workEnded();
63  void progress(int n);
64  void totalChanged(int tot);
65  void warning(QString,QString);
66  void completed (bool success);
67  void mainMessage (QString);
68  void progressMessage (QString);
69 
70 public slots:
71  void process();
72 
73 protected:
74  void setFail(QString msg) { mResult = false; mError = msg; }
75  void setSuccess() { mResult = true; }
76 
78  bool mResult;
79  QString mError;
80 };
81 
83 {
84  Q_OBJECT
85 public:
87 
88  WaitDialog *getWaitDialog() const { return mWaitDialog; }
89 
90  bool aborted() const { return mAborted; }
91 
92 signals:
93  void messageChanged(QString);
94  void progressBarVisibilityChanged(bool, int);
96 
97 public slots:
98  virtual void abortIssued();
99 
100 protected:
101  void setProgressMax(int);
102  void setProgress(int);
103  void setText(QString);
104  void setAbortEnabled(bool);
105 
107  bool mAborted;
108 };
109 
110 #endif // BACKGROUDWORKER_H
void mainMessage(QString)
Definition: moc_backgroundworker.cpp:254
MainWindow * mMain
Definition: backgroundworker.h:77
void totalChanged(int tot)
Definition: moc_backgroundworker.cpp:233
void progress(int n)
Definition: moc_backgroundworker.cpp:226
bool mAborted
Definition: backgroundworker.h:107
BackgroundWorker(MainWindow *main)
Definition: backgroundworker.cpp:28
void messageChanged(QString)
Definition: moc_backgroundworker.cpp:400
virtual void execute()=0
QString getError() const
Definition: backgroundworker.h:57
bool mResult
Definition: backgroundworker.h:78
void abortButtonVisibilityChanged(bool)
Definition: moc_backgroundworker.cpp:414
void setProgressMax(int)
Definition: backgroundworker.cpp:68
virtual bool success() const
Definition: backgroundworker.h:58
int main(int argc, char *argv[])
Definition: dteditor.cpp:27
void setAbortEnabled(bool)
Definition: backgroundworker.cpp:83
void setProgress(int)
Definition: backgroundworker.cpp:73
void progressMessage(QString)
Definition: moc_backgroundworker.cpp:261
Definition: backgroundworker.h:82
QString mError
Definition: backgroundworker.h:79
void workEnded()
Definition: moc_backgroundworker.cpp:220
void process()
Definition: backgroundworker.cpp:36
void progressBarVisibilityChanged(bool, int)
Definition: moc_backgroundworker.cpp:407
void setSuccess()
Definition: backgroundworker.h:75
WaitDialog * getWaitDialog() const
Definition: backgroundworker.h:88
Definition: waitdialog.h:56
BackgroundWorkerWithWaitDialog(MainWindow *main, WaitDialog *dialog)
Definition: backgroundworker.cpp:48
void warning(QString, QString)
Definition: moc_backgroundworker.cpp:240
WaitDialog * mWaitDialog
Definition: backgroundworker.h:106
void completed(bool success)
Definition: moc_backgroundworker.cpp:247
A workaround class for allowing calling the client.
Definition: waitdialog.h:51
Definition: mainwindow.h:75
void setFail(QString msg)
Definition: backgroundworker.h:74
void setText(QString)
Definition: backgroundworker.cpp:78
Definition: backgroundworker.h:49
void workStarted()
Definition: moc_backgroundworker.cpp:214
bool aborted() const
Definition: backgroundworker.h:90
virtual void abortIssued()
Definition: backgroundworker.cpp:63