-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfontmodel.h
43 lines (37 loc) · 1.05 KB
/
fontmodel.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
#ifndef FONTMODEL_H
#define FONTMODEL_H
#include <QAbstractListModel>
#include <QFont>
#include <QVector>
#include <QImage>
class FontModel : public QAbstractListModel
{
Q_OBJECT
Q_PROPERTY(bool isEmpty READ isEmpty NOTIFY isEmptyChanged)
public:
explicit FontModel(QObject *parent = nullptr);
enum Roles {
ImageRole = Qt::UserRole + 1,
MaskRole,
WidthRole,
HeightRole,
IsNullRole,
};
// QAbstractItemModel interface
virtual int rowCount(const QModelIndex &parent) const override;
virtual QVariant data(const QModelIndex &index, int role) const override;
virtual QHash<int, QByteArray> roleNames() const override;
bool isEmpty() const;
public slots:
void initFromFont(QFont font, const QString &encoding, bool antialiasing, bool renderAsPath = true);
void createMasks();
void clear();
signals:
void isEmptyChanged();
private:
void clearHelper();
QVector<QImage> m_images;
QVector<QImage> m_masks;
bool m_isEmpty = true;
};
#endif // FONTMODEL_H