QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
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 class QgsMessageOutput;
24 typedef QgsMessageOutput*( *MESSAGE_OUTPUT_CREATOR )();
25 
26 
38 class CORE_EXPORT QgsMessageOutput
39 {
40  public:
41 
43  enum MessageType { MessageText, MessageHtml };
44 
46  virtual ~QgsMessageOutput();
47 
49  virtual void setMessage( const QString& message, MessageType msgType ) = 0;
50 
52  virtual void appendMessage( const QString& message ) = 0;
53 
55  virtual void setTitle( const QString& title ) = 0;
56 
58  virtual void showMessage( bool blocking = true ) = 0;
59 
63  static void showMessage( const QString& title, const QString& message, MessageType msgType );
64 
67  // TODO: implementation where python class could be passed
68  static void setMessageOutputCreator( MESSAGE_OUTPUT_CREATOR f );
69 
72  static QgsMessageOutput* createMessageOutput();
73 
74  private:
75 
77  static MESSAGE_OUTPUT_CREATOR mMessageOutputCreator;
78 };
79 
80 
87 class CORE_EXPORT QgsMessageOutputConsole : public QObject, public QgsMessageOutput
88 {
89  Q_OBJECT
90 
91  public:
92 
94 
95  virtual void setMessage( const QString& message, MessageType msgType ) override;
96 
97  virtual void appendMessage( const QString& message ) override;
98 
99  virtual void setTitle( const QString& title ) override;
100 
102  virtual void showMessage( bool blocking = true ) override;
103 
104  signals:
105 
107  void destroyed();
108 
109  private:
110 
112  QString mMessage;
113 
115  QString mTitle;
116 
117  MessageType mMsgType;
118 };
119 
120 #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.
void destroyed(QObject *obj)