QGIS API Documentation  2.99.0-Master (08c2e66)
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 : denis.rouzaud@gmail.com
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 <qgsmessagebar.h>
22 
23 #include <QWidget>
24 #include <QIcon>
25 #include <QTextEdit>
26 #include <QHBoxLayout>
27 #include "qgis_gui.h"
28 
32 class GUI_EXPORT QgsMessageBarItem : public QWidget
33 {
34  Q_OBJECT
35  public:
37  QgsMessageBarItem( const QString &text, QgsMessageBar::MessageLevel level = QgsMessageBar::INFO, int duration = 0, QWidget *parent = nullptr );
38 
40  QgsMessageBarItem( const QString &title, const QString &text, QgsMessageBar::MessageLevel level = QgsMessageBar::INFO, int duration = 0, QWidget *parent = nullptr );
41 
43  QgsMessageBarItem( const QString &title, const QString &text, QWidget *widget, QgsMessageBar::MessageLevel level = QgsMessageBar::INFO, int duration = 0, QWidget *parent = nullptr );
44 
46  QgsMessageBarItem( QWidget *widget, QgsMessageBar::MessageLevel level = QgsMessageBar::INFO, int duration = 0, QWidget *parent = nullptr );
47 
48  QgsMessageBarItem *setText( const QString& text );
49 
50  QgsMessageBarItem *setTitle( const QString& title );
51 
53 
54  QgsMessageBarItem *setWidget( QWidget *widget );
55 
56  QgsMessageBarItem *setIcon( const QIcon &icon );
57 
58  QgsMessageBarItem *setDuration( int duration );
59 
61  int duration() const { return mDuration; }
62 
64  QgsMessageBar::MessageLevel level() { return mLevel; }
65 
67  QString getStyleSheet() { return mStyleSheet; }
68 
69  signals:
71  void styleChanged( const QString& styleSheet );
72 
73 
74  private:
75  void writeContent();
76 
77  QString mTitle;
78  QString mText;
80  int mDuration;
81  QWidget *mWidget = nullptr;
82  QIcon mUserIcon;
83  QHBoxLayout *mLayout = nullptr;
84  QLabel *mLblIcon = nullptr;
85  QString mStyleSheet;
86  QTextEdit *mTextEdit = nullptr;
87 };
88 
89 #endif // qgsmessagebaritem_H
QgsMessageBar::MessageLevel level()
returns the level
int duration() const
returns the duration in second of the message
QString getStyleSheet()
returns the styleSheet