QGIS API Documentation  2.99.0-Master (d55fa22)
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 "qgis.h"
22 #include <qgsmessagebar.h>
23 
24 #include <QWidget>
25 #include <QIcon>
26 #include <QTextEdit>
27 #include <QHBoxLayout>
28 #include "qgis_gui.h"
29 
33 class GUI_EXPORT QgsMessageBarItem : public QWidget
34 {
35  Q_OBJECT
36  public:
38  QgsMessageBarItem( const QString &text, QgsMessageBar::MessageLevel level = QgsMessageBar::INFO, int duration = 0, QWidget *parent SIP_TRANSFERTHIS = 0 );
39 
41  QgsMessageBarItem( const QString &title, const QString &text, QgsMessageBar::MessageLevel level = QgsMessageBar::INFO, int duration = 0, QWidget *parent SIP_TRANSFERTHIS = 0 );
42 
44  QgsMessageBarItem( const QString &title, const QString &text, QWidget *widget, QgsMessageBar::MessageLevel level = QgsMessageBar::INFO, int duration = 0, QWidget *parent SIP_TRANSFERTHIS = 0 );
45 
47  QgsMessageBarItem( QWidget *widget, QgsMessageBar::MessageLevel level = QgsMessageBar::INFO, int duration = 0, QWidget *parent SIP_TRANSFERTHIS = 0 );
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 = nullptr;
83  QIcon mUserIcon;
84  QHBoxLayout *mLayout = nullptr;
85  QLabel *mLblIcon = nullptr;
86  QString mStyleSheet;
87  QTextEdit *mTextEdit = nullptr;
88 };
89 
90 #endif // qgsmessagebaritem_H
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:34
int duration() const
returns the duration in second of the message
QgsMessageBar::MessageLevel level()
returns the level
QString getStyleSheet()
returns the styleSheet