Tulip  4.7.0
Better Visualization Through Research
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Groups Pages
SimplePluginProgressWidget.h
1 /*
2  *
3  * This file is part of Tulip (www.tulip-software.org)
4  *
5  * Authors: David Auber and the Tulip development Team
6  * from LaBRI, University of Bordeaux
7  *
8  * Tulip is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU Lesser General Public License
10  * as published by the Free Software Foundation, either version 3
11  * of the License, or (at your option) any later version.
12  *
13  * Tulip is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16  * See the GNU General Public License for more details.
17  *
18  */
19 ///@cond DOXYGEN_HIDDEN
20 
21 #ifndef SIMPLEPLUGINPROGRESSWIDGET_H
22 #define SIMPLEPLUGINPROGRESSWIDGET_H
23 
24 #include <tulip/PluginProgress.h>
25 
26 #include <QTime>
27 #include <QWidget>
28 #include <QDialog>
29 
30 namespace Ui {
31 class SimplePluginProgressWidgetData;
32 }
33 
34 class QCloseEvent;
35 
36 namespace tlp {
37 
38 
39 class TLP_QT_SCOPE SimplePluginProgressWidget: public QWidget, public tlp::PluginProgress {
40  Q_OBJECT
41  Ui::SimplePluginProgressWidgetData *_ui;
42 
43  QTime _lastUpdate;
44  void checkLastUpdate();
45 
46  std::string _error;
47  tlp::ProgressState _state;
48 
49 public:
50  explicit SimplePluginProgressWidget(QWidget *parent=NULL,Qt::WindowFlags f=0);
51  virtual ~SimplePluginProgressWidget();
52 
53  void setComment(const std::string&);
54  void setComment(const QString &);
55  void setComment(const char *);
56 
57  void setTitle(const std::string &) {}
58 
59  tlp::ProgressState progress(int step, int max_step);
60 
61  void cancel();
62  void stop();
63 
64  bool isPreviewMode() const;
65  void setPreviewMode(bool drawPreview);
66  void showPreview(bool showPreview);
67 
68  tlp::ProgressState state() const;
69 
70  std::string getError();
71  void setError(const std::string &error);
72 
73 protected:
74  void closeEvent(QCloseEvent *);
75 
76 public slots:
77  void setCancelButtonVisible(bool);
78  void setStopButtonVisible(bool);
79 
80 protected slots:
81  void cancelClicked();
82  void stopClicked();
83 };
84 
85 class TLP_QT_SCOPE SimplePluginProgressDialog: public QDialog, public tlp::PluginProgress {
86  Q_OBJECT
87 public:
88  explicit SimplePluginProgressDialog(QWidget *parent=NULL);
89  virtual ~SimplePluginProgressDialog();
90 
91  void setComment(const std::string&);
92  void setComment(const QString &);
93  void setComment(const char *);
94 
95  void setTitle(const std::string &title);
96 
97  tlp::ProgressState progress(int step, int max_step);
98 
99  void cancel();
100  void stop();
101 
102  bool isPreviewMode() const;
103  void setPreviewMode(bool drawPreview);
104  void showPreview(bool showPreview);
105 
106  tlp::ProgressState state() const;
107 
108  std::string getError();
109  void setError(const std::string &error);
110 
111 protected:
112  void closeEvent(QCloseEvent *);
113 
114 public slots:
115  void setCancelButtonVisible(bool v);
116  void setStopButtonVisible(bool v);
117 
118 private:
119  tlp::SimplePluginProgressWidget *_progress;
120 };
121 
122 }
123 
124 #endif // SIMPLEPLUGINPROGRESSWIDGET_H
125 ///@endcond
ProgressState
This enum describes callback actions for the underleying system when calling tlp::PluginProgress::pro...
PluginProcess subclasses are meant to notify about the progress state of some process (typically a pl...