Tulip  4.0.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 
50  void setComment(const std::string&);
51  void setComment(const QString &);
52  void setComment(const char *);
53 
54  tlp::ProgressState progress(int step, int max_step);
55 
56  void cancel();
57  void stop();
58 
59  bool isPreviewMode() const;
60  void setPreviewMode(bool drawPreview);
61  void showPreview(bool showPreview);
62 
63  tlp::ProgressState state() const;
64 
65  std::string getError();
66  void setError(const std::string &error);
67 
68 protected slots:
69  void cancelClicked();
70  void stopClicked();
71  void setPreview(bool);
72 };
73 
74 class TLP_QT_SCOPE SimplePluginProgressDialog: public QDialog, public tlp::PluginProgress {
75 public:
76  explicit SimplePluginProgressDialog(QWidget *parent=NULL);
77  virtual ~SimplePluginProgressDialog();
78 
79  void setComment(const std::string&);
80  void setComment(const QString &);
81  void setComment(const char *);
82 
83  tlp::ProgressState progress(int step, int max_step);
84 
85  void cancel();
86  void stop();
87 
88  bool isPreviewMode() const;
89  void setPreviewMode(bool drawPreview);
90  void showPreview(bool showPreview);
91 
92  tlp::ProgressState state() const;
93 
94  std::string getError();
95  void setError(const std::string &error);
96 
97 private:
98  tlp::SimplePluginProgressWidget *_progress;
99 };
100 
101 }
102 
103 #endif // SIMPLEPLUGINPROGRESSWIDGET_H
104 ///@endcond