Mantid
Loading...
Searching...
No Matches
Public Slots | Signals | Public Member Functions | Properties | Private Slots | Private Member Functions | Private Attributes | List of all members
MantidQt::MantidWidgets::MessageDisplay Class Reference

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>

Inheritance diagram for MantidQt::MantidWidgets::MessageDisplay:
MantidQt::MantidWidgets::Configurable< MessageDisplaySettings >

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
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ MessageDisplay() [1/3]

MantidQt::MantidWidgets::MessageDisplay::MessageDisplay ( QWidget *  parent = nullptr)

Default constructor with optional parent.

Construct a MessageDisplay with the default font.

Parameters
parentAn optional parent widget

Definition at line 82 of file MessageDisplay.cpp.

◆ MessageDisplay() [2/3]

MantidQt::MantidWidgets::MessageDisplay::MessageDisplay ( const QFont &  font,
QWidget *  parent = nullptr 
)

Constructor accepting a QFont.

Construct a MessageDisplay using the given font.

Parameters
fontA reference to a font object
parentAn optional parent widget

Definition at line 89 of file MessageDisplay.cpp.

References initActions(), initFormats(), and setupTextArea().

◆ MessageDisplay() [3/3]

MantidQt::MantidWidgets::MessageDisplay::MessageDisplay ( const MessageDisplay &  )
delete

◆ ~MessageDisplay()

MantidQt::MantidWidgets::MessageDisplay::~MessageDisplay ( )
override

Destructor.

Definition at line 100 of file MessageDisplay.cpp.

References m_logChannel, and m_textDisplay.

Member Function Documentation

◆ activeScript()

const QString & MantidQt::MantidWidgets::MessageDisplay::activeScript ( ) const
inline

Get the path of the currently active script.

Definition at line 110 of file MessageDisplay.h.

Referenced by shouldBeDisplayed().

◆ append

void MantidQt::MantidWidgets::MessageDisplay::append ( const Message &  msg)
slot

◆ appendDebug

void MantidQt::MantidWidgets::MessageDisplay::appendDebug ( const QString &  text)
slot

Convenience method for appending message at debug level.

Parameters
textThe text string to append at PRIO_DEBUG level

Definition at line 223 of file MessageDisplay.cpp.

References append().

◆ appendError

void MantidQt::MantidWidgets::MessageDisplay::appendError ( const QString &  text)
slot

Convenience method for appending message at error level.

Parameters
textThe text string to append at PRIO_ERROR level

Definition at line 199 of file MessageDisplay.cpp.

References append().

◆ appendFatal

void MantidQt::MantidWidgets::MessageDisplay::appendFatal ( const QString &  text)
slot

Convenience method for appending message at fatal level.

Parameters
textThe text string to append at PRIO_FATAL level

Definition at line 194 of file MessageDisplay.cpp.

References append().

◆ appendInformation

void MantidQt::MantidWidgets::MessageDisplay::appendInformation ( const QString &  text)
slot

Convenience method for appending message at information level.

Parameters
textThe text string to append at PRIO_INFORMATION level

Definition at line 216 of file MessageDisplay.cpp.

References append().

◆ appendNotice

void MantidQt::MantidWidgets::MessageDisplay::appendNotice ( const QString &  text)
slot

Convenience method for appending message at notice level.

Parameters
textThe text string to append at PRIO_NOTICE level

Definition at line 211 of file MessageDisplay.cpp.

References append().

◆ appendPython

void MantidQt::MantidWidgets::MessageDisplay::appendPython ( const QString &  text,
const int &  priority,
const QString &  filePath 
)
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.

Parameters
textThe message to display in the window
priorityThe priority level of the message
filePathThe path of the Python script being executed

Definition at line 255 of file MessageDisplay.cpp.

References append().

◆ appendToHistory()

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.

Parameters
msgThe Message object to append

Definition at line 181 of file MessageDisplay.cpp.

References m_messageHistory, and maximumLineCount().

Referenced by append().

◆ appendWarning

