2012-09-04 18:31:51 +10:00
|
|
|
class QgsMessageBar: QFrame
|
|
|
|
{
|
|
|
|
%TypeHeaderCode
|
|
|
|
#include <qgsmessagebar.h>
|
|
|
|
%End
|
|
|
|
|
|
|
|
public:
|
2013-01-11 18:03:32 -07:00
|
|
|
enum MessageLevel
|
|
|
|
{
|
2014-06-02 21:00:51 +02:00
|
|
|
INFO,
|
|
|
|
WARNING,
|
|
|
|
CRITICAL,
|
2014-12-14 15:55:50 +01:00
|
|
|
SUCCESS
|
2013-01-11 18:03:32 -07:00
|
|
|
};
|
|
|
|
|
2015-02-18 17:00:36 +11:00
|
|
|
QgsMessageBar( QWidget *parent /TransferThis/ = 0 );
|
2012-09-04 18:31:51 +10:00
|
|
|
~QgsMessageBar();
|
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Display a message item on the bar after hiding the currently visible one
|
2013-08-09 15:41:10 +02:00
|
|
|
* and putting it in a stack.
|
|
|
|
* @param item item to display
|
|
|
|
*/
|
|
|
|
void pushItem( QgsMessageBarItem *item /Transfer/);
|
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Display a widget as a message on the bar after hiding the currently visible one
|
2013-08-09 15:41:10 +02:00
|
|
|
* and putting it in a stack.
|
|
|
|
* @param widget message widget to display
|
2014-12-14 15:55:50 +01:00
|
|
|
* @param level is QgsMessageBar::INFO, WARNING, CRITICAL or SUCCESS
|
2013-01-10 16:51:03 -07:00
|
|
|
* @param duration timeout duration of message in seconds, 0 value indicates no timeout
|
2012-09-04 18:31:51 +10:00
|
|
|
*/
|
2013-08-09 15:41:10 +02:00
|
|
|
QgsMessageBarItem *pushWidget( QWidget *widget /Transfer/, MessageLevel level = INFO, int duration = 0 );
|
2012-09-04 18:31:51 +10:00
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Remove the passed widget from the bar (if previously added),
|
2012-09-04 18:31:51 +10:00
|
|
|
* then display the next one in the stack if any or hide the bar
|
2014-01-27 09:22:24 +01:00
|
|
|
* @param item item to remove
|
2012-09-04 18:31:51 +10:00
|
|
|
* @return true if the widget was removed, false otherwise
|
|
|
|
*/
|
2013-08-09 15:41:10 +02:00
|
|
|
bool popWidget( QgsMessageBarItem *item );
|
2012-09-04 18:31:51 +10:00
|
|
|
|
2014-01-27 09:22:24 +01:00
|
|
|
//! make out a widget containing a message to be displayed on the bar
|
2013-08-09 15:41:10 +02:00
|
|
|
static QgsMessageBarItem* createMessage( const QString &text, QWidget *parent = 0 ) /Factory/;
|
2012-09-04 18:31:51 +10:00
|
|
|
//! make out a widget containing title and message to be displayed on the bar
|
2013-08-09 15:41:10 +02:00
|
|
|
static QgsMessageBarItem* createMessage( const QString &title, const QString &text, QWidget *parent = 0 ) /Factory/;
|
2014-01-27 09:22:24 +01:00
|
|
|
//! make out a widget containing title and message to be displayed on the bar
|
2013-08-09 15:41:10 +02:00
|
|
|
static QgsMessageBarItem* createMessage( QWidget *widget, QWidget *parent = 0 ) /Factory/;
|
2013-09-17 12:33:57 +02:00
|
|
|
|
2014-01-27 09:22:24 +01:00
|
|
|
//! convenience method for pushing a message to the bar
|
2013-08-16 00:00:04 +10:00
|
|
|
void pushMessage( const QString &text, MessageLevel level = INFO, int duration = 0 );
|
2014-01-27 09:22:24 +01:00
|
|
|
//! convenience method for pushing a message with title to the bar
|
2013-08-16 00:00:04 +10:00
|
|
|
void pushMessage( const QString &title, const QString &text, MessageLevel level = INFO, int duration = 0 );
|
2013-01-12 08:43:38 -07:00
|
|
|
|
2012-09-04 18:31:51 +10:00
|
|
|
signals:
|
2012-11-07 12:45:00 -07:00
|
|
|
//! emitted when a message widget is added to the bar
|
2013-08-09 15:41:10 +02:00
|
|
|
void widgetAdded( QgsMessageBarItem *item );
|
2012-11-07 12:45:00 -07:00
|
|
|
|
2014-01-27 09:22:24 +01:00
|
|
|
//! emitted when a message widget was removed from the bar
|
2013-08-09 15:41:10 +02:00
|
|
|
void widgetRemoved( QgsMessageBarItem *item );
|
2012-09-04 18:31:51 +10:00
|
|
|
|
|
|
|
public slots:
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Remove the currently displayed widget from the bar and
|
2012-09-04 18:31:51 +10:00
|
|
|
* display the next in the stack if any or hide the bar
|
|
|
|
* @return true if the widget was removed, false otherwise
|
|
|
|
*/
|
|
|
|
bool popWidget();
|
2012-11-07 12:45:00 -07:00
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Remove all items from the bar's widget list
|
2012-11-07 12:45:00 -07:00
|
|
|
* @return true if all items were removed, false otherwise
|
|
|
|
*/
|
|
|
|
bool clearWidgets();
|
2013-01-14 17:04:21 -07:00
|
|
|
|
2015-01-15 13:50:27 +01:00
|
|
|
/**
|
|
|
|
* Pushes a warning with default timeout to the message bar
|
2015-02-02 16:02:16 +11:00
|
|
|
* @param title title string for message
|
2015-01-15 13:50:27 +01:00
|
|
|
* @param message The message to be displayed
|
|
|
|
* @note added in 2.8
|
|
|
|
*/
|
|
|
|
void pushSuccess( const QString& title, const QString& message );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Pushes a warning with default timeout to the message bar
|
2015-02-02 16:02:16 +11:00
|
|
|
* @param title title string for message
|
2015-01-15 13:50:27 +01:00
|
|
|
* @param message The message to be displayed
|
|
|
|
* @note added in 2.8
|
|
|
|
*/
|
|
|
|
void pushInfo( const QString& title, const QString& message );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Pushes a warning with default timeout to the message bar
|
2015-02-02 16:02:16 +11:00
|
|
|
* @param title title string for message
|
2015-01-15 13:50:27 +01:00
|
|
|
* @param message The message to be displayed
|
|
|
|
* @note added in 2.8
|
|
|
|
*/
|
|
|
|
void pushWarning( const QString& title, const QString& message );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Pushes a warning with default timeout to the message bar
|
2015-02-02 16:02:16 +11:00
|
|
|
* @param title title string for message
|
2015-01-15 13:50:27 +01:00
|
|
|
* @param message The message to be displayed
|
|
|
|
* @note added in 2.8
|
|
|
|
*/
|
|
|
|
void pushCritical( const QString& title, const QString& message );
|
|
|
|
|
2013-01-14 17:04:21 -07:00
|
|
|
protected:
|
|
|
|
void mousePressEvent( QMouseEvent * e );
|
2012-09-04 18:31:51 +10:00
|
|
|
};
|