QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
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 "qgis.h"
21 
22 #include <QWidget>
23 #include <QIcon>
24 #include <QHBoxLayout>
25 #include "qgis_gui.h"
26 
27 class QTextBrowser;
28 class QLabel;
29 class QgsMessageBar;
30 
38 class GUI_EXPORT QgsMessageBarItem : public QWidget
39 {
40  Q_OBJECT
41  public:
42 
52  QgsMessageBarItem( const QString &text, Qgis::MessageLevel level = Qgis::Info, int duration = 0, QWidget *parent SIP_TRANSFERTHIS = nullptr );
53 
63  QgsMessageBarItem( const QString &title, const QString &text, Qgis::MessageLevel level = Qgis::Info, int duration = 0, QWidget *parent SIP_TRANSFERTHIS = nullptr );
64 
74  QgsMessageBarItem( const QString &title, const QString &text, QWidget *widget, Qgis::MessageLevel level = Qgis::Info, int duration = 0, QWidget *parent SIP_TRANSFERTHIS = nullptr );
75 
85  QgsMessageBarItem( QWidget *widget, Qgis::MessageLevel level = Qgis::Info, int duration = 0, QWidget *parent SIP_TRANSFERTHIS = nullptr );
86 
92  QgsMessageBarItem *setText( const QString &text );
93 
99  QString text() const;
100 
106  QgsMessageBarItem *setTitle( const QString &title );
107 
113  QString title() const;
114 
121  QgsMessageBarItem *setLevel( Qgis::MessageLevel level );
122 
128  Qgis::MessageLevel level() const;
129 
135  QgsMessageBarItem *setWidget( QWidget *widget );
136 
142  QWidget *widget() const;
143 
149  QgsMessageBarItem *setIcon( const QIcon &icon );
150 
156  QIcon icon() const;
157 
165  QgsMessageBarItem *setDuration( int duration );
166 
175  int duration() const { return mDuration; }
176 
181  QString getStyleSheet() { return mStyleSheet; }
182 
183  public slots:
184 
192  void dismiss();
193 
194  signals:
195 
200  void styleChanged( const QString &styleSheet );
201 
202  private slots:
203 
204  void urlClicked( const QUrl &url );
205 
206  private:
207  void writeContent();
208 
209  QString mTitle;
210  QString mText;
211  Qgis::MessageLevel mLevel;
212  int mDuration;
213  QWidget *mWidget = nullptr;
214  QIcon mUserIcon;
215  QHBoxLayout *mLayout = nullptr;
216  QLabel *mLblIcon = nullptr;
217  QString mStyleSheet;
218  QTextBrowser *mTextBrowser = nullptr;
219  QgsMessageBar *mMessageBar = nullptr;
220 
221  friend class QgsMessageBar;
222 };
223 
224 #endif // QGSMESSAGEBARITEM_H
qgis.h
QgsMessageBarItem::duration
int duration() const
Returns the duration (in seconds) of the message.
Definition: qgsmessagebaritem.h:175
Qgis::Info
@ Info
Definition: qgis.h:90
QgsMessageBarItem
Represents an item shown within a QgsMessageBar widget.
Definition: qgsmessagebaritem.h:39
QgsMessageBarItem::getStyleSheet
QString getStyleSheet()
Returns the styleSheet which should be used to style a QgsMessageBar object when this item is display...
Definition: qgsmessagebaritem.h:181
QgsMessageBar
A bar for displaying non-blocking messages to the user.
Definition: qgsmessagebar.h:61
Qgis::MessageLevel
MessageLevel
Level for messages This will be used both for message log and message bar in application.
Definition: qgis.h:89
QgsMessageBarItem::styleChanged
void styleChanged(const QString &styleSheet)
Emitted when the item's message level has changed and the message bar style will need to be updated a...
SIP_TRANSFERTHIS
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53