QGIS API Documentation 3.41.0-Master (cea29feecf2)
Loading...
Searching...
No Matches
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
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
27class QTextBrowser;
28class QLabel;
29class QgsMessageBar;
30
38class GUI_EXPORT QgsMessageBarItem : public QWidget
39{
40 Q_OBJECT
41 public:
52 QgsMessageBarItem( const QString &text, Qgis::MessageLevel level = Qgis::MessageLevel::Info, int duration = 0, QWidget *parent SIP_TRANSFERTHIS = nullptr );
53
64 QgsMessageBarItem( const QString &title, const QString &text, Qgis::MessageLevel level = Qgis::MessageLevel::Info, int duration = 0, QWidget *parent SIP_TRANSFERTHIS = nullptr );
65
76 QgsMessageBarItem( const QString &title, const QString &text, QWidget *widget, Qgis::MessageLevel level = Qgis::MessageLevel::Info, int duration = 0, QWidget *parent SIP_TRANSFERTHIS = nullptr );
77
88 QgsMessageBarItem( QWidget *widget, Qgis::MessageLevel level = Qgis::MessageLevel::Info, int duration = 0, QWidget *parent SIP_TRANSFERTHIS = nullptr );
89
95 QgsMessageBarItem *setText( const QString &text );
96
102 QString text() const;
103
109 QgsMessageBarItem *setTitle( const QString &title );
110
116 QString title() const;
117
124 QgsMessageBarItem *setLevel( Qgis::MessageLevel level );
125
131 Qgis::MessageLevel level() const;
132
138 QgsMessageBarItem *setWidget( QWidget *widget );
139
145 QWidget *widget() const;
146
152 QgsMessageBarItem *setIcon( const QIcon &icon );
153
159 QIcon icon() const;
160
168 QgsMessageBarItem *setDuration( int duration );
169
178 int duration() const { return mDuration; }
179
184 QString getStyleSheet() { return mStyleSheet; }
185
186 public slots:
187
195 void dismiss();
196
197 signals:
198
203 void styleChanged( const QString &styleSheet );
204
205 private slots:
206
207 void urlClicked( const QUrl &url );
208
209 private:
210 void writeContent();
211
212 QString mTitle;
213 QString mText;
214 Qgis::MessageLevel mLevel;
215 int mDuration;
216 QWidget *mWidget = nullptr;
217 QIcon mUserIcon;
218 QHBoxLayout *mLayout = nullptr;
219 QLabel *mLblIcon = nullptr;
220 QString mStyleSheet;
221 QTextBrowser *mTextBrowser = nullptr;
222 QgsMessageBar *mMessageBar = nullptr;
223
224 friend class QgsMessageBar;
225};
226
227#endif // QGSMESSAGEBARITEM_H
MessageLevel
Level for messages This will be used both for message log and message bar in application.
Definition qgis.h:154
@ Info
Information message.
Definition qgis.h:155
Represents an item shown within a QgsMessageBar widget.
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...
int duration() const
Returns the duration (in seconds) of the message.
QString getStyleSheet()
Returns the styleSheet which should be used to style a QgsMessageBar object when this item is display...
A bar for displaying non-blocking messages to the user.
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53