From 3de2da944aaf08e66eb99da6a1b4222cbbb5f5a6 Mon Sep 17 00:00:00 2001 From: Martyn Gigg <martyn.gigg@gmail.com> Date: Fri, 24 Nov 2017 11:13:56 +0000 Subject: [PATCH] Move MessageDisplay-related classes to MantidQt::MantidWidgets Refs #21251 --- MantidPlot/src/ApplicationWindow.cpp | 11 ++++++----- MantidPlot/src/ApplicationWindow.h | 6 ++---- MantidPlot/src/Mantid/MantidUI.h | 4 +--- .../common/inc/MantidQtWidgets/Common/Message.h | 4 ++-- .../inc/MantidQtWidgets/Common/MessageDisplay.h | 15 +++++---------- .../inc/MantidQtWidgets/Common/QtSignalChannel.h | 2 +- qt/widgets/common/src/Message.cpp | 2 +- qt/widgets/common/src/MessageDisplay.cpp | 8 +++----- qt/widgets/common/src/QtSignalChannel.cpp | 4 ++-- 9 files changed, 23 insertions(+), 33 deletions(-) diff --git a/MantidPlot/src/ApplicationWindow.cpp b/MantidPlot/src/ApplicationWindow.cpp index 0f7eab59f5e..70b7e943dd6 100644 --- a/MantidPlot/src/ApplicationWindow.cpp +++ b/MantidPlot/src/ApplicationWindow.cpp @@ -363,7 +363,7 @@ void ApplicationWindow::init(bool factorySettings, const QStringList &args) { addDockWidget(Qt::TopDockWidgetArea, logWindow); using MantidQt::MantidWidgets::MessageDisplay; - using MantidQt::API::Message; + using MantidQt::MantidWidgets::Message; qRegisterMetaType<Message>("Message"); // Required to use it in signals-slots resultsLog = new MessageDisplay(MessageDisplay::EnableLogLevelControl, logWindow); @@ -4704,7 +4704,7 @@ bool ApplicationWindow::setScriptingLanguage(const QString &lang) { return true; if (m_bad_script_envs.contains(lang)) { - using MantidQt::API::Message; + using MantidQt::MantidWidgets::Message; writeToLogWindow( Message("Previous initialization of " + lang + " failed, cannot retry.", Message::Priority::PRIO_ERROR)); @@ -7976,7 +7976,7 @@ void ApplicationWindow::showResults(bool ok) { text = currentFolder()->logInfo(); else text = "Sorry, there are no results to display!"; - using MantidQt::API::Message; + using MantidQt::MantidWidgets::Message; resultsLog->replace(Message(text, Message::Priority::PRIO_INFORMATION)); } logWindow->setVisible(ok); @@ -7986,7 +7986,7 @@ void ApplicationWindow::showResults(const QString &s, bool ok) { currentFolder()->appendLogInfo(s); QString logInfo = currentFolder()->logInfo(); if (!logInfo.isEmpty()) { - using MantidQt::API::Message; + using MantidQt::MantidWidgets::Message; resultsLog->replace(Message(logInfo, Message::Priority::PRIO_INFORMATION)); } showResults(ok); @@ -16052,7 +16052,8 @@ void ApplicationWindow::setGeometry(MdiSubWindow *usr_win, * @param message :: A string containing the message * @param error :: A boolean indicating if this is an error */ -void ApplicationWindow::writeToLogWindow(const MantidQt::API::Message &msg) { +void ApplicationWindow::writeToLogWindow( + const MantidQt::MantidWidgets::Message &msg) { resultsLog->append(msg); } diff --git a/MantidPlot/src/ApplicationWindow.h b/MantidPlot/src/ApplicationWindow.h index 76e98843135..42b07ab063a 100644 --- a/MantidPlot/src/ApplicationWindow.h +++ b/MantidPlot/src/ApplicationWindow.h @@ -102,11 +102,9 @@ class TiledWindow; #endif namespace MantidQt { -namespace API { -class Message; -} namespace MantidWidgets { class FitPropertyBrowser; +class Message; class MessageDisplay; } } @@ -1066,7 +1064,7 @@ public slots: void savetoNexusFile(); // Slot for writing to log window - void writeToLogWindow(const MantidQt::API::Message &message); + void writeToLogWindow(const MantidQt::MantidWidgets::Message &message); /// Activate a subwindow (docked or floating) other than current active one void activateNewWindow(); diff --git a/MantidPlot/src/Mantid/MantidUI.h b/MantidPlot/src/Mantid/MantidUI.h index 00b9aed5554..e89c8b61538 100644 --- a/MantidPlot/src/Mantid/MantidUI.h +++ b/MantidPlot/src/Mantid/MantidUI.h @@ -52,11 +52,9 @@ class AlgorithmMonitor; class InstrumentWindow; namespace MantidQt { -namespace API { -class Message; -} namespace MantidWidgets { class FitPropertyBrowser; +class Message; class QWorkspaceDockView; } namespace SliceViewer { diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/Message.h b/qt/widgets/common/inc/MantidQtWidgets/Common/Message.h index 50b4c96a260..2b22c374a34 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/Message.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/Message.h @@ -16,7 +16,7 @@ //---------------------------------------------------------- namespace MantidQt { -namespace API { +namespace MantidWidgets { /** @class Message * Provides a simple binding of a text message with a priority */ @@ -54,6 +54,6 @@ private: } /// Required to operate in signals/slots -Q_DECLARE_METATYPE(MantidQt::API::Message) +Q_DECLARE_METATYPE(MantidQt::MantidWidgets::Message) #endif // MESSAGE_H_ diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/MessageDisplay.h b/qt/widgets/common/inc/MantidQtWidgets/Common/MessageDisplay.h index d9d1f94ecf0..a98b337bb9c 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/MessageDisplay.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/MessageDisplay.h @@ -9,7 +9,7 @@ #include "MantidQtWidgets/Common/Message.h" #include "MantidQtWidgets/Common/QtSignalChannel.h" -#include <QMap> +#include <QHash> #include <QTextCharFormat> #include <QTextCursor> #include <QWidget> @@ -26,10 +26,6 @@ class QPlainTextEdit; namespace MantidQt { namespace MantidWidgets { -using API::Message; // So that the slots work - //---------------------------------------------------------- - // Forward declarations - //---------------------------------------------------------- /** @class MessageDisplay * Provides a widget for display messages in a text box @@ -109,26 +105,25 @@ private: /// Set the properties of the text display void setupTextArea(); /// Return format for given log level - QTextCharFormat format(const API::Message::Priority priority) const; + QTextCharFormat format(const Message::Priority priority) const; /// Are we allowed to affect the log level LogLevelControl m_logLevelControl; /// A reference to the log channel - API::QtSignalChannel *m_logChannel; + QtSignalChannel *m_logChannel; /// A reference to the log channel Poco::FilterChannel *m_filterChannel; /// The actual widget holding the text QPlainTextEdit *m_textDisplay; /// Map priority to text formatting - QMap<API::Message::Priority, QTextCharFormat> m_formats; + QHash<Message::Priority, QTextCharFormat> m_formats; /// Mutually exclusive log actions QActionGroup *m_loglevels; /// Map action signal to log level parameter QSignalMapper *m_logLevelMapping; /// Log level actions QAction *m_error, *m_warning, *m_notice, *m_information, *m_debug; - - // the name of the fliter channel + // Name of the channel when registered with Poco const std::string m_FilterChannelName = "MessageDisplayPriority"; }; } diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/QtSignalChannel.h b/qt/widgets/common/inc/MantidQtWidgets/Common/QtSignalChannel.h index e09756dfed1..5b90b34a6cb 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/QtSignalChannel.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/QtSignalChannel.h @@ -7,7 +7,7 @@ #include <Poco/Channel.h> namespace MantidQt { -namespace API { +namespace MantidWidgets { //--------------------------------------------------------------------- // //--------------------------------------------------------------------- diff --git a/qt/widgets/common/src/Message.cpp b/qt/widgets/common/src/Message.cpp index baa19939df2..4b86a358451 100644 --- a/qt/widgets/common/src/Message.cpp +++ b/qt/widgets/common/src/Message.cpp @@ -4,7 +4,7 @@ #include "MantidQtWidgets/Common/Message.h" namespace MantidQt { -namespace API { +namespace MantidWidgets { //----------------------------------------------------------------------------------- // Public member functions //----------------------------------------------------------------------------------- diff --git a/qt/widgets/common/src/MessageDisplay.cpp b/qt/widgets/common/src/MessageDisplay.cpp index 61f35e6a67c..0de032513f9 100644 --- a/qt/widgets/common/src/MessageDisplay.cpp +++ b/qt/widgets/common/src/MessageDisplay.cpp @@ -22,7 +22,6 @@ namespace MantidQt { namespace MantidWidgets { -using API::Message; //------------------------------------------- // Public member functions @@ -33,7 +32,7 @@ using API::Message; */ MessageDisplay::MessageDisplay(QWidget *parent) : QWidget(parent), m_logLevelControl(DisableLogLevelControl), - m_logChannel(new API::QtSignalChannel), + m_logChannel(new QtSignalChannel), m_filterChannel(new Poco::FilterChannel), m_textDisplay(new QPlainTextEdit(this)), m_formats(), m_loglevels(new QActionGroup(this)), @@ -56,7 +55,7 @@ MessageDisplay::MessageDisplay(QWidget *parent) */ MessageDisplay::MessageDisplay(LogLevelControl logLevelControl, QWidget *parent) : QWidget(parent), m_logLevelControl(logLevelControl), - m_logChannel(new API::QtSignalChannel), + m_logChannel(new QtSignalChannel), m_filterChannel(new Poco::FilterChannel), m_textDisplay(new QPlainTextEdit(this)), m_loglevels(new QActionGroup(this)), @@ -378,8 +377,7 @@ void MessageDisplay::setupTextArea() { * @param priority An enumeration for the log level * @return format for given log level */ -QTextCharFormat -MessageDisplay::format(const API::Message::Priority priority) const { +QTextCharFormat MessageDisplay::format(const Message::Priority priority) const { return m_formats.value(priority, QTextCharFormat()); } } diff --git a/qt/widgets/common/src/QtSignalChannel.cpp b/qt/widgets/common/src/QtSignalChannel.cpp index 1a5b49dceff..cdde046ae98 100644 --- a/qt/widgets/common/src/QtSignalChannel.cpp +++ b/qt/widgets/common/src/QtSignalChannel.cpp @@ -5,7 +5,7 @@ #include <Poco/Message.h> namespace MantidQt { -namespace API { +namespace MantidWidgets { /** * Creates a QtSignalChannel. This channel receives @@ -36,7 +36,7 @@ void QtSignalChannel::setSource(const QString &source) { m_source = source; } */ void QtSignalChannel::log(const Poco::Message &msg) { if (m_source.isEmpty() || this->source() == msg.getSource().c_str()) { - emit messageReceived(API::Message( + emit messageReceived(Message( QString::fromStdString(msg.getText() + "\n"), msg.getPriority())); } } -- GitLab