7#include <klocalizedstring.h>
31 : QAbstractItemModel(parent)
36 Q_FOREACH (
const QString langCode, KLocalizedString::languages()) {
37 locales.append(QLocale(langCode));
49 for (
int i=0; i < axes.size(); i++) {
50 QString tag = axes.at(i).tag;
55 && !axes.at(i).axisHidden) {
56 newAxes.append(axes.at(i));
59 if (newAxes !=
d->axes) {
70 d->opticalSizeDisabled = disable;
75 d->blockAxesValuesUpdate = block;
80 return d->blockAxesValuesUpdate;
86 if (column != 0)
return QModelIndex();
87 if (row >= 0 && row < d->axes.size())
return createIndex(row, column, &row);
100 return d->axes.size();
111 if (!
index.isValid())
return QVariant();
114 if (role == Qt::DisplayRole) {
117 return i18nc(
"@info:label",
"Optical Size");
123 Q_FOREACH(
const QLocale &locale,
d->locales) {
130 }
else if (role == Qt::EditRole) {
132 }
else if (role ==
Min) {
134 }
else if (role ==
Max) {
136 }
else if (role ==
Hidden) {
144 if (
index.isValid() && role == Qt::EditRole) {
147 if (!
d->axisValues.keys().contains(axis.
tag) || !qFuzzyCompare(
d->axisValues.value(axis.
tag).toDouble(),
value.toDouble())) {
149 if (!
d->blockAxesValuesUpdate) {
152 emit dataChanged(
index,
index, { Qt::EditRole});
161 Qt::ItemFlags
flags = QAbstractItemModel::flags(
index) | Qt::ItemNeverHasChildren | Qt::ItemIsEditable;
173 QHash<int, QByteArray> roles = QAbstractItemModel::roleNames();
174 roles[
Min] =
"axismin";
175 roles[
Max] =
"axismax";
176 roles[
Hidden] =
"axishidden";
182 return d->axisValues;
187 QStringList families = textPropertiesModel->fontFamilies();
191 if (!families.isEmpty() &&
d->fontModel) {
194 QString familyName = !name? families.first(): name.value();
197 if (!res.isEmpty()) {
200 axes = family->axes();
212 if (
d->axisValues == newAxisValues)
214 d->axisValues = newAxisValues;
216 if (!
d->blockAxesValuesUpdate) {
220 QModelIndex idx1 =
index(0, 0, QModelIndex());
221 QModelIndex idx2 =
index(
rowCount(QModelIndex())-1, 0, QModelIndex());
222 if (idx1.isValid() && idx2.isValid()) {
223 emit dataChanged(idx1, idx2, {Qt::EditRole});
const QString OPTICAL_TAG
float value(const T *src, size_t ch)
const QString OPTICAL_TAG
void setAxisValues(const QVariantMap &newAxisValues)
void setAxesData(QList< KoSvgText::FontFamilyAxis > axes)
QVariant data(const QModelIndex &index, int role) const override
QModelIndex parent(const QModelIndex &child) const override
@ Min
double, represents lower end
@ Max
double, represents upper end
QHash< int, QByteArray > roleNames() const override
QModelIndex index(int row, int column, const QModelIndex &parent) const override
bool axesValueSignalBlocked() const
Qt::ItemFlags flags(const QModelIndex &index) const override
FontAxesModel(QObject *parent=nullptr)
int rowCount(const QModelIndex &parent) const override
void setBlockAxesValuesSignal(bool block)
Q_INVOKABLE void setFromTextPropertiesModel(KoSvgTextPropertiesModel *textPropertiesModel)
int columnCount(const QModelIndex &parent) const override
void setOpticalSizeDisabled(bool disable)
If optical size link is enabled, then the slider should be disabled.
const QScopedPointer< Private > d
bool setData(const QModelIndex &index, const QVariant &value, int role) override
The KisResourceModel class provides the main access to resources. It is possible to filter the resour...
The KoFontFamily class Abstract representation of a Weight/Width/Slant font family,...
std::optional< QString > wwsNameByFamilyName(const QString familyName) const
static KoFontRegistry * instance()
The KoSvgTextPropertiesModel class.
const QString FontFamilies
KisResourceModel * fontModel
bool blockAxesValuesUpdate
QList< KoSvgText::FontFamilyAxis > axes
QHash< QLocale, QString > localizedLabels