QGIS API Documentation  3.4.15-Madeira (e83d02e274)
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 
23 #include <QWidget>
24 #include <QIcon>
25 #include <QHBoxLayout>
26 #include "qgis_gui.h"
27 
28 class QTextBrowser;
29 class QLabel;
30 class QgsMessageBar;
31 
36 class GUI_EXPORT QgsMessageBarItem : public QWidget
37 {
38  Q_OBJECT
39  public:
41  QgsMessageBarItem( const QString &text, Qgis::MessageLevel level = Qgis::Info, int duration = 0, QWidget *parent SIP_TRANSFERTHIS = nullptr );
42 
44  QgsMessageBarItem( const QString &title, const QString &text, Qgis::MessageLevel level = Qgis::Info, int duration = 0, QWidget *parent SIP_TRANSFERTHIS = nullptr );
45 
47  QgsMessageBarItem( const QString &title, const QString &text, QWidget *widget, Qgis::MessageLevel level = Qgis::Info, int duration = 0, QWidget *parent SIP_TRANSFERTHIS = nullptr );
48 
50  QgsMessageBarItem( QWidget *widget, Qgis::MessageLevel level = Qgis::Info, int duration = 0, QWidget *parent SIP_TRANSFERTHIS = nullptr );
51 
52  QgsMessageBarItem *setText( const QString &text );
53 
57  QString text() const;
58 
59  QgsMessageBarItem *setTitle( const QString &title );
60 
64  QString title() const;
65 
66  QgsMessageBarItem *setLevel( Qgis::MessageLevel level );
67 
71  Qgis::MessageLevel level() const;
72 
73  QgsMessageBarItem *setWidget( QWidget *widget );
74 
78  QWidget *widget() const;
79 
80  QgsMessageBarItem *setIcon( const QIcon &icon );
81 
85  QIcon icon() const;
86 
87  QgsMessageBarItem *setDuration( int duration );
88 
90  int duration() const { return mDuration; }
91 
93  QString getStyleSheet() { return mStyleSheet; }
94 
95  public slots:
96 
104  void dismiss();
105 
106  signals:
108  void styleChanged( const QString &styleSheet );
109 
110  private slots:
111 
112  void urlClicked( const QUrl &url );
113 
114  private:
115  void writeContent();
116 
117  QString mTitle;
118  QString mText;
119  Qgis::MessageLevel mLevel;
120  int mDuration;
121  QWidget *mWidget = nullptr;
122  QIcon mUserIcon;
123  QHBoxLayout *mLayout = nullptr;
124  QLabel *mLblIcon = nullptr;
125  QString mStyleSheet;
126  QTextBrowser *mTextBrowser = nullptr;
127  QgsMessageBar *mMessageBar = nullptr;
128 
129  friend class QgsMessageBar;
130 };
131 
132 #endif // qgsmessagebaritem_H
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:46
A bar for displaying non-blocking messages to the user.
Definition: qgsmessagebar.h:45
MessageLevel
Level for messages This will be used both for message log and message bar in application.
Definition: qgis.h:79
int duration() const
returns the duration in second of the message
QString getStyleSheet()
returns the styleSheet