Tulip  4.1.0
Better Visualization Through Research
 All Classes 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 1 and Inria Bordeaux - Sud Ouest
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 <QtGui/QDialog>
25 #include <QtGui/QWidget>
26 #include <QtCore/QTime>
27 
28 #include <tulip/PluginProgress.h>
29 
30 namespace Ui {
31 class SimplePluginProgressWidgetData;
32 }
33 
34 namespace tlp {
35 
36 
37 class TLP_QT_SCOPE SimplePluginProgressWidget: public QWidget, public tlp::PluginProgress {
38  Q_OBJECT
39  Ui::SimplePluginProgressWidgetData *_ui;
40 
41  QTime _lastUpdate;
42  void checkLastUpdate();
43 
44  std::string _error;
45  tlp::ProgressState _state;
46 
47 public:
48  explicit SimplePluginProgressWidget(QWidget *parent=NULL,Qt::WindowFlags f=0);
49  virtual ~SimplePluginProgressWidget();
50 
51  void setComment(const std::string&);
52  void setComment(const QString &);
53  void setComment(const char *);
54 
55  tlp::ProgressState progress(int step, int max_step);
56 
57  void cancel();
58  void stop();
59 
60  bool isPreviewMode() const;
61  void setPreviewMode(bool drawPreview);
62  void showPreview(bool showPreview);
63 
64  tlp::ProgressState state() const;
65 
66  std::string getError();
67  void setError(const std::string &error);
68 
69 public slots:
70  void setCancelButtonVisible(bool);
71  void setStopButtonVisible(bool);
72  void setPreviewButtonVisible(bool);
73 
74 protected slots:
75  void cancelClicked();
76  void stopClicked();
77  void setPreview(bool);
78 };
79 
80 class TLP_QT_SCOPE SimplePluginProgressDialog: public QDialog, public tlp::PluginProgress {
81  Q_OBJECT
82 public:
83  explicit SimplePluginProgressDialog(QWidget *parent=NULL);
84  virtual ~SimplePluginProgressDialog();
85 
86  void setComment(const std::string&);
87  void setComment(const QString &);
88  void setComment(const char *);
89 
90  tlp::ProgressState progress(int step, int max_step);
91 
92  void cancel();
93  void stop();
94 
95  bool isPreviewMode() const;
96  void setPreviewMode(bool drawPreview);
97  void showPreview(bool showPreview);
98 
99  tlp::ProgressState state() const;
100 
101  std::string getError();
102  void setError(const std::string &error);
103 
104 public slots:
105  void setCancelButtonVisible(bool v);
106  void setStopButtonVisible(bool v);
107  void setPreviewButtonVisible(bool v);
108 
109 private:
110  tlp::SimplePluginProgressWidget *_progress;
111 };
112 
113 }
114 
115 #endif // SIMPLEPLUGINPROGRESSWIDGET_H
116 ///@endcond