Line | Source Code | Coverage |
---|
1 | /**************************************************************************** | - |
2 | ** | - |
3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). | - |
4 | ** Contact: http://www.qt-project.org/legal | - |
5 | ** | - |
6 | ** This file is part of the QtGui module of the Qt Toolkit. | - |
7 | ** | - |
8 | ** $QT_BEGIN_LICENSE:LGPL$ | - |
9 | ** Commercial License Usage | - |
10 | ** Licensees holding valid commercial Qt licenses may use this file in | - |
11 | ** accordance with the commercial license agreement provided with the | - |
12 | ** Software or, alternatively, in accordance with the terms contained in | - |
13 | ** a written agreement between you and Digia. For licensing terms and | - |
14 | ** conditions see http://qt.digia.com/licensing. For further information | - |
15 | ** use the contact form at http://qt.digia.com/contact-us. | - |
16 | ** | - |
17 | ** GNU Lesser General Public License Usage | - |
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - |
19 | ** General Public License version 2.1 as published by the Free Software | - |
20 | ** Foundation and appearing in the file LICENSE.LGPL included in the | - |
21 | ** packaging of this file. Please review the following information to | - |
22 | ** ensure the GNU Lesser General Public License version 2.1 requirements | - |
23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - |
24 | ** | - |
25 | ** In addition, as a special exception, Digia gives you certain additional | - |
26 | ** rights. These rights are described in the Digia Qt LGPL Exception | - |
27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - |
28 | ** | - |
29 | ** GNU General Public License Usage | - |
30 | ** Alternatively, this file may be used under the terms of the GNU | - |
31 | ** General Public License version 3.0 as published by the Free Software | - |
32 | ** Foundation and appearing in the file LICENSE.GPL included in the | - |
33 | ** packaging of this file. Please review the following information to | - |
34 | ** ensure the GNU General Public License version 3.0 requirements will be | - |
35 | ** met: http://www.gnu.org/copyleft/gpl.html. | - |
36 | ** | - |
37 | ** | - |
38 | ** $QT_END_LICENSE$ | - |
39 | ** | - |
40 | ****************************************************************************/ | - |
41 | | - |
42 | #include "qwindowdefs.h" | - |
43 | | - |
44 | #ifndef QT_NO_FONTDIALOG | - |
45 | | - |
46 | #include "qfontdialog.h" | - |
47 | #include "qfontdialog_p.h" | - |
48 | | - |
49 | #include <qapplication.h> | - |
50 | #include <qcheckbox.h> | - |
51 | #include <qcombobox.h> | - |
52 | #include <qevent.h> | - |
53 | #include <qfontdatabase.h> | - |
54 | #include <qgroupbox.h> | - |
55 | #include <qlabel.h> | - |
56 | #include <qlayout.h> | - |
57 | #include <qlineedit.h> | - |
58 | #include <qpushbutton.h> | - |
59 | #include <qstyle.h> | - |
60 | #include <qdialogbuttonbox.h> | - |
61 | #include <qheaderview.h> | - |
62 | #include <qlistview.h> | - |
63 | #include <qstringlistmodel.h> | - |
64 | #include <qvalidator.h> | - |
65 | #include <private/qdialog_p.h> | - |
66 | #include <private/qfont_p.h> | - |
67 | | - |
68 | QT_BEGIN_NAMESPACE | - |
69 | | - |
70 | class QFontListView : public QListView | - |
71 | { | - |
72 | Q_OBJECT | - |
73 | public: | - |
74 | QFontListView(QWidget *parent); | - |
75 | inline QStringListModel *model() const { | - |
76 | return static_cast<QStringListModel *>(QListView::model()); executed: return static_cast<QStringListModel *>(QListView::model()); Execution Count:3409 | 3409 |
77 | } | - |
78 | inline void setCurrentItem(int item) { | - |
79 | QListView::setCurrentIndex(static_cast<QAbstractListModel*>(model())->index(item)); executed (the execution status of this line is deduced): QListView::setCurrentIndex(static_cast<QAbstractListModel*>(model())->index(item)); | - |
80 | } executed: } Execution Count:320 | 320 |
81 | inline int currentItem() const { | - |
82 | return QListView::currentIndex().row(); never executed: return QListView::currentIndex().row(); | 0 |
83 | } | - |
84 | inline int count() const { | - |
85 | return model()->rowCount(); executed: return model()->rowCount(); Execution Count:266 | 266 |
86 | } | - |
87 | inline QString currentText() const { | - |
88 | int row = QListView::currentIndex().row(); executed (the execution status of this line is deduced): int row = QListView::currentIndex().row(); | - |
89 | return row < 0 ? QString() : model()->stringList().at(row); executed: return row < 0 ? QString() : model()->stringList().at(row); Execution Count:1868 | 1868 |
90 | } | - |
91 | void currentChanged(const QModelIndex ¤t, const QModelIndex &previous) { | - |
92 | QListView::currentChanged(current, previous); executed (the execution status of this line is deduced): QListView::currentChanged(current, previous); | - |
93 | if (current.isValid()) partially evaluated: current.isValid() yes Evaluation Count:407 | no Evaluation Count:0 |
| 0-407 |
94 | emit highlighted(current.row()); executed: highlighted(current.row()); Execution Count:407 | 407 |
95 | } executed: } Execution Count:407 | 407 |
96 | QString text(int i) const { | - |
97 | return model()->stringList().at(i); executed: return model()->stringList().at(i); Execution Count:641 | 641 |
98 | } | - |
99 | signals: | - |
100 | void highlighted(int); | - |
101 | }; | - |
102 | | - |
103 | QFontListView::QFontListView(QWidget *parent) | - |
104 | : QListView(parent) | - |
105 | { | - |
106 | setModel(new QStringListModel(parent)); executed (the execution status of this line is deduced): setModel(new QStringListModel(parent)); | - |
107 | setEditTriggers(NoEditTriggers); executed (the execution status of this line is deduced): setEditTriggers(NoEditTriggers); | - |
108 | } executed: } Execution Count:9 | 9 |
109 | | - |
110 | static const Qt::WindowFlags DefaultWindowFlags = | - |
111 | Qt::Dialog | Qt::WindowSystemMenuHint; | - |
112 | | - |
113 | /*! | - |
114 | \class QFontDialog | - |
115 | \ingroup standard-dialogs | - |
116 | \inmodule QtWidgets | - |
117 | | - |
118 | \brief The QFontDialog class provides a dialog widget for selecting a font. | - |
119 | | - |
120 | A font dialog is created through one of the static getFont() | - |
121 | functions. | - |
122 | | - |
123 | Examples: | - |
124 | | - |
125 | \snippet code/src_gui_dialogs_qfontdialog.cpp 0 | - |
126 | | - |
127 | The dialog can also be used to set a widget's font directly: | - |
128 | \snippet code/src_gui_dialogs_qfontdialog.cpp 1 | - |
129 | If the user clicks OK the font they chose will be used for myWidget, | - |
130 | and if they click Cancel the original font is used. | - |
131 | | - |
132 | \image fusion-fontdialog.png A font dialog in the Fusion widget style. | - |
133 | | - |
134 | \sa QFont, QFontInfo, QFontMetrics, QColorDialog, QFileDialog, | - |
135 | {Standard Dialogs Example} | - |
136 | */ | - |
137 | | - |
138 | /*! | - |
139 | \since 4.5 | - |
140 | | - |
141 | Constructs a standard font dialog. | - |
142 | | - |
143 | Use setCurrentFont() to set the initial font attributes. | - |
144 | | - |
145 | The \a parent parameter is passed to the QDialog constructor. | - |
146 | | - |
147 | \sa getFont() | - |
148 | */ | - |
149 | QFontDialog::QFontDialog(QWidget *parent) | - |
150 | : QDialog(*new QFontDialogPrivate, parent, DefaultWindowFlags) | - |
151 | { | - |
152 | Q_D(QFontDialog); executed (the execution status of this line is deduced): QFontDialogPrivate * const d = d_func(); | - |
153 | d->init(); executed (the execution status of this line is deduced): d->init(); | - |
154 | } executed: } Execution Count:3 | 3 |
155 | | - |
156 | /*! | - |
157 | \since 4.5 | - |
158 | | - |
159 | Constructs a standard font dialog with the given \a parent and specified | - |
160 | \a initial color. | - |
161 | */ | - |
162 | QFontDialog::QFontDialog(const QFont &initial, QWidget *parent) | - |
163 | : QDialog(*new QFontDialogPrivate, parent, DefaultWindowFlags) | - |
164 | { | - |
165 | Q_D(QFontDialog); never executed (the execution status of this line is deduced): QFontDialogPrivate * const d = d_func(); | - |
166 | d->init(); never executed (the execution status of this line is deduced): d->init(); | - |
167 | setCurrentFont(initial); never executed (the execution status of this line is deduced): setCurrentFont(initial); | - |
168 | } | 0 |
169 | | - |
170 | void QFontDialogPrivate::init() | - |
171 | { | - |
172 | Q_Q(QFontDialog); executed (the execution status of this line is deduced): QFontDialog * const q = q_func(); | - |
173 | | - |
174 | q->setSizeGripEnabled(true); executed (the execution status of this line is deduced): q->setSizeGripEnabled(true); | - |
175 | q->setWindowTitle(QFontDialog::tr("Select Font")); executed (the execution status of this line is deduced): q->setWindowTitle(QFontDialog::tr("Select Font")); | - |
176 | | - |
177 | // grid | - |
178 | familyEdit = new QLineEdit(q); executed (the execution status of this line is deduced): familyEdit = new QLineEdit(q); | - |
179 | familyEdit->setReadOnly(true); executed (the execution status of this line is deduced): familyEdit->setReadOnly(true); | - |
180 | familyList = new QFontListView(q); executed (the execution status of this line is deduced): familyList = new QFontListView(q); | - |
181 | familyEdit->setFocusProxy(familyList); executed (the execution status of this line is deduced): familyEdit->setFocusProxy(familyList); | - |
182 | | - |
183 | familyAccel = new QLabel(q); executed (the execution status of this line is deduced): familyAccel = new QLabel(q); | - |
184 | #ifndef QT_NO_SHORTCUT | - |
185 | familyAccel->setBuddy(familyList); executed (the execution status of this line is deduced): familyAccel->setBuddy(familyList); | - |
186 | #endif | - |
187 | familyAccel->setIndent(2); executed (the execution status of this line is deduced): familyAccel->setIndent(2); | - |
188 | | - |
189 | styleEdit = new QLineEdit(q); executed (the execution status of this line is deduced): styleEdit = new QLineEdit(q); | - |
190 | styleEdit->setReadOnly(true); executed (the execution status of this line is deduced): styleEdit->setReadOnly(true); | - |
191 | styleList = new QFontListView(q); executed (the execution status of this line is deduced): styleList = new QFontListView(q); | - |
192 | styleEdit->setFocusProxy(styleList); executed (the execution status of this line is deduced): styleEdit->setFocusProxy(styleList); | - |
193 | | - |
194 | styleAccel = new QLabel(q); executed (the execution status of this line is deduced): styleAccel = new QLabel(q); | - |
195 | #ifndef QT_NO_SHORTCUT | - |
196 | styleAccel->setBuddy(styleList); executed (the execution status of this line is deduced): styleAccel->setBuddy(styleList); | - |
197 | #endif | - |
198 | styleAccel->setIndent(2); executed (the execution status of this line is deduced): styleAccel->setIndent(2); | - |
199 | | - |
200 | sizeEdit = new QLineEdit(q); executed (the execution status of this line is deduced): sizeEdit = new QLineEdit(q); | - |
201 | sizeEdit->setFocusPolicy(Qt::ClickFocus); executed (the execution status of this line is deduced): sizeEdit->setFocusPolicy(Qt::ClickFocus); | - |
202 | QIntValidator *validator = new QIntValidator(1, 512, q); executed (the execution status of this line is deduced): QIntValidator *validator = new QIntValidator(1, 512, q); | - |
203 | sizeEdit->setValidator(validator); executed (the execution status of this line is deduced): sizeEdit->setValidator(validator); | - |
204 | sizeList = new QFontListView(q); executed (the execution status of this line is deduced): sizeList = new QFontListView(q); | - |
205 | | - |
206 | sizeAccel = new QLabel(q); executed (the execution status of this line is deduced): sizeAccel = new QLabel(q); | - |
207 | #ifndef QT_NO_SHORTCUT | - |
208 | sizeAccel->setBuddy(sizeEdit); executed (the execution status of this line is deduced): sizeAccel->setBuddy(sizeEdit); | - |
209 | #endif | - |
210 | sizeAccel->setIndent(2); executed (the execution status of this line is deduced): sizeAccel->setIndent(2); | - |
211 | | - |
212 | // effects box | - |
213 | effects = new QGroupBox(q); executed (the execution status of this line is deduced): effects = new QGroupBox(q); | - |
214 | QVBoxLayout *vbox = new QVBoxLayout(effects); executed (the execution status of this line is deduced): QVBoxLayout *vbox = new QVBoxLayout(effects); | - |
215 | strikeout = new QCheckBox(effects); executed (the execution status of this line is deduced): strikeout = new QCheckBox(effects); | - |
216 | vbox->addWidget(strikeout); executed (the execution status of this line is deduced): vbox->addWidget(strikeout); | - |
217 | underline = new QCheckBox(effects); executed (the execution status of this line is deduced): underline = new QCheckBox(effects); | - |
218 | vbox->addWidget(underline); executed (the execution status of this line is deduced): vbox->addWidget(underline); | - |
219 | | - |
220 | sample = new QGroupBox(q); executed (the execution status of this line is deduced): sample = new QGroupBox(q); | - |
221 | QHBoxLayout *hbox = new QHBoxLayout(sample); executed (the execution status of this line is deduced): QHBoxLayout *hbox = new QHBoxLayout(sample); | - |
222 | sampleEdit = new QLineEdit(sample); executed (the execution status of this line is deduced): sampleEdit = new QLineEdit(sample); | - |
223 | sampleEdit->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored)); executed (the execution status of this line is deduced): sampleEdit->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored)); | - |
224 | sampleEdit->setAlignment(Qt::AlignCenter); executed (the execution status of this line is deduced): sampleEdit->setAlignment(Qt::AlignCenter); | - |
225 | // Note that the sample text is *not* translated with tr(), as the | - |
226 | // characters used depend on the charset encoding. | - |
227 | sampleEdit->setText(QLatin1String("AaBbYyZz")); executed (the execution status of this line is deduced): sampleEdit->setText(QLatin1String("AaBbYyZz")); | - |
228 | hbox->addWidget(sampleEdit); executed (the execution status of this line is deduced): hbox->addWidget(sampleEdit); | - |
229 | | - |
230 | writingSystemCombo = new QComboBox(q); executed (the execution status of this line is deduced): writingSystemCombo = new QComboBox(q); | - |
231 | | - |
232 | writingSystemAccel = new QLabel(q); executed (the execution status of this line is deduced): writingSystemAccel = new QLabel(q); | - |
233 | #ifndef QT_NO_SHORTCUT | - |
234 | writingSystemAccel->setBuddy(writingSystemCombo); executed (the execution status of this line is deduced): writingSystemAccel->setBuddy(writingSystemCombo); | - |
235 | #endif | - |
236 | writingSystemAccel->setIndent(2); executed (the execution status of this line is deduced): writingSystemAccel->setIndent(2); | - |
237 | | - |
238 | size = 0; executed (the execution status of this line is deduced): size = 0; | - |
239 | smoothScalable = false; executed (the execution status of this line is deduced): smoothScalable = false; | - |
240 | | - |
241 | QObject::connect(writingSystemCombo, SIGNAL(activated(int)), q, SLOT(_q_writingSystemHighlighted(int))); executed (the execution status of this line is deduced): QObject::connect(writingSystemCombo, "2""activated(int)", q, "1""_q_writingSystemHighlighted(int)"); | - |
242 | QObject::connect(familyList, SIGNAL(highlighted(int)), q, SLOT(_q_familyHighlighted(int))); executed (the execution status of this line is deduced): QObject::connect(familyList, "2""highlighted(int)", q, "1""_q_familyHighlighted(int)"); | - |
243 | QObject::connect(styleList, SIGNAL(highlighted(int)), q, SLOT(_q_styleHighlighted(int))); executed (the execution status of this line is deduced): QObject::connect(styleList, "2""highlighted(int)", q, "1""_q_styleHighlighted(int)"); | - |
244 | QObject::connect(sizeList, SIGNAL(highlighted(int)), q, SLOT(_q_sizeHighlighted(int))); executed (the execution status of this line is deduced): QObject::connect(sizeList, "2""highlighted(int)", q, "1""_q_sizeHighlighted(int)"); | - |
245 | QObject::connect(sizeEdit, SIGNAL(textChanged(QString)), q, SLOT(_q_sizeChanged(QString))); executed (the execution status of this line is deduced): QObject::connect(sizeEdit, "2""textChanged(QString)", q, "1""_q_sizeChanged(QString)"); | - |
246 | | - |
247 | QObject::connect(strikeout, SIGNAL(clicked()), q, SLOT(_q_updateSample())); executed (the execution status of this line is deduced): QObject::connect(strikeout, "2""clicked()", q, "1""_q_updateSample()"); | - |
248 | QObject::connect(underline, SIGNAL(clicked()), q, SLOT(_q_updateSample())); executed (the execution status of this line is deduced): QObject::connect(underline, "2""clicked()", q, "1""_q_updateSample()"); | - |
249 | | - |
250 | for (int i = 0; i < QFontDatabase::WritingSystemsCount; ++i) { evaluated: i < QFontDatabase::WritingSystemsCount yes Evaluation Count:102 | yes Evaluation Count:3 |
| 3-102 |
251 | QFontDatabase::WritingSystem ws = QFontDatabase::WritingSystem(i); executed (the execution status of this line is deduced): QFontDatabase::WritingSystem ws = QFontDatabase::WritingSystem(i); | - |
252 | QString writingSystemName = QFontDatabase::writingSystemName(ws); executed (the execution status of this line is deduced): QString writingSystemName = QFontDatabase::writingSystemName(ws); | - |
253 | if (writingSystemName.isEmpty()) partially evaluated: writingSystemName.isEmpty() no Evaluation Count:0 | yes Evaluation Count:102 |
| 0-102 |
254 | break; | 0 |
255 | writingSystemCombo->addItem(writingSystemName); executed (the execution status of this line is deduced): writingSystemCombo->addItem(writingSystemName); | - |
256 | } executed: } Execution Count:102 | 102 |
257 | | - |
258 | updateFamilies(); executed (the execution status of this line is deduced): updateFamilies(); | - |
259 | if (familyList->count() != 0) partially evaluated: familyList->count() != 0 yes Evaluation Count:3 | no Evaluation Count:0 |
| 0-3 |
260 | familyList->setCurrentItem(0); executed: familyList->setCurrentItem(0); Execution Count:3 | 3 |
261 | | - |
262 | // grid layout | - |
263 | QGridLayout *mainGrid = new QGridLayout(q); executed (the execution status of this line is deduced): QGridLayout *mainGrid = new QGridLayout(q); | - |
264 | | - |
265 | int spacing = mainGrid->spacing(); executed (the execution status of this line is deduced): int spacing = mainGrid->spacing(); | - |
266 | if (spacing >= 0) { // uniform spacing partially evaluated: spacing >= 0 yes Evaluation Count:3 | no Evaluation Count:0 |
| 0-3 |
267 | mainGrid->setSpacing(0); executed (the execution status of this line is deduced): mainGrid->setSpacing(0); | - |
268 | | - |
269 | mainGrid->setColumnMinimumWidth(1, spacing); executed (the execution status of this line is deduced): mainGrid->setColumnMinimumWidth(1, spacing); | - |
270 | mainGrid->setColumnMinimumWidth(3, spacing); executed (the execution status of this line is deduced): mainGrid->setColumnMinimumWidth(3, spacing); | - |
271 | | - |
272 | int margin = 0; executed (the execution status of this line is deduced): int margin = 0; | - |
273 | mainGrid->getContentsMargins(0, 0, 0, &margin); executed (the execution status of this line is deduced): mainGrid->getContentsMargins(0, 0, 0, &margin); | - |
274 | | - |
275 | mainGrid->setRowMinimumHeight(3, margin); executed (the execution status of this line is deduced): mainGrid->setRowMinimumHeight(3, margin); | - |
276 | mainGrid->setRowMinimumHeight(6, 2); executed (the execution status of this line is deduced): mainGrid->setRowMinimumHeight(6, 2); | - |
277 | mainGrid->setRowMinimumHeight(8, margin); executed (the execution status of this line is deduced): mainGrid->setRowMinimumHeight(8, margin); | - |
278 | } executed: } Execution Count:3 | 3 |
279 | | - |
280 | mainGrid->addWidget(familyAccel, 0, 0); executed (the execution status of this line is deduced): mainGrid->addWidget(familyAccel, 0, 0); | - |
281 | mainGrid->addWidget(familyEdit, 1, 0); executed (the execution status of this line is deduced): mainGrid->addWidget(familyEdit, 1, 0); | - |
282 | mainGrid->addWidget(familyList, 2, 0); executed (the execution status of this line is deduced): mainGrid->addWidget(familyList, 2, 0); | - |
283 | | - |
284 | mainGrid->addWidget(styleAccel, 0, 2); executed (the execution status of this line is deduced): mainGrid->addWidget(styleAccel, 0, 2); | - |
285 | mainGrid->addWidget(styleEdit, 1, 2); executed (the execution status of this line is deduced): mainGrid->addWidget(styleEdit, 1, 2); | - |
286 | mainGrid->addWidget(styleList, 2, 2); executed (the execution status of this line is deduced): mainGrid->addWidget(styleList, 2, 2); | - |
287 | | - |
288 | mainGrid->addWidget(sizeAccel, 0, 4); executed (the execution status of this line is deduced): mainGrid->addWidget(sizeAccel, 0, 4); | - |
289 | mainGrid->addWidget(sizeEdit, 1, 4); executed (the execution status of this line is deduced): mainGrid->addWidget(sizeEdit, 1, 4); | - |
290 | mainGrid->addWidget(sizeList, 2, 4); executed (the execution status of this line is deduced): mainGrid->addWidget(sizeList, 2, 4); | - |
291 | | - |
292 | mainGrid->setColumnStretch(0, 38); executed (the execution status of this line is deduced): mainGrid->setColumnStretch(0, 38); | - |
293 | mainGrid->setColumnStretch(2, 24); executed (the execution status of this line is deduced): mainGrid->setColumnStretch(2, 24); | - |
294 | mainGrid->setColumnStretch(4, 10); executed (the execution status of this line is deduced): mainGrid->setColumnStretch(4, 10); | - |
295 | | - |
296 | mainGrid->addWidget(effects, 4, 0); executed (the execution status of this line is deduced): mainGrid->addWidget(effects, 4, 0); | - |
297 | | - |
298 | mainGrid->addWidget(sample, 4, 2, 4, 3); executed (the execution status of this line is deduced): mainGrid->addWidget(sample, 4, 2, 4, 3); | - |
299 | | - |
300 | mainGrid->addWidget(writingSystemAccel, 5, 0); executed (the execution status of this line is deduced): mainGrid->addWidget(writingSystemAccel, 5, 0); | - |
301 | mainGrid->addWidget(writingSystemCombo, 7, 0); executed (the execution status of this line is deduced): mainGrid->addWidget(writingSystemCombo, 7, 0); | - |
302 | | - |
303 | buttonBox = new QDialogButtonBox(q); executed (the execution status of this line is deduced): buttonBox = new QDialogButtonBox(q); | - |
304 | mainGrid->addWidget(buttonBox, 9, 0, 1, 5); executed (the execution status of this line is deduced): mainGrid->addWidget(buttonBox, 9, 0, 1, 5); | - |
305 | | - |
306 | QPushButton *button executed (the execution status of this line is deduced): QPushButton *button | - |
307 | = static_cast<QPushButton *>(buttonBox->addButton(QDialogButtonBox::Ok)); executed (the execution status of this line is deduced): = static_cast<QPushButton *>(buttonBox->addButton(QDialogButtonBox::Ok)); | - |
308 | QObject::connect(buttonBox, SIGNAL(accepted()), q, SLOT(accept())); executed (the execution status of this line is deduced): QObject::connect(buttonBox, "2""accepted()", q, "1""accept()"); | - |
309 | button->setDefault(true); executed (the execution status of this line is deduced): button->setDefault(true); | - |
310 | | - |
311 | buttonBox->addButton(QDialogButtonBox::Cancel); executed (the execution status of this line is deduced): buttonBox->addButton(QDialogButtonBox::Cancel); | - |
312 | QObject::connect(buttonBox, SIGNAL(rejected()), q, SLOT(reject())); executed (the execution status of this line is deduced): QObject::connect(buttonBox, "2""rejected()", q, "1""reject()"); | - |
313 | | - |
314 | #if defined(Q_OS_WINCE) | - |
315 | q->resize(180, 120); | - |
316 | #else | - |
317 | q->resize(500, 360); executed (the execution status of this line is deduced): q->resize(500, 360); | - |
318 | #endif // Q_OS_WINCE | - |
319 | | - |
320 | sizeEdit->installEventFilter(q); executed (the execution status of this line is deduced): sizeEdit->installEventFilter(q); | - |
321 | familyList->installEventFilter(q); executed (the execution status of this line is deduced): familyList->installEventFilter(q); | - |
322 | styleList->installEventFilter(q); executed (the execution status of this line is deduced): styleList->installEventFilter(q); | - |
323 | sizeList->installEventFilter(q); executed (the execution status of this line is deduced): sizeList->installEventFilter(q); | - |
324 | | - |
325 | familyList->setFocus(); executed (the execution status of this line is deduced): familyList->setFocus(); | - |
326 | retranslateStrings(); executed (the execution status of this line is deduced): retranslateStrings(); | - |
327 | } executed: } Execution Count:3 | 3 |
328 | | - |
329 | /*! | - |
330 | \internal | - |
331 | Destroys the font dialog and frees up its storage. | - |
332 | */ | - |
333 | | - |
334 | QFontDialog::~QFontDialog() | - |
335 | { | - |
336 | } | - |
337 | | - |
338 | /*! | - |
339 | Executes a modal font dialog and returns a font. | - |
340 | | - |
341 | If the user clicks \uicontrol OK, the selected font is returned. If the user | - |
342 | clicks \uicontrol Cancel, the \a initial font is returned. | - |
343 | | - |
344 | The dialog is constructed with the given \a parent and the options specified | - |
345 | in \a options. \a title is shown as the window title of the dialog and \a | - |
346 | initial is the initially selected font. If the \a ok parameter is not-null, | - |
347 | the value it refers to is set to true if the user clicks \uicontrol OK, and set to | - |
348 | false if the user clicks \uicontrol Cancel. | - |
349 | | - |
350 | Examples: | - |
351 | \snippet code/src_gui_dialogs_qfontdialog.cpp 2 | - |
352 | | - |
353 | The dialog can also be used to set a widget's font directly: | - |
354 | \snippet code/src_gui_dialogs_qfontdialog.cpp 3 | - |
355 | In this example, if the user clicks OK the font they chose will be | - |
356 | used, and if they click Cancel the original font is used. | - |
357 | | - |
358 | \warning Do not delete \a parent during the execution of the dialog. | - |
359 | If you want to do this, you should create the dialog | - |
360 | yourself using one of the QFontDialog constructors. | - |
361 | */ | - |
362 | QFont QFontDialog::getFont(bool *ok, const QFont &initial, QWidget *parent, const QString &title, | - |
363 | FontDialogOptions options) | - |
364 | { | - |
365 | return QFontDialogPrivate::getFont(ok, initial, parent, title, options); executed: return QFontDialogPrivate::getFont(ok, initial, parent, title, options); Execution Count:1 | 1 |
366 | } | - |
367 | | - |
368 | /*! | - |
369 | \overload | - |
370 | | - |
371 | Executes a modal font dialog and returns a font. | - |
372 | | - |
373 | If the user clicks \uicontrol OK, the selected font is returned. If the user | - |
374 | clicks \uicontrol Cancel, the Qt default font is returned. | - |
375 | | - |
376 | The dialog is constructed with the given \a parent. | - |
377 | If the \a ok parameter is not-null, the value it refers to is set | - |
378 | to true if the user clicks \uicontrol OK, and false if the user clicks | - |
379 | \uicontrol Cancel. | - |
380 | | - |
381 | Example: | - |
382 | \snippet code/src_gui_dialogs_qfontdialog.cpp 4 | - |
383 | | - |
384 | \warning Do not delete \a parent during the execution of the dialog. | - |
385 | If you want to do this, you should create the dialog | - |
386 | yourself using one of the QFontDialog constructors. | - |
387 | */ | - |
388 | QFont QFontDialog::getFont(bool *ok, QWidget *parent) | - |
389 | { | - |
390 | QFont initial; executed (the execution status of this line is deduced): QFont initial; | - |
391 | return QFontDialogPrivate::getFont(ok, initial, parent, QString(), 0); executed: return QFontDialogPrivate::getFont(ok, initial, parent, QString(), 0); Execution Count:1 | 1 |
392 | } | - |
393 | | - |
394 | QFont QFontDialogPrivate::getFont(bool *ok, const QFont &initial, QWidget *parent, | - |
395 | const QString &title, QFontDialog::FontDialogOptions options) | - |
396 | { | - |
397 | QFontDialog dlg(parent); executed (the execution status of this line is deduced): QFontDialog dlg(parent); | - |
398 | dlg.setOptions(options); executed (the execution status of this line is deduced): dlg.setOptions(options); | - |
399 | dlg.setCurrentFont(initial); executed (the execution status of this line is deduced): dlg.setCurrentFont(initial); | - |
400 | if (!title.isEmpty()) partially evaluated: !title.isEmpty() no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
401 | dlg.setWindowTitle(title); never executed: dlg.setWindowTitle(title); | 0 |
402 | | - |
403 | 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 |
404 | if (ok) partially evaluated: ok yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
405 | *ok = !!ret; executed: *ok = !!ret; Execution Count:2 | 2 |
406 | if (ret) { partially evaluated: ret yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
407 | return dlg.selectedFont(); executed: return dlg.selectedFont(); Execution Count:2 | 2 |
408 | } else { | - |
409 | return initial; never executed: return initial; | 0 |
410 | } | - |
411 | } | - |
412 | | - |
413 | /*! | - |
414 | \internal | - |
415 | An event filter to make the Up, Down, PageUp and PageDown keys work | - |
416 | correctly in the line edits. The source of the event is the object | - |
417 | \a o and the event is \a e. | - |
418 | */ | - |
419 | | - |
420 | bool QFontDialog::eventFilter(QObject *o , QEvent *e) | - |
421 | { | - |
422 | Q_D(QFontDialog); executed (the execution status of this line is deduced): QFontDialogPrivate * const d = d_func(); | - |
423 | if (e->type() == QEvent::KeyPress) { partially evaluated: e->type() == QEvent::KeyPress no Evaluation Count:0 | yes Evaluation Count:153 |
| 0-153 |
424 | QKeyEvent *k = (QKeyEvent *)e; never executed (the execution status of this line is deduced): QKeyEvent *k = (QKeyEvent *)e; | - |
425 | if (o == d->sizeEdit && never evaluated: o == d->sizeEdit | 0 |
426 | (k->key() == Qt::Key_Up || never evaluated: k->key() == Qt::Key_Up | 0 |
427 | k->key() == Qt::Key_Down || never evaluated: k->key() == Qt::Key_Down | 0 |
428 | k->key() == Qt::Key_PageUp || never evaluated: k->key() == Qt::Key_PageUp | 0 |
429 | k->key() == Qt::Key_PageDown)) { never evaluated: k->key() == Qt::Key_PageDown | 0 |
430 | | - |
431 | int ci = d->sizeList->currentItem(); never executed (the execution status of this line is deduced): int ci = d->sizeList->currentItem(); | - |
432 | (void)QApplication::sendEvent(d->sizeList, k); never executed (the execution status of this line is deduced): (void)QApplication::sendEvent(d->sizeList, k); | - |
433 | | - |
434 | if (ci != d->sizeList->currentItem() never evaluated: ci != d->sizeList->currentItem() | 0 |
435 | && style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, 0, this)) never evaluated: style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, 0, this) | 0 |
436 | d->sizeEdit->selectAll(); never executed: d->sizeEdit->selectAll(); | 0 |
437 | return true; never executed: return true; | 0 |
438 | } else if ((o == d->familyList || o == d->styleList) && never evaluated: o == d->familyList never evaluated: o == d->styleList | 0 |
439 | (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 |
440 | k->accept(); never executed (the execution status of this line is deduced): k->accept(); | - |
441 | accept(); never executed (the execution status of this line is deduced): accept(); | - |
442 | return true; never executed: return true; | 0 |
443 | } | - |
444 | } else if (e->type() == QEvent::FocusIn evaluated: e->type() == QEvent::FocusIn yes Evaluation Count:4 | yes Evaluation Count:149 |
| 4-149 |
445 | && 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 |
446 | if (o == d->familyList) partially evaluated: o == d->familyList yes Evaluation Count:4 | no Evaluation Count:0 |
| 0-4 |
447 | d->familyEdit->selectAll(); executed: d->familyEdit->selectAll(); Execution Count:4 | 4 |
448 | else if (o == d->styleList) never evaluated: o == d->styleList | 0 |
449 | d->styleEdit->selectAll(); never executed: d->styleEdit->selectAll(); | 0 |
450 | else if (o == d->sizeList) never evaluated: o == d->sizeList | 0 |
451 | d->sizeEdit->selectAll(); never executed: d->sizeEdit->selectAll(); | 0 |
452 | } 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 |
453 | d->sizeEdit->setFocus(); never executed (the execution status of this line is deduced): d->sizeEdit->setFocus(); | - |
454 | } | 0 |
455 | return QDialog::eventFilter(o, e); executed: return QDialog::eventFilter(o, e); Execution Count:153 | 153 |
456 | } | - |
457 | | - |
458 | void QFontDialogPrivate::initHelper(QPlatformDialogHelper *h) | - |
459 | { | - |
460 | QFontDialog *d = q_func(); never executed (the execution status of this line is deduced): QFontDialog *d = q_func(); | - |
461 | QObject::connect(h, SIGNAL(currentFontChanged(QFont)), d, SIGNAL(currentFontChanged(QFont))); never executed (the execution status of this line is deduced): QObject::connect(h, "2""currentFontChanged(QFont)", d, "2""currentFontChanged(QFont)"); | - |
462 | QObject::connect(h, SIGNAL(fontSelected(QFont)), d, SIGNAL(fontSelected(QFont))); never executed (the execution status of this line is deduced): QObject::connect(h, "2""fontSelected(QFont)", d, "2""fontSelected(QFont)"); | - |
463 | static_cast<QPlatformFontDialogHelper *>(h)->setOptions(options); never executed (the execution status of this line is deduced): static_cast<QPlatformFontDialogHelper *>(h)->setOptions(options); | - |
464 | } | 0 |
465 | | - |
466 | void QFontDialogPrivate::helperPrepareShow(QPlatformDialogHelper *) | - |
467 | { | - |
468 | options->setWindowTitle(q_func()->windowTitle()); never executed (the execution status of this line is deduced): options->setWindowTitle(q_func()->windowTitle()); | - |
469 | } | 0 |
470 | | - |
471 | /* | - |
472 | Updates the contents of the "font family" list box. This | - |
473 | function can be reimplemented if you have special requirements. | - |
474 | */ | - |
475 | | - |
476 | void QFontDialogPrivate::updateFamilies() | - |
477 | { | - |
478 | Q_Q(QFontDialog); executed (the execution status of this line is deduced): QFontDialog * const q = q_func(); | - |
479 | | - |
480 | enum match_t { MATCH_NONE = 0, MATCH_LAST_RESORT = 1, MATCH_APP = 2, MATCH_FAMILY = 3 }; executed (the execution status of this line is deduced): enum match_t { MATCH_NONE = 0, MATCH_LAST_RESORT = 1, MATCH_APP = 2, MATCH_FAMILY = 3 }; | - |
481 | | - |
482 | QStringList familyNames = fdb.families(writingSystem); executed (the execution status of this line is deduced): QStringList familyNames = fdb.families(writingSystem); | - |
483 | | - |
484 | familyList->model()->setStringList(familyNames); executed (the execution status of this line is deduced): familyList->model()->setStringList(familyNames); | - |
485 | | - |
486 | QString foundryName1, familyName1, foundryName2, familyName2; executed (the execution status of this line is deduced): QString foundryName1, familyName1, foundryName2, familyName2; | - |
487 | int bestFamilyMatch = -1; executed (the execution status of this line is deduced): int bestFamilyMatch = -1; | - |
488 | match_t bestFamilyType = MATCH_NONE; executed (the execution status of this line is deduced): match_t bestFamilyType = MATCH_NONE; | - |
489 | | - |
490 | QFont f; executed (the execution status of this line is deduced): QFont f; | - |
491 | | - |
492 | // ##### do the right thing for a list of family names in the font. | - |
493 | QFontDatabase::parseFontName(family, foundryName1, familyName1); executed (the execution status of this line is deduced): QFontDatabase::parseFontName(family, foundryName1, familyName1); | - |
494 | | - |
495 | QStringList::const_iterator it = familyNames.constBegin(); executed (the execution status of this line is deduced): QStringList::const_iterator it = familyNames.constBegin(); | - |
496 | int i = 0; executed (the execution status of this line is deduced): int i = 0; | - |
497 | for(; it != familyNames.constEnd(); ++it, ++i) { evaluated: it != familyNames.constEnd() yes Evaluation Count:440 | yes Evaluation Count:4 |
| 4-440 |
498 | QFontDatabase::parseFontName(*it, foundryName2, familyName2); executed (the execution status of this line is deduced): QFontDatabase::parseFontName(*it, foundryName2, familyName2); | - |
499 | | - |
500 | //try to match... | - |
501 | if (familyName1 == familyName2) { evaluated: familyName1 == familyName2 yes Evaluation Count:1 | yes Evaluation Count:439 |
| 1-439 |
502 | bestFamilyType = MATCH_FAMILY; executed (the execution status of this line is deduced): bestFamilyType = MATCH_FAMILY; | - |
503 | if (foundryName1 == foundryName2) { partially evaluated: foundryName1 == foundryName2 yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
504 | bestFamilyMatch = i; executed (the execution status of this line is deduced): bestFamilyMatch = i; | - |
505 | break; executed: break; Execution Count:1 | 1 |
506 | } | - |
507 | if (bestFamilyMatch < MATCH_FAMILY) never evaluated: bestFamilyMatch < MATCH_FAMILY | 0 |
508 | bestFamilyMatch = i; never executed: bestFamilyMatch = i; | 0 |
509 | } | 0 |
510 | | - |
511 | //and try some fall backs | - |
512 | match_t type = MATCH_NONE; executed (the execution status of this line is deduced): match_t type = MATCH_NONE; | - |
513 | 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 |
514 | type = MATCH_LAST_RESORT; never executed: type = MATCH_LAST_RESORT; | 0 |
515 | 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 |
516 | type = MATCH_APP; executed: type = MATCH_APP; Execution Count:4 | 4 |
517 | // ### add fallback for writingSystem | - |
518 | if (type != MATCH_NONE) { evaluated: type != MATCH_NONE yes Evaluation Count:4 | yes Evaluation Count:435 |
| 4-435 |
519 | bestFamilyType = type; executed (the execution status of this line is deduced): bestFamilyType = type; | - |
520 | bestFamilyMatch = i; executed (the execution status of this line is deduced): bestFamilyMatch = i; | - |
521 | } executed: } Execution Count:4 | 4 |
522 | } executed: } Execution Count:439 | 439 |
523 | | - |
524 | 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 |
525 | familyList->setCurrentItem(bestFamilyMatch); executed: familyList->setCurrentItem(bestFamilyMatch); Execution Count:5 | 5 |
526 | else | - |
527 | familyList->setCurrentItem(0); never executed: familyList->setCurrentItem(0); | 0 |
528 | familyEdit->setText(familyList->currentText()); executed (the execution status of this line is deduced): familyEdit->setText(familyList->currentText()); | - |
529 | 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 |
530 | && familyList->hasFocus()) partially evaluated: familyList->hasFocus() no Evaluation Count:0 | yes Evaluation Count:5 |
| 0-5 |
531 | familyEdit->selectAll(); never executed: familyEdit->selectAll(); | 0 |
532 | | - |
533 | updateStyles(); executed (the execution status of this line is deduced): updateStyles(); | - |
534 | } executed: } Execution Count:5 | 5 |
535 | | - |
536 | /* | - |
537 | Updates the contents of the "font style" list box. This | - |
538 | function can be reimplemented if you have special requirements. | - |
539 | */ | - |
540 | void QFontDialogPrivate::updateStyles() | - |
541 | { | - |
542 | Q_Q(QFontDialog); executed (the execution status of this line is deduced): QFontDialog * const q = q_func(); | - |
543 | QStringList styles = fdb.styles(familyList->currentText()); executed (the execution status of this line is deduced): QStringList styles = fdb.styles(familyList->currentText()); | - |
544 | styleList->model()->setStringList(styles); executed (the execution status of this line is deduced): styleList->model()->setStringList(styles); | - |
545 | | - |
546 | if (styles.isEmpty()) { partially evaluated: styles.isEmpty() no Evaluation Count:0 | yes Evaluation Count:103 |
| 0-103 |
547 | styleEdit->clear(); never executed (the execution status of this line is deduced): styleEdit->clear(); | - |
548 | smoothScalable = false; never executed (the execution status of this line is deduced): smoothScalable = false; | - |
549 | } else { | 0 |
550 | if (!style.isEmpty()) { evaluated: !style.isEmpty() yes Evaluation Count:100 | yes Evaluation Count:3 |
| 3-100 |
551 | bool found = false; executed (the execution status of this line is deduced): bool found = false; | - |
552 | bool first = true; executed (the execution status of this line is deduced): bool first = true; | - |
553 | QString cstyle = style; executed (the execution status of this line is deduced): QString cstyle = style; | - |
554 | | - |
555 | redo: code before this statement executed: redo: Execution Count:100 | 100 |
556 | for (int i = 0; i < (int)styleList->count(); i++) { evaluated: i < (int)styleList->count() yes Evaluation Count:231 | yes Evaluation Count:26 |
| 26-231 |
557 | if (cstyle == styleList->text(i)) { evaluated: cstyle == styleList->text(i) yes Evaluation Count:82 | yes Evaluation Count:149 |
| 82-149 |
558 | styleList->setCurrentItem(i); executed (the execution status of this line is deduced): styleList->setCurrentItem(i); | - |
559 | found = true; executed (the execution status of this line is deduced): found = true; | - |
560 | break; executed: break; Execution Count:82 | 82 |
561 | } | - |
562 | } executed: } Execution Count:149 | 149 |
563 | 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 |
564 | if (cstyle.contains(QLatin1String("Italic"))) { evaluated: cstyle.contains(QLatin1String("Italic")) yes Evaluation Count:6 | yes Evaluation Count:14 |
| 6-14 |
565 | cstyle.replace(QLatin1String("Italic"), QLatin1String("Oblique")); executed (the execution status of this line is deduced): cstyle.replace(QLatin1String("Italic"), QLatin1String("Oblique")); | - |
566 | first = false; executed (the execution status of this line is deduced): first = false; | - |
567 | goto redo; executed: goto redo; Execution Count:6 | 6 |
568 | } else if (cstyle.contains(QLatin1String("Oblique"))) { evaluated: cstyle.contains(QLatin1String("Oblique")) yes Evaluation Count:2 | yes Evaluation Count:12 |
| 2-12 |
569 | cstyle.replace(QLatin1String("Oblique"), QLatin1String("Italic")); executed (the execution status of this line is deduced): cstyle.replace(QLatin1String("Oblique"), QLatin1String("Italic")); | - |
570 | first = false; executed (the execution status of this line is deduced): first = false; | - |
571 | goto redo; executed: goto redo; Execution Count:2 | 2 |
572 | } | - |
573 | } | - |
574 | if (!found) evaluated: !found yes Evaluation Count:18 | yes Evaluation Count:82 |
| 18-82 |
575 | styleList->setCurrentItem(0); executed: styleList->setCurrentItem(0); Execution Count:18 | 18 |
576 | } else { executed: } Execution Count:100 | 100 |
577 | styleList->setCurrentItem(0); executed (the execution status of this line is deduced): styleList->setCurrentItem(0); | - |
578 | } executed: } Execution Count:3 | 3 |
579 | | - |
580 | styleEdit->setText(styleList->currentText()); executed (the execution status of this line is deduced): styleEdit->setText(styleList->currentText()); | - |
581 | 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 |
582 | && styleList->hasFocus()) partially evaluated: styleList->hasFocus() no Evaluation Count:0 | yes Evaluation Count:103 |
| 0-103 |
583 | styleEdit->selectAll(); never executed: styleEdit->selectAll(); | 0 |
584 | | - |
585 | smoothScalable = fdb.isSmoothlyScalable(familyList->currentText(), styleList->currentText()); executed (the execution status of this line is deduced): smoothScalable = fdb.isSmoothlyScalable(familyList->currentText(), styleList->currentText()); | - |
586 | } executed: } Execution Count:103 | 103 |
587 | | - |
588 | updateSizes(); executed (the execution status of this line is deduced): updateSizes(); | - |
589 | } executed: } Execution Count:103 | 103 |
590 | | - |
591 | /*! | - |
592 | \internal | - |
593 | Updates the contents of the "font size" list box. This | - |
594 | function can be reimplemented if you have special requirements. | - |
595 | */ | - |
596 | | - |
597 | void QFontDialogPrivate::updateSizes() | - |
598 | { | - |
599 | Q_Q(QFontDialog); executed (the execution status of this line is deduced): QFontDialog * const q = q_func(); | - |
600 | | - |
601 | if (!familyList->currentText().isEmpty()) { partially evaluated: !familyList->currentText().isEmpty() yes Evaluation Count:206 | no Evaluation Count:0 |
| 0-206 |
602 | QList<int> sizes = fdb.pointSizes(familyList->currentText(), styleList->currentText()); executed (the execution status of this line is deduced): QList<int> sizes = fdb.pointSizes(familyList->currentText(), styleList->currentText()); | - |
603 | | - |
604 | int i = 0; executed (the execution status of this line is deduced): int i = 0; | - |
605 | int current = -1; executed (the execution status of this line is deduced): int current = -1; | - |
606 | QStringList str_sizes; executed (the execution status of this line is deduced): QStringList str_sizes; | - |
607 | 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 |
608 | str_sizes.append(QString::number(*it)); executed (the execution status of this line is deduced): str_sizes.append(QString::number(*it)); | - |
609 | 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 |
610 | current = i; executed: current = i; Execution Count:206 | 206 |
611 | ++i; executed (the execution status of this line is deduced): ++i; | - |
612 | } executed: } Execution Count:3708 | 3708 |
613 | sizeList->model()->setStringList(str_sizes); executed (the execution status of this line is deduced): sizeList->model()->setStringList(str_sizes); | - |
614 | if (current == -1) { partially evaluated: current == -1 no Evaluation Count:0 | yes Evaluation Count:206 |
| 0-206 |
615 | // we request a size bigger than the ones in the list, select the biggest one | - |
616 | current = sizeList->count() - 1; never executed (the execution status of this line is deduced): current = sizeList->count() - 1; | - |
617 | } | 0 |
618 | sizeList->setCurrentItem(current); executed (the execution status of this line is deduced): sizeList->setCurrentItem(current); | - |
619 | | - |
620 | sizeEdit->blockSignals(true); executed (the execution status of this line is deduced): sizeEdit->blockSignals(true); | - |
621 | sizeEdit->setText((smoothScalable ? QString::number(size) : sizeList->currentText())); executed (the execution status of this line is deduced): sizeEdit->setText((smoothScalable ? QString::number(size) : sizeList->currentText())); | - |
622 | 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 |
623 | && sizeList->hasFocus()) partially evaluated: sizeList->hasFocus() no Evaluation Count:0 | yes Evaluation Count:206 |
| 0-206 |
624 | sizeEdit->selectAll(); never executed: sizeEdit->selectAll(); | 0 |
625 | sizeEdit->blockSignals(false); executed (the execution status of this line is deduced): sizeEdit->blockSignals(false); | - |
626 | } else { executed: } Execution Count:206 | 206 |
627 | sizeEdit->clear(); never executed (the execution status of this line is deduced): sizeEdit->clear(); | - |
628 | } | 0 |
629 | | - |
630 | _q_updateSample(); executed (the execution status of this line is deduced): _q_updateSample(); | - |
631 | } executed: } Execution Count:206 | 206 |
632 | | - |
633 | void QFontDialogPrivate::_q_updateSample() | - |
634 | { | - |
635 | // compute new font | - |
636 | int pSize = sizeEdit->text().toInt(); executed (the execution status of this line is deduced): int pSize = sizeEdit->text().toInt(); | - |
637 | QFont newFont(fdb.font(familyList->currentText(), style, pSize)); executed (the execution status of this line is deduced): QFont newFont(fdb.font(familyList->currentText(), style, pSize)); | - |
638 | newFont.setStrikeOut(strikeout->isChecked()); executed (the execution status of this line is deduced): newFont.setStrikeOut(strikeout->isChecked()); | - |
639 | newFont.setUnderline(underline->isChecked()); executed (the execution status of this line is deduced): newFont.setUnderline(underline->isChecked()); | - |
640 | | - |
641 | if (familyList->currentText().isEmpty()) partially evaluated: familyList->currentText().isEmpty() no Evaluation Count:0 | yes Evaluation Count:415 |
| 0-415 |
642 | sampleEdit->clear(); never executed: sampleEdit->clear(); | 0 |
643 | | - |
644 | updateSampleFont(newFont); executed (the execution status of this line is deduced): updateSampleFont(newFont); | - |
645 | } executed: } Execution Count:415 | 415 |
646 | | - |
647 | void QFontDialogPrivate::updateSampleFont(const QFont &newFont) | - |
648 | { | - |
649 | Q_Q(QFontDialog); executed (the execution status of this line is deduced): QFontDialog * const q = q_func(); | - |
650 | if (newFont != sampleEdit->font()) { evaluated: newFont != sampleEdit->font() yes Evaluation Count:98 | yes Evaluation Count:317 |
| 98-317 |
651 | sampleEdit->setFont(newFont); executed (the execution status of this line is deduced): sampleEdit->setFont(newFont); | - |
652 | emit q->currentFontChanged(newFont); executed (the execution status of this line is deduced): q->currentFontChanged(newFont); | - |
653 | } executed: } Execution Count:98 | 98 |
654 | } executed: } Execution Count:415 | 415 |
655 | | - |
656 | /*! | - |
657 | \internal | - |
658 | */ | - |
659 | void QFontDialogPrivate::_q_writingSystemHighlighted(int index) | - |
660 | { | - |
661 | writingSystem = QFontDatabase::WritingSystem(index); never executed (the execution status of this line is deduced): writingSystem = QFontDatabase::WritingSystem(index); | - |
662 | sampleEdit->setText(fdb.writingSystemSample(writingSystem)); never executed (the execution status of this line is deduced): sampleEdit->setText(fdb.writingSystemSample(writingSystem)); | - |
663 | updateFamilies(); never executed (the execution status of this line is deduced): updateFamilies(); | - |
664 | } | 0 |
665 | | - |
666 | /*! | - |
667 | \internal | - |
668 | */ | - |
669 | void QFontDialogPrivate::_q_familyHighlighted(int i) | - |
670 | { | - |
671 | Q_Q(QFontDialog); executed (the execution status of this line is deduced): QFontDialog * const q = q_func(); | - |
672 | family = familyList->text(i); executed (the execution status of this line is deduced): family = familyList->text(i); | - |
673 | familyEdit->setText(family); executed (the execution status of this line is deduced): familyEdit->setText(family); | - |
674 | 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 |
675 | && familyList->hasFocus()) partially evaluated: familyList->hasFocus() no Evaluation Count:0 | yes Evaluation Count:98 |
| 0-98 |
676 | familyEdit->selectAll(); never executed: familyEdit->selectAll(); | 0 |
677 | | - |
678 | updateStyles(); executed (the execution status of this line is deduced): updateStyles(); | - |
679 | } executed: } Execution Count:98 | 98 |
680 | | - |
681 | | - |
682 | /*! | - |
683 | \internal | - |
684 | */ | - |
685 | | - |
686 | void QFontDialogPrivate::_q_styleHighlighted(int index) | - |
687 | { | - |
688 | Q_Q(QFontDialog); executed (the execution status of this line is deduced): QFontDialog * const q = q_func(); | - |
689 | QString s = styleList->text(index); executed (the execution status of this line is deduced): QString s = styleList->text(index); | - |
690 | styleEdit->setText(s); executed (the execution status of this line is deduced): styleEdit->setText(s); | - |
691 | 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 |
692 | && styleList->hasFocus()) partially evaluated: styleList->hasFocus() no Evaluation Count:0 | yes Evaluation Count:103 |
| 0-103 |
693 | styleEdit->selectAll(); never executed: styleEdit->selectAll(); | 0 |
694 | | - |
695 | style = s; executed (the execution status of this line is deduced): style = s; | - |
696 | | - |
697 | updateSizes(); executed (the execution status of this line is deduced): updateSizes(); | - |
698 | } executed: } Execution Count:103 | 103 |
699 | | - |
700 | | - |
701 | /*! | - |
702 | \internal | - |
703 | */ | - |
704 | | - |
705 | void QFontDialogPrivate::_q_sizeHighlighted(int index) | - |
706 | { | - |
707 | Q_Q(QFontDialog); executed (the execution status of this line is deduced): QFontDialog * const q = q_func(); | - |
708 | QString s = sizeList->text(index); executed (the execution status of this line is deduced): QString s = sizeList->text(index); | - |
709 | sizeEdit->setText(s); executed (the execution status of this line is deduced): sizeEdit->setText(s); | - |
710 | 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 |
711 | && sizeEdit->hasFocus()) partially evaluated: sizeEdit->hasFocus() no Evaluation Count:0 | yes Evaluation Count:206 |
| 0-206 |
712 | sizeEdit->selectAll(); never executed: sizeEdit->selectAll(); | 0 |
713 | | - |
714 | size = s.toInt(); executed (the execution status of this line is deduced): size = s.toInt(); | - |
715 | _q_updateSample(); executed (the execution status of this line is deduced): _q_updateSample(); | - |
716 | } executed: } Execution Count:206 | 206 |
717 | | - |
718 | /*! | - |
719 | \internal | - |
720 | This slot is called if the user changes the font size. | - |
721 | The size is passed in the \a s argument as a \e string. | - |
722 | */ | - |
723 | | - |
724 | void QFontDialogPrivate::_q_sizeChanged(const QString &s) | - |
725 | { | - |
726 | // no need to check if the conversion is valid, since we have an QIntValidator in the size edit | - |
727 | int size = s.toInt(); executed (the execution status of this line is deduced): int size = s.toInt(); | - |
728 | if (this->size == size) evaluated: this->size == size yes Evaluation Count:2 | yes Evaluation Count:3 |
| 2-3 |
729 | return; executed: return; Execution Count:2 | 2 |
730 | | - |
731 | this->size = size; executed (the execution status of this line is deduced): this->size = size; | - |
732 | if (sizeList->count() != 0) { partially evaluated: sizeList->count() != 0 yes Evaluation Count:3 | no Evaluation Count:0 |
| 0-3 |
733 | int i; executed (the execution status of this line is deduced): int i; | - |
734 | for (i = 0; i < sizeList->count() - 1; i++) { partially evaluated: i < sizeList->count() - 1 yes Evaluation Count:3 | no Evaluation Count:0 |
| 0-3 |
735 | 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 |
736 | break; executed: break; Execution Count:3 | 3 |
737 | } | 0 |
738 | sizeList->blockSignals(true); executed (the execution status of this line is deduced): sizeList->blockSignals(true); | - |
739 | sizeList->setCurrentItem(i); executed (the execution status of this line is deduced): sizeList->setCurrentItem(i); | - |
740 | sizeList->blockSignals(false); executed (the execution status of this line is deduced): sizeList->blockSignals(false); | - |
741 | } executed: } Execution Count:3 | 3 |
742 | _q_updateSample(); executed (the execution status of this line is deduced): _q_updateSample(); | - |
743 | } executed: } Execution Count:3 | 3 |
744 | | - |
745 | void QFontDialogPrivate::retranslateStrings() | - |
746 | { | - |
747 | familyAccel->setText(QFontDialog::tr("&Font")); executed (the execution status of this line is deduced): familyAccel->setText(QFontDialog::tr("&Font")); | - |
748 | styleAccel->setText(QFontDialog::tr("Font st&yle")); executed (the execution status of this line is deduced): styleAccel->setText(QFontDialog::tr("Font st&yle")); | - |
749 | sizeAccel->setText(QFontDialog::tr("&Size")); executed (the execution status of this line is deduced): sizeAccel->setText(QFontDialog::tr("&Size")); | - |
750 | effects->setTitle(QFontDialog::tr("Effects")); executed (the execution status of this line is deduced): effects->setTitle(QFontDialog::tr("Effects")); | - |
751 | strikeout->setText(QFontDialog::tr("Stri&keout")); executed (the execution status of this line is deduced): strikeout->setText(QFontDialog::tr("Stri&keout")); | - |
752 | underline->setText(QFontDialog::tr("&Underline")); executed (the execution status of this line is deduced): underline->setText(QFontDialog::tr("&Underline")); | - |
753 | sample->setTitle(QFontDialog::tr("Sample")); executed (the execution status of this line is deduced): sample->setTitle(QFontDialog::tr("Sample")); | - |
754 | writingSystemAccel->setText(QFontDialog::tr("Wr&iting System")); executed (the execution status of this line is deduced): writingSystemAccel->setText(QFontDialog::tr("Wr&iting System")); | - |
755 | } executed: } Execution Count:3 | 3 |
756 | | - |
757 | /*! | - |
758 | \reimp | - |
759 | */ | - |
760 | void QFontDialog::changeEvent(QEvent *e) | - |
761 | { | - |
762 | Q_D(QFontDialog); executed (the execution status of this line is deduced): QFontDialogPrivate * const d = d_func(); | - |
763 | if (e->type() == QEvent::LanguageChange) { partially evaluated: e->type() == QEvent::LanguageChange no Evaluation Count:0 | yes Evaluation Count:7 |
| 0-7 |
764 | d->retranslateStrings(); never executed (the execution status of this line is deduced): d->retranslateStrings(); | - |
765 | } | 0 |
766 | QDialog::changeEvent(e); executed (the execution status of this line is deduced): QDialog::changeEvent(e); | - |
767 | } executed: } Execution Count:7 | 7 |
768 | | - |
769 | /*! | - |
770 | \since 4.5 | - |
771 | | - |
772 | \property QFontDialog::currentFont | - |
773 | \brief the current font of the dialog. | - |
774 | */ | - |
775 | | - |
776 | /*! | - |
777 | \since 4.5 | - |
778 | | - |
779 | Sets the font highlighted in the QFontDialog to the given \a font. | - |
780 | | - |
781 | \sa selectedFont() | - |
782 | */ | - |
783 | void QFontDialog::setCurrentFont(const QFont &font) | - |
784 | { | - |
785 | Q_D(QFontDialog); executed (the execution status of this line is deduced): QFontDialogPrivate * const d = d_func(); | - |
786 | d->family = font.family(); executed (the execution status of this line is deduced): d->family = font.family(); | - |
787 | d->style = d->fdb.styleString(font); executed (the execution status of this line is deduced): d->style = d->fdb.styleString(font); | - |
788 | d->size = font.pointSize(); executed (the execution status of this line is deduced): d->size = font.pointSize(); | - |
789 | if (d->size == -1) { evaluated: d->size == -1 yes Evaluation Count:1 | yes Evaluation Count:1 |
| 1 |
790 | QFontInfo fi(font); executed (the execution status of this line is deduced): QFontInfo fi(font); | - |
791 | d->size = fi.pointSize(); executed (the execution status of this line is deduced): d->size = fi.pointSize(); | - |
792 | } executed: } Execution Count:1 | 1 |
793 | d->strikeout->setChecked(font.strikeOut()); executed (the execution status of this line is deduced): d->strikeout->setChecked(font.strikeOut()); | - |
794 | d->underline->setChecked(font.underline()); executed (the execution status of this line is deduced): d->underline->setChecked(font.underline()); | - |
795 | d->updateFamilies(); executed (the execution status of this line is deduced): d->updateFamilies(); | - |
796 | if (d->canBeNativeDialog()) { partially evaluated: d->canBeNativeDialog() yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
797 | if (QPlatformFontDialogHelper *helper = d->platformFontDialogHelper()) partially evaluated: QPlatformFontDialogHelper *helper = d->platformFontDialogHelper() no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
798 | helper->setCurrentFont(font); never executed: helper->setCurrentFont(font); | 0 |
799 | } executed: } Execution Count:2 | 2 |
800 | } executed: } Execution Count:2 | 2 |
801 | | - |
802 | /*! | - |
803 | \since 4.5 | - |
804 | | - |
805 | Returns the current font. | - |
806 | | - |
807 | \sa selectedFont() | - |
808 | */ | - |
809 | QFont QFontDialog::currentFont() const | - |
810 | { | - |
811 | Q_D(const QFontDialog); executed (the execution status of this line is deduced): const QFontDialogPrivate * const d = d_func(); | - |
812 | if (d->canBeNativeDialog()) { evaluated: d->canBeNativeDialog() yes Evaluation Count:2 | yes Evaluation Count:91 |
| 2-91 |
813 | if (const QPlatformFontDialogHelper *helper = d->platformFontDialogHelper()) partially evaluated: const QPlatformFontDialogHelper *helper = d->platformFontDialogHelper() no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
814 | return helper->currentFont(); never executed: return helper->currentFont(); | 0 |
815 | } executed: } Execution Count:2 | 2 |
816 | return d->sampleEdit->font(); executed: return d->sampleEdit->font(); Execution Count:93 | 93 |
817 | } | - |
818 | | - |
819 | /*! | - |
820 | Returns the font that the user selected by clicking the \uicontrol{OK} | - |
821 | or equivalent button. | - |
822 | | - |
823 | \note This font is not always the same as the font held by the | - |
824 | \l currentFont property since the user can choose different fonts | - |
825 | before finally selecting the one to use. | - |
826 | */ | - |
827 | QFont QFontDialog::selectedFont() const | - |
828 | { | - |
829 | Q_D(const QFontDialog); executed (the execution status of this line is deduced): const QFontDialogPrivate * const d = d_func(); | - |
830 | return d->selectedFont; executed: return d->selectedFont; Execution Count:2 | 2 |
831 | } | - |
832 | | - |
833 | /*! | - |
834 | \enum QFontDialog::FontDialogOption | - |
835 | \since 4.5 | - |
836 | | - |
837 | This enum specifies various options that affect the look and feel | - |
838 | of a font dialog. | - |
839 | | - |
840 | \value NoButtons Don't display \uicontrol{OK} and \uicontrol{Cancel} buttons. (Useful for "live dialogs".) | - |
841 | \value DontUseNativeDialog Use Qt's standard font dialog on the Mac instead of Apple's | - |
842 | native font panel. (Currently, the native dialog is never used, | - |
843 | but this is likely to change in future Qt releases.) | - |
844 | | - |
845 | \sa options, setOption(), testOption() | - |
846 | */ | - |
847 | | - |
848 | /*! | - |
849 | Sets the given \a option to be enabled if \a on is true; | - |
850 | otherwise, clears the given \a option. | - |
851 | | - |
852 | \sa options, testOption() | - |
853 | */ | - |
854 | void QFontDialog::setOption(FontDialogOption option, bool on) | - |
855 | { | - |
856 | const QFontDialog::FontDialogOptions previousOptions = options(); executed (the execution status of this line is deduced): const QFontDialog::FontDialogOptions previousOptions = options(); | - |
857 | if (!(previousOptions & option) != !on) partially evaluated: !(previousOptions & option) != !on yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
858 | setOptions(previousOptions ^ option); executed: setOptions(previousOptions ^ option); Execution Count:1 | 1 |
859 | } executed: } Execution Count:1 | 1 |
860 | | - |
861 | /*! | - |
862 | Returns true if the given \a option is enabled; otherwise, returns | - |
863 | false. | - |
864 | | - |
865 | \sa options, setOption() | - |
866 | */ | - |
867 | bool QFontDialog::testOption(FontDialogOption option) const | - |
868 | { | - |
869 | Q_D(const QFontDialog); never executed (the execution status of this line is deduced): const QFontDialogPrivate * const d = d_func(); | - |
870 | return d->options->testOption(static_cast<QFontDialogOptions::FontDialogOption>(option)); never executed: return d->options->testOption(static_cast<QFontDialogOptions::FontDialogOption>(option)); | 0 |
871 | } | - |
872 | | - |
873 | /*! | - |
874 | \property QFontDialog::options | - |
875 | \brief the various options that affect the look and feel of the dialog | - |
876 | \since 4.5 | - |
877 | | - |
878 | By default, all options are disabled. | - |
879 | | - |
880 | Options should be set before showing the dialog. Setting them while the | - |
881 | dialog is visible is not guaranteed to have an immediate effect on the | - |
882 | dialog (depending on the option and on the platform). | - |
883 | | - |
884 | \sa setOption(), testOption() | - |
885 | */ | - |
886 | void QFontDialog::setOptions(FontDialogOptions options) | - |
887 | { | - |
888 | Q_D(QFontDialog); executed (the execution status of this line is deduced): QFontDialogPrivate * const d = d_func(); | - |
889 | | - |
890 | if (QFontDialog::options() == options) evaluated: QFontDialog::options() == options yes Evaluation Count:2 | yes Evaluation Count:1 |
| 1-2 |
891 | return; executed: return; Execution Count:2 | 2 |
892 | | - |
893 | d->options->setOptions(QFontDialogOptions::FontDialogOptions(int(options))); executed (the execution status of this line is deduced): d->options->setOptions(QFontDialogOptions::FontDialogOptions(int(options))); | - |
894 | d->buttonBox->setVisible(!(options & NoButtons)); executed (the execution status of this line is deduced): d->buttonBox->setVisible(!(options & NoButtons)); | - |
895 | } executed: } Execution Count:1 | 1 |
896 | | - |
897 | QFontDialog::FontDialogOptions QFontDialog::options() const | - |
898 | { | - |
899 | Q_D(const QFontDialog); executed (the execution status of this line is deduced): const QFontDialogPrivate * const d = d_func(); | - |
900 | return QFontDialog::FontDialogOptions(int(d->options->options())); executed: return QFontDialog::FontDialogOptions(int(d->options->options())); Execution Count:4 | 4 |
901 | } | - |
902 | | - |
903 | /*! | - |
904 | \since 4.5 | - |
905 | \overload | - |
906 | | - |
907 | Opens the dialog and connects its fontSelected() signal to the slot specified | - |
908 | by \a receiver and \a member. | - |
909 | | - |
910 | The signal will be disconnected from the slot when the dialog is closed. | - |
911 | */ | - |
912 | void QFontDialog::open(QObject *receiver, const char *member) | - |
913 | { | - |
914 | Q_D(QFontDialog); never executed (the execution status of this line is deduced): QFontDialogPrivate * const d = d_func(); | - |
915 | connect(this, SIGNAL(fontSelected(QFont)), receiver, member); never executed (the execution status of this line is deduced): connect(this, "2""fontSelected(QFont)", receiver, member); | - |
916 | d->receiverToDisconnectOnClose = receiver; never executed (the execution status of this line is deduced): d->receiverToDisconnectOnClose = receiver; | - |
917 | d->memberToDisconnectOnClose = member; never executed (the execution status of this line is deduced): d->memberToDisconnectOnClose = member; | - |
918 | QDialog::open(); never executed (the execution status of this line is deduced): QDialog::open(); | - |
919 | } | 0 |
920 | | - |
921 | /*! | - |
922 | \since 4.5 | - |
923 | | - |
924 | \fn void QFontDialog::currentFontChanged(const QFont &font) | - |
925 | | - |
926 | This signal is emitted when the current font is changed. The new font is | - |
927 | specified in \a font. | - |
928 | | - |
929 | The signal is emitted while a user is selecting a font. Ultimately, the | - |
930 | chosen font may differ from the font currently selected. | - |
931 | | - |
932 | \sa currentFont, fontSelected(), selectedFont() | - |
933 | */ | - |
934 | | - |
935 | /*! | - |
936 | \since 4.5 | - |
937 | | - |
938 | \fn void QFontDialog::fontSelected(const QFont &font) | - |
939 | | - |
940 | This signal is emitted when a font has been selected. The selected font is | - |
941 | specified in \a font. | - |
942 | | - |
943 | The signal is only emitted when a user has chosen the final font to be | - |
944 | used. It is not emitted while the user is changing the current font in the | - |
945 | font dialog. | - |
946 | | - |
947 | \sa selectedFont(), currentFontChanged(), currentFont | - |
948 | */ | - |
949 | | - |
950 | /*! | - |
951 | \reimp | - |
952 | */ | - |
953 | void QFontDialog::setVisible(bool visible) | - |
954 | { | - |
955 | 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 |
956 | return; | 0 |
957 | Q_D(QFontDialog); executed (the execution status of this line is deduced): QFontDialogPrivate * const d = d_func(); | - |
958 | if (d->canBeNativeDialog()) partially evaluated: d->canBeNativeDialog() yes Evaluation Count:4 | no Evaluation Count:0 |
| 0-4 |
959 | d->setNativeDialogVisible(visible); executed: d->setNativeDialogVisible(visible); Execution Count:4 | 4 |
960 | if (d->nativeDialogInUse) { partially evaluated: d->nativeDialogInUse no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
961 | // Set WA_DontShowOnScreen so that QDialog::setVisible(visible) below | - |
962 | // updates the state correctly, but skips showing the non-native version: | - |
963 | setAttribute(Qt::WA_DontShowOnScreen, true); never executed (the execution status of this line is deduced): setAttribute(Qt::WA_DontShowOnScreen, true); | - |
964 | } else { | 0 |
965 | d->nativeDialogInUse = false; executed (the execution status of this line is deduced): d->nativeDialogInUse = false; | - |
966 | setAttribute(Qt::WA_DontShowOnScreen, false); executed (the execution status of this line is deduced): setAttribute(Qt::WA_DontShowOnScreen, false); | - |
967 | } executed: } Execution Count:4 | 4 |
968 | QDialog::setVisible(visible); executed (the execution status of this line is deduced): QDialog::setVisible(visible); | - |
969 | } executed: } Execution Count:4 | 4 |
970 | | - |
971 | /*! | - |
972 | Closes the dialog and sets its result code to \a result. If this dialog | - |
973 | is shown with exec(), done() causes the local event loop to finish, | - |
974 | and exec() to return \a result. | - |
975 | | - |
976 | \sa QDialog::done() | - |
977 | */ | - |
978 | void QFontDialog::done(int result) | - |
979 | { | - |
980 | Q_D(QFontDialog); executed (the execution status of this line is deduced): QFontDialogPrivate * const d = d_func(); | - |
981 | QDialog::done(result); executed (the execution status of this line is deduced): QDialog::done(result); | - |
982 | if (result == Accepted) { partially evaluated: result == Accepted yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
983 | // We check if this is the same font we had before, if so we emit currentFontChanged | - |
984 | QFont selectedFont = currentFont(); executed (the execution status of this line is deduced): QFont selectedFont = currentFont(); | - |
985 | if(selectedFont != d->selectedFont) evaluated: selectedFont != d->selectedFont yes Evaluation Count:1 | yes Evaluation Count:1 |
| 1 |
986 | emit(currentFontChanged(selectedFont)); executed: (currentFontChanged(selectedFont)); Execution Count:1 | 1 |
987 | d->selectedFont = selectedFont; executed (the execution status of this line is deduced): d->selectedFont = selectedFont; | - |
988 | emit fontSelected(d->selectedFont); executed (the execution status of this line is deduced): fontSelected(d->selectedFont); | - |
989 | } else executed: } Execution Count:2 | 2 |
990 | d->selectedFont = QFont(); never executed: d->selectedFont = QFont(); | 0 |
991 | if (d->receiverToDisconnectOnClose) { partially evaluated: d->receiverToDisconnectOnClose no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
992 | disconnect(this, SIGNAL(fontSelected(QFont)), never executed (the execution status of this line is deduced): disconnect(this, "2""fontSelected(QFont)", | - |
993 | d->receiverToDisconnectOnClose, d->memberToDisconnectOnClose); never executed (the execution status of this line is deduced): d->receiverToDisconnectOnClose, d->memberToDisconnectOnClose); | - |
994 | d->receiverToDisconnectOnClose = 0; never executed (the execution status of this line is deduced): d->receiverToDisconnectOnClose = 0; | - |
995 | } | 0 |
996 | d->memberToDisconnectOnClose.clear(); executed (the execution status of this line is deduced): d->memberToDisconnectOnClose.clear(); | - |
997 | } executed: } Execution Count:2 | 2 |
998 | | - |
999 | bool QFontDialogPrivate::canBeNativeDialog() const | - |
1000 | { | - |
1001 | Q_Q(const QFontDialog); executed (the execution status of this line is deduced): const QFontDialog * const q = q_func(); | - |
1002 | if (nativeDialogInUse) partially evaluated: nativeDialogInUse no Evaluation Count:0 | yes Evaluation Count:99 |
| 0-99 |
1003 | return true; never executed: return true; | 0 |
1004 | if (q->testAttribute(Qt::WA_DontShowOnScreen)) partially evaluated: q->testAttribute(Qt::WA_DontShowOnScreen) no Evaluation Count:0 | yes Evaluation Count:99 |
| 0-99 |
1005 | return false; never executed: return false; | 0 |
1006 | if (options->options() & QFontDialog::DontUseNativeDialog) evaluated: options->options() & QFontDialog::DontUseNativeDialog yes Evaluation Count:91 | yes Evaluation Count:8 |
| 8-91 |
1007 | return false; executed: return false; Execution Count:91 | 91 |
1008 | | - |
1009 | QLatin1String staticName(QFontDialog::staticMetaObject.className()); executed (the execution status of this line is deduced): QLatin1String staticName(QFontDialog::staticMetaObject.className()); | - |
1010 | QLatin1String dynamicName(q->metaObject()->className()); executed (the execution status of this line is deduced): QLatin1String dynamicName(q->metaObject()->className()); | - |
1011 | return (staticName == dynamicName); executed: return (staticName == dynamicName); Execution Count:8 | 8 |
1012 | } | - |
1013 | | - |
1014 | QT_END_NAMESPACE | - |
1015 | | - |
1016 | #include "qfontdialog.moc" | - |
1017 | #include "moc_qfontdialog.cpp" | - |
1018 | | - |
1019 | #endif // QT_NO_FONTDIALOG | - |
1020 | | - |
| | |