QGIS API Documentation  2.99.0-Master (f1c3692)
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 
34 class GUI_EXPORT QgsMessageBarItem : public QWidget
35 {
36  Q_OBJECT
37  public:
39  QgsMessageBarItem( const QString &text, QgsMessageBar::MessageLevel level = QgsMessageBar::INFO, int duration = 0, QWidget *parent SIP_TRANSFERTHIS = 0 );
40 
42  QgsMessageBarItem( const QString &title, const QString &text, QgsMessageBar::MessageLevel level = QgsMessageBar::INFO, int duration = 0, QWidget *parent SIP_TRANSFERTHIS = 0 );
43 
45  QgsMessageBarItem( const QString &title, const QString &text, QWidget *widget, QgsMessageBar::MessageLevel level = QgsMessageBar::INFO, int duration = 0, QWidget *parent SIP_TRANSFERTHIS = 0 );
46 
48  QgsMessageBarItem( QWidget *widget, QgsMessageBar::MessageLevel level = QgsMessageBar::INFO, int duration = 0, QWidget *parent SIP_TRANSFERTHIS = 0 );
49 
50  QgsMessageBarItem *setText( const QString &text );
51 
55  QString text() const;
56 
57  QgsMessageBarItem *setTitle( const QString &title );
58 
62  QString title() const;
63 
65 
69  QgsMessageBar::MessageLevel level() const;
70 
71  QgsMessageBarItem *setWidget( QWidget *widget );
72 
76  QWidget *widget() const;
77 
78  QgsMessageBarItem *setIcon( const QIcon &icon );
79 
83  QIcon icon() const;
84 
85  QgsMessageBarItem *setDuration( int duration );
86 
88  int duration() const { return mDuration; }
89 
91  QString getStyleSheet() { return mStyleSheet; }
92 
93  signals:
95  void styleChanged( const QString &styleSheet );
96 
97 
98  private:
99  void writeContent();
100 
101  QString mTitle;
102  QString mText;
104  int mDuration;
105  QWidget *mWidget = nullptr;
106  QIcon mUserIcon;
107  QHBoxLayout *mLayout = nullptr;
108  QLabel *mLblIcon = nullptr;
109  QString mStyleSheet;
110  QTextEdit *mTextEdit = nullptr;
111 };
112 
113 #endif // qgsmessagebaritem_H
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:46
int duration() const
returns the duration in second of the message
QString getStyleSheet()
returns the styleSheet