QGIS API Documentation  2.8.2-Wien
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
qgsmessagebar.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsmessagebar.h - description
3  -------------------
4  begin : June 2012
5  copyright : (C) 2012 by Giuseppe Sucameli
6  email : sucameli at faunalia dot it
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 #ifndef QGSMESSAGEBAR_H
18 #define QGSMESSAGEBAR_H
19 
20 #include <qgisgui.h>
21 
22 #include <QString>
23 #include <QFrame>
24 #include <QIcon>
25 #include <QColor>
26 #include <QList>
27 
28 class QWidget;
29 class QGridLayout;
30 class QMenu;
31 class QProgressBar;
32 class QToolButton;
33 class QLabel;
34 class QAction;
35 class QTimer;
36 
37 class QgsMessageBarItem;
38 
42 class GUI_EXPORT QgsMessageBar: public QFrame
43 {
44  Q_OBJECT
45 
46  public:
48  {
49  INFO = 0,
50  WARNING = 1,
51  CRITICAL = 2,
52  SUCCESS = 3
53  };
54 
55  QgsMessageBar( QWidget *parent = 0 );
56  ~QgsMessageBar();
57 
62  void pushItem( QgsMessageBarItem *item );
63 
70  QgsMessageBarItem *pushWidget( QWidget *widget, MessageLevel level = INFO, int duration = 0 );
71 
77  bool popWidget( QgsMessageBarItem *item );
78 
80  static QgsMessageBarItem* createMessage( const QString &text, QWidget *parent = 0 );
82  static QgsMessageBarItem* createMessage( const QString &title, const QString &text, QWidget *parent = 0 );
84  static QgsMessageBarItem* createMessage( QWidget *widget, QWidget *parent = 0 );
85 
87  void pushMessage( const QString &text, MessageLevel level = INFO, int duration = 0 ) { return pushMessage( QString::null, text, level, duration ); }
89  void pushMessage( const QString &title, const QString &text, MessageLevel level = INFO, int duration = 0 );
90 
91  signals:
93  void widgetAdded( QgsMessageBarItem *item );
94 
96  void widgetRemoved( QgsMessageBarItem *item );
97 
98  public slots:
103  bool popWidget();
104 
108  bool clearWidgets();
109 
116  void pushSuccess( const QString& title, const QString& message );
117 
124  void pushInfo( const QString& title, const QString& message );
125 
132  void pushWarning( const QString& title, const QString& message );
133 
140  void pushCritical( const QString& title, const QString& message );
141 
142  protected:
143  void mousePressEvent( QMouseEvent * e ) override;
144 
145  private:
146  void popItem( QgsMessageBarItem *item );
147  void showItem( QgsMessageBarItem *item );
148  QgsMessageBarItem *mCurrentItem;
149  QList<QgsMessageBarItem *> mItems;
150  QMenu *mCloseMenu;
151  QToolButton *mCloseBtn;
152  QGridLayout *mLayout;
153  QLabel *mItemCount;
154  QAction *mActionCloseAll;
155  QTimer *mCountdownTimer;
156  QProgressBar *mCountProgress;
157  QString mCountStyleSheet;
158 
159  private slots:
161  void updateItemCount();
162 
164  void updateCountdown();
165  void resetCountdown();
166 };
167 
168 #endif