QGIS API Documentation 3.99.0-Master (2fe06baccd8)
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#include "qgis_gui.h"
22
23#include <QHBoxLayout>
24#include <QIcon>
25#include <QWidget>
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
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
125
132
139
145 QWidget *widget() const;
146
152 QgsMessageBarItem *setIcon( const QIcon &icon );
153
159 QIcon icon() const;
160
169
178 int duration() const { return mDuration; }
179
184 QString getStyleSheet() const { 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:156
@ Info
Information message.
Definition qgis.h:157
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...
QIcon icon() const
Returns the icon for the message.
QgsMessageBarItem * setLevel(Qgis::MessageLevel level)
Sets the message level for the item, which controls how the message bar is styled when the item is di...
int duration() const
Returns the duration (in seconds) of the message.
QgsMessageBarItem * setText(const QString &text)
Sets the message text to show in the item.
QgsMessageBarItem * setIcon(const QIcon &icon)
Sets the icon associated with the message.
QString text() const
Returns the text for the message.
QWidget * widget() const
Returns the widget for the message.
friend class QgsMessageBar
QgsMessageBarItem(const QString &text, Qgis::MessageLevel level=Qgis::MessageLevel::Info, int duration=0, QWidget *parent=nullptr)
Constructor for QgsMessageBarItem, containing a message with the specified text to be displayed on th...
QString title() const
Returns the title for the message.
QString getStyleSheet() const
Returns the styleSheet which should be used to style a QgsMessageBar object when this item is display...
QgsMessageBarItem * setTitle(const QString &title)
Sets the title for in the item.
Qgis::MessageLevel level() const
Returns the message level for the message.
QgsMessageBarItem * setDuration(int duration)
Sets the duration (in seconds) to show the message for.
QgsMessageBarItem * setWidget(QWidget *widget)
Sets a custom widget to show in the item.
A bar for displaying non-blocking messages to the user.
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53