QGIS API Documentation  3.24.2-Tisler (13c1a02865)
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 
43 class CORE_EXPORT QgsMessageOutput
44 {
45  public:
46 
48  enum MessageType { MessageText, MessageHtml };
49 
50  virtual ~QgsMessageOutput() = default;
51 
53  virtual void setMessage( const QString &message, MessageType msgType ) = 0;
54 
56  virtual void appendMessage( const QString &message ) = 0;
57 
59  virtual void setTitle( const QString &title ) = 0;
60 
62  virtual void showMessage( bool blocking = true ) = 0;
63 
68  static void showMessage( const QString &title, const QString &message, MessageType msgType );
69 
70  // TODO: implementation where Python class could be passed
71 
76  static void setMessageOutputCreator( MESSAGE_OUTPUT_CREATOR f ) SIP_SKIP;
77 
82  static QgsMessageOutput *createMessageOutput();
83 
84  private:
85 
87  static MESSAGE_OUTPUT_CREATOR mMessageOutputCreator;
88 };
89 
90 
98 class CORE_EXPORT QgsMessageOutputConsole : public QObject, public QgsMessageOutput
99 {
100  Q_OBJECT
101 
102  public:
103 
108 
109  void setMessage( const QString &message, MessageType msgType ) override;
110 
111  void appendMessage( const QString &message ) override;
112 
113  void setTitle( const QString &title ) override;
114 
116  void showMessage( bool blocking = true ) override;
117 
118  signals:
119 
121  void destroyed();
122 
123  private:
124 
126  QString mMessage;
127 
129  QString mTitle;
130 
131  MessageType mMsgType = MessageText;
132 };
133 
134 #endif
Default implementation of message output interface.
void destroyed()
signals that object will be destroyed and shouldn't be used anymore
QgsMessageOutputConsole()=default
Constructor for QgsMessageOutputConsole.
Interface for showing messages from QGIS in GUI independent way.
MessageType
message can be in plain text or in html format
virtual void showMessage(bool blocking=true)=0
display the message to the user and deletes itself
virtual void appendMessage(const QString &message)=0
message to be appended to the current text
virtual ~QgsMessageOutput()=default
virtual void setMessage(const QString &message, MessageType msgType)=0
Sets message, it won't be displayed until.
virtual void setTitle(const QString &title)=0
Sets title for the messages.
#define SIP_SKIP
Definition: qgis_sip.h:126
QgsMessageOutput *(* MESSAGE_OUTPUT_CREATOR)()