QtPdCom  1.5.2
MessageModel Class Reference

List of Messages. More...

#include <MessageModel.h>

Inheritance diagram for MessageModel:
Collaboration diagram for MessageModel:

Classes

struct  Exception
 Exception type. More...
class  Impl

Public Types

enum  Columns { TextColumn = 0 , TimeOccurredColumn , TimeResetColumn }
enum  Roles { DecorationPathRole = Qt::UserRole + 1 , TimeStringRole = Qt::UserRole + 2 , ResetTimeStringRole = Qt::UserRole + 3 , MessageTypeRole = Qt::UserRole + 4 }

Signals

void currentMessage (const QtPdCom::Message *message)
 Emitted, when a new message gets active.
void anyMessage (const QtPdCom::Message *message)
 Emitted, when a new message gets active.

Public Member Functions

 MessageModel (QObject *parent=nullptr)
 Constructor.
 ~MessageModel ()
 Destructor.
Q_INVOKABLE void load (const QString &path, const QString &lang=QString(), const QString &pathPrefix=QString())
 Loads messages from an Xml file.
Q_INVOKABLE void clear ()
 Clears the messages.
void setRowLimit (int)
 Sets the maximum number of rows to fetch.
int getRowLimit () const
 Gets the maxium number of rows to fetch.
void connect (QtPdCom::Process *)
 Connects messages to the given process.
QtPdCom::ProcessgetProcess () const
Q_INVOKABLE void translate (const QString &)
 Sets a new language and notifies views.
void setIcon (Message::Type, const QIcon &)
 Sets an icon for a specific message type.
const QIcon & getIcon (Message::Type) const
Q_INVOKABLE void setIconPath (Message::Type, const QString &)
 Sets the path (url) to an icon for a specific message type.
QVariantMap getIconPathMap () const
void setIconPathMap (QVariantMap map)
virtual int rowCount (const QModelIndex &) const override
 Implements the model interface.
virtual int columnCount (const QModelIndex &) const override
 Implements the model interface.
virtual QVariant data (const QModelIndex &, int) const override
 Implements the Model interface.
virtual QVariant headerData (int, Qt::Orientation, int) const override
 Implements the Model interface.
virtual Qt::ItemFlags flags (const QModelIndex &) const override
 Implements the Model interface.
virtual QHash< int, QByteArray > roleNames () const override
 Additional Rolename for decoration for use in QML views.
virtual bool canFetchMore (const QModelIndex &) const override
virtual void fetchMore (const QModelIndex &) override

Protected Member Functions

bool event (QEvent *) override
 Event handler.

Properties

int rowLimit
QtPdCom::Processprocess
QVariantMap iconPaths
 Define Icon Paths for decoration role.

Private Attributes

class Q_DECL_HIDDEN Impl
std::unique_ptr< Implimpl

Friends

class Message::Impl

Detailed Description

List of Messages.

See also
Message.

Member Enumeration Documentation

◆ Columns

Enumerator
TextColumn 
TimeOccurredColumn 
TimeResetColumn 

◆ Roles

Enumerator
DecorationPathRole 
TimeStringRole 
ResetTimeStringRole 
MessageTypeRole 

Constructor & Destructor Documentation

◆ MessageModel()

MessageModel::MessageModel ( QObject * parent = nullptr)

Constructor.

◆ ~MessageModel()

Destructor.

Member Function Documentation

◆ anyMessage

void QtPdCom::MessageModel::anyMessage ( const QtPdCom::Message * message)
signal

Emitted, when a new message gets active.

This signal announces any new arriving message.

Parameters
messageThe message that got active.

◆ canFetchMore()

bool MessageModel::canFetchMore ( const QModelIndex & parent) const
overridevirtual

◆ clear()

Clears the messages.

◆ columnCount()

int MessageModel::columnCount ( const QModelIndex & index) const
overridevirtual

Implements the model interface.

Returns
Number of columns.

◆ connect()

Connects messages to the given process.

Parameters
processPdCom process.

◆ currentMessage

Emitted, when a new message gets active.

This signal announces the most recent message. It is only emitted for the first message getting active, or for a subsequent message with a higher type.

In QML, a currentMessage property is available.

Parameters
messageThe message that got active. The signal is emitted with message being NULL, if no messages are active any more.

◆ data()

QVariant MessageModel::data ( const QModelIndex & index,
int role ) const
overridevirtual

Implements the Model interface.

◆ event()

bool MessageModel::event ( QEvent * event)
overrideprotected

Event handler.

Parameters
eventPaint event flags.

◆ fetchMore()

void MessageModel::fetchMore ( const QModelIndex & parent)
overridevirtual

◆ flags()

Qt::ItemFlags MessageModel::flags ( const QModelIndex & index) const
overridevirtual

Implements the Model interface.

◆ getIcon()

const QIcon & MessageModel::getIcon ( Message::Type type) const
Returns
Icon for given message type.

◆ getIconPathMap()

◆ getProcess()

◆ getRowLimit()

Gets the maxium number of rows to fetch.

◆ headerData()

QVariant MessageModel::headerData ( int section,
Qt::Orientation o,
int role ) const
overridevirtual

Implements the Model interface.

◆ load()

void MessageModel::load ( const QString & path,
const QString & lang = QString(),
const QString & pathPrefix = QString() )

Loads messages from an Xml file.

Parameters
pathPath to Xml file.
langLanguage identifier.
pathPrefixPrefix to path (with leading /).

◆ roleNames()

QHash< int, QByteArray > MessageModel::roleNames ( ) const
overridevirtual

Additional Rolename for decoration for use in QML views.

◆ rowCount()

int MessageModel::rowCount ( const QModelIndex & index) const
overridevirtual

Implements the model interface.

Returns
Number of active messages.

◆ setIcon()

void MessageModel::setIcon ( Message::Type type,
const QIcon & icon )

Sets an icon for a specific message type.

◆ setIconPath()

void MessageModel::setIconPath ( Message::Type type,
const QString & iconPath )

Sets the path (url) to an icon for a specific message type.

If the model is used with QML views this is the only way to store the icon information.

◆ setIconPathMap()

void QtPdCom::MessageModel::setIconPathMap ( QVariantMap map)

◆ setRowLimit()

void MessageModel::setRowLimit ( int limit)

Sets the maximum number of rows to fetch.

Parameters
limitMaximum number of rows.

◆ translate()

void MessageModel::translate ( const QString & lang)

Sets a new language and notifies views.

◆ Message::Impl

friend class Message::Impl
friend

Member Data Documentation

◆ Impl

class Q_DECL_HIDDEN QtPdCom::MessageModel::Impl
private

◆ impl

std::unique_ptr<Impl> QtPdCom::MessageModel::impl
private

Property Documentation

◆ iconPaths

QVariantMap QtPdCom::MessageModel::iconPaths
readwrite

Define Icon Paths for decoration role.

This property is intended to be used from QML. Use the values of Message::Type as string for keys.

"Critical": ":/images/dialog-error.svg",
"Error": ":/images/dialog-error.svg",
"Information": ":/images/dialog-information.svg",
"Warning": ":/images/dialog-warning.svg"
}
}
MessageModel(QObject *parent=nullptr)
Constructor.
Definition MessageModel.cpp:41
QVariantMap iconPaths
Define Icon Paths for decoration role.
Definition MessageModel.h:63

◆ process

◆ rowLimit


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