QGIS API Documentation  2.10.1-Pisa
 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 
65  void pushItem( QgsMessageBarItem *item );
66 
73  QgsMessageBarItem *pushWidget( QWidget *widget, MessageLevel level = INFO, int duration = 0 );
74 
80  bool popWidget( QgsMessageBarItem *item );
81 
83  static QgsMessageBarItem* createMessage( const QString &text, QWidget *parent = 0 );
85  static QgsMessageBarItem* createMessage( const QString &title, const QString &text, QWidget *parent = 0 );
87  static QgsMessageBarItem* createMessage( QWidget *widget, QWidget *parent = 0 );
88 
90  void pushMessage( const QString &text, MessageLevel level = INFO, int duration = 0 ) { return pushMessage( QString::null, text, level, duration ); }
92  void pushMessage( const QString &title, const QString &text, MessageLevel level = INFO, int duration = 0 );
93 
94  signals:
96  void widgetAdded( QgsMessageBarItem *item );
97 
99  void widgetRemoved( QgsMessageBarItem *item );
100 
101  public slots:
106  bool popWidget();
107 
111  bool clearWidgets();
112 
119  void pushSuccess( const QString& title, const QString& message );
120 
127  void pushInfo( const QString& title, const QString& message );
128 
135  void pushWarning( const QString& title, const QString& message );
136 
143  void pushCritical( const QString& title, const QString& message );
144 
145  protected:
146  void mousePressEvent( QMouseEvent * e ) override;
147 
148  private:
149  void popItem( QgsMessageBarItem *item );
150  void showItem( QgsMessageBarItem *item );
151  QgsMessageBarItem *mCurrentItem;
153  QMenu *mCloseMenu;
154  QToolButton *mCloseBtn;
155  QGridLayout *mLayout;
156  QLabel *mItemCount;
157  QAction *mActionCloseAll;
158  QTimer *mCountdownTimer;
159  QProgressBar *mCountProgress;
160  QString mCountStyleSheet;
161 
162  private slots:
164  void updateItemCount();
165 
167  void updateCountdown();
168  void resetCountdown();
169 };
170 
171 #endif
void pushMessage(const QString &text, MessageLevel level=INFO, int duration=0)
convenience method for pushing a message to the bar
Definition: qgsmessagebar.h:90
A bar for displaying non-blocking messages to the user.
Definition: qgsmessagebar.h:42
virtual void mousePressEvent(QMouseEvent *event)