Tulip  4.2.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 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  void setTitle(const std::string &) {}
56 
57  tlp::ProgressState progress(int step, int max_step);
58 
59  void cancel();
60  void stop();
61 
62  bool isPreviewMode() const;
63  void setPreviewMode(bool drawPreview);
64  void showPreview(bool showPreview);
65 
66  tlp::ProgressState state() const;
67 
68  std::string getError();
69  void setError(const std::string &error);
70 
71 protected:
72  void closeEvent(QCloseEvent *);
73 
74 public slots:
75  void setCancelButtonVisible(bool);
76  void setStopButtonVisible(bool);
77 
78 protected slots:
79  void cancelClicked();
80  void stopClicked();
81 };
82 
83 class TLP_QT_SCOPE SimplePluginProgressDialog: public QDialog, public tlp::PluginProgress {
84  Q_OBJECT
85 public:
86  explicit SimplePluginProgressDialog(QWidget *parent=NULL);
87  virtual ~SimplePluginProgressDialog();
88 
89  void setComment(const std::string&);
90  void setComment(const QString &);
91  void setComment(const char *);
92 
93  void setTitle(const std::string &title);
94 
95  tlp::ProgressState progress(int step, int max_step);
96 
97  void cancel();
98  void stop();
99 
100  bool isPreviewMode() const;
101  void setPreviewMode(bool drawPreview);
102  void showPreview(bool showPreview);
103 
104  tlp::ProgressState state() const;
105 
106  std::string getError();
107  void setError(const std::string &error);
108 
109 protected:
110  void closeEvent(QCloseEvent *);
111 
112 public slots:
113  void setCancelButtonVisible(bool v);
114  void setStopButtonVisible(bool v);
115 
116 private:
117  tlp::SimplePluginProgressWidget *_progress;
118 };
119 
120 }
121 
122 #endif // SIMPLEPLUGINPROGRESSWIDGET_H
123 ///@endcond