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