QGIS API Documentation  3.0.2-Girona (307d082)
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 #include "qgsmessagebar.h"
23 
24 #include <QWidget>
25 #include <QIcon>
26 #include <QHBoxLayout>
27 #include "qgis_gui.h"
28 
29 class QTextBrowser;
30 
35 class GUI_EXPORT QgsMessageBarItem : public QWidget
36 {
37  Q_OBJECT
38  public:
40  QgsMessageBarItem( const QString &text, Qgis::MessageLevel level = Qgis::Info, int duration = 0, QWidget *parent SIP_TRANSFERTHIS = nullptr );
41 
43  QgsMessageBarItem( const QString &title, const QString &text, Qgis::MessageLevel level = Qgis::Info, int duration = 0, QWidget *parent SIP_TRANSFERTHIS = nullptr );
44 
46  QgsMessageBarItem( const QString &title, const QString &text, QWidget *widget, Qgis::MessageLevel level = Qgis::Info, int duration = 0, QWidget *parent SIP_TRANSFERTHIS = nullptr );
47 
49  QgsMessageBarItem( QWidget *widget, Qgis::MessageLevel level = Qgis::Info, int duration = 0, QWidget *parent SIP_TRANSFERTHIS = nullptr );
50 
51  QgsMessageBarItem *setText( const QString &text );
52 
56  QString text() const;
57 
58  QgsMessageBarItem *setTitle( const QString &title );
59 
63  QString title() const;
64 
65  QgsMessageBarItem *setLevel( Qgis::MessageLevel level );
66 
70  Qgis::MessageLevel level() const;
71 
72  QgsMessageBarItem *setWidget( QWidget *widget );
73 
77  QWidget *widget() const;
78 
79  QgsMessageBarItem *setIcon( const QIcon &icon );
80 
84  QIcon icon() const;
85 
86  QgsMessageBarItem *setDuration( int duration );
87 
89  int duration() const { return mDuration; }
90 
92  QString getStyleSheet() { return mStyleSheet; }
93 
94  signals:
96  void styleChanged( const QString &styleSheet );
97 
98  private slots:
99 
100  void urlClicked( const QUrl &url );
101 
102  private:
103  void writeContent();
104 
105  QString mTitle;
106  QString mText;
107  Qgis::MessageLevel mLevel;
108  int mDuration;
109  QWidget *mWidget = nullptr;
110  QIcon mUserIcon;
111  QHBoxLayout *mLayout = nullptr;
112  QLabel *mLblIcon = nullptr;
113  QString mStyleSheet;
114  QTextBrowser *mTextBrowser = nullptr;
115 };
116 
117 #endif // qgsmessagebaritem_H
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:46
int duration() const
returns the duration in second of the message
MessageLevel
Level for messages This will be used both for message log and message bar in application.
Definition: qgis.h:78
QString getStyleSheet()
returns the styleSheet