QGIS API Documentation  2.2.0-Valmiera
 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 
43 class GUI_EXPORT QgsMessageBar: public QFrame
44 {
45  Q_OBJECT
46 
47  public:
49  {
50  INFO = 0,
51  WARNING = 1,
52  CRITICAL = 2
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 
110  protected:
111  void mousePressEvent( QMouseEvent * e );
112 
113  private:
114  void popItem( QgsMessageBarItem *item );
115  void showItem( QgsMessageBarItem *item );
117  QList<QgsMessageBarItem *> mItems;
118  QMenu *mCloseMenu;
119  QToolButton *mCloseBtn;
120  QGridLayout *mLayout;
121  QLabel *mItemCount;
122  QAction *mActionCloseAll;
124  QProgressBar *mCountProgress;
126 
127  private slots:
129  void updateItemCount();
130 
132  void updateCountdown();
133  void resetCountdown();
134 };
135 
136 #endif