void MantidQt::MantidWidgets::MessageDisplay::appendWarning ( const QString &  text)
slot

Convenience method for appending message at warning level.

Parameters
textThe text string to append at PRIO_WARNING level

Definition at line 204 of file MessageDisplay.cpp.

References append().

◆ attachLoggingChannel()

void MantidQt::MantidWidgets::MessageDisplay::attachLoggingChannel ( int  logLevel = 0)

Attaches the Mantid logging framework.

Starts the ConfigService if required

Parameters
logLevelIf > 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.

◆ captureSettings()

MessageDisplaySettings MantidQt::MantidWidgets::MessageDisplay::captureSettings ( ) const
overridevirtual

Capture current widget state without persistent I/O.

Implements MantidQt::MantidWidgets::Configurable< MessageDisplaySettings >.

Definition at line 68 of file MessageDisplay.cpp.

References maximumLineCount().

◆ clear

void MantidQt::MantidWidgets::MessageDisplay::clear ( )
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().

◆ errorReceived

void MantidQt::MantidWidgets::MessageDisplay::errorReceived ( const QString &  text)
signal

Indicate that a message of error or higher has been received.

Referenced by append().

◆ filePathModified()

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.

Parameters
oldPathThe path of the file being renamed
newPathThe new path of the file

Definition at line 169 of file MessageDisplay.cpp.

References m_messageHistory.

◆ filterMessages()

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().

◆ format()

QTextCharFormat MantidQt::MantidWidgets::MessageDisplay::format ( const Message::Priority  priority) const
private

Return format for given log level.

Parameters
priorityAn enumeration for the log level
Returns
format for given log level

Definition at line 471 of file MessageDisplay.cpp.

References m_formats.

Referenced by append(), and filterMessages().

◆ generateContextMenu()

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().

◆ getHistory()

const QList< Message > & MantidQt::MantidWidgets::MessageDisplay::getHistory ( )
inline

Get the window's message history.

Definition at line 88 of file MessageDisplay.h.

Referenced by filterMessages().

◆ getTextEdit()

QPlainTextEdit * MantidQt::MantidWidgets::MessageDisplay::getTextEdit ( )
inline

Get the window's QPlainTextEdit object.

Definition at line 86 of file MessageDisplay.h.

◆ initActions()

void MantidQt::MantidWidgets::MessageDisplay::initActions ( )
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().

◆ initFormats()

void MantidQt::MantidWidgets::MessageDisplay::initFormats ( )
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().

◆ isScrollbarAtBottom

bool MantidQt::MantidWidgets::MessageDisplay::isScrollbarAtBottom ( ) const
slot

Returns true if scroll-bar is at the bottom of widget.

Returns
True if scroll bar is at bottom, false otherwise

Definition at line 289 of file MessageDisplay.cpp.

References m_textDisplay.

◆ maximumLineCount

int MantidQt::MantidWidgets::MessageDisplay::maximumLineCount ( ) const
privateslot

Return the maximum number of lines displayed.

Returns
The maximum number of lines displayed in the text edit

Definition at line 352 of file MessageDisplay.cpp.

References m_textDisplay.

Referenced by appendToHistory(), captureSettings(), and setScrollbackLimit().

◆ moveCursorToEnd

QTextCursor MantidQt::MantidWidgets::MessageDisplay::moveCursorToEnd ( )
slot

Move the text cursor to after the last character.

Returns
The cursor at the end of the text

Definition at line 279 of file MessageDisplay.cpp.

References m_textDisplay.

Referenced by append(), and filterMessages().

◆ operator=()

MessageDisplay & MantidQt::MantidWidgets::MessageDisplay::operator= ( const MessageDisplay &  )
delete

◆ readSettings()

MessageDisplaySettings MantidQt::MantidWidgets::MessageDisplay::readSettings ( const QSettings &  storage) const

Query persistent storage without changing the widget.

Definition at line 57 of file MessageDisplay.cpp.

◆ replace

void MantidQt::MantidWidgets::MessageDisplay::replace ( const Message &  msg)
slot

