QGIS API Documentation  2.99.0-Master (7d4f81d)
qgsmessageoutput.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsmessageoutput.h - interface for showing messages
3  ----------------------
4  begin : April 2006
5  copyright : (C) 2006 by Martin Dobias
6  email : wonder.sk at gmail dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 
17 #ifndef QGSMESSAGEOUTPUT_H
18 #define QGSMESSAGEOUTPUT_H
19 
20 #include <QString>
21 #include "qgis_sip.h"
22 #include <QObject>
23 
24 #include "qgis_core.h"
25 
26 class QgsMessageOutput;
27 typedef QgsMessageOutput *( *MESSAGE_OUTPUT_CREATOR )() SIP_SKIP;
28 
29 
41 class CORE_EXPORT QgsMessageOutput
42 {
43  public:
44 
46  enum MessageType { MessageText, MessageHtml };
47 
48  virtual ~QgsMessageOutput() = default;
49 
51  virtual void setMessage( const QString &message, MessageType msgType ) = 0;
52 
54  virtual void appendMessage( const QString &message ) = 0;
55 
57  virtual void setTitle( const QString &title ) = 0;
58 
60  virtual void showMessage( bool blocking = true ) = 0;
61 
65  static void showMessage( const QString &title, const QString &message, MessageType msgType );
66 
69  // TODO: implementation where Python class could be passed
70  static void setMessageOutputCreator( MESSAGE_OUTPUT_CREATOR f ) SIP_SKIP;
71 
74  static QgsMessageOutput *createMessageOutput();
75 
76  private:
77 
79  static MESSAGE_OUTPUT_CREATOR mMessageOutputCreator;
80 };
81 
82 
89 class CORE_EXPORT QgsMessageOutputConsole : public QObject, public QgsMessageOutput
90 {
91  Q_OBJECT
92 
93  public:
94 
96 
97  virtual void setMessage( const QString &message, MessageType msgType ) override;
98 
99  virtual void appendMessage( const QString &message ) override;
100 
101  virtual void setTitle( const QString &title ) override;
102 
104  virtual void showMessage( bool blocking = true ) override;
105 
106  signals:
107 
109  void destroyed();
110 
111  private:
112 
114  QString mMessage;
115 
117  QString mTitle;
118 
119  MessageType mMsgType;
120 };
121 
122 #endif
MessageType
message can be in plain text or in html format
virtual void setTitle(const QString &title)=0
set title for the messages
virtual void appendMessage(const QString &message)=0
message to be appended to the current text
QgsMessageOutput *(* MESSAGE_OUTPUT_CREATOR)()
#define SIP_SKIP
Definition: qgis_sip.h:119
Default implementation of message output interface.
virtual void setMessage(const QString &message, MessageType msgType)=0
set message, it won&#39;t be displayed until
virtual void showMessage(bool blocking=true)=0
display the message to the user and deletes itself
Interface for showing messages from QGIS in GUI independent way.