62 lines
1.5 KiB
C++
62 lines
1.5 KiB
C++
#ifndef OMOBIDISPLAYTEXTMODEL_H
|
|
#define OMOBIDISPLAYTEXTMODEL_H
|
|
|
|
#include <QAbstractListModel>
|
|
#include <QObject>
|
|
#include <QColor>
|
|
#include <QDebug>
|
|
|
|
|
|
class OmobiDisplayTextModel : public QAbstractListModel
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
friend class OmobiDisplayBackend;
|
|
|
|
enum QBluetoothLeUartDeviceModelRole {
|
|
TextRole = Qt::DisplayRole,
|
|
ActiveRole,
|
|
RuntimeRole,
|
|
ColorRole,
|
|
AlignmentRole,
|
|
ScrollRole,
|
|
ScrollSpeedRole,
|
|
ScrollCountRole,
|
|
BrightnessRole
|
|
};
|
|
Q_ENUM(QBluetoothLeUartDeviceModelRole)
|
|
|
|
int rowCount(const QModelIndex & = QModelIndex()) const;
|
|
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
|
|
QHash<int, QByteArray> roleNames() const;
|
|
|
|
Q_INVOKABLE void append(
|
|
QString text,
|
|
bool active,
|
|
unsigned int runtime,
|
|
QString color,
|
|
QString alignment,
|
|
bool scroll,
|
|
unsigned int scrollSpeed,
|
|
unsigned int scrollCount,
|
|
unsigned int brightness
|
|
);
|
|
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);
|
|
|
|
protected:
|
|
OmobiDisplayTextModel(QObject* parent = nullptr);
|
|
|
|
void reloadFromJson(QString json);
|
|
QString getAsJson();
|
|
|
|
void clear();
|
|
|
|
private:
|
|
QList<QMap<int, QVariant>> texts;
|
|
};
|
|
|
|
#endif // OMOBIDISPLAYTEXTMODEL_H
|