Replace the display text with the given contents.

Parameters
msgReplace the current contents with this message

Definition at line 263 of file MessageDisplay.cpp.

References append(), clear(), and MantidQt::MantidWidgets::Message::text().

◆ restoreSettings()

void MantidQt::MantidWidgets::MessageDisplay::restoreSettings ( const MessageDisplaySettings &  settings)
overridevirtual

◆ saveSettings()

void MantidQt::MantidWidgets::MessageDisplay::saveSettings ( QSettings &  storage,
const MessageDisplaySettings &  settings 
) const

◆ scrollToBottom

void MantidQt::MantidWidgets::MessageDisplay::scrollToBottom ( )
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.

◆ scrollToTop

void MantidQt::MantidWidgets::MessageDisplay::scrollToTop ( )
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.

◆ setActiveScript()

void MantidQt::MantidWidgets::MessageDisplay::setActiveScript ( const QString &  scriptPath)
inline

Set the path of the currently active script.

Definition at line 112 of file MessageDisplay.h.

◆ setLogLevel

void MantidQt::MantidWidgets::MessageDisplay::setLogLevel ( int  priority)
privateslot

Set the global logging level.

Definition at line 331 of file MessageDisplay.cpp.

Referenced by initActions().

◆ setMaximumLineCount

void MantidQt::MantidWidgets::MessageDisplay::setMaximumLineCount ( int  count)
privateslot

Set the maximum number of lines displayed.

The maximum number of lines that are to be displayed in the text edit.

Parameters
countThe 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().

◆ setScrollbackLimit

void MantidQt::MantidWidgets::MessageDisplay::setScrollbackLimit ( )
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().

◆ setShowActiveScriptOutput()

void MantidQt::MantidWidgets::MessageDisplay::setShowActiveScriptOutput ( const bool &  show)
inline

Get whether only active script output should be displayed.

Definition at line 108 of file MessageDisplay.h.

◆ setShowAllScriptOutput()

void MantidQt::MantidWidgets::MessageDisplay::setShowAllScriptOutput ( const bool &  show)
inline

Set whether all script output should be displayed.

Definition at line 104 of file MessageDisplay.h.

◆ setShowFrameworkOutput()

void MantidQt::MantidWidgets::MessageDisplay::setShowFrameworkOutput ( const bool &  show)
inline

Set whether framework output should be displayed.

Definition at line 100 of file MessageDisplay.h.

◆ setSource()

void MantidQt::MantidWidgets::MessageDisplay::setSource ( const QString &  source)

If set, only Mantid log messages from this source are emitted.

Parameters
sourceA 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.

◆ setupTextArea()

void MantidQt::MantidWidgets::MessageDisplay::setupTextArea ( const QFont &  font)
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.

Parameters
fontA 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().

◆ shouldBeDisplayed()

bool MantidQt::MantidWidgets::MessageDisplay::shouldBeDisplayed ( const Message &  msg)
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.

Parameters
msgA 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().

◆ showActiveScriptOutput()

bool MantidQt::MantidWidgets::MessageDisplay::showActiveScriptOutput ( ) const
inline

Get whether only active script output is being displayed.

Definition at line 106 of file MessageDisplay.h.

Referenced by shouldBeDisplayed().

◆ showAllScriptOutput()

bool MantidQt::MantidWidgets::MessageDisplay::showAllScriptOutput ( ) const
inline

Get whether all script output is being displayed.

Definition at line 102 of file MessageDisplay.h.

Referenced by shouldBeDisplayed().

◆ showContextMenu

void MantidQt::MantidWidgets::MessageDisplay::showContextMenu ( const QPoint &  event)
privateslot

Provide a custom context menu.

Definition at line 321 of file MessageDisplay.cpp.

References generateContextMenu().

Referenced by setupTextArea().

◆ showFrameworkOutput()

bool MantidQt::MantidWidgets::MessageDisplay::showFrameworkOutput ( ) const
inline

Get whether framework output is being displayed.

