Line | Source Code | Coverage |
---|
1 | | - |
2 | | - |
3 | | - |
4 | | - |
5 | | - |
6 | | - |
7 | | - |
8 | class QFontListView : public QListView | - |
9 | { | - |
10 | public: template <typename T> inline void qt_check_for_QOBJECT_macro(const T &_q_argument) const { int i = qYouForgotTheQ_OBJECT_Macro(this, &_q_argument); i = i + 1; } static const QMetaObject staticMetaObject; virtual const QMetaObject *metaObject() const; virtual void *qt_metacast(const char *); static inline QString tr(const char *s, const char *c = 0, int n = -1) { return staticMetaObject.tr(s, c, n); } __attribute__ ((__deprecated__)) static inline QString trUtf8(const char *s, const char *c = 0, int n = -1) { return staticMetaObject.tr(s, c, n); } virtual int qt_metacall(QMetaObject::Call, int, void **); private: __attribute__((visibility("hidden"))) static void qt_static_metacall(QObject *, QMetaObject::Call, int, void **); struct QPrivateSignal {}; | - |
11 | public: | - |
12 | QFontListView(QWidget *parent); | - |
13 | inline QStringListModel *model() const { | - |
14 | return static_cast<QStringListModel *>(QListView::model()); executed: return static_cast<QStringListModel *>(QListView::model()); Execution Count:3409 | 3409 |
15 | } | - |
16 | inline void setCurrentItem(int item) { | - |
17 | QListView::setCurrentIndex(static_cast<QAbstractListModel*>(model())->index(item)); | - |
18 | } executed: } Execution Count:320 | 320 |
19 | inline int currentItem() const { | - |
20 | return QListView::currentIndex().row(); never executed: return QListView::currentIndex().row(); | 0 |
21 | } | - |
22 | inline int count() const { | - |
23 | return model()->rowCount(); executed: return model()->rowCount(); Execution Count:266 | 266 |
24 | } | - |
25 | inline QString currentText() const { | - |
26 | int row = QListView::currentIndex().row(); | - |
27 | return row < 0 ? QString() : model()->stringList().at(row); executed: return row < 0 ? QString() : model()->stringList().at(row); Execution Count:1868 | 1868 |
28 | } | - |
29 | void currentChanged(const QModelIndex ¤t, const QModelIndex &previous) { | - |
30 | QListView::currentChanged(current, previous); | - |
31 | if (current.isValid()) partially evaluated: current.isValid() yes Evaluation Count:407 | no Evaluation Count:0 |
| 0-407 |
32 | highlighted(current.row()); executed: highlighted(current.row()); Execution Count:407 | 407 |
33 | } executed: } Execution Count:407 | 407 |
34 | QString text(int i) const { | - |
35 | return model()->stringList().at(i); executed: return model()->stringList().at(i); Execution Count:641 | 641 |
36 | } | - |
37 | public: | - |
38 | void highlighted(int); | - |
39 | }; | - |
40 | | - |
41 | QFontListView::QFontListView(QWidget *parent) | - |
42 | : QListView(parent) | - |
43 | { | - |
44 | setModel(new QStringListModel(parent)); | - |
45 | setEditTriggers(NoEditTriggers); | - |
46 | } executed: } Execution Count:9 | 9 |
47 | | - |
48 | static const Qt::WindowFlags DefaultWindowFlags = | - |
49 | Qt::Dialog | Qt::WindowSystemMenuHint; | - |
50 | QFontDialog::QFontDialog(QWidget *parent) | - |
51 | : QDialog(*new QFontDialogPrivate, parent, DefaultWindowFlags) | - |
52 | { | - |
53 | QFontDialogPrivate * const d = d_func(); | - |
54 | d->init(); | - |
55 | } executed: } Execution Count:3 | 3 |
56 | | - |
57 | | - |
58 | | - |
59 | | - |
60 | | - |
61 | | - |
62 | | - |
63 | QFontDialog::QFontDialog(const QFont &initial, QWidget *parent) | - |
64 | : QDialog(*new QFontDialogPrivate, parent, DefaultWindowFlags) | - |
65 | { | - |
66 | QFontDialogPrivate * const d = d_func(); | - |
67 | d->init(); | - |
68 | setCurrentFont(initial); | - |
69 | } | 0 |
70 | | - |
71 | void QFontDialogPrivate::init() | - |
72 | { | - |
73 | QFontDialog * const q = q_func(); | - |
74 | | - |
75 | q->setSizeGripEnabled(true); | - |
76 | q->setWindowTitle(QFontDialog::tr("Select Font")); | - |
77 | | - |
78 | | - |
79 | familyEdit = new QLineEdit(q); | - |
80 | familyEdit->setReadOnly(true); | - |
81 | familyList = new QFontListView(q); | - |
82 | familyEdit->setFocusProxy(familyList); | - |
83 | | - |
84 | familyAccel = new QLabel(q); | - |
85 | | - |
86 | familyAccel->setBuddy(familyList); | - |
87 | | - |
88 | familyAccel->setIndent(2); | - |
89 | | - |
90 | styleEdit = new QLineEdit(q); | - |
91 | styleEdit->setReadOnly(true); | - |
92 | styleList = new QFontListView(q); | - |
93 | styleEdit->setFocusProxy(styleList); | - |
94 | | - |
95 | styleAccel = new QLabel(q); | - |
96 | | - |
97 | styleAccel->setBuddy(styleList); | - |
98 | | - |
99 | styleAccel->setIndent(2); | - |
100 | | - |
101 | sizeEdit = new QLineEdit(q); | - |
102 | sizeEdit->setFocusPolicy(Qt::ClickFocus); | - |
103 | QIntValidator *validator = new QIntValidator(1, 512, q); | - |
104 | sizeEdit->setValidator(validator); | - |
105 | sizeList = new QFontListView(q); | - |
106 | | - |
107 | sizeAccel = new QLabel(q); | - |
108 | | - |
109 | sizeAccel->setBuddy(sizeEdit); | - |
110 | | - |
111 | sizeAccel->setIndent(2); | - |
112 | | - |
113 | | - |
114 | effects = new QGroupBox(q); | - |
115 | QVBoxLayout *vbox = new QVBoxLayout(effects); | - |
116 | strikeout = new QCheckBox(effects); | - |
117 | vbox->addWidget(strikeout); | - |
118 | underline = new QCheckBox(effects); | - |
119 | vbox->addWidget(underline); | - |
120 | | - |
121 | sample = new QGroupBox(q); | - |
122 | QHBoxLayout *hbox = new QHBoxLayout(sample); | - |
123 | sampleEdit = new QLineEdit(sample); | - |
124 | sampleEdit->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored)); | - |
125 | sampleEdit->setAlignment(Qt::AlignCenter); | - |
126 | | - |
127 | | - |
128 | sampleEdit->setText(QLatin1String("AaBbYyZz")); | - |
129 | hbox->addWidget(sampleEdit); | - |
130 | | - |
131 | writingSystemCombo = new QComboBox(q); | - |
132 | | - |
133 | writingSystemAccel = new QLabel(q); | - |
134 | | - |
135 | writingSystemAccel->setBuddy(writingSystemCombo); | - |
136 | | - |
137 | writingSystemAccel->setIndent(2); | - |
138 | | - |
139 | size = 0; | - |
140 | smoothScalable = false; | - |
141 | | - |
142 | QObject::connect(writingSystemCombo, "2""activated(int)", q, "1""_q_writingSystemHighlighted(int)"); | - |
143 | QObject::connect(familyList, "2""highlighted(int)", q, "1""_q_familyHighlighted(int)"); | - |
144 | QObject::connect(styleList, "2""highlighted(int)", q, "1""_q_styleHighlighted(int)"); | - |
145 | QObject::connect(sizeList, "2""highlighted(int)", q, "1""_q_sizeHighlighted(int)"); | - |
146 | QObject::connect(sizeEdit, "2""textChanged(QString)", q, "1""_q_sizeChanged(QString)"); | - |
147 | | - |
148 | QObject::connect(strikeout, "2""clicked()", q, "1""_q_updateSample()"); | - |
149 | QObject::connect(underline, "2""clicked()", q, "1""_q_updateSample()"); | - |
150 | | - |
151 | for (int i = 0; i < QFontDatabase::WritingSystemsCount; ++i) { evaluated: i < QFontDatabase::WritingSystemsCount yes Evaluation Count:102 | yes Evaluation Count:3 |
| 3-102 |
152 | QFontDatabase::WritingSystem ws = QFontDatabase::WritingSystem(i); | - |
153 | QString writingSystemName = QFontDatabase::writingSystemName(ws); | - |
154 | if (writingSystemName.isEmpty()) partially evaluated: writingSystemName.isEmpty() no Evaluation Count:0 | yes Evaluation Count:102 |
| 0-102 |
155 | break; | 0 |
156 | writingSystemCombo->addItem(writingSystemName); | - |
157 | } executed: } Execution Count:102 | 102 |
158 | | - |
159 | updateFamilies(); | - |
160 | if (familyList->count() != 0) partially evaluated: familyList->count() != 0 yes Evaluation Count:3 | no Evaluation Count:0 |
| 0-3 |
161 | familyList->setCurrentItem(0); executed: familyList->setCurrentItem(0); Execution Count:3 | 3 |
162 | | - |
163 | | - |
164 | QGridLayout *mainGrid = new QGridLayout(q); | - |
165 | | - |
166 | int spacing = mainGrid->spacing(); | - |
167 | if (spacing >= 0) { partially evaluated: spacing >= 0 yes Evaluation Count:3 | no Evaluation Count:0 |
| 0-3 |
168 | mainGrid->setSpacing(0); | - |
169 | | - |
170 | mainGrid->setColumnMinimumWidth(1, spacing); | - |
171 | mainGrid->setColumnMinimumWidth(3, spacing); | - |
172 | | - |
173 | int margin = 0; | - |
174 | mainGrid->getContentsMargins(0, 0, 0, &margin); | - |
175 | | - |
176 | mainGrid->setRowMinimumHeight(3, margin); | - |
177 | mainGrid->setRowMinimumHeight(6, 2); | - |
178 | mainGrid->setRowMinimumHeight(8, margin); | - |
179 | } executed: } Execution Count:3 | 3 |
180 | | - |
181 | mainGrid->addWidget(familyAccel, 0, 0); | - |
182 | mainGrid->addWidget(familyEdit, 1, 0); | - |
183 | mainGrid->addWidget(familyList, 2, 0); | - |
184 | | - |
185 | mainGrid->addWidget(styleAccel, 0, 2); | - |
186 | mainGrid->addWidget(styleEdit, 1, 2); | - |
187 | mainGrid->addWidget(styleList, 2, 2); | - |
188 | | - |
189 | mainGrid->addWidget(sizeAccel, 0, 4); | - |
190 | mainGrid->addWidget(sizeEdit, 1, 4); | - |
191 | mainGrid->addWidget(sizeList, 2, 4); | - |
192 | | - |
193 | mainGrid->setColumnStretch(0, 38); | - |
194 | mainGrid->setColumnStretch(2, 24); | - |
195 | mainGrid->setColumnStretch(4, 10); | - |
196 | | - |
197 | mainGrid->addWidget(effects, 4, 0); | - |
198 | | - |
199 | mainGrid->addWidget(sample, 4, 2, 4, 3); | - |
200 | | - |
201 | mainGrid->addWidget(writingSystemAccel, 5, 0); | - |
202 | mainGrid->addWidget(writingSystemCombo, 7, 0); | - |
203 | | - |
204 | buttonBox = new QDialogButtonBox(q); | - |
205 | mainGrid->addWidget(buttonBox, 9, 0, 1, 5); | - |
206 | | - |
207 | QPushButton *button | - |
208 | = static_cast<QPushButton *>(buttonBox->addButton(QDialogButtonBox::Ok)); | - |
209 | QObject::connect(buttonBox, "2""accepted()", q, "1""accept()"); | - |
210 | button->setDefault(true); | - |
211 | | - |
212 | buttonBox->addButton(QDialogButtonBox::Cancel); | - |
213 | QObject::connect(buttonBox, "2""rejected()", q, "1""reject()"); | - |
214 | | - |
215 | | - |
216 | | - |
217 | | - |
218 | q->resize(500, 360); | - |
219 | | - |
220 | | - |
221 | sizeEdit->installEventFilter(q); | - |
222 | familyList->installEventFilter(q); | - |
223 | styleList->installEventFilter(q); | - |
224 | sizeList->installEventFilter(q); | - |
225 | | - |
226 | familyList->setFocus(); | - |
227 | retranslateStrings(); | - |
228 | } executed: } Execution Count:3 | 3 |
229 | | - |
230 | | - |
231 | | - |
232 | | - |
233 | | - |
234 | | - |
235 | QFontDialog::~QFontDialog() | - |
236 | { | - |
237 | } | - |
238 | QFont QFontDialog::getFont(bool *ok, const QFont &initial, QWidget *parent, const QString &title, | - |
239 | FontDialogOptions options) | - |
240 | { | - |
241 | return QFontDialogPrivate::getFont(ok, initial, parent, title, options); executed: return QFontDialogPrivate::getFont(ok, initial, parent, title, options); Execution Count:1 | 1 |
242 | } | - |
243 | QFont QFontDialog::getFont(bool *ok, QWidget *parent) | - |
244 | { | - |
245 | QFont initial; | - |
246 | return QFontDialogPrivate::getFont(ok, initial, parent, QString(), 0); executed: return QFontDialogPrivate::getFont(ok, initial, parent, QString(), 0); Execution Count:1 | 1 |
247 | } | - |
248 | | - |
249 | QFont QFontDialogPrivate::getFont(bool *ok, const QFont &initial, QWidget *parent, | - |
250 | const QString &title, QFontDialog::FontDialogOptions options) | - |
251 | { | - |
252 | QFontDialog dlg(parent); | - |
253 | dlg.setOptions(options); | - |
254 | dlg.setCurrentFont(initial); | - |
255 | if (!title.isEmpty()) partially evaluated: !title.isEmpty() no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
256 | dlg.setWindowTitle(title); never executed: dlg.setWindowTitle(title); | 0 |
257 | | - |
258 | int ret = (dlg.exec() || (options & QFontDialog::NoButtons)); partially evaluated: dlg.exec() yes Evaluation Count:2 | no Evaluation Count:0 |
never evaluated: (options & QFontDialog::NoButtons) | 0-2 |
259 | if (ok) partially evaluated: ok yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
260 | *ok = !!ret; executed: *ok = !!ret; Execution Count:2 | 2 |
261 | if (ret) { partially evaluated: ret yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
262 | return dlg.selectedFont(); executed: return dlg.selectedFont(); Execution Count:2 | 2 |
263 | } else { | - |
264 | return initial; never executed: return initial; | 0 |
265 | } | - |
266 | } | - |
267 | bool QFontDialog::eventFilter(QObject *o , QEvent *e) | - |
268 | { | - |
269 | QFontDialogPrivate * const d = d_func(); | - |
270 | if (e->type() == QEvent::KeyPress) { partially evaluated: e->type() == QEvent::KeyPress no Evaluation Count:0 | yes Evaluation Count:153 |
| 0-153 |
271 | QKeyEvent *k = (QKeyEvent *)e; | - |
272 | if (o == d->sizeEdit && never evaluated: o == d->sizeEdit | 0 |
273 | (k->key() == Qt::Key_Up || never evaluated: k->key() == Qt::Key_Up | 0 |
274 | k->key() == Qt::Key_Down || never evaluated: k->key() == Qt::Key_Down | 0 |
275 | k->key() == Qt::Key_PageUp || never evaluated: k->key() == Qt::Key_PageUp | 0 |
276 | k->key() == Qt::Key_PageDown)) { never evaluated: k->key() == Qt::Key_PageDown | 0 |
277 | | - |
278 | int ci = d->sizeList->currentItem(); | - |
279 | (void)QApplication::sendEvent(d->sizeList, k); | - |
280 | | - |
281 | if (ci != d->sizeList->currentItem() never evaluated: ci != d->sizeList->currentItem() | 0 |
282 | && style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, 0, this)) never evaluated: style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, 0, this) | 0 |
283 | d->sizeEdit->selectAll(); never executed: d->sizeEdit->selectAll(); | 0 |
284 | return true; never executed: return true; | 0 |
285 | } else if ((o == d->familyList || o == d->styleList) && never evaluated: o == d->familyList never evaluated: o == d->styleList | 0 |
286 | (k->key() == Qt::Key_Return || k->key() == Qt::Key_Enter)) { never evaluated: k->key() == Qt::Key_Return never evaluated: k->key() == Qt::Key_Enter | 0 |
287 | k->accept(); | - |
288 | accept(); | - |
289 | return true; never executed: return true; | 0 |
290 | } | - |
291 | } else if (e->type() == QEvent::FocusIn evaluated: e->type() == QEvent::FocusIn yes Evaluation Count:4 | yes Evaluation Count:149 |
| 4-149 |
292 | && style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, 0, this)) { partially evaluated: style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, 0, this) yes Evaluation Count:4 | no Evaluation Count:0 |
| 0-4 |
293 | if (o == d->familyList) partially evaluated: o == d->familyList yes Evaluation Count:4 | no Evaluation Count:0 |
| 0-4 |
294 | d->familyEdit->selectAll(); executed: d->familyEdit->selectAll(); Execution Count:4 | 4 |
295 | else if (o == d->styleList) never evaluated: o == d->styleList | 0 |
296 | d->styleEdit->selectAll(); never executed: d->styleEdit->selectAll(); | 0 |
297 | else if (o == d->sizeList) never evaluated: o == d->sizeList | 0 |
298 | d->sizeEdit->selectAll(); never executed: d->sizeEdit->selectAll(); | 0 |
299 | } else if (e->type() == QEvent::MouseButtonPress && o == d->sizeList) { partially evaluated: e->type() == QEvent::MouseButtonPress no Evaluation Count:0 | yes Evaluation Count:149 |
never evaluated: o == d->sizeList | 0-149 |
300 | d->sizeEdit->setFocus(); | - |
301 | } | 0 |
302 | return QDialog::eventFilter(o, e); executed: return QDialog::eventFilter(o, e); Execution Count:153 | 153 |
303 | } | - |
304 | | - |
305 | void QFontDialogPrivate::initHelper(QPlatformDialogHelper *h) | - |
306 | { | - |
307 | QFontDialog *d = q_func(); | - |
308 | QObject::connect(h, "2""currentFontChanged(QFont)", d, "2""currentFontChanged(QFont)"); | - |
309 | QObject::connect(h, "2""fontSelected(QFont)", d, "2""fontSelected(QFont)"); | - |
310 | static_cast<QPlatformFontDialogHelper *>(h)->setOptions(options); | - |
311 | } | 0 |
312 | | - |
313 | void QFontDialogPrivate::helperPrepareShow(QPlatformDialogHelper *) | - |
314 | { | - |
315 | options->setWindowTitle(q_func()->windowTitle()); | - |
316 | } | 0 |
317 | | - |
318 | | - |
319 | | - |
320 | | - |
321 | | - |
322 | | - |
323 | void QFontDialogPrivate::updateFamilies() | - |
324 | { | - |
325 | QFontDialog * const q = q_func(); | - |
326 | | - |
327 | enum match_t { MATCH_NONE = 0, MATCH_LAST_RESORT = 1, MATCH_APP = 2, MATCH_FAMILY = 3 }; | - |
328 | | - |
329 | QStringList familyNames = fdb.families(writingSystem); | - |
330 | | - |
331 | familyList->model()->setStringList(familyNames); | - |
332 | | - |
333 | QString foundryName1, familyName1, foundryName2, familyName2; | - |
334 | int bestFamilyMatch = -1; | - |
335 | match_t bestFamilyType = MATCH_NONE; | - |
336 | | - |
337 | QFont f; | - |
338 | | - |
339 | | - |
340 | QFontDatabase::parseFontName(family, foundryName1, familyName1); | - |
341 | | - |
342 | QStringList::const_iterator it = familyNames.constBegin(); | - |
343 | int i = 0; | - |
344 | for(; it != familyNames.constEnd(); ++it, ++i) { evaluated: it != familyNames.constEnd() yes Evaluation Count:440 | yes Evaluation Count:4 |
| 4-440 |
345 | QFontDatabase::parseFontName(*it, foundryName2, familyName2); | - |
346 | | - |
347 | | - |
348 | if (familyName1 == familyName2) { evaluated: familyName1 == familyName2 yes Evaluation Count:1 | yes Evaluation Count:439 |
| 1-439 |
349 | bestFamilyType = MATCH_FAMILY; | - |
350 | if (foundryName1 == foundryName2) { partially evaluated: foundryName1 == foundryName2 yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
351 | bestFamilyMatch = i; | - |
352 | break; executed: break; Execution Count:1 | 1 |
353 | } | - |
354 | if (bestFamilyMatch < MATCH_FAMILY) never evaluated: bestFamilyMatch < MATCH_FAMILY | 0 |
355 | bestFamilyMatch = i; never executed: bestFamilyMatch = i; | 0 |
356 | } | 0 |
357 | | - |
358 | | - |
359 | match_t type = MATCH_NONE; | - |
360 | if (bestFamilyType <= MATCH_NONE && familyName2 == f.lastResortFamily()) evaluated: bestFamilyType <= MATCH_NONE yes Evaluation Count:379 | yes Evaluation Count:60 |
partially evaluated: familyName2 == f.lastResortFamily() no Evaluation Count:0 | yes Evaluation Count:379 |
| 0-379 |
361 | type = MATCH_LAST_RESORT; never executed: type = MATCH_LAST_RESORT; | 0 |
362 | if (bestFamilyType <= MATCH_LAST_RESORT && familyName2 == f.family()) evaluated: bestFamilyType <= MATCH_LAST_RESORT yes Evaluation Count:379 | yes Evaluation Count:60 |
evaluated: familyName2 == f.family() yes Evaluation Count:4 | yes Evaluation Count:375 |
| 4-379 |
363 | type = MATCH_APP; executed: type = MATCH_APP; Execution Count:4 | 4 |
364 | | - |
365 | if (type != MATCH_NONE) { evaluated: type != MATCH_NONE yes Evaluation Count:4 | yes Evaluation Count:435 |
| 4-435 |
366 | bestFamilyType = type; | - |
367 | bestFamilyMatch = i; | - |
368 | } executed: } Execution Count:4 | 4 |
369 | } executed: } Execution Count:439 | 439 |
370 | | - |
371 | if (i != -1 && bestFamilyType != MATCH_NONE) partially evaluated: i != -1 yes Evaluation Count:5 | no Evaluation Count:0 |
partially evaluated: bestFamilyType != MATCH_NONE yes Evaluation Count:5 | no Evaluation Count:0 |
| 0-5 |
372 | familyList->setCurrentItem(bestFamilyMatch); executed: familyList->setCurrentItem(bestFamilyMatch); Execution Count:5 | 5 |
373 | else | - |
374 | familyList->setCurrentItem(0); never executed: familyList->setCurrentItem(0); | 0 |
375 | familyEdit->setText(familyList->currentText()); | - |
376 | if (q->style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, 0, q) partially evaluated: q->style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, 0, q) yes Evaluation Count:5 | no Evaluation Count:0 |
| 0-5 |
377 | && familyList->hasFocus()) partially evaluated: familyList->hasFocus() no Evaluation Count:0 | yes Evaluation Count:5 |
| 0-5 |
378 | familyEdit->selectAll(); never executed: familyEdit->selectAll(); | 0 |
379 | | - |
380 | updateStyles(); | - |
381 | } executed: } Execution Count:5 | 5 |
382 | | - |
383 | | - |
384 | | - |
385 | | - |
386 | | - |
387 | void QFontDialogPrivate::updateStyles() | - |
388 | { | - |
389 | QFontDialog * const q = q_func(); | - |
390 | QStringList styles = fdb.styles(familyList->currentText()); | - |
391 | styleList->model()->setStringList(styles); | - |
392 | | - |
393 | if (styles.isEmpty()) { partially evaluated: styles.isEmpty() no Evaluation Count:0 | yes Evaluation Count:103 |
| 0-103 |
394 | styleEdit->clear(); | - |
395 | smoothScalable = false; | - |
396 | } else { | 0 |
397 | if (!style.isEmpty()) { evaluated: !style.isEmpty() yes Evaluation Count:100 | yes Evaluation Count:3 |
| 3-100 |
398 | bool found = false; | - |
399 | bool first = true; | - |
400 | QString cstyle = style; | - |
401 | | - |
402 | redo: code before this statement executed: redo: Execution Count:100 | 100 |
403 | for (int i = 0; i < (int)styleList->count(); i++) { evaluated: i < (int)styleList->count() yes Evaluation Count:231 | yes Evaluation Count:26 |
| 26-231 |
404 | if (cstyle == styleList->text(i)) { evaluated: cstyle == styleList->text(i) yes Evaluation Count:82 | yes Evaluation Count:149 |
| 82-149 |
405 | styleList->setCurrentItem(i); | - |
406 | found = true; | - |
407 | break; executed: break; Execution Count:82 | 82 |
408 | } | - |
409 | } executed: } Execution Count:149 | 149 |
410 | if (!found && first) { evaluated: !found yes Evaluation Count:26 | yes Evaluation Count:82 |
evaluated: first yes Evaluation Count:20 | yes Evaluation Count:6 |
| 6-82 |
411 | if (cstyle.contains(QLatin1String("Italic"))) { evaluated: cstyle.contains(QLatin1String("Italic")) yes Evaluation Count:6 | yes Evaluation Count:14 |
| 6-14 |
412 | cstyle.replace(QLatin1String("Italic"), QLatin1String("Oblique")); | - |
413 | first = false; | - |
414 | goto redo; executed: goto redo; Execution Count:6 | 6 |
415 | } else if (cstyle.contains(QLatin1String("Oblique"))) { evaluated: cstyle.contains(QLatin1String("Oblique")) yes Evaluation Count:2 | yes Evaluation Count:12 |
| 2-12 |
416 | cstyle.replace(QLatin1String("Oblique"), QLatin1String("Italic")); | - |
417 | first = false; | - |
418 | goto redo; executed: goto redo; Execution Count:2 | 2 |
419 | } | - |
420 | } | - |
421 | if (!found) evaluated: !found yes Evaluation Count:18 | yes Evaluation Count:82 |
| 18-82 |
422 | styleList->setCurrentItem(0); executed: styleList->setCurrentItem(0); Execution Count:18 | 18 |
423 | } else { executed: } Execution Count:100 | 100 |
424 | styleList->setCurrentItem(0); | - |
425 | } executed: } Execution Count:3 | 3 |
426 | | - |
427 | styleEdit->setText(styleList->currentText()); | - |
428 | if (q->style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, 0, q) partially evaluated: q->style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, 0, q) yes Evaluation Count:103 | no Evaluation Count:0 |
| 0-103 |
429 | && styleList->hasFocus()) partially evaluated: styleList->hasFocus() no Evaluation Count:0 | yes Evaluation Count:103 |
| 0-103 |
430 | styleEdit->selectAll(); never executed: styleEdit->selectAll(); | 0 |
431 | | - |
432 | smoothScalable = fdb.isSmoothlyScalable(familyList->currentText(), styleList->currentText()); | - |
433 | } executed: } Execution Count:103 | 103 |
434 | | - |
435 | updateSizes(); | - |
436 | } executed: } Execution Count:103 | 103 |
437 | | - |
438 | | - |
439 | | - |
440 | | - |
441 | | - |
442 | | - |
443 | | - |
444 | void QFontDialogPrivate::updateSizes() | - |
445 | { | - |
446 | QFontDialog * const q = q_func(); | - |
447 | | - |
448 | if (!familyList->currentText().isEmpty()) { partially evaluated: !familyList->currentText().isEmpty() yes Evaluation Count:206 | no Evaluation Count:0 |
| 0-206 |
449 | QList<int> sizes = fdb.pointSizes(familyList->currentText(), styleList->currentText()); | - |
450 | | - |
451 | int i = 0; | - |
452 | int current = -1; | - |
453 | QStringList str_sizes; | - |
454 | for(QList<int>::const_iterator it = sizes.constBegin(); it != sizes.constEnd(); ++it) { evaluated: it != sizes.constEnd() yes Evaluation Count:3708 | yes Evaluation Count:206 |
| 206-3708 |
455 | str_sizes.append(QString::number(*it)); | - |
456 | if (current == -1 && *it >= size) evaluated: current == -1 yes Evaluation Count:266 | yes Evaluation Count:3442 |
evaluated: *it >= size yes Evaluation Count:206 | yes Evaluation Count:60 |
| 60-3442 |
457 | current = i; executed: current = i; Execution Count:206 | 206 |
458 | ++i; | - |
459 | } executed: } Execution Count:3708 | 3708 |
460 | sizeList->model()->setStringList(str_sizes); | - |
461 | if (current == -1) { partially evaluated: current == -1 no Evaluation Count:0 | yes Evaluation Count:206 |
| 0-206 |
462 | | - |
463 | current = sizeList->count() - 1; | - |
464 | } | 0 |
465 | sizeList->setCurrentItem(current); | - |
466 | | - |
467 | sizeEdit->blockSignals(true); | - |
468 | sizeEdit->setText((smoothScalable ? QString::number(size) : sizeList->currentText())); | - |
469 | if (q->style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, 0, q) partially evaluated: q->style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, 0, q) yes Evaluation Count:206 | no Evaluation Count:0 |
| 0-206 |
470 | && sizeList->hasFocus()) partially evaluated: sizeList->hasFocus() no Evaluation Count:0 | yes Evaluation Count:206 |
| 0-206 |
471 | sizeEdit->selectAll(); never executed: sizeEdit->selectAll(); | 0 |
472 | sizeEdit->blockSignals(false); | - |
473 | } else { executed: } Execution Count:206 | 206 |
474 | sizeEdit->clear(); | - |
475 | } | 0 |
476 | | - |
477 | _q_updateSample(); | - |
478 | } executed: } Execution Count:206 | 206 |
479 | | - |
480 | void QFontDialogPrivate::_q_updateSample() | - |
481 | { | - |
482 | | - |
483 | int pSize = sizeEdit->text().toInt(); | - |
484 | QFont newFont(fdb.font(familyList->currentText(), style, pSize)); | - |
485 | newFont.setStrikeOut(strikeout->isChecked()); | - |
486 | newFont.setUnderline(underline->isChecked()); | - |
487 | | - |
488 | if (familyList->currentText().isEmpty()) partially evaluated: familyList->currentText().isEmpty() no Evaluation Count:0 | yes Evaluation Count:415 |
| 0-415 |
489 | sampleEdit->clear(); never executed: sampleEdit->clear(); | 0 |
490 | | - |
491 | updateSampleFont(newFont); | - |
492 | } executed: } Execution Count:415 | 415 |
493 | | - |
494 | void QFontDialogPrivate::updateSampleFont(const QFont &newFont) | - |
495 | { | - |
496 | QFontDialog * const q = q_func(); | - |
497 | if (newFont != sampleEdit->font()) { evaluated: newFont != sampleEdit->font() yes Evaluation Count:98 | yes Evaluation Count:317 |
| 98-317 |
498 | sampleEdit->setFont(newFont); | - |
499 | q->currentFontChanged(newFont); | - |
500 | } executed: } Execution Count:98 | 98 |
501 | } executed: } Execution Count:415 | 415 |
502 | | - |
503 | | - |
504 | | - |
505 | | - |
506 | void QFontDialogPrivate::_q_writingSystemHighlighted(int index) | - |
507 | { | - |
508 | writingSystem = QFontDatabase::WritingSystem(index); | - |
509 | sampleEdit->setText(fdb.writingSystemSample(writingSystem)); | - |
510 | updateFamilies(); | - |
511 | } | 0 |
512 | | - |
513 | | - |
514 | | - |
515 | | - |
516 | void QFontDialogPrivate::_q_familyHighlighted(int i) | - |
517 | { | - |
518 | QFontDialog * const q = q_func(); | - |
519 | family = familyList->text(i); | - |
520 | familyEdit->setText(family); | - |
521 | if (q->style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, 0, q) partially evaluated: q->style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, 0, q) yes Evaluation Count:98 | no Evaluation Count:0 |
| 0-98 |
522 | && familyList->hasFocus()) partially evaluated: familyList->hasFocus() no Evaluation Count:0 | yes Evaluation Count:98 |
| 0-98 |
523 | familyEdit->selectAll(); never executed: familyEdit->selectAll(); | 0 |
524 | | - |
525 | updateStyles(); | - |
526 | } executed: } Execution Count:98 | 98 |
527 | | - |
528 | | - |
529 | | - |
530 | | - |
531 | | - |
532 | | - |
533 | void QFontDialogPrivate::_q_styleHighlighted(int index) | - |
534 | { | - |
535 | QFontDialog * const q = q_func(); | - |
536 | QString s = styleList->text(index); | - |
537 | styleEdit->setText(s); | - |
538 | if (q->style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, 0, q) partially evaluated: q->style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, 0, q) yes Evaluation Count:103 | no Evaluation Count:0 |
| 0-103 |
539 | && styleList->hasFocus()) partially evaluated: styleList->hasFocus() no Evaluation Count:0 | yes Evaluation Count:103 |
| 0-103 |
540 | styleEdit->selectAll(); never executed: styleEdit->selectAll(); | 0 |
541 | | - |
542 | style = s; | - |
543 | | - |
544 | updateSizes(); | - |
545 | } executed: } Execution Count:103 | 103 |
546 | | - |
547 | | - |
548 | | - |
549 | | - |
550 | | - |
551 | | - |
552 | void QFontDialogPrivate::_q_sizeHighlighted(int index) | - |
553 | { | - |
554 | QFontDialog * const q = q_func(); | - |
555 | QString s = sizeList->text(index); | - |
556 | sizeEdit->setText(s); | - |
557 | if (q->style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, 0, q) partially evaluated: q->style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, 0, q) yes Evaluation Count:206 | no Evaluation Count:0 |
| 0-206 |
558 | && sizeEdit->hasFocus()) partially evaluated: sizeEdit->hasFocus() no Evaluation Count:0 | yes Evaluation Count:206 |
| 0-206 |
559 | sizeEdit->selectAll(); never executed: sizeEdit->selectAll(); | 0 |
560 | | - |
561 | size = s.toInt(); | - |
562 | _q_updateSample(); | - |
563 | } executed: } Execution Count:206 | 206 |
564 | | - |
565 | | - |
566 | | - |
567 | | - |
568 | | - |
569 | | - |
570 | | - |
571 | void QFontDialogPrivate::_q_sizeChanged(const QString &s) | - |
572 | { | - |
573 | | - |
574 | int size = s.toInt(); | - |
575 | if (this->size == size) evaluated: this->size == size yes Evaluation Count:2 | yes Evaluation Count:3 |
| 2-3 |
576 | return; executed: return; Execution Count:2 | 2 |
577 | | - |
578 | this->size = size; | - |
579 | if (sizeList->count() != 0) { partially evaluated: sizeList->count() != 0 yes Evaluation Count:3 | no Evaluation Count:0 |
| 0-3 |
580 | int i; | - |
581 | for (i = 0; i < sizeList->count() - 1; i++) { partially evaluated: i < sizeList->count() - 1 yes Evaluation Count:3 | no Evaluation Count:0 |
| 0-3 |
582 | if (sizeList->text(i).toInt() >= this->size) partially evaluated: sizeList->text(i).toInt() >= this->size yes Evaluation Count:3 | no Evaluation Count:0 |
| 0-3 |
583 | break; executed: break; Execution Count:3 | 3 |
584 | } | 0 |
585 | sizeList->blockSignals(true); | - |
586 | sizeList->setCurrentItem(i); | - |
587 | sizeList->blockSignals(false); | - |
588 | } executed: } Execution Count:3 | 3 |
589 | _q_updateSample(); | - |
590 | } executed: } Execution Count:3 | 3 |
591 | | - |
592 | void QFontDialogPrivate::retranslateStrings() | - |
593 | { | - |
594 | familyAccel->setText(QFontDialog::tr("&Font")); | - |
595 | styleAccel->setText(QFontDialog::tr("Font st&yle")); | - |
596 | sizeAccel->setText(QFontDialog::tr("&Size")); | - |
597 | effects->setTitle(QFontDialog::tr("Effects")); | - |
598 | strikeout->setText(QFontDialog::tr("Stri&keout")); | - |
599 | underline->setText(QFontDialog::tr("&Underline")); | - |
600 | sample->setTitle(QFontDialog::tr("Sample")); | - |
601 | writingSystemAccel->setText(QFontDialog::tr("Wr&iting System")); | - |
602 | } executed: } Execution Count:3 | 3 |
603 | | - |
604 | | - |
605 | | - |
606 | | - |
607 | void QFontDialog::changeEvent(QEvent *e) | - |
608 | { | - |
609 | QFontDialogPrivate * const d = d_func(); | - |
610 | if (e->type() == QEvent::LanguageChange) { partially evaluated: e->type() == QEvent::LanguageChange no Evaluation Count:0 | yes Evaluation Count:7 |
| 0-7 |
611 | d->retranslateStrings(); | - |
612 | } | 0 |
613 | QDialog::changeEvent(e); | - |
614 | } executed: } Execution Count:7 | 7 |
615 | void QFontDialog::setCurrentFont(const QFont &font) | - |
616 | { | - |
617 | QFontDialogPrivate * const d = d_func(); | - |
618 | d->family = font.family(); | - |
619 | d->style = d->fdb.styleString(font); | - |
620 | d->size = font.pointSize(); | - |
621 | if (d->size == -1) { evaluated: d->size == -1 yes Evaluation Count:1 | yes Evaluation Count:1 |
| 1 |
622 | QFontInfo fi(font); | - |
623 | d->size = fi.pointSize(); | - |
624 | } executed: } Execution Count:1 | 1 |
625 | d->strikeout->setChecked(font.strikeOut()); | - |
626 | d->underline->setChecked(font.underline()); | - |
627 | d->updateFamilies(); | - |
628 | if (d->canBeNativeDialog()) { partially evaluated: d->canBeNativeDialog() yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
629 | if (QPlatformFontDialogHelper *helper = d->platformFontDialogHelper()) partially evaluated: QPlatformFontDialogHelper *helper = d->platformFontDialogHelper() no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
630 | helper->setCurrentFont(font); never executed: helper->setCurrentFont(font); | 0 |
631 | } executed: } Execution Count:2 | 2 |
632 | } executed: } Execution Count:2 | 2 |
633 | QFont QFontDialog::currentFont() const | - |
634 | { | - |
635 | const QFontDialogPrivate * const d = d_func(); | - |
636 | if (d->canBeNativeDialog()) { evaluated: d->canBeNativeDialog() yes Evaluation Count:2 | yes Evaluation Count:91 |
| 2-91 |
637 | if (const QPlatformFontDialogHelper *helper = d->platformFontDialogHelper()) partially evaluated: const QPlatformFontDialogHelper *helper = d->platformFontDialogHelper() no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
638 | return helper->currentFont(); never executed: return helper->currentFont(); | 0 |
639 | } executed: } Execution Count:2 | 2 |
640 | return d->sampleEdit->font(); executed: return d->sampleEdit->font(); Execution Count:93 | 93 |
641 | } | - |
642 | QFont QFontDialog::selectedFont() const | - |
643 | { | - |
644 | const QFontDialogPrivate * const d = d_func(); | - |
645 | return d->selectedFont; executed: return d->selectedFont; Execution Count:2 | 2 |
646 | } | - |
647 | void QFontDialog::setOption(FontDialogOption option, bool on) | - |
648 | { | - |
649 | const QFontDialog::FontDialogOptions previousOptions = options(); | - |
650 | if (!(previousOptions & option) != !on) partially evaluated: !(previousOptions & option) != !on yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
651 | setOptions(previousOptions ^ option); executed: setOptions(previousOptions ^ option); Execution Count:1 | 1 |
652 | } executed: } Execution Count:1 | 1 |
653 | | - |
654 | | - |
655 | | - |
656 | | - |
657 | | - |
658 | | - |
659 | | - |
660 | bool QFontDialog::testOption(FontDialogOption option) const | - |
661 | { | - |
662 | const QFontDialogPrivate * const d = d_func(); | - |
663 | return d->options->testOption(static_cast<QFontDialogOptions::FontDialogOption>(option)); never executed: return d->options->testOption(static_cast<QFontDialogOptions::FontDialogOption>(option)); | 0 |
664 | } | - |
665 | void QFontDialog::setOptions(FontDialogOptions options) | - |
666 | { | - |
667 | QFontDialogPrivate * const d = d_func(); | - |
668 | | - |
669 | if (QFontDialog::options() == options) evaluated: QFontDialog::options() == options yes Evaluation Count:2 | yes Evaluation Count:1 |
| 1-2 |
670 | return; executed: return; Execution Count:2 | 2 |
671 | | - |
672 | d->options->setOptions(QFontDialogOptions::FontDialogOptions(int(options))); | - |
673 | d->buttonBox->setVisible(!(options & NoButtons)); | - |
674 | } executed: } Execution Count:1 | 1 |
675 | | - |
676 | QFontDialog::FontDialogOptions QFontDialog::options() const | - |
677 | { | - |
678 | const QFontDialogPrivate * const d = d_func(); | - |
679 | return QFontDialog::FontDialogOptions(int(d->options->options())); executed: return QFontDialog::FontDialogOptions(int(d->options->options())); Execution Count:4 | 4 |
680 | } | - |
681 | void QFontDialog::open(QObject *receiver, const char *member) | - |
682 | { | - |
683 | QFontDialogPrivate * const d = d_func(); | - |
684 | connect(this, "2""fontSelected(QFont)", receiver, member); | - |
685 | d->receiverToDisconnectOnClose = receiver; | - |
686 | d->memberToDisconnectOnClose = member; | - |
687 | QDialog::open(); | - |
688 | } | 0 |
689 | void QFontDialog::setVisible(bool visible) | - |
690 | { | - |
691 | if (testAttribute(Qt::WA_WState_ExplicitShowHide) && testAttribute(Qt::WA_WState_Hidden) != visible) evaluated: testAttribute(Qt::WA_WState_ExplicitShowHide) yes Evaluation Count:2 | yes Evaluation Count:2 |
partially evaluated: testAttribute(Qt::WA_WState_Hidden) != visible no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
692 | return; | 0 |
693 | QFontDialogPrivate * const d = d_func(); | - |
694 | if (d->canBeNativeDialog()) partially evaluated: d->canBeNativeDialog() yes Evaluation Count:4 | no Evaluation Count:0 |
| 0-4 |
695 | d->setNativeDialogVisible(visible); executed: d->setNativeDialogVisible(visible); Execution Count:4 | 4 |
696 | if (d->nativeDialogInUse) { partially evaluated: d->nativeDialogInUse no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
697 | | - |
698 | | - |
699 | setAttribute(Qt::WA_DontShowOnScreen, true); | - |
700 | } else { | 0 |
701 | d->nativeDialogInUse = false; | - |
702 | setAttribute(Qt::WA_DontShowOnScreen, false); | - |
703 | } executed: } Execution Count:4 | 4 |
704 | QDialog::setVisible(visible); | - |
705 | } executed: } Execution Count:4 | 4 |
706 | void QFontDialog::done(int result) | - |
707 | { | - |
708 | QFontDialogPrivate * const d = d_func(); | - |
709 | QDialog::done(result); | - |
710 | if (result == Accepted) { partially evaluated: result == Accepted yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
711 | | - |
712 | QFont selectedFont = currentFont(); | - |
713 | if(selectedFont != d->selectedFont) evaluated: selectedFont != d->selectedFont yes Evaluation Count:1 | yes Evaluation Count:1 |
| 1 |
714 | (currentFontChanged(selectedFont)); executed: (currentFontChanged(selectedFont)); Execution Count:1 | 1 |
715 | d->selectedFont = selectedFont; | - |
716 | fontSelected(d->selectedFont); | - |
717 | } else executed: } Execution Count:2 | 2 |
718 | d->selectedFont = QFont(); never executed: d->selectedFont = QFont(); | 0 |
719 | if (d->receiverToDisconnectOnClose) { partially evaluated: d->receiverToDisconnectOnClose no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
720 | disconnect(this, "2""fontSelected(QFont)", | - |
721 | d->receiverToDisconnectOnClose, d->memberToDisconnectOnClose); | - |
722 | d->receiverToDisconnectOnClose = 0; | - |
723 | } | 0 |
724 | d->memberToDisconnectOnClose.clear(); | - |
725 | } executed: } Execution Count:2 | 2 |
726 | | - |
727 | bool QFontDialogPrivate::canBeNativeDialog() const | - |
728 | { | - |
729 | const QFontDialog * const q = q_func(); | - |
730 | if (nativeDialogInUse) partially evaluated: nativeDialogInUse no Evaluation Count:0 | yes Evaluation Count:99 |
| 0-99 |
731 | return true; never executed: return true; | 0 |
732 | if (q->testAttribute(Qt::WA_DontShowOnScreen)) partially evaluated: q->testAttribute(Qt::WA_DontShowOnScreen) no Evaluation Count:0 | yes Evaluation Count:99 |
| 0-99 |
733 | return false; never executed: return false; | 0 |
734 | if (options->options() & QFontDialog::DontUseNativeDialog) evaluated: options->options() & QFontDialog::DontUseNativeDialog yes Evaluation Count:91 | yes Evaluation Count:8 |
| 8-91 |
735 | return false; executed: return false; Execution Count:91 | 91 |
736 | | - |
737 | QLatin1String staticName(QFontDialog::staticMetaObject.className()); | - |
738 | QLatin1String dynamicName(q->metaObject()->className()); | - |
739 | return (staticName == dynamicName); executed: return (staticName == dynamicName); Execution Count:8 | 8 |
740 | } | - |
741 | | - |
742 | | - |
743 | | - |
744 | | - |
| | |