QGIS API Documentation  2.99.0-Master (cb63e82)
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 <QObject>
22 
23 #include "qgis_core.h"
24 
25 class QgsMessageOutput;
26 typedef QgsMessageOutput *( *MESSAGE_OUTPUT_CREATOR )();
27 
28 
40 class CORE_EXPORT QgsMessageOutput
41 {
42  public:
43 
45  enum MessageType { MessageText, MessageHtml };
46 
47  virtual ~QgsMessageOutput() = default;
48 
50  virtual void setMessage( const QString &message, MessageType msgType ) = 0;
51 
53  virtual void appendMessage( const QString &message ) = 0;
54 
56  virtual void setTitle( const QString &title ) = 0;
57 
59  virtual void showMessage( bool blocking = true ) = 0;
60 
64  static void showMessage( const QString &title, const QString &message, MessageType msgType );
65 
68  // TODO: implementation where Python class could be passed
69  static void setMessageOutputCreator( MESSAGE_OUTPUT_CREATOR f );
70 
73  static QgsMessageOutput *createMessageOutput();
74 
75  private:
76 
78  static MESSAGE_OUTPUT_CREATOR mMessageOutputCreator;
79 };
80 
81 
88 class CORE_EXPORT QgsMessageOutputConsole : public QObject, public QgsMessageOutput
89 {
90  Q_OBJECT
91 
92  public:
93 
95 
96  virtual void setMessage( const QString &message, MessageType msgType ) override;
97 
98  virtual void appendMessage( const QString &message ) override;
99 
100  virtual void setTitle( const QString &title ) override;
101 
103  virtual void showMessage( bool blocking = true ) override;
104 
105  signals:
106 
108  void destroyed();
109 
110  private:
111 
113  QString mMessage;
114 
116  QString mTitle;
117 
118  MessageType mMsgType;
119 };
120 
121 #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)()
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.