Tulip  4.6.0
Better Visualization Through Research
library/tulip-gui/include/tulip/SimplePluginProgressWidget.h
00001 /*
00002  *
00003  * This file is part of Tulip (www.tulip-software.org)
00004  *
00005  * Authors: David Auber and the Tulip development Team
00006  * from LaBRI, University of Bordeaux
00007  *
00008  * Tulip is free software; you can redistribute it and/or modify
00009  * it under the terms of the GNU Lesser General Public License
00010  * as published by the Free Software Foundation, either version 3
00011  * of the License, or (at your option) any later version.
00012  *
00013  * Tulip is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00016  * See the GNU General Public License for more details.
00017  *
00018  */
00019 ///@cond DOXYGEN_HIDDEN
00020 
00021 #ifndef SIMPLEPLUGINPROGRESSWIDGET_H
00022 #define SIMPLEPLUGINPROGRESSWIDGET_H
00023 
00024 #include <tulip/PluginProgress.h>
00025 
00026 #include <QTime>
00027 #include <QWidget>
00028 #include <QDialog>
00029 
00030 namespace Ui {
00031 class SimplePluginProgressWidgetData;
00032 }
00033 
00034 class QCloseEvent;
00035 
00036 namespace tlp {
00037 
00038 
00039 class TLP_QT_SCOPE SimplePluginProgressWidget: public QWidget, public tlp::PluginProgress {
00040   Q_OBJECT
00041   Ui::SimplePluginProgressWidgetData *_ui;
00042 
00043   QTime _lastUpdate;
00044   void checkLastUpdate();
00045 
00046   std::string _error;
00047   tlp::ProgressState _state;
00048 
00049 public:
00050   explicit SimplePluginProgressWidget(QWidget *parent=NULL,Qt::WindowFlags f=0);
00051   virtual ~SimplePluginProgressWidget();
00052 
00053   void setComment(const std::string&);
00054   void setComment(const QString &);
00055   void setComment(const char *);
00056 
00057   void setTitle(const std::string &) {}
00058 
00059   tlp::ProgressState progress(int step, int max_step);
00060 
00061   void cancel();
00062   void stop();
00063 
00064   bool isPreviewMode() const;
00065   void setPreviewMode(bool drawPreview);
00066   void showPreview(bool showPreview);
00067 
00068   tlp::ProgressState state() const;
00069 
00070   std::string getError();
00071   void setError(const std::string &error);
00072 
00073 protected:
00074   void closeEvent(QCloseEvent *);
00075 
00076 public slots:
00077   void setCancelButtonVisible(bool);
00078   void setStopButtonVisible(bool);
00079 
00080 protected slots:
00081   void cancelClicked();
00082   void stopClicked();
00083 };
00084 
00085 class TLP_QT_SCOPE SimplePluginProgressDialog: public QDialog, public tlp::PluginProgress {
00086   Q_OBJECT
00087 public:
00088   explicit SimplePluginProgressDialog(QWidget *parent=NULL);
00089   virtual ~SimplePluginProgressDialog();
00090 
00091   void setComment(const std::string&);
00092   void setComment(const QString &);
00093   void setComment(const char *);
00094 
00095   void setTitle(const std::string &title);
00096 
00097   tlp::ProgressState progress(int step, int max_step);
00098 
00099   void cancel();
00100   void stop();
00101 
00102   bool isPreviewMode() const;
00103   void setPreviewMode(bool drawPreview);
00104   void showPreview(bool showPreview);
00105 
00106   tlp::ProgressState state() const;
00107 
00108   std::string getError();
00109   void setError(const std::string &error);
00110 
00111 protected:
00112   void closeEvent(QCloseEvent *);
00113 
00114 public slots:
00115   void setCancelButtonVisible(bool v);
00116   void setStopButtonVisible(bool v);
00117 
00118 private:
00119   tlp::SimplePluginProgressWidget *_progress;
00120 };
00121 
00122 }
00123 
00124 #endif // SIMPLEPLUGINPROGRESSWIDGET_H
00125 ///@endcond
 All Classes Files Functions Variables Enumerations Enumerator Properties