QGIS API Documentation 3.40.0-Bratislava (b56115d8743)
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:
42
53 QgsMessageBarItem( const QString &text, Qgis::MessageLevel level = Qgis::MessageLevel::Info, int duration = 0, QWidget *parent SIP_TRANSFERTHIS = nullptr );
54
65 QgsMessageBarItem( const QString &title, const QString &text, Qgis::MessageLevel level = Qgis::MessageLevel::Info, int duration = 0, QWidget *parent SIP_TRANSFERTHIS = nullptr );
66
77 QgsMessageBarItem( const QString &title, const QString &text, QWidget *widget, Qgis::MessageLevel level = Qgis::MessageLevel::Info, int duration = 0, QWidget *parent SIP_TRANSFERTHIS = nullptr );
78
89 QgsMessageBarItem( QWidget *widget, Qgis::MessageLevel level = Qgis::MessageLevel::Info, int duration = 0, QWidget *parent SIP_TRANSFERTHIS = nullptr );
90
96 QgsMessageBarItem *setText( const QString &text );
97
103 QString text() const;
104
110 QgsMessageBarItem *setTitle( const QString &title );
111
117 QString title() const;
118
125 QgsMessageBarItem *setLevel( Qgis::MessageLevel level );
126
132 Qgis::MessageLevel level() const;
133
139 QgsMessageBarItem *setWidget( QWidget *widget );
140
146 QWidget *widget() const;
147
153 QgsMessageBarItem *setIcon( const QIcon &icon );
154
160 QIcon icon() const;
161
169 QgsMessageBarItem *setDuration( int duration );
170
179 int duration() const { return mDuration; }
180
185 QString getStyleSheet() { return mStyleSheet; }
186
187 public slots:
188
196 void dismiss();
197
198 signals:
199
204 void styleChanged( const QString &styleSheet );
205
206 private slots:
207
208 void urlClicked( const QUrl &url );
209
210 private:
211 void writeContent();
212
213 QString mTitle;
214 QString mText;
215 Qgis::MessageLevel mLevel;
216 int mDuration;
217 QWidget *mWidget = nullptr;
218 QIcon mUserIcon;
219 QHBoxLayout *mLayout = nullptr;
220 QLabel *mLblIcon = nullptr;
221 QString mStyleSheet;
222 QTextBrowser *mTextBrowser = nullptr;
223 QgsMessageBar *mMessageBar = nullptr;
224
225 friend class QgsMessageBar;
226};
227
228#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