Tulip  5.7.4
Large graphs analysis and drawing
SimplePluginProgressWidget.h
1 /*
2  *
3  * This file is part of Tulip (https://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,
50  Qt::WindowFlags f = Qt::WindowFlags());
51  ~SimplePluginProgressWidget() override;
52 
53  void setComment(const std::string &) override;
54  void setComment(const QString &);
55  void setComment(const char *);
56 
57  void setTitle(const std::string &) override {}
58 
59  tlp::ProgressState progress(int step, int max_step) override;
60 
61  void cancel() override;
62  void stop() override;
63 
64  bool isPreviewMode() const override;
65  void setPreviewMode(bool drawPreview) override;
66  void showPreview(bool showPreview) override;
67  void showStops(bool showButtons) override;
68  void showText(bool show) override;
69  void showLogo(bool show);
70 
71  tlp::ProgressState state() const override;
72 
73  std::string getError() override;
74  void setError(const std::string &error) override;
75 
76 protected:
77  void closeEvent(QCloseEvent *) override;
78 
79 public slots:
80  void setCancelButtonVisible(bool);
81  void setStopButtonVisible(bool);
82 
83 protected slots:
84  void cancelClicked();
85  void stopClicked();
86 };
87 
88 class TLP_QT_SCOPE SimplePluginProgressDialog : public QDialog, public tlp::PluginProgress {
89  Q_OBJECT
90 public:
91  explicit SimplePluginProgressDialog(QWidget *parent = nullptr);
92  ~SimplePluginProgressDialog() override;
93 
94  void setComment(const std::string &) override;
95  void setComment(const QString &);
96  void setComment(const char *);
97 
98  void setTitle(const std::string &title) override;
99 
100  tlp::ProgressState progress(int step, int max_step) override;
101 
102  void cancel() override;
103  void stop() override;
104 
105  bool isPreviewMode() const override;
106  void setPreviewMode(bool drawPreview) override;
107  void showPreview(bool showPreview) override;
108  void showStops(bool showButtons) override;
109  void showText(bool show) override;
110  void showLogo(bool show) {
111  _progress->showLogo(show);
112  }
113 
114  tlp::ProgressState state() const override;
115 
116  std::string getError() override;
117  void setError(const std::string &error) override;
118 
119 protected:
120  void closeEvent(QCloseEvent *) override;
121  void paintEvent(QPaintEvent *) override;
122  bool _painted;
123 
124 public slots:
125  void setCancelButtonVisible(bool v);
126  void setStopButtonVisible(bool v);
127 
128 private:
129  tlp::SimplePluginProgressWidget *_progress;
130 };
131 } // namespace tlp
132 
133 #endif // SIMPLEPLUGINPROGRESSWIDGET_H
134 ///@endcond
PluginProcess subclasses are meant to notify about the progress state of some process (typically a pl...
ProgressState
This enum describes callback actions for the underlying system when calling tlp::PluginProgress::prog...