Krita Source Code Documentation
Loading...
Searching...
No Matches
FontStyleModel.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2024 Wolthera van Hövell tot Westerflier <griffinvalley@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6#ifndef FONTSTYLEMODEL_H
7#define FONTSTYLEMODEL_H
8
9#include <QAbstractItemModel>
10#include <KoSvgText.h>
11#include <QLocale>
12
19class FontStyleModel: public QAbstractItemModel
20{
21 Q_OBJECT
22 enum Roles {
23 Weight = Qt::UserRole + 1,
28 };
29
30public:
31 FontStyleModel(QObject *parent = nullptr);
33
36
37 Q_INVOKABLE qreal weightValue(int row);
38 Q_INVOKABLE qreal widthValue(int row);
39 Q_INVOKABLE int styleModeValue(int row);
40 Q_INVOKABLE qreal slantValue(int row);
41 Q_INVOKABLE QVariantHash axesValues(int row);
42
44 Q_INVOKABLE int rowForStyle(const qreal &weight, const qreal &width, const int &styleMode, const qreal &styleValue);
45
47 Q_INVOKABLE void setFromTextPropertiesModel(KoSvgTextPropertiesModel *textPropertiesModel);
48
49 // QAbstractItemModel interface
50public:
51 QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
52 QModelIndex parent(const QModelIndex &child) const;
53 int rowCount(const QModelIndex &parent) const override;
54 int columnCount(const QModelIndex &parent) const override;
55 QVariant data(const QModelIndex &index, int role) const override;
56 QHash<int, QByteArray> roleNames() const override;
57private:
58 struct Private;
59 const QScopedPointer<Private> d;
60};
61
62#endif // FONTSTYLEMODEL_H
The FontStyleModel class.
Q_INVOKABLE void setFromTextPropertiesModel(KoSvgTextPropertiesModel *textPropertiesModel)
Update styles model from current text properties.
Q_INVOKABLE QVariantHash axesValues(int row)
Q_INVOKABLE int styleModeValue(int row)
int rowCount(const QModelIndex &parent) const override
Q_INVOKABLE qreal weightValue(int row)
QModelIndex parent(const QModelIndex &child) const
int columnCount(const QModelIndex &parent) const override
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
Q_INVOKABLE qreal widthValue(int row)
QVariant data(const QModelIndex &index, int role) const override
QHash< int, QByteArray > roleNames() const override
@ AxisValues
other axis values
@ StyleMode
QFont::Style.
@ Width
qreal, represents 'wdth'
@ Weight
qreal, represents 'wgth'
@ Slant
qreal, represents 'slnt'
Q_INVOKABLE qreal slantValue(int row)
Q_INVOKABLE int rowForStyle(const qreal &weight, const qreal &width, const int &styleMode, const qreal &styleValue)
Find the closest style that represents the current width, weight and stylemode.
const QScopedPointer< Private > d
void setStylesInfo(QList< KoSvgText::FontFamilyStyleInfo > styles)
Set the base style info;.
FontStyleModel(QObject *parent=nullptr)
The KoSvgTextPropertiesModel class.