80 lines
1.5 KiB
C++
Executable File
80 lines
1.5 KiB
C++
Executable File
/**
|
|
* @RDE_HEADER@
|
|
* The MessageModel class handles message related data
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
* Created by Hannes Fritsche, SLSE, 2017-09-06
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <LtsWidgets/lts_abstract_table_model.h>
|
|
#include <QDateTime>
|
|
|
|
class QWebSocket;
|
|
|
|
struct MessageInfo
|
|
{
|
|
QDateTime time;
|
|
int32_t idVal;
|
|
QString direction;
|
|
QString type;
|
|
QString uuid;
|
|
QString data;
|
|
|
|
MessageInfo(int32_t id, const QString &direction, const QString &type, const QString &uuid, const QString &data)
|
|
: time(QDateTime::currentDateTime())
|
|
, idVal(id)
|
|
, direction(direction)
|
|
, type(type)
|
|
, uuid(uuid)
|
|
, data(data)
|
|
{}
|
|
|
|
MessageInfo()
|
|
: time(QDateTime::currentDateTime())
|
|
, idVal(-1)
|
|
, direction(QLatin1String("-"))
|
|
, type(QLatin1String("-"))
|
|
, uuid(QLatin1String("-"))
|
|
, data(QLatin1String("-"))
|
|
{}
|
|
|
|
int32_t id() const { return idVal; }
|
|
};
|
|
|
|
class MessageModel
|
|
: public LtsWidgets::LtsAbstractTableModel<MessageInfo>
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
enum MessageDirection
|
|
{
|
|
TO_PROXY,
|
|
FROM_PROXY
|
|
};
|
|
|
|
enum Column
|
|
{
|
|
TIME,
|
|
DIRECTION,
|
|
TYPE,
|
|
UUID,
|
|
DATA
|
|
};
|
|
|
|
MessageModel(QObject *parent = nullptr);
|
|
|
|
void addMessage(MessageDirection direction, const QString &message);
|
|
void addMessage(MessageDirection direction, const QString &type, const QString &uuid, const QString &data);
|
|
|
|
QVariant data(const QModelIndex &index, int role) const override final;
|
|
|
|
private: // methods
|
|
QString toString(MessageDirection direction) const;
|
|
|
|
public:
|
|
};
|
|
|