The GlyphPaletteProxyModel class.
More...
#include <GlyphPaletteProxyModel.h>
|
| bool | filterAcceptsRow (int sourceRow, const QModelIndex &sourceParent) const override |
| |
The GlyphPaletteProxyModel class.
This class is a filter model for the KoFontGlyphModel, which allows it to be used as a character map, allowing filtering on blocks and strings.
Definition at line 20 of file GlyphPaletteProxyModel.h.
◆ GlyphPaletteProxyModel()
| GlyphPaletteProxyModel::GlyphPaletteProxyModel |
( |
QObject * | parent = nullptr | ) |
|
◆ ~GlyphPaletteProxyModel()
| GlyphPaletteProxyModel::~GlyphPaletteProxyModel |
( |
| ) |
|
|
override |
◆ blockFilter()
| int GlyphPaletteProxyModel::blockFilter |
( |
| ) |
const |
blockFilter
- Returns
- current blockfilter, value is value in blockLabels.
Definition at line 28 of file GlyphPaletteProxyModel.cpp.
29{
30 return d->filterIndex;
31}
References d.
◆ blockFilterChanged
| void GlyphPaletteProxyModel::blockFilterChanged |
( |
| ) |
|
|
signal |
◆ blockLabels()
| QVariantList GlyphPaletteProxyModel::blockLabels |
( |
| ) |
const |
blockLabels
- Returns
- list of unicode block filter labels, with each entry representing a QVariantMap with a "name" and a "value"
Definition at line 38 of file GlyphPaletteProxyModel.cpp.
39{
40 QVariantList labels;
41
43 labels.append(QVariantMap({{"name", i18nc("@title", "All glyphs")}, {"value", 0}}));
44 if (model) {
45 for (
int i=0; i < model->
blocks().size(); i++) {
46 labels.append(QVariantMap({{
"name", model->
blocks().at(i).name}, {
"value", i+1}}));
47 }
48 }
49 return labels;
50}
The KoFontGlyphModel class Creates a tree model of all the glyphs in a given face.
QVector< KoUnicodeBlockData > blocks() const
blocks
References KoFontGlyphModel::blocks().
◆ blockLabelsChanged
| void GlyphPaletteProxyModel::blockLabelsChanged |
( |
| ) |
|
|
signal |
◆ emitBlockLabelsChanged
| void GlyphPaletteProxyModel::emitBlockLabelsChanged |
( |
| ) |
|
|
slot |
◆ filterAcceptsRow()
| bool GlyphPaletteProxyModel::filterAcceptsRow |
( |
int | sourceRow, |
|
|
const QModelIndex & | sourceParent ) const |
|
overrideprotected |
Definition at line 100 of file GlyphPaletteProxyModel.cpp.
101{
102 if (sourceParent.isValid()) return true;
103 const QModelIndex idx = sourceModel()->index(sourceRow, 0, sourceParent);
104 const QString
main = sourceModel()->data(idx).toString();
105 if (
main.isEmpty())
return false;
106 const uint firstChar =
main.toUcs4().first();
107
108 if (!
d->searchText.isEmpty()) {
109 const QString decomposition = QChar::decomposition(firstChar);
110 const uint searchFirst =
d->searchText.toUcs4().first();
111 return searchFirst == firstChar
112 || (!decomposition.isEmpty() && searchFirst == decomposition.toUcs4().first());
113 }
114 if (
d->filterIndex == 0)
return true;
115
116 return d->block.match(firstChar);
117}
int main(int argc, char **argv)
References d, and main().
◆ searchText()
| QString GlyphPaletteProxyModel::searchText |
( |
| ) |
const |
searchText
- Returns
- current search text. This is a single unicode codepoint.
Definition at line 33 of file GlyphPaletteProxyModel.cpp.
References d.
◆ searchTextChanged
| void GlyphPaletteProxyModel::searchTextChanged |
( |
| ) |
|
|
signal |
◆ setBlockFilter
| void GlyphPaletteProxyModel::setBlockFilter |
( |
int | filter | ) |
|
|
slot |
◆ setSearchText
| void GlyphPaletteProxyModel::setSearchText |
( |
const QString & | text | ) |
|
|
slot |
setSearchText
- Parameters
-
| text | – if the text starts with "U+", the consecutive characters are interpreted as a hex value. Otherwise, the first codepoint of text is searched upon. |
Definition at line 52 of file GlyphPaletteProxyModel.cpp.
53{
54 QString adjustedText = text;
55 if (text.startsWith("U+")) {
56 bool ok = false;
57 const uint code = text.mid(2).toUInt(&ok, 16);
58 if (ok) {
59 adjustedText = QString::fromUcs4(&code, 1);
60 }
61 }
62 if (!
d->searchText.isEmpty() && !adjustedText.isEmpty() &&
d->searchText.toUcs4().first() == adjustedText.toUcs4().first()) {
63 return;
64 } else {
65 d->searchText = adjustedText.isEmpty()? adjustedText: QString::fromUcs4(&adjustedText.toUcs4().first(), 1);
67 invalidateFilter();
68 }
69}
References d, and searchTextChanged().
| QScopedPointer<Private> GlyphPaletteProxyModel::d |
|
private |
◆ blockFilter
| int GlyphPaletteProxyModel::blockFilter |
|
readwrite |
◆ blockLabels
| QVariantList GlyphPaletteProxyModel::blockLabels |
|
read |
◆ searchText
| QString GlyphPaletteProxyModel::searchText |
|
read |
The documentation for this class was generated from the following files: