@@ -63,36 +63,37 @@ void DiagnosticsDialog::waitUntilHidden(unsigned int interval)
6363 }
6464}
6565
66- void DiagnosticsDialog::infoMessage (const QString& message)
66+ void DiagnosticsDialog::infoMessage (const QString& message, MessageFormat format )
6767{
68- pushMessage (MS_INFO, message);
68+ pushMessage (MS_INFO, message, format );
6969}
7070
71- void DiagnosticsDialog::warningMessage (const QString& message)
71+ void DiagnosticsDialog::warningMessage (const QString& message, MessageFormat format )
7272{
73- pushMessage (MS_WARNING, message);
73+ pushMessage (MS_WARNING, message, format );
7474
7575 // warning message is important, make sure the diagnostics are shown
7676 show ();
7777}
7878
79- void DiagnosticsDialog::errorMessage (const QString& message)
79+ void DiagnosticsDialog::errorMessage (const QString& message, MessageFormat format )
8080{
81- pushMessage (MS_ERROR, message);
81+ pushMessage (MS_ERROR, message, format );
8282
8383 // error message is important, make sure the diagnostics are shown
8484 show ();
8585}
8686
87- void DiagnosticsDialog::exceptionMessage (const std::exception& e, const QString& context)
87+ void DiagnosticsDialog::exceptionMessage (const std::exception& e, const QString& context, MessageFormat format )
8888{
89- pushMessage (MS_EXCEPTION, (context.isEmpty () ? " " : context + " \n\n " + QString::fromUtf8 (e.what ())));
89+ pushMessage (MS_EXCEPTION, (context.isEmpty () ? " " : context + " \n\n " + QString::fromUtf8 (e.what ())), format );
9090
9191 // error message is important, make sure the diagnostics are shown
9292 show ();
9393}
9494
95- void DiagnosticsDialog::pushMessage (MessageSeverity severity, const QString& fullMessage)
95+
96+ void DiagnosticsDialog::pushMessage (MessageSeverity severity, const QString& fullMessage, MessageFormat format)
9697{
9798 char stime[11 ];
9899 stime[10 ] = ' \0 ' ;
@@ -132,9 +133,21 @@ void DiagnosticsDialog::pushMessage(MessageSeverity severity, const QString& ful
132133 strSeverity = strSeverity.leftJustified (8 );
133134
134135 std::cerr << stime << " | " << strSeverity.toUtf8 ().constData () << " | " << fullMessage.toUtf8 ().constData () << std::endl;
136+
137+ QString outputMessage = fullMessage;
138+ if (format & MF_XML)
139+ {
140+ outputMessage = Qt::escape (outputMessage);
141+ }
142+
143+ if (format & MF_PREFORMATTED)
144+ {
145+ outputMessage = QString (" <pre>%1</pre>" ).arg (outputMessage);
146+ }
147+
135148 mUI .messages ->append (
136149 QString (" <table><tr><td style=\" padding:5px 0px 0px 5px\" ><pre>%1 </pre></td><td style=\" background: %2; padding:5px\" ><pre>%3 </pre></td><td>%4</td></tr></table>\n " )
137- .arg (stime, bgCol, strSeverity, fullMessage )
150+ .arg (stime, bgCol, strSeverity, outputMessage )
138151 );
139152}
140153
0 commit comments