Tulip 5.7.1
Large graphs analysis and drawing
Loading...
Searching...
No Matches
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
30namespace Ui {
31class SimplePluginProgressWidgetData;
32}
33
34class QCloseEvent;
35
36namespace tlp {
37
38class 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
48public:
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
70 tlp::ProgressState state() const override;
71
72 std::string getError() override;
73 void setError(const std::string &error) override;
74
75protected:
76 void closeEvent(QCloseEvent *) override;
77
78public slots:
79 void setCancelButtonVisible(bool);
80 void setStopButtonVisible(bool);
81
82protected slots:
83 void cancelClicked();
84 void stopClicked();
85};
86
87class TLP_QT_SCOPE SimplePluginProgressDialog : public QDialog, public tlp::PluginProgress {
88 Q_OBJECT
89public:
90 explicit SimplePluginProgressDialog(QWidget *parent = nullptr);
91 ~SimplePluginProgressDialog() override;
92
93 void setComment(const std::string &) override;
94 void setComment(const QString &);
95 void setComment(const char *);
96
97 void setTitle(const std::string &title) override;
98
99 tlp::ProgressState progress(int step, int max_step) override;
100
101 void cancel() override;
102 void stop() override;
103
104 bool isPreviewMode() const override;
105 void setPreviewMode(bool drawPreview) override;
106 void showPreview(bool showPreview) override;
107 void showStops(bool showButtons) override;
108 void showText(bool show) override;
109
110 tlp::ProgressState state() const override;
111
112 std::string getError() override;
113 void setError(const std::string &error) override;
114
115protected:
116 void closeEvent(QCloseEvent *) override;
117 void paintEvent(QPaintEvent *) override;
118 bool _painted;
119
120public slots:
121 void setCancelButtonVisible(bool v);
122 void setStopButtonVisible(bool v);
123
124private:
125 tlp::SimplePluginProgressWidget *_progress;
126};
127} // namespace tlp
128
129#endif // SIMPLEPLUGINPROGRESSWIDGET_H
130///@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...