QGIS API Documentation  2.99.0-Master (7d4f81d)
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 
54  QString text() const;
55 
56  QgsMessageBarItem *setTitle( const QString &title );
57 
61  QString title() const;
62 
64 
68  QgsMessageBar::MessageLevel level() const;
69 
70  QgsMessageBarItem *setWidget( QWidget *widget );
71 
75  QWidget *widget() const;
76 
77  QgsMessageBarItem *setIcon( const QIcon &icon );
78 
82  QIcon icon() const;
83 
84  QgsMessageBarItem *setDuration( int duration );
85 
87  int duration() const { return mDuration; }
88 
90  QString getStyleSheet() { return mStyleSheet; }
91 
92  signals:
94  void styleChanged( const QString &styleSheet );
95 
96 
97  private:
98  void writeContent();
99 
100  QString mTitle;
101  QString mText;
103  int mDuration;
104  QWidget *mWidget = nullptr;
105  QIcon mUserIcon;
106  QHBoxLayout *mLayout = nullptr;
107  QLabel *mLblIcon = nullptr;
108  QString mStyleSheet;
109  QTextEdit *mTextEdit = nullptr;
110 };
111 
112 #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