ImportantMessagesWidget Class Reference

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

#include <importantmessageswidget.h>

+ Inheritance diagram for ImportantMessagesWidget:

Classes

class  Handler
 

Public Slots

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

Public Member Functions

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

Friends

class Handler
 

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 45 of file importantmessageswidget.h.

Member Function Documentation

QSharedPointer< ImportantMessagesWidget::Handler > ImportantMessagesWidget::addMessage ( const QString &  message)
slot

Adds a new message without a timestamp.

Returns
A Handler to this message.

Definition at line 95 of file importantmessageswidget.cpp.

QSharedPointer< ImportantMessagesWidget::Handler > ImportantMessagesWidget::addMessage ( const QString &  message,
const QDateTime &  dateTime 
)
slot

Adds a message with a timestamp.

Parameters
messageMessage to add.
timestampQDateTime object representing time.
Returns
A Handler to this message.

Definition at line 101 of file importantmessageswidget.cpp.

QSharedPointer< ImportantMessagesWidget::Handler > ImportantMessagesWidget::addMessage ( const QString &  message,
unsigned  timestamp 
)
slot

Adds a message with a timestamp.

Parameters
messageMessage to add.
timestampTime in seconds since the epoch.
Returns
A Handler to this message.

Definition at line 132 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 142 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 208 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 168 of file importantmessageswidget.cpp.

void ImportantMessagesWidget::removeOneOldest ( )
slot

Will remove one oldest message.

Definition at line 179 of file importantmessageswidget.cpp.


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