QGIS API Documentation  2.6.0-Brighton
 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  };
53 
54  QgsMessageBar( QWidget *parent = 0 );
55  ~QgsMessageBar();
56 
61  void pushItem( QgsMessageBarItem *item );
62 
69  QgsMessageBarItem *pushWidget( QWidget *widget, MessageLevel level = INFO, int duration = 0 );
70 
76  bool popWidget( QgsMessageBarItem *item );
77 
79  static QgsMessageBarItem* createMessage( const QString &text, QWidget *parent = 0 );
81  static QgsMessageBarItem* createMessage( const QString &title, const QString &text, QWidget *parent = 0 );
83  static QgsMessageBarItem* createMessage( QWidget *widget, QWidget *parent = 0 );
84 
86  void pushMessage( const QString &text, MessageLevel level = INFO, int duration = 0 ) { return pushMessage( QString::null, text, level, duration ); }
88  void pushMessage( const QString &title, const QString &text, MessageLevel level = INFO, int duration = 0 );
89 
90  signals:
92  void widgetAdded( QgsMessageBarItem *item );
93 
95  void widgetRemoved( QgsMessageBarItem *item );
96 
97  public slots:
102  bool popWidget();
103 
107  bool clearWidgets();
108 
109  protected:
110  void mousePressEvent( QMouseEvent * e );
111 
112  private:
113  void popItem( QgsMessageBarItem *item );
114  void showItem( QgsMessageBarItem *item );
115  QgsMessageBarItem *mCurrentItem;
116  QList<QgsMessageBarItem *> mItems;
117  QMenu *mCloseMenu;
118  QToolButton *mCloseBtn;
119  QGridLayout *mLayout;
120  QLabel *mItemCount;
121  QAction *mActionCloseAll;
122  QTimer *mCountdownTimer;
123  QProgressBar *mCountProgress;
124  QString mCountStyleSheet;
125 
126  private slots:
128  void updateItemCount();
129 
131  void updateCountdown();
132  void resetCountdown();
133 };
134 
135 #endif