QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
qgsmessagebaritem.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsmessagebaritem.h - description
3  -------------------
4  begin : August 2013
5  copyright : (C) 2013 by Denis Rouzaud
6  email : [email protected]
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 qgsmessagebaritem_H
18 #define qgsmessagebaritem_H
19 
20 #include <qgsmessagebaritem.h>
21 #include <qgsmessagebar.h>
22 
23 #include <QWidget>
24 #include <QIcon>
25 #include <QTextEdit>
26 #include <QHBoxLayout>
27 
31 class GUI_EXPORT QgsMessageBarItem : public QWidget
32 {
33  Q_OBJECT
34  public:
36  QgsMessageBarItem( const QString &text, QgsMessageBar::MessageLevel level = QgsMessageBar::INFO, int duration = 0, QWidget *parent = nullptr );
37 
39  QgsMessageBarItem( const QString &title, const QString &text, QgsMessageBar::MessageLevel level = QgsMessageBar::INFO, int duration = 0, QWidget *parent = nullptr );
40 
42  QgsMessageBarItem( const QString &title, const QString &text, QWidget *widget, QgsMessageBar::MessageLevel level = QgsMessageBar::INFO, int duration = 0, QWidget *parent = nullptr );
43 
45  QgsMessageBarItem( QWidget *widget, QgsMessageBar::MessageLevel level = QgsMessageBar::INFO, int duration = 0, QWidget *parent = nullptr );
46 
48 
49  QgsMessageBarItem *setText( const QString& text );
50 
51  QgsMessageBarItem *setTitle( const QString& title );
52 
54 
55  QgsMessageBarItem *setWidget( QWidget *widget );
56 
57  QgsMessageBarItem *setIcon( const QIcon &icon );
58 
59  QgsMessageBarItem *setDuration( int duration );
60 
62  int duration() const { return mDuration; }
63 
65  QgsMessageBar::MessageLevel level() { return mLevel; }
66 
68  QString getStyleSheet() { return mStyleSheet; }
69 
70  signals:
72  void styleChanged( const QString& styleSheet );
73 
74 
75  private:
76  void writeContent();
77 
78  QString mTitle;
79  QString mText;
81  int mDuration;
82  QWidget *mWidget;
83  QIcon mUserIcon;
84  QHBoxLayout *mLayout;
85  QLabel *mLblIcon;
86  QString mStyleSheet;
87  QTextEdit *mTextEdit;
88 };
89 
90 #endif // qgsmessagebaritem_H
void setIcon(const QPixmap &i)
int duration() const
returns the duration in second of the message
QgsMessageBar::MessageLevel level()
returns the level
QString getStyleSheet()
returns the styleSheet