iRoCS Toolbox  1.1.0
ProgressReporterQt5.hh
Go to the documentation of this file.
1 /**************************************************************************
2  *
3  * Copyright (C) 2015 Thorsten Falk
4  *
5  * Image Analysis Lab, University of Freiburg, Germany
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software Foundation,
19  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  *
21  **************************************************************************/
22 
23 #ifndef ATBPROGRESSREPORTERQT5_HH
24 #define ATBPROGRESSREPORTERQT5_HH
25 
26 #ifdef HAVE_CONFIG_H
27 #include <config.hh>
28 #endif
29 
31 
32 #include <QApplication>
33 #include <QProgressBar>
34 #include <QLabel>
35 #include <QAbstractButton>
36 
37 namespace iRoCS
38 {
39 
41  public QObject, public ProgressReporter
42  {
43 
44  Q_OBJECT
45 
46  public:
47 
49  QProgressBar *progressBar = NULL, QLabel *headerLabel = NULL,
50  QLabel *messageLabel = NULL, QAbstractButton *cancelButton = NULL,
51  std::ostream *stream = NULL);
52 
54 
55  void setProgressMin(int progressMin);
56 
57  int progressMin() const;
58 
59  void setProgressMax(int progressMax);
60 
61  int progressMax() const;
62 
63  void setHeaderMessage(std::string const &message);
64 
65  std::string headerMessage() const;
66 
67  void setProgressMessage(std::string const &message);
68 
69  std::string progressMessage() const;
70 
71  void setProgress(int progress);
72 
73  int progress() const;
74 
75  void setAborted(bool abort);
76 
77  void abort();
78 
79  void abortWithError(std::string const &msg);
80 
81  bool isAborted() const;
82 
83  bool updateProgress(int progress);
84 
85  bool updateProgressMessage(std::string const &message);
86 
87  QProgressBar *progressBar() const;
88 
89  signals:
90 
91  void progressMinChanged(int);
92  void progressMaxChanged(int);
93  void progressChanged(int);
94  void headerMessageChanged(QString);
95  void progressMessageChanged(QString);
96  void error(QString const &);
97 
98  public slots:
99 
100  void setVisible(bool visible);
101  void reset();
102 
103  private slots:
104 
105  void cancel();
106 
107  private:
108 
109  QProgressBar *p_progressBar;
110  QLabel *p_headerLabel, *p_messageLabel;
111  QAbstractButton *p_cancelButton;
112 
113  bool _aborted;
114  std::ostream *p_stream;
115 
116  };
117 
118 }
119 
120 #endif
void setHeaderMessage(std::string const &message)
bool updateProgressMessage(std::string const &message)
void setProgressMax(int progressMax)
void setProgressMin(int progressMin)
std::string headerMessage() const
void setProgressMessage(std::string const &message)
void abortWithError(std::string const &msg)
void error(QString const &)
bool updateProgress(int progress)
std::string progressMessage() const
void progressMessageChanged(QString)
void setAborted(bool abort)
void setProgress(int progress)
void headerMessageChanged(QString)
QProgressBar * progressBar() const
void setVisible(bool visible)
ProgressReporterQt5(QProgressBar *progressBar=NULL, QLabel *headerLabel=NULL, QLabel *messageLabel=NULL, QAbstractButton *cancelButton=NULL, std::ostream *stream=NULL)