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. More... | |
void | appendDebug (const QString &text) |
Convenience method for appending message at debug level. More... | |
void | appendError (const QString &text) |
Convenience method for appending message at error level. More... | |
void | appendFatal (const QString &text) |
Convenience method for appending message at fatal level. More... | |
void | appendInformation (const QString &text) |
Convenience method for appending message at information level. More... | |
void | appendNotice (const QString &text) |
Convenience method for appending message at notice level. More... | |
void | appendPython (const QString &text, const int &priority, const QString &fileName) |
Write a Python script message, intended for use with Python API. More... | |
void | appendWarning (const QString &text) |
Convenience method for appending message at warning level. More... | |
void | clear () |
Clear all of the text. More... | |
bool | isScrollbarAtBottom () const |
Returns true if scroll-bar is at the bottom of widget. More... | |
QTextCursor | moveCursorToEnd () |
Move the text cursor to after the last character. More... | |
void | replace (const Message &msg) |
Replace the display text with the given contents. More... | |
void | scrollToBottom () |
Scroll to the bottom of the text. More... | |
void | scrollToTop () |
Scroll to the bottom of the text. More... | |
Signals | |
void | errorReceived (const QString &text) |
Indicate that a message of error or higher has been received. More... | |
void | warningReceived (const QString &text) |
Indicate that a message of warning or higher has been received. More... | |
Public Member Functions | |
QString | activeScript () const |
Get the path of the currently active script. More... | |
void | appendToHistory (const Message &msg) |
Append a message to the message history. More... | |
void | attachLoggingChannel (int logLevel=0) |
Attaches the Mantid logging framework. More... | |
void | filePathModified (const QString &oldPath, const QString &newPath) |
Method to be called when a file's path is modified. More... | |
void | filterMessages () |
Filter messages by message type. More... | |
QMenu * | generateContextMenu () |
Generate the display's context menu QMenu object. More... | |
QList< Message > | getHistory () |
Get the window's message history. More... | |
QPlainTextEdit * | getTextEdit () |
Get the window's QPlainTextEdit object. More... | |
MessageDisplay (const MessageDisplay &)=delete | |
MessageDisplay (const QFont &font, QWidget *parent=nullptr) | |
Constructor accepting a QFont. More... | |
MessageDisplay (QWidget *parent=nullptr) | |
Default constructor with optional parent. More... | |
MessageDisplay & | operator= (const MessageDisplay &)=delete |
void | readSettings (const QSettings &storage) override |
Load settings from the persistent store. More... | |
void | setActiveScript (const QString &scriptPath) |
Set the path of the currently active script. More... | |
void | setShowActiveScriptOutput (const bool &show) |
Get whether only active script output should be displayed. More... | |
void | setShowAllScriptOutput (const bool &show) |
Set whether all script output should be displayed. More... | |
void | setShowFrameworkOutput (const bool &show) |
Set whether framework output should be displayed. More... | |
void | setSource (const QString &source) |
If set, only Mantid log messages from this source are emitted. More... | |
bool | showActiveScriptOutput () const |
Get whether only active script output is being displayed. More... | |
bool | showAllScriptOutput () const |
Get whether all script output is being displayed. More... | |
bool | showFrameworkOutput () const |
Get whether framework output is being displayed. More... | |
const QString & | source () const |
Get the current source are emitted. More... | |
void | writeSettings (QSettings &storage) const override |
Load settings from the persistent store. More... | |
~MessageDisplay () override | |
Destructor. More... | |
Public Member Functions inherited from MantidQt::MantidWidgets::Configurable | |
virtual void | readSettings (const QSettings &)=0 |
virtual void | writeSettings (QSettings &) const =0 |
virtual | ~Configurable ()=default |
Properties | |
QString | source |
Private Slots | |
int | maximumLineCount () const |
Return the maximum number of lines displayed. More... | |
void | setLogLevel (int priority) |
Set the global logging level. More... | |
void | setMaximumLineCount (int count) |
Set the maximum number of lines displayed. More... | |
void | setScrollbackLimit () |
Set the number of blocks kept by the display. More... | |
void | showContextMenu (const QPoint &event) |
Provide a custom context menu. More... | |
Private Member Functions | |
QTextCharFormat | format (const Message::Priority priority) const |
Return format for given log level. More... | |
void | initActions () |
Setup the actions. More... | |
void | initFormats () |
Initialize the text formats. More... | |
void | setupTextArea (const QFont &font) |
Set the properties of the text display. More... | |
bool | shouldBeDisplayed (const Message &msg) |
Return True if message should be shown given current user settings. More... | |
Private Attributes | |
QString | m_activeScript |
QAction * | m_debug |
QAction * | m_error |
Log level actions. More... | |
QHash< Message::Priority, QTextCharFormat > | m_formats |
Map priority to text formatting. More... | |
QAction * | m_information |
QtSignalChannel * | m_logChannel |
A reference to the log channel. More... | |
QSignalMapper * | m_logLevelMapping |
Map action signal to log level parameter. More... | |
QActionGroup * | m_loglevels |
Mutually exclusive log actions. More... | |
QList< Message > | m_messageHistory |
Keep track of the message history. More... | |
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. More... | |
QPlainTextEdit * | m_textDisplay |
The actual widget holding the text. More... | |
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 43 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 78 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 85 of file MessageDisplay.cpp.
References initActions(), initFormats(), and setupTextArea().
|
delete |
|
override |
Destructor.
Definition at line 96 of file MessageDisplay.cpp.
References m_logChannel, and m_textDisplay.
|
inline |
Get the path of the currently active script.
Definition at line 93 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 225 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 219 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 195 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 190 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 212 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 207 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 251 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 177 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 200 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 118 of file MessageDisplay.cpp.
References append(), Mantid::Kernel::SingletonHolder< T >::Instance(), and m_logChannel.
|
slot |
Clear all of the text.
Definition at line 267 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 165 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 149 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 467 of file MessageDisplay.cpp.
References m_formats.
Referenced by append(), filterMessages(), and initFormats().
QMenu * MantidQt::MantidWidgets::MessageDisplay::generateContextMenu | ( | ) |
Generate the display's context menu QMenu object.
Definition at line 359 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 71 of file MessageDisplay.h.
Referenced by filterMessages().
|
inline |
Get the window's QPlainTextEdit object.
Definition at line 69 of file MessageDisplay.h.
|
private |
Setup the actions.
Definition at line 391 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 422 of file MessageDisplay.cpp.
References format(), and m_formats.
Referenced by MessageDisplay().
|
slot |
Returns true if scroll-bar is at the bottom of widget.
Definition at line 285 of file MessageDisplay.cpp.
References m_textDisplay.
|
privateslot |
Return the maximum number of lines displayed.
Definition at line 348 of file MessageDisplay.cpp.
References m_textDisplay.
Referenced by appendToHistory(), setScrollbackLimit(), and writeSettings().
|
slot |
Move the text cursor to after the last character.
Definition at line 275 of file MessageDisplay.cpp.
References m_textDisplay.
Referenced by append(), and filterMessages().
|
delete |
|
overridevirtual |
Load settings from the persistent store.
The client is expected to call this method with the QSettings object opened at the approriate group
storage | A pointer to an existing QSettings instance opened at the group containing the values |
Implements MantidQt::MantidWidgets::Configurable.
Definition at line 55 of file MessageDisplay.cpp.
References Mantid::Kernel::SingletonHolder< T >::Instance(), and setMaximumLineCount().
|
slot |
Replace the display text with the given contents.
msg | Replace the current contents with this message |
Definition at line 259 of file MessageDisplay.cpp.
References append(), clear(), and MantidQt::MantidWidgets::Message::text().
|
slot |
Scroll to the bottom of the text.
Moves the cursor to the bottom of the document.
Definition at line 304 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 292 of file MessageDisplay.cpp.
References m_textDisplay.
|
inline |
Set the path of the currently active script.
Definition at line 95 of file MessageDisplay.h.
|
privateslot |
Set the global logging level.
Definition at line 327 of file MessageDisplay.cpp.
References Mantid::Kernel::SingletonHolder< T >::Instance().
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 354 of file MessageDisplay.cpp.
References count, and m_textDisplay.
Referenced by readSettings(), 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 332 of file MessageDisplay.cpp.
References maximumLineCount(), and setMaximumLineCount().
Referenced by generateContextMenu().
|
inline |
Get whether only active script output should be displayed.
Definition at line 91 of file MessageDisplay.h.
|
inline |
Set whether all script output should be displayed.
Definition at line 87 of file MessageDisplay.h.
|
inline |
Set whether framework output should be displayed.
Definition at line 83 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 144 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 444 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 475 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 89 of file MessageDisplay.h.
Referenced by shouldBeDisplayed().
|
inline |
Get whether all script output is being displayed.
Definition at line 85 of file MessageDisplay.h.
Referenced by shouldBeDisplayed().
|
privateslot |
Provide a custom context menu.
Definition at line 317 of file MessageDisplay.cpp.
References generateContextMenu().
Referenced by setupTextArea().
|
inline |
Get whether framework output is being displayed.
Definition at line 81 of file MessageDisplay.h.
Referenced by shouldBeDisplayed().
|
inline |
Get the current source are emitted.
Definition at line 67 of file MessageDisplay.h.
|
signal |
Indicate that a message of warning or higher has been received.
Referenced by append().
|
overridevirtual |
Load settings from the persistent store.
The client is expected to call this method with the QSettings object opened at the approriate group
storage | A pointer to an existing QSettings instance opened at the group where the values should be stored. |
Implements MantidQt::MantidWidgets::Configurable.
Definition at line 69 of file MessageDisplay.cpp.
References maximumLineCount().
|
private |
Definition at line 173 of file MessageDisplay.h.
|
private |
Definition at line 168 of file MessageDisplay.h.
Referenced by generateContextMenu(), and initActions().
|
private |
Log level actions.
Definition at line 168 of file MessageDisplay.h.
Referenced by generateContextMenu(), and initActions().
|
private |
Map priority to text formatting.
Definition at line 162 of file MessageDisplay.h.
Referenced by format(), and initFormats().
|
private |
Definition at line 168 of file MessageDisplay.h.
Referenced by generateContextMenu(), and initActions().
|
private |
A reference to the log channel.
Definition at line 158 of file MessageDisplay.h.
Referenced by attachLoggingChannel(), setSource(), and ~MessageDisplay().
|
private |
Map action signal to log level parameter.
Definition at line 166 of file MessageDisplay.h.
Referenced by initActions().
|
private |
Mutually exclusive log actions.
Definition at line 164 of file MessageDisplay.h.
Referenced by initActions().
Keep track of the message history.
Definition at line 170 of file MessageDisplay.h.
Referenced by appendToHistory(), clear(), and filePathModified().
|
private |
Definition at line 168 of file MessageDisplay.h.
Referenced by generateContextMenu(), and initActions().
|
private |
Definition at line 172 of file MessageDisplay.h.
|
private |
Definition at line 172 of file MessageDisplay.h.
|
private |
Bools to dictate whether to print certain types of messages.
Definition at line 172 of file MessageDisplay.h.
|
private |
The actual widget holding the text.
Definition at line 160 of file MessageDisplay.h.
Referenced by clear(), filterMessages(), generateContextMenu(), isScrollbarAtBottom(), maximumLineCount(), moveCursorToEnd(), scrollToBottom(), scrollToTop(), setMaximumLineCount(), setupTextArea(), and ~MessageDisplay().
|
private |
Definition at line 168 of file MessageDisplay.h.
Referenced by generateContextMenu(), and initActions().
|
readwrite |
Definition at line 43 of file MessageDisplay.h.
Referenced by setSource().