ImportantMessagesWidget Class Reference

A self-scaling widget that displays messages as separate instances of QLabel. More...

#include <importantmessageswidget.h>

+ Inheritance diagram for ImportantMessagesWidget:

Public Slots

void addMessage (const QString &message)
 Adds a new message without a timestamp. More...
 
void addMessage (const QString &message, const QDateTime &dateTime)
 Adds a message with a timestamp. More...
 
void addMessage (const QString &message, unsigned timestamp)
 Adds a message with a timestamp. More...
 
void clear ()
 Clears all messages from the widghet. More...
 
void removeOldest (int num)
 Removes a number of oldest messages from the widget. More...
 
void removeOneOldest ()
 Will remove one oldest message. More...
 

Public Member Functions

 ImportantMessagesWidget (QWidget *pParent=NULL)
 
unsigned maxMessages () const
 Amount of messages that can be displayed in the widget at the same time. More...
 
void setMaxMessages (unsigned num)
 

Detailed Description

A self-scaling widget that displays messages as separate instances of QLabel.

This widget adds new messages by wrapping them in a QLabel widgets and inserting those widgets into a vertical layout. Number of QLabel widgets is limited by _maxMessages field. Old messages will be removed once their time of life exceeds MAX_MSG_KEEP_TIME_SEC . Widget will auto-hide and auto-show

Definition at line 27 of file importantmessageswidget.h.

Member Function Documentation

void ImportantMessagesWidget::addMessage ( const QString &  message)
slot

Adds a new message without a timestamp.

Definition at line 51 of file importantmessageswidget.cpp.

void ImportantMessagesWidget::addMessage ( const QString &  message,
const QDateTime &  dateTime 
)
slot

Adds a message with a timestamp.

Parameters
messageMessage to add.
timestampQDateTime object representing time.

Definition at line 56 of file importantmessageswidget.cpp.

void ImportantMessagesWidget::addMessage ( const QString &  message,
unsigned  timestamp 
)
slot

Adds a message with a timestamp.

Parameters
messageMessage to add.
timestampTime in seconds since the epoch.

Definition at line 86 of file importantmessageswidget.cpp.

void ImportantMessagesWidget::clear ( )
slot

Clears all messages from the widghet.

Widget will shrink itself in a way that will make it invisible.

Definition at line 91 of file importantmessageswidget.cpp.

unsigned ImportantMessagesWidget::maxMessages ( ) const

Amount of messages that can be displayed in the widget at the same time.

Definition at line 148 of file importantmessageswidget.cpp.

void ImportantMessagesWidget::removeOldest ( int  num)
slot

Removes a number of oldest messages from the widget.

Widget will shrink with each message removed.

Parameters
numAmount of messages to remove. If higher than the actual count of messages, will work the same as clear().

Definition at line 119 of file importantmessageswidget.cpp.

void ImportantMessagesWidget::removeOneOldest ( )
slot

Will remove one oldest message.

Definition at line 134 of file importantmessageswidget.cpp.


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