-
Notifications
You must be signed in to change notification settings - Fork 142
/
LVGLStyleModel.h
80 lines (55 loc) · 1.98 KB
/
LVGLStyleModel.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#ifndef LVGLSTYLEMODEL_H
#define LVGLSTYLEMODEL_H
#include <QAbstractItemModel>
#include <QStyledItemDelegate>
#include <QDialog>
#include "LVGLStyle.h"
#include "widgets/LVGLWidget.h"
class LVGLObject;
class LVGLStyleModel : public QAbstractItemModel
{
Q_OBJECT
public:
explicit LVGLStyleModel(QObject *parent = nullptr);
// Header:
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
// Basic functionality:
QModelIndex index(int row, int column,
const QModelIndex &parent = QModelIndex()) const override;
QModelIndex parent(const QModelIndex &index) const override;
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
Qt::ItemFlags flags(const QModelIndex& index) const override;
LVGLStyle *styleBase() const;
void setStyle(lv_style_t *style, LVGL::StyleParts editableStyles = LVGL::None);
signals:
void styleChanged();
public slots:
private:
void updateValue(const LVGLStyleItem *item);
QModelIndex indexOf(const LVGLStyleItem *item, int column);
LVGLStyle *m_styleBase;
LVGL::StyleParts m_editableStyles;
};
class LVGLBodyPartDialog : public QDialog
{
Q_OBJECT
public:
LVGLBodyPartDialog(QWidget *parent = nullptr);
void setBodyParts(lv_border_part_t parts);
lv_border_part_t bodyParts() const;
private:
class QListWidget *m_list;
};
class LVGLStyleDelegate : public QStyledItemDelegate
{
public:
LVGLStyleDelegate(LVGLStyle *styleBase, QObject* parent = nullptr);
QWidget *createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const override;
void setEditorData(QWidget* editor, const QModelIndex& index) const override;
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override;
private:
LVGLStyle *m_styleBase;
};
#endif // LVGLSTYLEMODEL_H