|
Mantid
|
Provides a widget for display messages in a text box It deals with Message objects which in turn hide whether a message is a framework Poco message or a simple string. More...
#include <MessageDisplay.h>
Public Slots | |
| void | append (const Message &msg) |
| Write a message after the current contents. | |
| void | appendDebug (const QString &text) |
| Convenience method for appending message at debug level. | |
| void | appendError (const QString &text) |
| Convenience method for appending message at error level. | |
| void | appendFatal (const QString &text) |
| Convenience method for appending message at fatal level. | |
| void | appendInformation (const QString &text) |
| Convenience method for appending message at information level. | |
| void | appendNotice (const QString &text) |
| Convenience method for appending message at notice level. | |
| void | appendPython (const QString &text, const int &priority, const QString &fileName) |
| Write a Python script message, intended for use with Python API. | |
| void | appendWarning (const QString &text) |
| Convenience method for appending message at warning level. | |
| void | clear () |
| Clear all of the text. | |
| bool | isScrollbarAtBottom () const |
| Returns true if scroll-bar is at the bottom of widget. | |
| QTextCursor | moveCursorToEnd () |
| Move the text cursor to after the last character. | |
| void | replace (const Message &msg) |
| Replace the display text with the given contents. | |
| void | scrollToBottom () |
| Scroll to the bottom of the text. | |
| void | scrollToTop () |
| Scroll to the bottom of the text. | |
Signals | |
| void | errorReceived (const QString &text) |
| Indicate that a message of error or higher has been received. | |
| void | warningReceived (const QString &text) |
| Indicate that a message of warning or higher has been received. | |
Public Member Functions | |
| const QString & | activeScript () const |
| Get the path of the currently active script. | |
| void | appendToHistory (const Message &msg) |
| Append a message to the message history. | |
| void | attachLoggingChannel (int logLevel=0) |
| Attaches the Mantid logging framework. | |
| MessageDisplaySettings | captureSettings () const override |
| Capture current widget state without persistent I/O. | |
| void | filePathModified (const QString &oldPath, const QString &newPath) |
| Method to be called when a file's path is modified. | |
| void | filterMessages () |
| Filter messages by message type. | |
| QMenu * | generateContextMenu () |
| Generate the display's context menu QMenu object. | |
| const QList< Message > & | getHistory () |
| Get the window's message history. | |
| QPlainTextEdit * | getTextEdit () |
| Get the window's QPlainTextEdit object. | |
| MessageDisplay (const MessageDisplay &)=delete | |
| MessageDisplay (const QFont &font, QWidget *parent=nullptr) | |
| Constructor accepting a QFont. | |
| MessageDisplay (QWidget *parent=nullptr) | |
| Default constructor with optional parent. | |
| MessageDisplay & | operator= (const MessageDisplay &)=delete |
| MessageDisplaySettings | readSettings (const QSettings &storage) const |
| Query persistent storage without changing the widget. | |
| void | restoreSettings (const MessageDisplaySettings &settings) override |
| Apply an already-read snapshot without persistent I/O. | |
| void | saveSettings (QSettings &storage, const MessageDisplaySettings &settings) const |
| Persist an explicit snapshot. | |
| void | setActiveScript (const QString &scriptPath) |
| Set the path of the currently active script. | |
| void | setShowActiveScriptOutput (const bool &show) |
| Get whether only active script output should be displayed. | |
| void | setShowAllScriptOutput (const bool &show) |
| Set whether all script output should be displayed. | |
| void | setShowFrameworkOutput (const bool &show) |
| Set whether framework output should be displayed. | |
| void | setSource (const QString &source) |
| If set, only Mantid log messages from this source are emitted. | |
| bool | showActiveScriptOutput () const |
| Get whether only active script output is being displayed. | |
| bool | showAllScriptOutput () const |
| Get whether all script output is being displayed. | |
| bool | showFrameworkOutput () const |
| Get whether framework output is being displayed. | |
| const QString & | source () const |
| Get the current source are emitted. | |
| ~MessageDisplay () override | |
| Destructor. | |
Public Member Functions inherited from MantidQt::MantidWidgets::Configurable< MessageDisplaySettings > | |
| virtual | ~Configurable ()=default |
Properties | |
| QString | source |
Private Slots | |
| int | maximumLineCount () const |
| Return the maximum number of lines displayed. | |
| void | setLogLevel (int priority) |
| Set the global logging level. | |
| void | setMaximumLineCount (int count) |
| Set the maximum number of lines displayed. | |
| void | setScrollbackLimit () |
| Set the number of blocks kept by the display. | |
| void | showContextMenu (const QPoint &event) |
| Provide a custom context menu. | |
Private Member Functions | |
| QTextCharFormat | format (const Message::Priority priority) const |
| Return format for given log level. | |
| void | initActions () |
| Setup the actions. | |
| void | initFormats () |
| Initialize the text formats. | |
| void | setupTextArea (const QFont &font) |
| Set the properties of the text display. | |
| bool | shouldBeDisplayed (const Message &msg) |
| Return True if message should be shown given current user settings. | |
Private Attributes | |
| QString | m_activeScript |
| QAction * | m_debug |
| QAction * | m_error |
| Log level actions. | |
| QHash< Message::Priority, QTextCharFormat > | m_formats |
| Map priority to text formatting. | |
| QAction * | m_information |
| QtSignalChannel * | m_logChannel |
| A reference to the log channel. | |
| QSignalMapper * | m_logLevelMapping |
| Map action signal to log level parameter. | |
| QActionGroup * | m_loglevels |
| Mutually exclusive log actions. | |
| QList< Message > | m_messageHistory |
| Keep track of the message history. | |
| QAction * | m_notice |
| bool | m_showActiveScriptOutput {false} |
| bool | m_showAllScriptOutput {true} |
| bool | m_showFrameworkOutput {true} |
| Bools to dictate whether to print certain types of messages. | |
| QPlainTextEdit * | m_textDisplay |
| The actual widget holding the text. | |
| QAction * | m_warning |
Provides a widget for display messages in a text box It deals with Message objects which in turn hide whether a message is a framework Poco message or a simple string.
It can connect to the Mantid logging framework if required
Definition at line 55 of file MessageDisplay.h.
| MantidQt::MantidWidgets::MessageDisplay::MessageDisplay | ( | QWidget * | parent = nullptr | ) |
Default constructor with optional parent.
Construct a MessageDisplay with the default font.
| parent | An optional parent widget |
Definition at line 82 of file MessageDisplay.cpp.
| MantidQt::MantidWidgets::MessageDisplay::MessageDisplay | ( | const QFont & | font, |
| QWidget * | parent = nullptr |
||
| ) |
Constructor accepting a QFont.
Construct a MessageDisplay using the given font.
| font | A reference to a font object |
| parent | An optional parent widget |
Definition at line 89 of file MessageDisplay.cpp.
References initActions(), initFormats(), and setupTextArea().
|
delete |
|
override |
Destructor.
Definition at line 100 of file MessageDisplay.cpp.
References m_logChannel, and m_textDisplay.
|
inline |
Get the path of the currently active script.
Definition at line 110 of file MessageDisplay.h.
Referenced by shouldBeDisplayed().
|
slot |
Write a message after the current contents.
| msg | A message that is echoed to the display after the current text |
Definition at line 229 of file MessageDisplay.cpp.
References appendToHistory(), errorReceived(), format(), moveCursorToEnd(), MantidQt::MantidWidgets::Message::priority(), shouldBeDisplayed(), MantidQt::MantidWidgets::NotificationService::showMessage(), MantidQt::MantidWidgets::Message::text(), and warningReceived().
Referenced by appendDebug(), appendError(), appendFatal(), appendInformation(), appendNotice(), appendPython(), appendWarning(), attachLoggingChannel(), and replace().
|
slot |
Convenience method for appending message at debug level.
| text | The text string to append at PRIO_DEBUG level |
Definition at line 223 of file MessageDisplay.cpp.
References append().
|
slot |
Convenience method for appending message at error level.
| text | The text string to append at PRIO_ERROR level |
Definition at line 199 of file MessageDisplay.cpp.
References append().
|
slot |
Convenience method for appending message at fatal level.
| text | The text string to append at PRIO_FATAL level |
Definition at line 194 of file MessageDisplay.cpp.
References append().
|
slot |
Convenience method for appending message at information level.
| text | The text string to append at PRIO_INFORMATION level |
Definition at line 216 of file MessageDisplay.cpp.
References append().
|
slot |
Convenience method for appending message at notice level.
| text | The text string to append at PRIO_NOTICE level |
Definition at line 211 of file MessageDisplay.cpp.
References append().
|
slot |
Write a Python script message, intended for use with Python API.
Append a message to the message window, adding the script name associated with the message.
| text | The message to display in the window |
| priority | The priority level of the message |
| filePath | The path of the Python script being executed |
Definition at line 255 of file MessageDisplay.cpp.
References append().
| void MantidQt::MantidWidgets::MessageDisplay::appendToHistory | ( | const Message & | msg | ) |
Append a message to the message history.
If the length of the history exceeds the max line count, remove entries from the start until it does not.
| msg | The Message object to append |
Definition at line 181 of file MessageDisplay.cpp.
References m_messageHistory, and maximumLineCount().
Referenced by append().
|
slot |
Convenience method for appending message at warning level.
| text | The text string to append at PRIO_WARNING level |
Definition at line 204 of file MessageDisplay.cpp.
References append().
| void MantidQt::MantidWidgets::MessageDisplay::attachLoggingChannel | ( | int | logLevel = 0 | ) |
Attaches the Mantid logging framework.
Starts the ConfigService if required
| logLevel | If > 0 then set the filter channel level to this. A number =< 0 uses the channel |
Definition at line 122 of file MessageDisplay.cpp.
References append(), and m_logChannel.
|
overridevirtual |
Capture current widget state without persistent I/O.
Implements MantidQt::MantidWidgets::Configurable< MessageDisplaySettings >.
Definition at line 68 of file MessageDisplay.cpp.
References maximumLineCount().
|
slot |
Clear all of the text.
Definition at line 271 of file MessageDisplay.cpp.
References m_messageHistory, and m_textDisplay.
Referenced by generateContextMenu(), and replace().
|
signal |
Indicate that a message of error or higher has been received.
Referenced by append().
| void MantidQt::MantidWidgets::MessageDisplay::filePathModified | ( | const QString & | oldPath, |
| const QString & | newPath | ||
| ) |
Method to be called when a file's path is modified.
Each Message object associated with the file has its scriptPath attribute updated.
| oldPath | The path of the file being renamed |
| newPath | The new path of the file |
Definition at line 169 of file MessageDisplay.cpp.
References m_messageHistory.
| void MantidQt::MantidWidgets::MessageDisplay::filterMessages | ( | ) |
Filter messages by message type.
Filter messages, either by Framework or all/individual scripts.
Definition at line 153 of file MessageDisplay.cpp.
References format(), getHistory(), m_textDisplay, moveCursorToEnd(), and shouldBeDisplayed().
|
private |
Return format for given log level.
| priority | An enumeration for the log level |
Definition at line 471 of file MessageDisplay.cpp.
References m_formats.
Referenced by append(), and filterMessages().
| QMenu * MantidQt::MantidWidgets::MessageDisplay::generateContextMenu | ( | ) |
Generate the display's context menu QMenu object.
Definition at line 363 of file MessageDisplay.cpp.
References clear(), m_debug, m_error, m_information, m_notice, m_textDisplay, m_warning, and setScrollbackLimit().
Referenced by showContextMenu().
Get the window's message history.
Definition at line 88 of file MessageDisplay.h.
Referenced by filterMessages().
|
inline |
Get the window's QPlainTextEdit object.
Definition at line 86 of file MessageDisplay.h.
|
private |
Setup the actions.
Definition at line 395 of file MessageDisplay.cpp.
References m_debug, m_error, m_information, m_logLevelMapping, m_loglevels, m_notice, m_warning, and setLogLevel().
Referenced by MessageDisplay().
|
private |
Initialize the text formats.
Sets up the internal map of text formatters for each log level.
Definition at line 426 of file MessageDisplay.cpp.
References m_formats.
Referenced by MessageDisplay().
|
slot |
Returns true if scroll-bar is at the bottom of widget.
Definition at line 289 of file MessageDisplay.cpp.
References m_textDisplay.
|
privateslot |
Return the maximum number of lines displayed.
Definition at line 352 of file MessageDisplay.cpp.
References m_textDisplay.
Referenced by appendToHistory(), captureSettings(), and setScrollbackLimit().
|
slot |
Move the text cursor to after the last character.
Definition at line 279 of file MessageDisplay.cpp.
References m_textDisplay.
Referenced by append(), and filterMessages().
|
delete |
| MessageDisplaySettings MantidQt::MantidWidgets::MessageDisplay::readSettings | ( | const QSettings & | storage | ) | const |
Query persistent storage without changing the widget.
Definition at line 57 of file MessageDisplay.cpp.
|
slot |
Replace the display text with the given contents.
| msg | Replace the current contents with this message |
Definition at line 263 of file MessageDisplay.cpp.
References append(), clear(), and MantidQt::MantidWidgets::Message::text().
|
overridevirtual |
Apply an already-read snapshot without persistent I/O.
Implements MantidQt::MantidWidgets::Configurable< MessageDisplaySettings >.
Definition at line 62 of file MessageDisplay.cpp.
References MantidQt::MantidWidgets::MessageDisplaySettings::logLevel(), MantidQt::MantidWidgets::MessageDisplaySettings::maximumLineCount(), and setMaximumLineCount().
| void MantidQt::MantidWidgets::MessageDisplay::saveSettings | ( | QSettings & | storage, |
| const MessageDisplaySettings & | settings | ||
| ) | const |
Persist an explicit snapshot.
Definition at line 72 of file MessageDisplay.cpp.
References MantidQt::MantidWidgets::MessageDisplaySettings::logLevel(), MantidQt::MantidWidgets::MessageDisplaySettings::maximumLineCount(), and MantidQt::MantidWidgets::QSettingsChangeAware::setValue().
|
slot |
Scroll to the bottom of the text.
Moves the cursor to the bottom of the document.
Definition at line 308 of file MessageDisplay.cpp.
References m_textDisplay.
|
slot |
Scroll to the bottom of the text.
Moves the cursor to the top of the document.
Definition at line 296 of file MessageDisplay.cpp.
References m_textDisplay.
|
inline |
Set the path of the currently active script.
Definition at line 112 of file MessageDisplay.h.
|
privateslot |
Set the global logging level.
Definition at line 331 of file MessageDisplay.cpp.
Referenced by initActions().
|
privateslot |
Set the maximum number of lines displayed.
The maximum number of lines that are to be displayed in the text edit.
| count | The new maximum number of lines to retain. |
Definition at line 358 of file MessageDisplay.cpp.
References count, and m_textDisplay.
Referenced by restoreSettings(), setScrollbackLimit(), and setupTextArea().
|
privateslot |
Set the number of blocks kept by the display.
Set the maximum number of blocks kept by the text edit.
Definition at line 336 of file MessageDisplay.cpp.
References maximumLineCount(), and setMaximumLineCount().
Referenced by generateContextMenu().
|
inline |
Get whether only active script output should be displayed.
Definition at line 108 of file MessageDisplay.h.
|
inline |
Set whether all script output should be displayed.
Definition at line 104 of file MessageDisplay.h.
|
inline |
Set whether framework output should be displayed.
Definition at line 100 of file MessageDisplay.h.
| void MantidQt::MantidWidgets::MessageDisplay::setSource | ( | const QString & | source | ) |
If set, only Mantid log messages from this source are emitted.
| source | A string specifying the required source for messages that will be emitted |
Definition at line 148 of file MessageDisplay.cpp.
References m_logChannel, MantidQt::MantidWidgets::QtSignalChannel::setSource(), and source.
|
private |
Set the properties of the text display.
Set the properties of the text display, i.e read-only and make it occupy the whole widget.
| font | A reference to the font for the text area |
Definition at line 448 of file MessageDisplay.cpp.
References m_textDisplay, setMaximumLineCount(), and showContextMenu().
Referenced by MessageDisplay().
|
private |
Return True if message should be shown given current user settings.
Returns true if the given message should be displayed given the current settings.
| msg | A Message object |
Definition at line 479 of file MessageDisplay.cpp.
References activeScript(), MantidQt::MantidWidgets::Message::scriptPath(), showActiveScriptOutput(), showAllScriptOutput(), and showFrameworkOutput().
Referenced by append(), and filterMessages().
|
inline |
Get whether only active script output is being displayed.
Definition at line 106 of file MessageDisplay.h.
Referenced by shouldBeDisplayed().
|
inline |
Get whether all script output is being displayed.
Definition at line 102 of file MessageDisplay.h.
Referenced by shouldBeDisplayed().
|
privateslot |
Provide a custom context menu.
Definition at line 321 of file MessageDisplay.cpp.
References generateContextMenu().
Referenced by setupTextArea().
|
inline |
Get whether framework output is being displayed.
Definition at line 98 of file MessageDisplay.h.
Referenced by shouldBeDisplayed().
|
inline |
Get the current source are emitted.
Definition at line 84 of file MessageDisplay.h.
|
signal |
Indicate that a message of warning or higher has been received.
Referenced by append().
|
private |
Definition at line 190 of file MessageDisplay.h.
|
private |
Definition at line 185 of file MessageDisplay.h.
Referenced by generateContextMenu(), and initActions().
|
private |
Log level actions.
Definition at line 185 of file MessageDisplay.h.
Referenced by generateContextMenu(), and initActions().
|
private |
Map priority to text formatting.
Definition at line 179 of file MessageDisplay.h.
Referenced by format(), and initFormats().
|
private |
Definition at line 185 of file MessageDisplay.h.
Referenced by generateContextMenu(), and initActions().
|
private |
A reference to the log channel.
Definition at line 175 of file MessageDisplay.h.
Referenced by attachLoggingChannel(), setSource(), and ~MessageDisplay().
|
private |
Map action signal to log level parameter.
Definition at line 183 of file MessageDisplay.h.
Referenced by initActions().
|
private |
Mutually exclusive log actions.
Definition at line 181 of file MessageDisplay.h.
Referenced by initActions().
Keep track of the message history.
Definition at line 187 of file MessageDisplay.h.
Referenced by appendToHistory(), clear(), and filePathModified().
|
private |
Definition at line 185 of file MessageDisplay.h.
Referenced by generateContextMenu(), and initActions().
|
private |
Definition at line 189 of file MessageDisplay.h.
|
private |
Definition at line 189 of file MessageDisplay.h.
|
private |
Bools to dictate whether to print certain types of messages.
Definition at line 189 of file MessageDisplay.h.
|
private |
The actual widget holding the text.
Definition at line 177 of file MessageDisplay.h.
Referenced by clear(), filterMessages(), generateContextMenu(), isScrollbarAtBottom(), maximumLineCount(), moveCursorToEnd(), scrollToBottom(), scrollToTop(), setMaximumLineCount(), setupTextArea(), and ~MessageDisplay().
|
private |
Definition at line 185 of file MessageDisplay.h.
Referenced by generateContextMenu(), and initActions().
|
readwrite |
Definition at line 57 of file MessageDisplay.h.
Referenced by setSource().