Definition at line 98 of file MessageDisplay.h.

Referenced by shouldBeDisplayed().

◆ source()

const QString & MantidQt::MantidWidgets::MessageDisplay::source ( ) const
inline

Get the current source are emitted.

Definition at line 84 of file MessageDisplay.h.

◆ warningReceived

void MantidQt::MantidWidgets::MessageDisplay::warningReceived ( const QString &  text)
signal

Indicate that a message of warning or higher has been received.

Referenced by append().

Member Data Documentation

◆ m_activeScript

QString MantidQt::MantidWidgets::MessageDisplay::m_activeScript
private

Definition at line 190 of file MessageDisplay.h.

◆ m_debug

QAction * MantidQt::MantidWidgets::MessageDisplay::m_debug
private

Definition at line 185 of file MessageDisplay.h.

Referenced by generateContextMenu(), and initActions().

◆ m_error

QAction* MantidQt::MantidWidgets::MessageDisplay::m_error
private

Log level actions.

Definition at line 185 of file MessageDisplay.h.

Referenced by generateContextMenu(), and initActions().

◆ m_formats

QHash<Message::Priority, QTextCharFormat> MantidQt::MantidWidgets::MessageDisplay::m_formats
private

Map priority to text formatting.

Definition at line 179 of file MessageDisplay.h.

Referenced by format(), and initFormats().

◆ m_information

QAction * MantidQt::MantidWidgets::MessageDisplay::m_information
private

Definition at line 185 of file MessageDisplay.h.

Referenced by generateContextMenu(), and initActions().

◆ m_logChannel

QtSignalChannel* MantidQt::MantidWidgets::MessageDisplay::m_logChannel
private

A reference to the log channel.

Definition at line 175 of file MessageDisplay.h.

Referenced by attachLoggingChannel(), setSource(), and ~MessageDisplay().

◆ m_logLevelMapping

QSignalMapper* MantidQt::MantidWidgets::MessageDisplay::m_logLevelMapping
private

Map action signal to log level parameter.

Definition at line 183 of file MessageDisplay.h.

Referenced by initActions().

◆ m_loglevels

QActionGroup* MantidQt::MantidWidgets::MessageDisplay::m_loglevels
private

Mutually exclusive log actions.

Definition at line 181 of file MessageDisplay.h.

Referenced by initActions().

◆ m_messageHistory

QList<Message> MantidQt::MantidWidgets::MessageDisplay::m_messageHistory
private

Keep track of the message history.

Definition at line 187 of file MessageDisplay.h.

Referenced by appendToHistory(), clear(), and filePathModified().

◆ m_notice

QAction * MantidQt::MantidWidgets::MessageDisplay::m_notice
private

Definition at line 185 of file MessageDisplay.h.

Referenced by generateContextMenu(), and initActions().

◆ m_showActiveScriptOutput

bool MantidQt::MantidWidgets::MessageDisplay::m_showActiveScriptOutput {false}
private

Definition at line 189 of file MessageDisplay.h.

◆ m_showAllScriptOutput

bool MantidQt::MantidWidgets::MessageDisplay::m_showAllScriptOutput {true}
private

Definition at line 189 of file MessageDisplay.h.

◆ m_showFrameworkOutput

bool MantidQt::MantidWidgets::MessageDisplay::m_showFrameworkOutput {true}
private

Bools to dictate whether to print certain types of messages.

Definition at line 189 of file MessageDisplay.h.

◆ m_textDisplay

QPlainTextEdit* MantidQt::MantidWidgets::MessageDisplay::m_textDisplay
private

◆ m_warning

QAction * MantidQt::MantidWidgets::MessageDisplay::m_warning
private

Definition at line 185 of file MessageDisplay.h.

Referenced by generateContextMenu(), and initActions().

Property Documentation

◆ source

QString MantidQt::MantidWidgets::MessageDisplay::source
readwrite

Definition at line 57 of file MessageDisplay.h.

Referenced by setSource().


The documentation for this class was generated from the following files: