Version: 9.12.0
LogWindow Class Reference

Widget, displaying log messages. More...

#include <LogWindow.h>

Inheritance diagram for LogWindow:
Inheritance graph

Public Types

enum  {
  CopyId = 0x01 , ClearId = 0x02 , SelectAllId = 0x04 , SaveToFileId = 0x08 ,
  All = CopyId | ClearId | SelectAllId | SaveToFileId
}
 Context popup menu actions flags. More...
 
enum  {
  DisplayNormal = 0x00 , DisplayDate = 0x01 , DisplayTime = 0x02 , DisplaySeparator = 0x04 ,
  DisplayNoColor = 0x08 , DisplayDateTime = DisplayDate | DisplayTime
}
 Display messages flags. More...
 

Public Member Functions

 LogWindow (QWidget *)
 Constructor. More...
 
virtual ~LogWindow ()
 Destructor. More...
 
virtual QString popupClientType () const
 Get popup client symbolic name, used in popup menu management system. More...
 
virtual void contextMenuPopup (QMenu *)
 Create the context popup menu. More...
 
virtual bool eventFilter (QObject *, QEvent *)
 Custom event handler. More...
 
QString banner () const
 Get current banner (text shown when log window is empty). More...
 
QString separator () const
 Get current separator (text which is printed between messages). More...
 
void setBanner (const QString &)
 Set current banner (text shown when log window is empty). More...
 
void setSeparator (const QString &)
 
void putMessage (const QString &, const int=DisplayNormal)
 Put new message to the log window. More...
 
virtual void putMessage (const QString &, const QColor &, const int=DisplayNormal)
 Put new message to the log window. More...
 
void clear (const bool=false)
 Clear message log. More...
 
bool saveLog (const QString &)
 Save messages log to the file. More...
 
void setMenuActions (const int)
 Set actions to be visible in the context popup menu. More...
 
int menuActions () const
 Get menu actions which are currently visible in the context popup menu. More...
 
void handleQtMessages (bool)
 Activate/deactivate Qt messages handling. More...
 
- Public Member Functions inherited from SUIT_PopupClient
 SUIT_PopupClient ()
 
virtual ~SUIT_PopupClient ()
 
bool connectPopupRequest (QObject *reciever, const char *slot)
 
bool disconnectPopupRequest (QObject *reciever, const char *slot)
 
- Public Member Functions inherited from QtxMsgHandlerCallback
 QtxMsgHandlerCallback (bool=true)
 
virtual ~QtxMsgHandlerCallback ()
 

Protected Slots

void onSaveToFile ()
 Called when user selects "Save To File" command in the popup menu. More...
 
void onSelectAll ()
 Called when user selects "Select all" command in the popup menu. More...
 
void onClear ()
 Called when user click "Clear" command in the popup menu. More...
 
void onCopy ()
 Called when user click "Copy" command in the popup menu. More...
 

Private Member Functions

void append (const QString text)
 Append text to the log window. More...
 
void createActions ()
 Create context popup menu actions. More...
 
void updateActions ()
 Update menu actions. More...
 
void qtMessage (QtMsgType, const QMessageLogContext &, const QString &)
 Handle Qt messages. More...
 

Private Attributes

QTextEdit * myView
 internal view window More...
 
QString myBanner
 current banner More...
 
QStringList myHistory
 messages history More...
 
QString mySeparator
 current separator More...
 
int myBannerSize
 current banner's size More...
 
QMap< int, QAction * > myActions
 popup menu actions More...
 

Additional Inherited Members

- Protected Member Functions inherited from SUIT_PopupClient
void contextMenuRequest (QContextMenuEvent *e)
 
- Protected Member Functions inherited from QtxMsgHandlerCallback
void activate ()
 
void deactivate ()
 

Detailed Description

Widget, displaying log messages.

The log messages window provides operations like:

  • show messages
  • display timestamps at the message beginning
  • color messages according to their purposes (e.g., errors/warning)
  • clear log output
  • copy messages to clipvoard
  • save message log to to the text file

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

Context popup menu actions flags.

Enumerator
CopyId 

"Copy" menu action

ClearId 

"Clear" menu action

SelectAllId 

"Select All" menu action

SaveToFileId 

"Save To File" menu action

All 

all menu actions

◆ anonymous enum

anonymous enum

Display messages flags.

Enumerator
DisplayNormal 

do not display extra data

DisplayDate 

display message date

DisplayTime 

display message time

DisplaySeparator 

display separator between messages

DisplayNoColor 

display non-colored message

DisplayDateTime 

display date & time

Constructor & Destructor Documentation

◆ LogWindow()

LogWindow::LogWindow ( QWidget parent)

Constructor.

Creates new messages log window widget.

Parameters
parentparent widget

References clear(), createActions(), DEFAULT_SEPARATOR, main(), mySeparator, myView, SUIT_Session::resourceMgr(), SUIT_Session::session(), Qtx::stringToFont(), and QtxResourceMgr::stringValue().

◆ ~LogWindow()

LogWindow::~LogWindow ( )
virtual

Destructor.

Does nothing for the moment.

Member Function Documentation

◆ append()

void LogWindow::append ( const QString  text)
private

Append text to the log window.

Parameters
textText being added.

References myView.

◆ banner()

QString LogWindow::banner ( ) const

Get current banner (text shown when log window is empty).

Returns
string representing the current banner

References myView.

◆ clear()

void LogWindow::clear ( const bool  clearHistory = false)

Clear message log.

Parameters
clearHistoryif True, clear also the messages history

References myHistory, and myView.

◆ contextMenuPopup()

void LogWindow::contextMenuPopup ( QMenu popup)
virtual

Create the context popup menu.

Fill in the popup menu with the commands.

Parameters
menucontext popup menu

Reimplemented from SUIT_PopupClient.

References ClearId, CopyId, myActions, SaveToFileId, SelectAllId, Qtx::simplifySeparators(), and updateActions().

◆ createActions()

void LogWindow::createActions ( )
private

Create context popup menu actions.

References ClearId, CopyId, myActions, onClear(), onCopy(), onSaveToFile(), onSelectAll(), SaveToFileId, and SelectAllId.

◆ eventFilter()

bool LogWindow::eventFilter ( QObject o,
QEvent e 
)
virtual

Custom event handler.

Process context popup menu request event.

Parameters
oobject
eevent
Returns
True if the event is processed and further processing should be stopped

References SUIT_PopupClient::contextMenuRequest(), and myView.

◆ handleQtMessages()

void LogWindow::handleQtMessages ( bool  on)

Activate/deactivate Qt messages handling.

Parameters
onIf true, Qt messags are handled by log window.

References QtxMsgHandlerCallback::activate(), and QtxMsgHandlerCallback::deactivate().

◆ menuActions()

int LogWindow::menuActions ( ) const

Get menu actions which are currently visible in the context popup menu.

Returns
ORed together actions flags
See also
setMenuActions()

References ClearId, CopyId, myActions, SaveToFileId, and SelectAllId.

◆ onClear

void LogWindow::onClear ( )
protectedslot

Called when user click "Clear" command in the popup menu.

References clear().

◆ onCopy

void LogWindow::onCopy ( )
protectedslot

Called when user click "Copy" command in the popup menu.

References myView.

◆ onSaveToFile

void LogWindow::onSaveToFile ( )
protectedslot

Called when user selects "Save To File" command in the popup menu.

References SUIT_Session::activeApplication(), SUIT_MessageBox::critical(), SUIT_Application::getFileName(), saveLog(), and SUIT_Session::session().

◆ onSelectAll

void LogWindow::onSelectAll ( )
protectedslot

Called when user selects "Select all" command in the popup menu.

References myView.

◆ popupClientType()

QString LogWindow::popupClientType ( ) const
inlinevirtual

Get popup client symbolic name, used in popup menu management system.

Returns
symbolic name

Implements SUIT_PopupClient.

◆ putMessage() [1/2]

void LogWindow::putMessage ( const QString &  message,
const int  flags = DisplayNormal 
)

Put new message to the log window.

Parameters
messagetext of the message
flagsORed flags which define how the message should be printed

◆ putMessage() [2/2]

void LogWindow::putMessage ( const QString &  message,
const QColor &  color,
const int  flags = DisplayNormal 
)
virtual

Put new message to the log window.

Parameters
messagetext of the message
colortext color of the message
flagsORed flags which define how the message should be printed

References append(), OCCViewer::color(), DisplayDate, DisplayNoColor, DisplaySeparator, DisplayTime, myHistory, mySeparator, and myView.

◆ qtMessage()

void LogWindow::qtMessage ( QtMsgType  type,
const QMessageLogContext &  ,
const QString &  message 
)
privatevirtual

Handle Qt messages.

Parameters
typeQt message type.
contextMessage context.
messageMessage text.

Reimplemented from QtxMsgHandlerCallback.

References OCCViewer::color(), DisplayNormal, and putMessage().

◆ saveLog()

bool LogWindow::saveLog ( const QString &  fileName)

Save messages log to the file.

Parameters
fileNamename of the file
Returns
true on success and false on error

References myHistory.

◆ separator()

QString LogWindow::separator ( ) const

Get current separator (text which is printed between messages).

Returns
string representing the current separator

References mySeparator.

◆ setBanner()

void LogWindow::setBanner ( const QString &  banner)

Set current banner (text shown when log window is empty).

Parameters
bannernew banner

References banner(), and myView.

◆ setMenuActions()

void LogWindow::setMenuActions ( const int  flags)

Set actions to be visible in the context popup menu.

Actions, which IDs are set in flags parameter, will be shown in the context popup menu. Other actions will not be shown.

Parameters
flagsORed together actions flags

References ClearId, CopyId, myActions, SaveToFileId, and SelectAllId.

◆ setSeparator()

void LogWindow::setSeparator ( const QString &  separator)

Set current separator (text which is printed between messages).

Parameters
separatornew separator

References clear(), mySeparator, and separator().

◆ updateActions()

void LogWindow::updateActions ( )
private

Update menu actions.

Update context popup menu action state.

References ClearId, CopyId, myActions, myHistory, myView, SaveToFileId, and SelectAllId.

Member Data Documentation

◆ myActions

QMap<int, QAction*> LogWindow::myActions
private

popup menu actions

◆ myBanner

QString LogWindow::myBanner
private

current banner

◆ myBannerSize

int LogWindow::myBannerSize
private

current banner's size

◆ myHistory

QStringList LogWindow::myHistory
private

messages history

◆ mySeparator

QString LogWindow::mySeparator
private

current separator

◆ myView

QTextEdit* LogWindow::myView
private

internal view window


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