Tulip  5.3.0
Large graphs analysis and drawing
SimplePluginProgressWidget.h
1 /*
2  *
3  * This file is part of Tulip (http://tulip.labri.fr)
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 class TLP_QT_SCOPE SimplePluginProgressWidget : public QWidget, public tlp::PluginProgress {
39  Q_OBJECT
40  Ui::SimplePluginProgressWidgetData *_ui;
41 
42  QTime _lastUpdate;
43  void checkLastUpdate();
44 
45  std::string _error;
46  tlp::ProgressState _state;
47 
48 public:
49  explicit SimplePluginProgressWidget(QWidget *parent = nullptr, Qt::WindowFlags f = nullptr);
50  ~SimplePluginProgressWidget() override;
51 
52  void setComment(const std::string &) override;
53  void setComment(const QString &);
54  void setComment(const char *);
55 
56  void setTitle(const std::string &) override {}
57 
58  tlp::ProgressState progress(int step, int max_step) override;
59 
60  void cancel() override;
61  void stop() override;
62 
63  bool isPreviewMode() const override;
64  void setPreviewMode(bool drawPreview) override;
65  void showPreview(bool showPreview) override;
66  void showStops(bool showButtons) override;
67 
68  tlp::ProgressState state() const override;
69 
70  std::string getError() override;
71  void setError(const std::string &error) override;
72 
73 protected:
74  void closeEvent(QCloseEvent *) override;
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 = nullptr);
89  ~SimplePluginProgressDialog() override;
90 
91  void setComment(const std::string &) override;
92  void setComment(const QString &);
93  void setComment(const char *);
94 
95  void setTitle(const std::string &title) override;
96 
97  tlp::ProgressState progress(int step, int max_step) override;
98 
99  void cancel() override;
100  void stop() override;
101 
102  bool isPreviewMode() const override;
103  void setPreviewMode(bool drawPreview) override;
104  void showPreview(bool showPreview) override;
105  void showStops(bool showButtons) override;
106 
107  tlp::ProgressState state() const override;
108 
109  std::string getError() override;
110  void setError(const std::string &error) override;
111 
112 protected:
113  void closeEvent(QCloseEvent *) override;
114  void paintEvent(QPaintEvent *) override;
115  bool _painted;
116 
117 public slots:
118  void setCancelButtonVisible(bool v);
119  void setStopButtonVisible(bool v);
120 
121 private:
122  tlp::SimplePluginProgressWidget *_progress;
123 };
124 } // namespace tlp
125 
126 #endif // SIMPLEPLUGINPROGRESSWIDGET_H
127 ///@endcond
ProgressState
This enum describes callback actions for the underlaying system when calling tlp::PluginProgress::pro...
PluginProcess subclasses are meant to notify about the progress state of some process (typically a pl...