qfontcombobox.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/widgets/widgets/qfontcombobox.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7static QFontDatabase::WritingSystem writingSystemFromScript(QLocale::Script script)-
8{-
9 switch (script) {-
10 case
never executed: case QLocale::ArabicScript:
QLocale::ArabicScript:
never executed: case QLocale::ArabicScript:
0
11 return
never executed: return QFontDatabase::Arabic;
QFontDatabase::Arabic;
never executed: return QFontDatabase::Arabic;
0
12 case
never executed: case QLocale::CyrillicScript:
QLocale::CyrillicScript:
never executed: case QLocale::CyrillicScript:
0
13 return
never executed: return QFontDatabase::Cyrillic;
QFontDatabase::Cyrillic;
never executed: return QFontDatabase::Cyrillic;
0
14 case
never executed: case QLocale::GurmukhiScript:
QLocale::GurmukhiScript:
never executed: case QLocale::GurmukhiScript:
0
15 return
never executed: return QFontDatabase::Gurmukhi;
QFontDatabase::Gurmukhi;
never executed: return QFontDatabase::Gurmukhi;
0
16 case
never executed: case QLocale::SimplifiedHanScript:
QLocale::SimplifiedHanScript:
never executed: case QLocale::SimplifiedHanScript:
0
17 return
never executed: return QFontDatabase::SimplifiedChinese;
QFontDatabase::SimplifiedChinese;
never executed: return QFontDatabase::SimplifiedChinese;
0
18 case
never executed: case QLocale::TraditionalHanScript:
QLocale::TraditionalHanScript:
never executed: case QLocale::TraditionalHanScript:
0
19 return
never executed: return QFontDatabase::TraditionalChinese;
QFontDatabase::TraditionalChinese;
never executed: return QFontDatabase::TraditionalChinese;
0
20 case
never executed: case QLocale::LatinScript:
QLocale::LatinScript:
never executed: case QLocale::LatinScript:
0
21 return
never executed: return QFontDatabase::Latin;
QFontDatabase::Latin;
never executed: return QFontDatabase::Latin;
0
22 case
never executed: case QLocale::ArmenianScript:
QLocale::ArmenianScript:
never executed: case QLocale::ArmenianScript:
0
23 return
never executed: return QFontDatabase::Armenian;
QFontDatabase::Armenian;
never executed: return QFontDatabase::Armenian;
0
24 case
never executed: case QLocale::BengaliScript:
QLocale::BengaliScript:
never executed: case QLocale::BengaliScript:
0
25 return
never executed: return QFontDatabase::Bengali;
QFontDatabase::Bengali;
never executed: return QFontDatabase::Bengali;
0
26 case
never executed: case QLocale::DevanagariScript:
QLocale::DevanagariScript:
never executed: case QLocale::DevanagariScript:
0
27 return
never executed: return QFontDatabase::Devanagari;
QFontDatabase::Devanagari;
never executed: return QFontDatabase::Devanagari;
0
28 case
never executed: case QLocale::GeorgianScript:
QLocale::GeorgianScript:
never executed: case QLocale::GeorgianScript:
0
29 return
never executed: return QFontDatabase::Georgian;
QFontDatabase::Georgian;
never executed: return QFontDatabase::Georgian;
0
30 case
never executed: case QLocale::GreekScript:
QLocale::GreekScript:
never executed: case QLocale::GreekScript:
0
31 return
never executed: return QFontDatabase::Greek;
QFontDatabase::Greek;
never executed: return QFontDatabase::Greek;
0
32 case
never executed: case QLocale::GujaratiScript:
QLocale::GujaratiScript:
never executed: case QLocale::GujaratiScript:
0
33 return
never executed: return QFontDatabase::Gujarati;
QFontDatabase::Gujarati;
never executed: return QFontDatabase::Gujarati;
0
34 case
never executed: case QLocale::HebrewScript:
QLocale::HebrewScript:
never executed: case QLocale::HebrewScript:
0
35 return
never executed: return QFontDatabase::Hebrew;
QFontDatabase::Hebrew;
never executed: return QFontDatabase::Hebrew;
0
36 case
never executed: case QLocale::JapaneseScript:
QLocale::JapaneseScript:
never executed: case QLocale::JapaneseScript:
0
37 return
never executed: return QFontDatabase::Japanese;
QFontDatabase::Japanese;
never executed: return QFontDatabase::Japanese;
0
38 case
never executed: case QLocale::KhmerScript:
QLocale::KhmerScript:
never executed: case QLocale::KhmerScript:
0
39 return
never executed: return QFontDatabase::Khmer;
QFontDatabase::Khmer;
never executed: return QFontDatabase::Khmer;
0
40 case
never executed: case QLocale::KannadaScript:
QLocale::KannadaScript:
never executed: case QLocale::KannadaScript:
0
41 return
never executed: return QFontDatabase::Kannada;
QFontDatabase::Kannada;
never executed: return QFontDatabase::Kannada;
0
42 case
never executed: case QLocale::KoreanScript:
QLocale::KoreanScript:
never executed: case QLocale::KoreanScript:
0
43 return
never executed: return QFontDatabase::Korean;
QFontDatabase::Korean;
never executed: return QFontDatabase::Korean;
0
44 case
never executed: case QLocale::LaoScript:
QLocale::LaoScript:
never executed: case QLocale::LaoScript:
0
45 return
never executed: return QFontDatabase::Lao;
QFontDatabase::Lao;
never executed: return QFontDatabase::Lao;
0
46 case
never executed: case QLocale::MalayalamScript:
QLocale::MalayalamScript:
never executed: case QLocale::MalayalamScript:
0
47 return
never executed: return QFontDatabase::Malayalam;
QFontDatabase::Malayalam;
never executed: return QFontDatabase::Malayalam;
0
48 case
never executed: case QLocale::MyanmarScript:
QLocale::MyanmarScript:
never executed: case QLocale::MyanmarScript:
0
49 return
never executed: return QFontDatabase::Myanmar;
QFontDatabase::Myanmar;
never executed: return QFontDatabase::Myanmar;
0
50 case
never executed: case QLocale::TamilScript:
QLocale::TamilScript:
never executed: case QLocale::TamilScript:
0
51 return
never executed: return QFontDatabase::Tamil;
QFontDatabase::Tamil;
never executed: return QFontDatabase::Tamil;
0
52 case
never executed: case QLocale::TeluguScript:
QLocale::TeluguScript:
never executed: case QLocale::TeluguScript:
0
53 return
never executed: return QFontDatabase::Telugu;
QFontDatabase::Telugu;
never executed: return QFontDatabase::Telugu;
0
54 case
never executed: case QLocale::ThaanaScript:
QLocale::ThaanaScript:
never executed: case QLocale::ThaanaScript:
0
55 return
never executed: return QFontDatabase::Thaana;
QFontDatabase::Thaana;
never executed: return QFontDatabase::Thaana;
0
56 case
never executed: case QLocale::ThaiScript:
QLocale::ThaiScript:
never executed: case QLocale::ThaiScript:
0
57 return
never executed: return QFontDatabase::Thai;
QFontDatabase::Thai;
never executed: return QFontDatabase::Thai;
0
58 case
never executed: case QLocale::TibetanScript:
QLocale::TibetanScript:
never executed: case QLocale::TibetanScript:
0
59 return
never executed: return QFontDatabase::Tibetan;
QFontDatabase::Tibetan;
never executed: return QFontDatabase::Tibetan;
0
60 case
never executed: case QLocale::SinhalaScript:
QLocale::SinhalaScript:
never executed: case QLocale::SinhalaScript:
0
61 return
never executed: return QFontDatabase::Sinhala;
QFontDatabase::Sinhala;
never executed: return QFontDatabase::Sinhala;
0
62 case
never executed: case QLocale::SyriacScript:
QLocale::SyriacScript:
never executed: case QLocale::SyriacScript:
0
63 return
never executed: return QFontDatabase::Syriac;
QFontDatabase::Syriac;
never executed: return QFontDatabase::Syriac;
0
64 case
never executed: case QLocale::OriyaScript:
QLocale::OriyaScript:
never executed: case QLocale::OriyaScript:
0
65 return
never executed: return QFontDatabase::Oriya;
QFontDatabase::Oriya;
never executed: return QFontDatabase::Oriya;
0
66 case
never executed: case QLocale::OghamScript:
QLocale::OghamScript:
never executed: case QLocale::OghamScript:
0
67 return
never executed: return QFontDatabase::Ogham;
QFontDatabase::Ogham;
never executed: return QFontDatabase::Ogham;
0
68 case
never executed: case QLocale::RunicScript:
QLocale::RunicScript:
never executed: case QLocale::RunicScript:
0
69 return
never executed: return QFontDatabase::Runic;
QFontDatabase::Runic;
never executed: return QFontDatabase::Runic;
0
70 case
never executed: case QLocale::NkoScript:
QLocale::NkoScript:
never executed: case QLocale::NkoScript:
0
71 return
never executed: return QFontDatabase::Nko;
QFontDatabase::Nko;
never executed: return QFontDatabase::Nko;
0
72 default
never executed: default:
:
never executed: default:
0
73 return
never executed: return QFontDatabase::Any;
QFontDatabase::Any;
never executed: return QFontDatabase::Any;
0
74 }-
75}-
76-
77static QFontDatabase::WritingSystem writingSystemFromLocale()-
78{-
79 QStringList uiLanguages = QLocale::system().uiLanguages();-
80 QLocale::Script script;-
81 if (!uiLanguages.isEmpty()
!uiLanguages.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
82 script = QLocale(uiLanguages.at(0)).script();
never executed: script = QLocale(uiLanguages.at(0)).script();
0
83 else-
84 script = QLocale::system().script();
never executed: script = QLocale::system().script();
0
85-
86 return
never executed: return writingSystemFromScript(script);
writingSystemFromScript(script);
never executed: return writingSystemFromScript(script);
0
87}-
88-
89static QFontDatabase::WritingSystem writingSystemForFont(const QFont &font, bool *hasLatin)-
90{-
91 QList<QFontDatabase::WritingSystem> writingSystems = QFontDatabase().writingSystems(font.family());-
92-
93-
94-
95 writingSystems.removeOne(QFontDatabase::Vietnamese);-
96 *hasLatin = writingSystems.removeOne(QFontDatabase::Latin);-
97-
98 if (writingSystems.isEmpty()
writingSystems.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
99 return
never executed: return QFontDatabase::Any;
QFontDatabase::Any;
never executed: return QFontDatabase::Any;
0
100-
101 QFontDatabase::WritingSystem system = writingSystemFromLocale();-
102-
103 if (writingSystems.contains(system)
writingSystems...ntains(system)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
104 return
never executed: return system;
system;
never executed: return system;
0
105-
106 if (system == QFontDatabase::TraditionalChinese
system == QFon...itionalChineseDescription
TRUEnever evaluated
FALSEnever evaluated
0
107 && writingSystems.contains(QFontDatabase::SimplifiedChinese)
writingSystems...lifiedChinese)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
108 return
never executed: return QFontDatabase::SimplifiedChinese;
QFontDatabase::SimplifiedChinese;
never executed: return QFontDatabase::SimplifiedChinese;
0
109 }-
110-
111 if (system == QFontDatabase::SimplifiedChinese
system == QFon...plifiedChineseDescription
TRUEnever evaluated
FALSEnever evaluated
0
112 && writingSystems.contains(QFontDatabase::TraditionalChinese)
writingSystems...tionalChinese)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
113 return
never executed: return QFontDatabase::TraditionalChinese;
QFontDatabase::TraditionalChinese;
never executed: return QFontDatabase::TraditionalChinese;
0
114 }-
115-
116 system = writingSystems.constLast();-
117-
118 if (!*hasLatin
!*hasLatinDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
119-
120 return
never executed: return system;
system;
never executed: return system;
0
121 }-
122-
123 if (writingSystems.count() == 1
writingSystems.count() == 1Description
TRUEnever evaluated
FALSEnever evaluated
&& system > QFontDatabase::Cyrillic
system > QFont...base::CyrillicDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
124 return
never executed: return system;
system;
never executed: return system;
0
125-
126 if (writingSystems.count() <= 2
writingSystems.count() <= 2Description
TRUEnever evaluated
FALSEnever evaluated
&& system > QFontDatabase::Armenian
system > QFont...base::ArmenianDescription
TRUEnever evaluated
FALSEnever evaluated
&& system < QFontDatabase::Vietnamese
system < QFont...se::VietnameseDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
127 return
never executed: return system;
system;
never executed: return system;
0
128-
129 if (writingSystems.count() <= 5
writingSystems.count() <= 5Description
TRUEnever evaluated
FALSEnever evaluated
&& system >= QFontDatabase::SimplifiedChinese
system >= QFon...plifiedChineseDescription
TRUEnever evaluated
FALSEnever evaluated
&& system <= QFontDatabase::Korean
system <= QFon...tabase::KoreanDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
130 return
never executed: return system;
system;
never executed: return system;
0
131-
132 return
never executed: return QFontDatabase::Any;
QFontDatabase::Any;
never executed: return QFontDatabase::Any;
0
133}-
134-
135class QFontFamilyDelegate : public QAbstractItemDelegate-
136{-
137 public: template <typename ThisObject> inline void qt_check_for_QOBJECT_macro(const ThisObject &_q_argument) const { int i = qYouForgotTheQ_OBJECT_Macro(this, &_q_argument); i = i + 1; }-
138#pragma GCC diagnostic push-
139 static const QMetaObject staticMetaObject; virtual const QMetaObject *metaObject() const; virtual void *qt_metacast(const char *); virtual int qt_metacall(QMetaObject::Call, int, void **); static inline QString tr(const char *s, const char *c = nullptr, int n = -1) { return staticMetaObject.tr(s, c, n); } __attribute__ ((__deprecated__)) static inline QString trUtf8(const char *s, const char *c = nullptr, int n = -1) { return staticMetaObject.tr(s, c, n); } private: __attribute__((visibility("hidden"))) static void qt_static_metacall(QObject *, QMetaObject::Call, int, void **);-
140#pragma GCC diagnostic pop-
141 struct QPrivateSignal {};-
142public:-
143 explicit QFontFamilyDelegate(QObject *parent);-
144-
145-
146 void paint(QPainter *painter,-
147 const QStyleOptionViewItem &option,-
148 const QModelIndex &index) const override;-
149-
150 QSize sizeHint(const QStyleOptionViewItem &option,-
151 const QModelIndex &index) const override;-
152-
153 const QIcon truetype;-
154 const QIcon bitmap;-
155 QFontDatabase::WritingSystem writingSystem;-
156};-
157-
158QFontFamilyDelegate::QFontFamilyDelegate(QObject *parent)-
159 : QAbstractItemDelegate(parent),-
160 truetype(([]() -> QString { enum { Size = sizeof(u"" ":/qt-project.org/styles/commonstyle/images/fonttruetype-16.png")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" ":/qt-project.org/styles/commonstyle/images/fonttruetype-16.png" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }())),-
161 bitmap(([]() -> QString { enum { Size = sizeof(u"" ":/qt-project.org/styles/commonstyle/images/fontbitmap-16.png")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" ":/qt-project.org/styles/commonstyle/images/fontbitmap-16.png" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }())),-
162 writingSystem(QFontDatabase::Any)-
163{-
164}
never executed: end of block
0
165-
166void QFontFamilyDelegate::paint(QPainter *painter,-
167 const QStyleOptionViewItem &option,-
168 const QModelIndex &index) const-
169{-
170 QString text = index.data(Qt::DisplayRole).toString();-
171 QFont font(option.font);-
172 font.setPointSize(QFontInfo(font).pointSize() * 3 / 2);-
173 QFont font2 = font;-
174 font2.setFamily(text);-
175-
176 bool hasLatin;-
177 QFontDatabase::WritingSystem system = writingSystemForFont(font2, &hasLatin);-
178 if (hasLatin
hasLatinDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
179 font = font2;
never executed: font = font2;
0
180-
181 QRect r = option.rect;-
182-
183 if (option.state & QStyle::State_Selected
option.state &...State_SelectedDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
184 painter->save();-
185 painter->setBrush(option.palette.highlight());-
186 painter->setPen(Qt::NoPen);-
187 painter->drawRect(option.rect);-
188 painter->setPen(QPen(option.palette.highlightedText(), 0));-
189 }
never executed: end of block
0
190-
191 const QIcon *icon = &bitmap;-
192 if (QFontDatabase().isSmoothlyScalable(text)
QFontDatabase(...Scalable(text)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
193 icon = &truetype;-
194 }
never executed: end of block
0
195 QSize actualSize = icon->actualSize(r.size());-
196-
197 icon->paint(painter, r, Qt::AlignLeft|Qt::AlignVCenter);-
198 if (option.direction == Qt::RightToLeft
option.directi...t::RightToLeftDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
199 r.setRight(r.right() - actualSize.width() - 4);
never executed: r.setRight(r.right() - actualSize.width() - 4);
0
200 else-
201 r.setLeft(r.left() + actualSize.width() + 4);
never executed: r.setLeft(r.left() + actualSize.width() + 4);
0
202-
203 QFont old = painter->font();-
204 painter->setFont(font);-
205-
206-
207-
208-
209-
210 QFontMetricsF fontMetrics(font);-
211 if (fontMetrics.ascent() > r.height()
fontMetrics.as...) > r.height()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
212 QRectF tbr = fontMetrics.tightBoundingRect(text);-
213 painter->drawText(r.x(), r.y() + (r.height() + tbr.height()) / 2.0, text);-
214 }
never executed: end of block
else {
0
215 painter->drawText(r, Qt::AlignVCenter|Qt::AlignLeading|Qt::TextSingleLine, text);-
216 }
never executed: end of block
0
217-
218 if (writingSystem != QFontDatabase::Any
writingSystem ...tDatabase::AnyDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
219 system = writingSystem;
never executed: system = writingSystem;
0
220-
221 if (system != QFontDatabase::Any
system != QFontDatabase::AnyDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
222 int w = painter->fontMetrics().width(text + QLatin1String(" "));-
223 painter->setFont(font2);-
224 QString sample = QFontDatabase().writingSystemSample(system);-
225 if (option.direction == Qt::RightToLeft
option.directi...t::RightToLeftDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
226 r.setRight(r.right() - w);
never executed: r.setRight(r.right() - w);
0
227 else-
228 r.setLeft(r.left() + w);
never executed: r.setLeft(r.left() + w);
0
229 painter->drawText(r, Qt::AlignVCenter|Qt::AlignLeading|Qt::TextSingleLine, sample);-
230 }
never executed: end of block
0
231 painter->setFont(old);-
232-
233 if (option.state & QStyle::State_Selected
option.state &...State_SelectedDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
234 painter->restore();
never executed: painter->restore();
0
235-
236}
never executed: end of block
0
237-
238QSize QFontFamilyDelegate::sizeHint(const QStyleOptionViewItem &option,-
239 const QModelIndex &index) const-
240{-
241 QString text = index.data(Qt::DisplayRole).toString();-
242 QFont font(option.font);-
243-
244 font.setPointSize(QFontInfo(font).pointSize() * 3/2);-
245 QFontMetrics fontMetrics(font);-
246 return
never executed: return QSize(fontMetrics.width(text), fontMetrics.height());
QSize(fontMetrics.width(text), fontMetrics.height());
never executed: return QSize(fontMetrics.width(text), fontMetrics.height());
0
247}-
248-
249-
250class QFontComboBoxPrivate : public QComboBoxPrivate-
251{-
252public:-
253 inline QFontComboBoxPrivate() { filters = QFontComboBox::AllFonts; }
never executed: end of block
0
254-
255 QFontComboBox::FontFilters filters;-
256 QFont currentFont;-
257-
258 void _q_updateModel();-
259 void _q_currentChanged(const QString &);-
260-
261 inline QFontComboBox* q_func() { return static_cast<QFontComboBox *>(q_ptr); } inline const QFontComboBox* q_func() const { return static_cast<const QFontComboBox *>(q_ptr); } friend class QFontComboBox;-
262};-
263-
264-
265void QFontComboBoxPrivate::_q_updateModel()-
266{-
267 QFontComboBox * const q = q_func();-
268 const int scalableMask = (QFontComboBox::ScalableFonts | QFontComboBox::NonScalableFonts);-
269 const int spacingMask = (QFontComboBox::ProportionalFonts | QFontComboBox::MonospacedFonts);-
270-
271 QStringListModel *m = qobject_cast<QStringListModel *>(q->model());-
272 if (!m
!mDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
273 return;
never executed: return;
0
274 QFontFamilyDelegate *delegate = qobject_cast<QFontFamilyDelegate *>(q->view()->itemDelegate());-
275 QFontDatabase::WritingSystem system = delegate
delegateDescription
TRUEnever evaluated
FALSEnever evaluated
? delegate->writingSystem : QFontDatabase::Any;
0
276-
277 QFontDatabase fdb;-
278 QStringList list = fdb.families(system);-
279 QStringList result;-
280-
281 int offset = 0;-
282 QFontInfo fi(currentFont);-
283-
284 for (int i = 0; i < list.size()
i < list.size()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
285 if (fdb.isPrivateFamily(list.at(i))
fdb.isPrivateF...ly(list.at(i))Description
TRUEnever evaluated
FALSEnever evaluated
)
0
286 continue;
never executed: continue;
0
287-
288 if ((
(filters & scalableMask)Description
TRUEnever evaluated
FALSEnever evaluated
filters & scalableMask)
(filters & scalableMask)Description
TRUEnever evaluated
FALSEnever evaluated
&& (
(filters & sca...= scalableMaskDescription
TRUEnever evaluated
FALSEnever evaluated
filters & scalableMask) != scalableMask
(filters & sca...= scalableMaskDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
289 if (bool(filters & QFontComboBox::ScalableFonts) != fdb.isSmoothlyScalable(list.at(i))
bool(filters &...le(list.at(i))Description
TRUEnever evaluated
FALSEnever evaluated
)
0
290 continue;
never executed: continue;
0
291 }
never executed: end of block
0
292 if ((
(filters & spacingMask)Description
TRUEnever evaluated
FALSEnever evaluated
filters & spacingMask)
(filters & spacingMask)Description
TRUEnever evaluated
FALSEnever evaluated
&& (
(filters & spa...!= spacingMaskDescription
TRUEnever evaluated
FALSEnever evaluated
filters & spacingMask) != spacingMask
(filters & spa...!= spacingMaskDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
293 if (bool(filters & QFontComboBox::MonospacedFonts) != fdb.isFixedPitch(list.at(i))
bool(filters &...ch(list.at(i))Description
TRUEnever evaluated
FALSEnever evaluated
)
0
294 continue;
never executed: continue;
0
295 }
never executed: end of block
0
296 result += list.at(i);-
297 if (list.at(i) == fi.family()
list.at(i) == fi.family()Description
TRUEnever evaluated
FALSEnever evaluated
|| list.at(i).startsWith(fi.family() + QLatin1String(" ["))
list.at(i).sta...1String(" ["))Description
TRUEnever evaluated
FALSEnever evaluated
)
0
298 offset = result.count() - 1;
never executed: offset = result.count() - 1;
0
299 }
never executed: end of block
0
300 list = result;-
301-
302-
303-
304-
305-
306 {-
307 const QSignalBlocker blocker(m);-
308 m->setStringList(list);-
309 }-
310-
311 if (list.isEmpty()
list.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
312 if (currentFont != QFont()
currentFont != QFont()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
313 currentFont = QFont();-
314 q->currentFontChanged(currentFont);-
315 }
never executed: end of block
0
316 }
never executed: end of block
else {
0
317 q->setCurrentIndex(offset);-
318 }
never executed: end of block
0
319}-
320-
321-
322void QFontComboBoxPrivate::_q_currentChanged(const QString &text)-
323{-
324 QFontComboBox * const q = q_func();-
325 if (currentFont.family() != text
currentFont.family() != textDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
326 currentFont.setFamily(text);-
327 q->currentFontChanged(currentFont);-
328 }
never executed: end of block
0
329}
never executed: end of block
0
330QFontComboBox::QFontComboBox(QWidget *parent)-
331 : QComboBox(*new QFontComboBoxPrivate, parent)-
332{-
333 QFontComboBoxPrivate * const d = d_func();-
334 d->currentFont = font();-
335 setEditable(true);-
336-
337 QStringListModel *m = new QStringListModel(this);-
338 setModel(m);-
339 setItemDelegate(new QFontFamilyDelegate(this));-
340 QListView *lview = qobject_cast<QListView*>(view());-
341 if (lview
lviewDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
342 lview->setUniformItemSizes(true);
never executed: lview->setUniformItemSizes(true);
0
343 setWritingSystem(QFontDatabase::Any);-
344-
345 connect(this, qFlagLocation("2""currentIndexChanged(QString)" "\0" __FILE__ ":" "427"),-
346 this, qFlagLocation("1""_q_currentChanged(QString)" "\0" __FILE__ ":" "428"));-
347-
348 connect((static_cast<QApplication *>(QCoreApplication::instance())), qFlagLocation("2""fontDatabaseChanged()" "\0" __FILE__ ":" "430"),-
349 this, qFlagLocation("1""_q_updateModel()" "\0" __FILE__ ":" "431"));-
350}
never executed: end of block
0
351-
352-
353-
354-
355-
356QFontComboBox::~QFontComboBox()-
357{-
358}-
359void QFontComboBox::setWritingSystem(QFontDatabase::WritingSystem script)-
360{-
361 QFontComboBoxPrivate * const d = d_func();-
362 QFontFamilyDelegate *delegate = qobject_cast<QFontFamilyDelegate *>(view()->itemDelegate());-
363 if (delegate
delegateDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
364 delegate->
never executed: delegate->writingSystem = script;
writingSystem = script;
never executed: delegate->writingSystem = script;
0
365 d->_q_updateModel();-
366}
never executed: end of block
0
367-
368QFontDatabase::WritingSystem QFontComboBox::writingSystem() const-
369{-
370 QFontFamilyDelegate *delegate = qobject_cast<QFontFamilyDelegate *>(view()->itemDelegate());-
371 if (delegate
delegateDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
372 return
never executed: return delegate->writingSystem;
delegate->writingSystem;
never executed: return delegate->writingSystem;
0
373 return
never executed: return QFontDatabase::Any;
QFontDatabase::Any;
never executed: return QFontDatabase::Any;
0
374}-
375void QFontComboBox::setFontFilters(FontFilters filters)-
376{-
377 QFontComboBoxPrivate * const d = d_func();-
378 d->filters = filters;-
379 d->_q_updateModel();-
380}
never executed: end of block
0
381-
382QFontComboBox::FontFilters QFontComboBox::fontFilters() const-
383{-
384 const QFontComboBoxPrivate * const d = d_func();-
385 return
never executed: return d->filters;
d->filters;
never executed: return d->filters;
0
386}-
387-
388-
389-
390-
391-
392-
393-
394QFont QFontComboBox::currentFont() const-
395{-
396 const QFontComboBoxPrivate * const d = d_func();-
397 return
never executed: return d->currentFont;
d->currentFont;
never executed: return d->currentFont;
0
398}-
399-
400void QFontComboBox::setCurrentFont(const QFont &font)-
401{-
402 QFontComboBoxPrivate * const d = d_func();-
403 if (font != d->currentFont
font != d->currentFontDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
404 d->currentFont = font;-
405 d->_q_updateModel();-
406 if (d->currentFont == font
d->currentFont == fontDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
407 currentFontChanged(d->currentFont);-
408 }
never executed: end of block
0
409 }
never executed: end of block
0
410}
never executed: end of block
0
411bool QFontComboBox::event(QEvent *e)-
412{-
413 if (e->type() == QEvent::Resize
e->type() == QEvent::ResizeDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
414 QListView *lview = qobject_cast<QListView*>(view());-
415 if (lview
lviewDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
416 lview->window()->setFixedWidth(qMin(width() * 5 / 3,-
417 QApplication::desktop()->availableGeometry(lview).width()));-
418 }
never executed: end of block
0
419 }
never executed: end of block
0
420 return
never executed: return QComboBox::event(e);
QComboBox::event(e);
never executed: return QComboBox::event(e);
0
421}-
422-
423-
424-
425-
426QSize QFontComboBox::sizeHint() const-
427{-
428 QSize sz = QComboBox::sizeHint();-
429 QFontMetrics fm(font());-
430 sz.setWidth(fm.width(QLatin1Char('m'))*14);-
431 return
never executed: return sz;
sz;
never executed: return sz;
0
432}-
433-
434-
435-
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9