QGIS API Documentation
4.3.0-Master (16eddb2670e)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
core
qgsmessageoutput.cpp
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
#include "
qgsmessageoutput.h
"
17
18
#include "
qgslogger.h
"
19
#include "
qgsmessagelog.h
"
20
21
#include <QRegularExpression>
22
#include <QString>
23
24
#include "moc_qgsmessageoutput.cpp"
25
26
using namespace
Qt::StringLiterals;
27
28
static
QgsMessageOutput
*messageOutputConsole_()
29
{
30
return
new
QgsMessageOutputConsole
;
31
}
32
33
// default output creator - console
34
MESSAGE_OUTPUT_CREATOR
QgsMessageOutput::mMessageOutputCreator = messageOutputConsole_;
35
36
37
void
QgsMessageOutput::setMessageOutputCreator
(
MESSAGE_OUTPUT_CREATOR
f )
38
{
39
mMessageOutputCreator = f;
40
}
41
42
QgsMessageOutput
*
QgsMessageOutput::createMessageOutput
()
43
{
44
return
mMessageOutputCreator();
45
}
46
47
void
QgsMessageOutput::showMessage
(
const
QString &title,
const
QString &message,
Qgis::StringFormat
format )
48
{
49
QgsMessageOutput
*output =
QgsMessageOutput::createMessageOutput
();
50
output->
setTitle
( title );
51
output->
setMessage
( message, format );
52
output->
showMessage
();
53
}
54
56
// QgsMessageOutputConsole
57
58
void
QgsMessageOutputConsole::setMessage
(
const
QString &message,
Qgis::StringFormat
format )
59
{
60
mMessage = message;
61
mFormat = format;
62
}
63
64
void
QgsMessageOutputConsole::appendMessage
(
const
QString &message )
65
{
66
mMessage += message;
67
}
68
69
void
QgsMessageOutputConsole::showMessage
(
bool
)
70
{
71
if
( mFormat ==
Qgis::StringFormat::Html
)
72
{
73
mMessage.replace(
"<br>"
_L1,
"\n"
_L1 );
74
mMessage.replace(
" "
_L1,
" "
_L1 );
75
const
thread_local
QRegularExpression tagRX( u
"</?[^>]+>"
_s );
76
mMessage.replace( tagRX, QString() );
77
}
78
QgsMessageLog::logMessage
( mMessage, mTitle.isNull() ? QObject::tr(
"Console"
) : mTitle );
79
emit
destroyed
();
80
delete
this
;
81
}
82
83
void
QgsMessageOutputConsole::setTitle
(
const
QString &title )
84
{
85
mTitle = title;
86
}
Qgis::StringFormat
StringFormat
Format of log message.
Definition
qgis.h:175
Qgis::StringFormat::Html
@ Html
HTML message.
Definition
qgis.h:177
QgsMessageLog::logMessage
static void logMessage(const QString &message, const QString &tag=QString(), Qgis::MessageLevel level=Qgis::MessageLevel::Warning, bool notifyUser=true, const char *file=__builtin_FILE(), const char *function=__builtin_FUNCTION(), int line=__builtin_LINE(), Qgis::StringFormat format=Qgis::StringFormat::PlainText)
Adds a message to the log instance (and creates it if necessary).
Definition
qgsmessagelog.cpp:35
QgsMessageOutputConsole
Default implementation of message output interface.
Definition
qgsmessageoutput.h:94
QgsMessageOutputConsole::setTitle
void setTitle(const QString &title) override
Sets title for the messages.
Definition
qgsmessageoutput.cpp:83
QgsMessageOutputConsole::destroyed
void destroyed()
signals that object will be destroyed and shouldn't be used anymore
QgsMessageOutputConsole::appendMessage
void appendMessage(const QString &message) override
message to be appended to the current text
Definition
qgsmessageoutput.cpp:64
QgsMessageOutputConsole::setMessage
void setMessage(const QString &message, Qgis::StringFormat format) override
Sets message, it won't be displayed until.
Definition
qgsmessageoutput.cpp:58
QgsMessageOutputConsole::showMessage
void showMessage(bool blocking=true) override
sends the message to the standard output
Definition
qgsmessageoutput.cpp:69
QgsMessageOutput
Interface for showing messages from QGIS in GUI independent way.
Definition
qgsmessageoutput.h:45
QgsMessageOutput::showMessage
virtual void showMessage(bool blocking=true)=0
display the message to the user and deletes itself
QgsMessageOutput::createMessageOutput
static QgsMessageOutput * createMessageOutput()
function that returns new class derived from QgsMessageOutput (don't forget to delete it then if show...
Definition
qgsmessageoutput.cpp:42
QgsMessageOutput::setMessageOutputCreator
static void setMessageOutputCreator(MESSAGE_OUTPUT_CREATOR f)
sets function that will be used to create message output
Definition
qgsmessageoutput.cpp:37
QgsMessageOutput::setMessage
virtual void setMessage(const QString &message, Qgis::StringFormat format)=0
Sets message, it won't be displayed until.
QgsMessageOutput::setTitle
virtual void setTitle(const QString &title)=0
Sets title for the messages.
qgslogger.h
qgsmessagelog.h
qgsmessageoutput.h
MESSAGE_OUTPUT_CREATOR
QgsMessageOutput *(* MESSAGE_OUTPUT_CREATOR)()
Definition
qgsmessageoutput.h:28
Generated on
for QGIS API Documentation by
1.17.0