2020-10-18 15:08:12 +02:00
|
|
|
#ifndef LEDDISPLAYTEXTMODEL_H
|
|
|
|
#define LEDDISPLAYTEXTMODEL_H
|
2020-10-11 21:01:21 +02:00
|
|
|
|
|
|
|
#include <QAbstractListModel>
|
|
|
|
#include <QObject>
|
|
|
|
#include <QColor>
|
|
|
|
#include <QDebug>
|
|
|
|
|
2020-10-18 15:08:12 +02:00
|
|
|
class LedDisplayTextModel : public QAbstractListModel
|
2020-10-11 21:01:21 +02:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
2020-10-14 23:54:12 +02:00
|
|
|
Q_PROPERTY(int rowCount READ rowCount NOTIFY rowCountChanged)
|
|
|
|
Q_PROPERTY(int maximumTextSets READ getMaximumTextSets NOTIFY maximumTextSetsChanged)
|
|
|
|
|
2020-10-11 21:01:21 +02:00
|
|
|
public:
|
2020-10-18 15:08:12 +02:00
|
|
|
friend class LedDisplayBackend;
|
2020-10-11 21:01:21 +02:00
|
|
|
|
2020-10-18 15:08:12 +02:00
|
|
|
enum LedDisplayTextModelRole {
|
2020-10-11 21:01:21 +02:00
|
|
|
TextRole = Qt::DisplayRole,
|
|
|
|
ActiveRole,
|
|
|
|
RuntimeRole,
|
|
|
|
ColorRole,
|
|
|
|
AlignmentRole,
|
|
|
|
ScrollRole,
|
2020-10-12 14:13:52 +02:00
|
|
|
ScrollSpeedRole,
|
|
|
|
ScrollCountRole,
|
2020-10-14 23:54:12 +02:00
|
|
|
IndexRole,
|
2020-10-18 15:08:12 +02:00
|
|
|
LedDisplayTextModelRoleCount
|
2020-10-11 21:01:21 +02:00
|
|
|
};
|
2020-10-18 15:08:12 +02:00
|
|
|
Q_ENUM(LedDisplayTextModelRole)
|
2020-10-13 17:00:25 +02:00
|
|
|
|
2020-10-14 23:54:12 +02:00
|
|
|
enum OmobiDisplayTextAlignment
|
|
|
|
{
|
|
|
|
AlignLeft,
|
|
|
|
AlignCenter,
|
|
|
|
AlignRignt
|
|
|
|
};
|
2020-10-13 17:00:25 +02:00
|
|
|
|
2020-10-14 23:54:12 +02:00
|
|
|
Q_INVOKABLE int rowCount(const QModelIndex & = QModelIndex()) const;
|
2020-10-11 21:01:21 +02:00
|
|
|
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
|
2020-10-14 23:54:12 +02:00
|
|
|
QVariant data(int i, int role = Qt::DisplayRole) const;
|
2020-10-11 21:01:21 +02:00
|
|
|
QHash<int, QByteArray> roleNames() const;
|
|
|
|
|
|
|
|
Q_INVOKABLE void append(
|
|
|
|
QString text,
|
|
|
|
bool active,
|
|
|
|
unsigned int runtime,
|
|
|
|
QString color,
|
|
|
|
QString alignment,
|
|
|
|
bool scroll,
|
2020-10-12 14:13:52 +02:00
|
|
|
unsigned int scrollSpeed,
|
2020-10-13 01:58:14 +02:00
|
|
|
unsigned int scrollCount
|
2020-10-11 21:01:21 +02:00
|
|
|
);
|
|
|
|
void append(const QMap<int, QVariant> &roles);
|
|
|
|
|
|
|
|
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
|
|
|
|
|
|
|
|
Q_INVOKABLE void remove(int row);
|
|
|
|
|
2020-10-14 23:54:12 +02:00
|
|
|
Q_INVOKABLE int getMaximumTextSets();
|
|
|
|
|
2020-10-11 21:01:21 +02:00
|
|
|
protected:
|
2020-10-18 15:08:12 +02:00
|
|
|
LedDisplayTextModel(QObject* parent = nullptr);
|
2020-10-11 21:01:21 +02:00
|
|
|
|
2020-10-13 01:58:14 +02:00
|
|
|
bool setTexts(QList<QMap<int, QVariant>> json);
|
|
|
|
QList<QMap<int, QVariant>> getTexts();
|
2020-10-14 23:54:12 +02:00
|
|
|
QMap<int, QVariant> getText(const QModelIndex &index);
|
2020-10-11 21:01:21 +02:00
|
|
|
|
|
|
|
void clear();
|
|
|
|
|
|
|
|
private:
|
|
|
|
QList<QMap<int, QVariant>> texts;
|
2020-10-14 23:54:12 +02:00
|
|
|
|
|
|
|
int maximumTextSets;
|
|
|
|
int maximumTextLength;
|
|
|
|
|
2020-10-18 15:08:12 +02:00
|
|
|
const QMap<LedDisplayTextModelRole, QVariant::Type> roleDataTypes = {
|
2020-10-14 23:54:12 +02:00
|
|
|
{TextRole, QVariant::String},
|
|
|
|
{ActiveRole, QVariant::Bool},
|
|
|
|
{RuntimeRole, QVariant::Int},
|
|
|
|
{ColorRole, QVariant::String},
|
|
|
|
{AlignmentRole, QVariant::Int},
|
|
|
|
{ScrollRole, QVariant::Bool},
|
|
|
|
{ScrollSpeedRole, QVariant::Int},
|
|
|
|
{ScrollCountRole, QVariant::Int},
|
|
|
|
{IndexRole, QVariant::Int}
|
|
|
|
};
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void rowCountChanged();
|
|
|
|
void maximumTextSetsChanged();
|
2020-10-11 21:01:21 +02:00
|
|
|
};
|
|
|
|
|
2020-10-18 15:08:12 +02:00
|
|
|
#endif // LEDDISPLAYTEXTMODEL_H
|