49 : QAbstractItemModel(parent)
61 if (column != 0)
return QModelIndex();
62 if (row >= 0 && row < d->currentFeatures.size())
return createIndex(row, column, &row);
75 return d->currentFeatures.size();
89 const QString feature =
d->currentFeatures.keys().at(
index.row());
91 if (role == Qt::DisplayRole) {
93 }
else if (role == Qt::ToolTipRole) {
95 }
else if (role == Qt::EditRole) {
96 return d->currentFeatures.value(feature, QVariant(0)).toInt();
97 }
else if (role ==
Tag) {
99 }
else if (role ==
Sample) {
102 QVariantList features;
103 for (
int i = 0; i <= info.
maxValue; i++) {
105 map.insert(
"value", QVariant(i));
107 if (entry.isEmpty()) {
109 entry = info.
name +
": " + i18nc(
"Feature value toggle",
"On");
111 entry = info.
name +
": " + i18nc(
"Feature value toggle",
"Off");
113 entry = info.
name +
": " + QString::number(i);
116 map.insert(
"display", entry);
117 features.append(map);
120 }
else if (role ==
Max) {
131 if (
index.isValid() && role == Qt::EditRole) {
132 const QString feature =
d->currentFeatures.keys().at(
index.row());
133 d->currentFeatures.insert(feature,
value.toInt());
146 Qt::ItemFlags
flags = QAbstractItemModel::flags(
index) | Qt::ItemNeverHasChildren | Qt::ItemIsEditable;
153 QHash<int, QByteArray> roles = QAbstractItemModel::roleNames();
163 const bool changeFont = props.
cssFontInfo() !=
d->fontInfo;
165 const bool changeFeatures =
d->currentFeatures != newFeatures;
167 if (!changeFont && !changeFeatures)
return;
171 const qreal res = 72.0;
178 static_cast<quint32
>(res),
179 static_cast<quint32
>(res));
181 if (!faces.empty()) {
184 d->glyphModel->setFace(faces.front(), QLatin1String(language.toLatin1()),
true);
185 d->allFeatures->setAvailableFeatures(
d->availableFeatures());
190 if (changeFeatures) {
191 d->currentFeatures = newFeatures;
199 return d->currentFeatures;
204 if (
d->currentFeatures == newOpenTypeFeatures)
207 d->currentFeatures = newOpenTypeFeatures;
214 if (tag.isEmpty())
return;
215 if (
d->currentFeatures.keys().contains(tag))
return;
217 QVariantMap dummy =
d->currentFeatures;
218 dummy.insert(tag, QVariant(1));
219 const int index = dummy.keys().indexOf(tag);
222 d->currentFeatures.insert(tag, QVariant(1));
229 if (tag.isEmpty())
return;
230 const int index =
d->currentFeatures.keys().indexOf(tag);
231 if (
index < 0)
return;
234 d->currentFeatures.remove(tag);
241 return d->allFeatures;
247 if (textPropertiesModel) {
250 main.inheritFrom(
data.inheritedProperties);
269 if (feature.
tag == tag) {
283 const QString tag = QString::fromLatin1(feature.
tag.data(), 4);
294 : QAbstractListModel(parent)
308 d->availableFeatures = features;
309 d->setAvailableTags();
315 if (!index.isValid())
318 const QString feature =
d->allTags.at(index.row());
320 if (role == Qt::DisplayRole) {
322 }
else if (role == Qt::ToolTipRole) {
324 }
else if (role ==
Tag) {
326 }
else if (role ==
Sample) {
329 return d->featureAvailable(feature);
337 return d->allTags.size();
342 if (role == Qt::DisplayRole) {
343 if (orientation == Qt::Horizontal && section == 0) {
344 return i18nc(
"@title:column",
"OpenType Feature Tag");
352 QHash<int, QByteArray> roles = QAbstractItemModel::roleNames();
360 : QSortFilterProxyModel(parent)
367 const QModelIndex idx = index(0, 0, QModelIndex());
368 if (!idx.isValid())
return QString();
375 const QModelIndex idx = sourceModel()->index(source_row, 0, source_parent);
376 if (!idx.isValid())
return false;
379 if (filterRegularExpression().pattern().isEmpty())
return true;
381 const QString name = sourceModel()->data(idx, Qt::DisplayRole).toString();
382 return (tag.contains(filterRegularExpression()) || name.contains(filterRegularExpression()));
401 return filterRegularExpression().pattern();
406 if (filterRegularExpression().pattern() == newSearchText)
408 setFilterRegularExpression(newSearchText);
float value(const T *src, size_t ch)
QVariant data(const QModelIndex &index, int role) const override
void setAvailableFeatures(const QList< KoOpenTypeFeatureInfo > &features)
QVariant headerData(int section, Qt::Orientation orientation, int role) const
const QScopedPointer< Private > d
AllOpenTypeFeaturesModel(QObject *parent=nullptr)
~AllOpenTypeFeaturesModel()
int rowCount(const QModelIndex &parent) const override
QHash< int, QByteArray > roleNames() const override
The KoFontGlyphModel class Creates a tree model of all the glyphs in a given face.
QMap< QString, KoOpenTypeFeatureInfo > featureInfo() const
featureInfo
std::vector< FT_FaceSP > facesForCSSValues(QVector< int > &lengths, KoCSSFontInfo info=KoCSSFontInfo(), const QString &text="", quint32 xRes=72, quint32 yRes=72, bool disableFontMatching=false, const QString &language=QString())
facesForCSSValues This selects a font with fontconfig using the given values. If "text" is not empty ...
static KoFontRegistry * instance()
The KoSvgTextPropertiesModel class.
lager::cursor< KoSvgTextPropertyData > textData
@ FontFeatureSettingsId
QStringList.
@ TextLanguage
a language string.
KoCSSFontInfo cssFontInfo() const
cssFontInfo
QVariant propertyOrDefault(PropertyId id) const
void filterAvailableChanged()
void setFilterAvailable(bool newFilterAvailable)
void setSearchText(const QString &newSearchText)
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override
Q_INVOKABLE QString firstValidTag() const
OpenTypeFeatureFilterModel(QObject *parent=nullptr)
int rowCount(const QModelIndex &parent=QModelIndex()) const override
void setFromTextProperties(const KoSvgTextProperties &props)
Q_INVOKABLE void setFromTextPropertiesModel(KoSvgTextPropertiesModel *textPropertiesModel)
setFromTextPropertiesModel Set the current glyph model font from the lager text properties model....
QVariantMap openTypeFeatures
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
int columnCount(const QModelIndex &parent=QModelIndex()) const override
Q_INVOKABLE QAbstractItemModel * allFeatureModel() const
featureFilterModel
QModelIndex parent(const QModelIndex &index) const override
OpenTypeFeatureModel(QObject *parent=nullptr)
void setOpenTypeFeatures(const QVariantMap &newOpenTypeFeatures)
@ Max
int, max count, default is 1, but can be larger depending on the font.
@ Sample
QString, the sample for this feature, may be empty.
@ Tag
QString, opentype tag.
@ Parameters
QVariantList, indices with names of the feature count.
Q_INVOKABLE void removeFeature(const QString &tag)
Q_INVOKABLE void addFeature(const QString &tag)
const QScopedPointer< Private > d
QHash< int, QByteArray > roleNames() const override
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
Qt::ItemFlags flags(const QModelIndex &index) const override
void openTypeFeaturesChanged()
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
int main(int argc, char **argv)
QStringList availableTags
KoOpenTypeFeatureInfo featureByTag(QLatin1String tag) const
KoOpenTypeFeatureInfoFactory factory
QList< KoOpenTypeFeatureInfo > availableFeatures
bool featureAvailable(const QString &tag) const
The KoCSSFontInfo class Convenience struct to make it easier to use KoFontRegistry....
The KoOpenTypeFeatureInfoFactory class.
QList< QString > tags() const
tags
KoOpenTypeFeatureInfo infoByTag(const QLatin1String &tag) const
infoByTag
QString description
Description of the feature.
QString name
User-friendly name.
QStringList namedParameters
QString sample
Sample of the feature, if any. Only used by CVXX features and retrieved from the font.
int maxValue
The maximum value possible, this is by default 1 (on), but for alternate substitution(gsub 3),...
QLatin1String tag
4 char tag.
The KoSvgTextPropertyData struct.
AllOpenTypeFeaturesModel * allFeatures
KoFontGlyphModel * glyphModel
KoOpenTypeFeatureInfoFactory factory
QVariantMap currentFeatures
KoOpenTypeFeatureInfo featureByTag(QLatin1String tag) const
QList< KoOpenTypeFeatureInfo > availableFeatures() const