Line | Source | Count |
1 | | - |
2 | | - |
3 | | - |
4 | | - |
5 | | - |
6 | | - |
7 | const int GapBetweenLogoAndRightEdge = 5; | - |
8 | const int ModernHeaderTopMargin = 2; | - |
9 | const int ClassicHMargin = 4; | - |
10 | const int MacButtonTopMargin = 13; | - |
11 | const int MacLayoutLeftMargin = 20; | - |
12 | | - |
13 | const int MacLayoutRightMargin = 20; | - |
14 | const int MacLayoutBottomMargin = 17; | - |
15 | | - |
16 | static void changeSpacerSize(QLayout *layout, int index, int width, int height) | - |
17 | { | - |
18 | QSpacerItem *spacer = layout->itemAt(index)->spacerItem(); | - |
19 | if (!spacer) | - |
20 | return; | - |
21 | spacer->changeSize(width, height); | - |
22 | } | - |
23 | | - |
24 | static QWidget *iWantTheFocus(QWidget *ancestor) | - |
25 | { | - |
26 | const int MaxIterations = 100; | - |
27 | | - |
28 | QWidget *candidate = ancestor; | - |
29 | for (int i = 0; i < MaxIterations; ++i) { | - |
30 | candidate = candidate->nextInFocusChain(); | - |
31 | if (!candidate) | - |
32 | break; | - |
33 | | - |
34 | if (candidate->focusPolicy() & Qt::TabFocus) { | - |
35 | if (candidate != ancestor && ancestor->isAncestorOf(candidate)) | - |
36 | return candidate; | - |
37 | } | - |
38 | } | - |
39 | return 0; | - |
40 | } | - |
41 | | - |
42 | static bool objectInheritsXAndXIsCloserThanY(const QObject *object, const QByteArray &classX, | - |
43 | const QByteArray &classY) | - |
44 | { | - |
45 | const QMetaObject *metaObject = object->metaObject(); | - |
46 | while (metaObject) { | - |
47 | if (metaObject->className() == classX) | - |
48 | return true; | - |
49 | if (metaObject->className() == classY) | - |
50 | return false; | - |
51 | metaObject = metaObject->superClass(); | - |
52 | } | - |
53 | return false; | - |
54 | } | - |
55 | | - |
56 | const struct { | - |
57 | const char className[16]; | - |
58 | const char property[13]; | - |
59 | } fallbackProperties[] = { | - |
60 | | - |
61 | { "QAbstractButton", "checked" }, | - |
62 | { "QAbstractSlider", "value" }, | - |
63 | { "QComboBox", "currentIndex" }, | - |
64 | { "QDateTimeEdit", "dateTime" }, | - |
65 | { "QLineEdit", "text" }, | - |
66 | { "QListWidget", "currentRow" }, | - |
67 | { "QSpinBox", "value" }, | - |
68 | }; | - |
69 | const size_t NFallbackDefaultProperties = sizeof fallbackProperties / sizeof *fallbackProperties; | - |
70 | | - |
71 | static const char *changed_signal(int which) | - |
72 | { | - |
73 | | - |
74 | | - |
75 | | - |
76 | | - |
77 | | - |
78 | switch (which) { | - |
79 | case 0: return qFlagLocation("2""toggled(bool)" "\0" __FILE__ ":" "148""154"); | - |
80 | case 1: return qFlagLocation("2""valueChanged(int)" "\0" __FILE__ ":" "149""155"); | - |
81 | case 2: return qFlagLocation("2""currentIndexChanged(int)" "\0" __FILE__ ":" "150""156"); | - |
82 | case 3: return qFlagLocation("2""dateTimeChanged(QDateTime)" "\0" __FILE__ ":" "151""157"); | - |
83 | case 4: return qFlagLocation("2""textChanged(QString)" "\0" __FILE__ ":" "152""158"); | - |
84 | case 5: return qFlagLocation("2""currentRowChanged(int)" "\0" __FILE__ ":" "153""159"); | - |
85 | case 6: return qFlagLocation("2""valueChanged(int)" "\0" __FILE__ ":" "154""160"); | - |
86 | }; | - |
87 | static_assert(bool(7 == NFallbackDefaultProperties), "7 == NFallbackDefaultProperties"); | - |
88 | do { ((!(false)) ? qt_assert_x("Q_UNREACHABLE()", "Q_UNREACHABLE was reached",__FILE__,157163) : qt_noop()); __builtin_unreachable(); } while (0); | - |
89 | return 0; | - |
90 | } | - |
91 | | - |
92 | class QWizardDefaultProperty | - |
93 | { | - |
94 | public: | - |
95 | QByteArray className; | - |
96 | QByteArray property; | - |
97 | QByteArray changedSignal; | - |
98 | | - |
99 | inline QWizardDefaultProperty() {} | - |
100 | inline QWizardDefaultProperty(const char *className, const char *property, | - |
101 | const char *changedSignal) | - |
102 | : className(className), property(property), changedSignal(changedSignal) {} | - |
103 | }; | - |
104 | template<> class QTypeInfo<QWizardDefaultProperty > { public: enum { isComplex = (((Q_MOVABLE_TYPE) & Q_PRIMITIVE_TYPE) == 0), isStatic = (((Q_MOVABLE_TYPE) & (Q_MOVABLE_TYPE | Q_PRIMITIVE_TYPE)) == 0), isRelocatable = !isStatic || ((Q_MOVABLE_TYPE) & Q_RELOCATABLE_TYPE), isLarge = (sizeof(QWizardDefaultProperty)>sizeof(void*)), isPointer = false, isIntegral = QtPrivate::is_integral< QWizardDefaultProperty >::value, isDummy = (((Q_MOVABLE_TYPE) & Q_DUMMY_TYPE) != 0), sizeOf = sizeof(QWizardDefaultProperty) }; static inline const char *name() { return "QWizardDefaultProperty"; } }; | - |
105 | | - |
106 | class QWizardField | - |
107 | { | - |
108 | public: | - |
109 | inline QWizardField() {} | - |
110 | QWizardField(QWizardPage *page, const QString &spec, QObject *object, const char *property, | - |
111 | const char *changedSignal); | - |
112 | | - |
113 | void resolve(const QVector<QWizardDefaultProperty> &defaultPropertyTable); | - |
114 | void findProperty(const QWizardDefaultProperty *properties, int propertyCount); | - |
115 | | - |
116 | QWizardPage *page; | - |
117 | QString name; | - |
118 | bool mandatory; | - |
119 | QObject *object; | - |
120 | QByteArray property; | - |
121 | QByteArray changedSignal; | - |
122 | QVariant initialValue; | - |
123 | }; | - |
124 | template<> class QTypeInfo<QWizardField > { public: enum { isComplex = (((Q_MOVABLE_TYPE) & Q_PRIMITIVE_TYPE) == 0), isStatic = (((Q_MOVABLE_TYPE) & (Q_MOVABLE_TYPE | Q_PRIMITIVE_TYPE)) == 0), isRelocatable = !isStatic || ((Q_MOVABLE_TYPE) & Q_RELOCATABLE_TYPE), isLarge = (sizeof(QWizardField)>sizeof(void*)), isPointer = false, isIntegral = QtPrivate::is_integral< QWizardField >::value, isDummy = (((Q_MOVABLE_TYPE) & Q_DUMMY_TYPE) != 0), sizeOf = sizeof(QWizardField) }; static inline const char *name() { return "QWizardField"; } }; | - |
125 | | - |
126 | QWizardField::QWizardField(QWizardPage *page, const QString &spec, QObject *object, | - |
127 | const char *property, const char *changedSignal) | - |
128 | : page(page), name(spec), mandatory(false), object(object), property(property), | - |
129 | changedSignal(changedSignal) | - |
130 | { | - |
131 | if (name.endsWith(QLatin1Char('*'))) { | - |
132 | name.chop(1); | - |
133 | mandatory = true; | - |
134 | } | - |
135 | } | - |
136 | | - |
137 | void QWizardField::resolve(const QVector<QWizardDefaultProperty> &defaultPropertyTable) | - |
138 | { | - |
139 | if (property.isEmpty()) | - |
140 | findProperty(defaultPropertyTable.constData(), defaultPropertyTable.count()); | - |
141 | initialValue = object->property(property); | - |
142 | } | - |
143 | | - |
144 | void QWizardField::findProperty(const QWizardDefaultProperty *properties, int propertyCount) | - |
145 | { | - |
146 | QByteArray className; | - |
147 | | - |
148 | for (int i = 0; i < propertyCount; ++i) { | - |
149 | if (objectInheritsXAndXIsCloserThanY(object, properties[i].className, className)) { | - |
150 | className = properties[i].className; | - |
151 | property = properties[i].property; | - |
152 | changedSignal = properties[i].changedSignal; | - |
153 | } | - |
154 | } | - |
155 | } | - |
156 | | - |
157 | class QWizardLayoutInfo | - |
158 | { | - |
159 | public: | - |
160 | inline QWizardLayoutInfo() | - |
161 | : topLevelMarginLeft(-1), topLevelMarginRight(-1), topLevelMarginTop(-1), | - |
162 | topLevelMarginBottom(-1), childMarginLeft(-1), childMarginRight(-1), | - |
163 | childMarginTop(-1), childMarginBottom(-1), hspacing(-1), vspacing(-1), | - |
164 | wizStyle(QWizard::ClassicStyle), header(false), watermark(false), title(false), | - |
165 | subTitle(false), extension(false), sideWidget(false) {} | - |
166 | | - |
167 | int topLevelMarginLeft; | - |
168 | int topLevelMarginRight; | - |
169 | int topLevelMarginTop; | - |
170 | int topLevelMarginBottom; | - |
171 | int childMarginLeft; | - |
172 | int childMarginRight; | - |
173 | int childMarginTop; | - |
174 | int childMarginBottom; | - |
175 | int hspacing; | - |
176 | int vspacing; | - |
177 | int buttonSpacing; | - |
178 | QWizard::WizardStyle wizStyle; | - |
179 | bool header; | - |
180 | bool watermark; | - |
181 | bool title; | - |
182 | bool subTitle; | - |
183 | bool extension; | - |
184 | bool sideWidget; | - |
185 | | - |
186 | bool operator==(const QWizardLayoutInfo &other); | - |
187 | inline bool operator!=(const QWizardLayoutInfo &other) { return !operator==(other); } | - |
188 | }; | - |
189 | | - |
190 | bool QWizardLayoutInfo::operator==(const QWizardLayoutInfo &other) | - |
191 | { | - |
192 | return topLevelMarginLeft == other.topLevelMarginLeft | - |
193 | && topLevelMarginRight == other.topLevelMarginRight | - |
194 | && topLevelMarginTop == other.topLevelMarginTop | - |
195 | && topLevelMarginBottom == other.topLevelMarginBottom | - |
196 | && childMarginLeft == other.childMarginLeft | - |
197 | && childMarginRight == other.childMarginRight | - |
198 | && childMarginTop == other.childMarginTop | - |
199 | && childMarginBottom == other.childMarginBottom | - |
200 | && hspacing == other.hspacing | - |
201 | && vspacing == other.vspacing | - |
202 | && buttonSpacing == other.buttonSpacing | - |
203 | && wizStyle == other.wizStyle | - |
204 | && header == other.header | - |
205 | && watermark == other.watermark | - |
206 | && title == other.title | - |
207 | && subTitle == other.subTitle | - |
208 | && extension == other.extension | - |
209 | && sideWidget == other.sideWidget; | - |
210 | } | - |
211 | | - |
212 | class QWizardHeader : public QWidget | - |
213 | { | - |
214 | public: | - |
215 | enum RulerType { Ruler }; | - |
216 | | - |
217 | inline QWizardHeader(RulerType , QWidget *parent = 0) | - |
218 | : QWidget(parent) { setFixedHeight(2); } | - |
219 | QWizardHeader(QWidget *parent = 0); | - |
220 | | - |
221 | void setup(const QWizardLayoutInfo &info, const QString &title, | - |
222 | const QString &subTitle, const QPixmap &logo, const QPixmap &banner, | - |
223 | Qt::TextFormat titleFormat, Qt::TextFormat subTitleFormat); | - |
224 | | - |
225 | protected: | - |
226 | void paintEvent(QPaintEvent *event) override; | - |
227 | | - |
228 | | - |
229 | | - |
230 | | - |
231 | private: | - |
232 | QLabel *titleLabel; | - |
233 | QLabel *subTitleLabel; | - |
234 | QLabel *logoLabel; | - |
235 | QGridLayout *layout; | - |
236 | QPixmap bannerPixmap; | - |
237 | }; | - |
238 | | - |
239 | QWizardHeader::QWizardHeader(QWidget *parent) | - |
240 | : QWidget(parent) | - |
241 | { | - |
242 | setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); | - |
243 | setBackgroundRole(QPalette::Base); | - |
244 | | - |
245 | titleLabel = new QLabel(this); | - |
246 | titleLabel->setBackgroundRole(QPalette::Base); | - |
247 | | - |
248 | subTitleLabel = new QLabel(this); | - |
249 | subTitleLabel->setAlignment(Qt::AlignTop | Qt::AlignLeft); | - |
250 | subTitleLabel->setWordWrap(true); | - |
251 | | - |
252 | logoLabel = new QLabel(this); | - |
253 | | - |
254 | QFont font = titleLabel->font(); | - |
255 | font.setBold(true); | - |
256 | titleLabel->setFont(font); | - |
257 | | - |
258 | layout = new QGridLayout(this); | - |
259 | layout->setMargin(0); | - |
260 | layout->setSpacing(0); | - |
261 | | - |
262 | layout->setRowMinimumHeight(3, 1); | - |
263 | layout->setRowStretch(4, 1); | - |
264 | | - |
265 | layout->setColumnStretch(2, 1); | - |
266 | layout->setColumnMinimumWidth(4, 2 * GapBetweenLogoAndRightEdge); | - |
267 | layout->setColumnMinimumWidth(6, GapBetweenLogoAndRightEdge); | - |
268 | | - |
269 | layout->addWidget(titleLabel, 2, 1, 1, 2); | - |
270 | layout->addWidget(subTitleLabel, 4, 2); | - |
271 | layout->addWidget(logoLabel, 1, 5, 5, 1); | - |
272 | } | - |
273 | void QWizardHeader::setup(const QWizardLayoutInfo &info, const QString &title, | - |
274 | const QString &subTitle, const QPixmap &logo, const QPixmap &banner, | - |
275 | Qt::TextFormat titleFormat, Qt::TextFormat subTitleFormat) | - |
276 | { | - |
277 | bool modern = ((info.wizStyle == QWizard::ModernStyle) | - |
278 | | - |
279 | | - |
280 | | - |
281 | | - |
282 | ); | - |
283 | | - |
284 | layout->setRowMinimumHeight(0, modern ? ModernHeaderTopMargin : 0); | - |
285 | layout->setRowMinimumHeight(1, modern ? info.topLevelMarginTop - ModernHeaderTopMargin - 1 : 0); | - |
286 | layout->setRowMinimumHeight(6, (modern ? 3 : GapBetweenLogoAndRightEdge) + 2); | - |
287 | | - |
288 | int minColumnWidth0 = modern ? info.topLevelMarginLeft + info.topLevelMarginRight : 0; | - |
289 | int minColumnWidth1 = modern ? info.topLevelMarginLeft + info.topLevelMarginRight + 1 | - |
290 | : info.topLevelMarginLeft + ClassicHMargin; | - |
291 | layout->setColumnMinimumWidth(0, minColumnWidth0); | - |
292 | layout->setColumnMinimumWidth(1, minColumnWidth1); | - |
293 | | - |
294 | titleLabel->setTextFormat(titleFormat); | - |
295 | titleLabel->setText(title); | - |
296 | logoLabel->setPixmap(logo); | - |
297 | | - |
298 | subTitleLabel->setTextFormat(subTitleFormat); | - |
299 | subTitleLabel->setText(QLatin1String("Pq\nPq")); | - |
300 | int desiredSubTitleHeight = subTitleLabel->sizeHint().height(); | - |
301 | subTitleLabel->setText(subTitle); | - |
302 | | - |
303 | if (modern) { | - |
304 | bannerPixmap = banner; | - |
305 | } else { | - |
306 | bannerPixmap = QPixmap(); | - |
307 | } | - |
308 | | - |
309 | if (bannerPixmap.isNull()) { | - |
310 | | - |
311 | | - |
312 | | - |
313 | int candidateSubTitleWidth = qMin(512, 2 * QApplication::desktop()->width() / 3); | - |
314 | int delta = candidateSubTitleWidth >> 1; | - |
315 | while (delta > 0) { | - |
316 | if (subTitleLabel->heightForWidth(candidateSubTitleWidth - delta) | - |
317 | <= desiredSubTitleHeight) | - |
318 | candidateSubTitleWidth -= delta; | - |
319 | delta >>= 1; | - |
320 | } | - |
321 | | - |
322 | subTitleLabel->setMinimumSize(candidateSubTitleWidth, desiredSubTitleHeight); | - |
323 | | - |
324 | QSize size = layout->totalMinimumSize(); | - |
325 | setMinimumSize(size); | - |
326 | setMaximumSize(((1<<24)-1), size.height()); | - |
327 | } else { | - |
328 | subTitleLabel->setMinimumSize(0, 0); | - |
329 | setFixedSize(banner.size() + QSize(0, 2)); | - |
330 | } | - |
331 | updateGeometry(); | - |
332 | } | - |
333 | | - |
334 | void QWizardHeader::paintEvent(QPaintEvent * ) | - |
335 | { | - |
336 | QPainter painter(this); | - |
337 | painter.drawPixmap(0, 0, bannerPixmap); | - |
338 | | - |
339 | int x = width() - 2; | - |
340 | int y = height() - 2; | - |
341 | const QPalette &pal = palette(); | - |
342 | painter.setPen(pal.mid().color()); | - |
343 | painter.drawLine(0, y, x, y); | - |
344 | painter.setPen(pal.base().color()); | - |
345 | painter.drawPoint(x + 1, y); | - |
346 | painter.drawLine(0, y + 1, x + 1, y + 1); | - |
347 | } | - |
348 | | - |
349 | | - |
350 | class QWizardRuler : public QWizardHeader | - |
351 | { | - |
352 | public: | - |
353 | inline QWizardRuler(QWidget *parent = 0) | - |
354 | : QWizardHeader(Ruler, parent) {} | - |
355 | }; | - |
356 | | - |
357 | class QWatermarkLabel : public QLabel | - |
358 | { | - |
359 | public: | - |
360 | QWatermarkLabel(QWidget *parent, QWidget *sideWidget) : QLabel(parent), m_sideWidget(sideWidget) { | - |
361 | m_layout = new QVBoxLayout(this); | - |
362 | if (m_sideWidget) | - |
363 | m_layout->addWidget(m_sideWidget); | - |
364 | } | - |
365 | | - |
366 | QSize minimumSizeHint() const override { | - |
367 | if (!pixmap() && !pixmap()->isNull()) | - |
368 | return pixmap()->size(); | - |
369 | return QFrame::minimumSizeHint(); | - |
370 | } | - |
371 | | - |
372 | void setSideWidget(QWidget *widget) { | - |
373 | if (m_sideWidget == widget) | - |
374 | return; | - |
375 | if (m_sideWidget) { | - |
376 | m_layout->removeWidget(m_sideWidget); | - |
377 | m_sideWidget->hide(); | - |
378 | } | - |
379 | m_sideWidget = widget; | - |
380 | if (m_sideWidget) | - |
381 | m_layout->addWidget(m_sideWidget); | - |
382 | } | - |
383 | QWidget *sideWidget() const { | - |
384 | return m_sideWidget; | - |
385 | } | - |
386 | private: | - |
387 | QVBoxLayout *m_layout; | - |
388 | QWidget *m_sideWidget; | - |
389 | }; | - |
390 | | - |
391 | class QWizardPagePrivate : public QWidgetPrivate | - |
392 | { | - |
393 | inline QWizardPage* q_func() { return static_cast<QWizardPage *>(q_ptr); } inline const QWizardPage* q_func() const { return static_cast<const QWizardPage *>(q_ptr); } friend class QWizardPage; | - |
394 | | - |
395 | public: | - |
396 | enum TriState { Tri_Unknown = -1, Tri_False, Tri_True }; | - |
397 | | - |
398 | inline QWizardPagePrivate() | - |
399 | : wizard(0), completeState(Tri_Unknown), explicitlyFinal(false), commit(false) {} | - |
400 | | - |
401 | bool cachedIsComplete() const; | - |
402 | void _q_maybeEmitCompleteChanged(); | - |
403 | void _q_updateCachedCompleteState(); | - |
404 | | - |
405 | QWizard *wizard; | - |
406 | QString title; | - |
407 | QString subTitle; | - |
408 | QPixmap pixmaps[QWizard::NPixmaps]; | - |
409 | QVector<QWizardField> pendingFields; | - |
410 | mutable TriState completeState; | - |
411 | bool explicitlyFinal; | - |
412 | bool commit; | - |
413 | QMap<int, QString> buttonCustomTexts; | - |
414 | }; | - |
415 | | - |
416 | bool QWizardPagePrivate::cachedIsComplete() const | - |
417 | { | - |
418 | const QWizardPage * const q = q_func(); | - |
419 | if (completeState == Tri_Unknown) | - |
420 | completeState = q->isComplete() ? Tri_True : Tri_False; | - |
421 | return completeState == Tri_True; | - |
422 | } | - |
423 | | - |
424 | void QWizardPagePrivate::_q_maybeEmitCompleteChanged() | - |
425 | { | - |
426 | QWizardPage * const q = q_func(); | - |
427 | TriState newState = q->isComplete() ? Tri_True : Tri_False; | - |
428 | if (newState != completeState) | - |
429 | q->completeChanged(); | - |
430 | } | - |
431 | | - |
432 | void QWizardPagePrivate::_q_updateCachedCompleteState() | - |
433 | { | - |
434 | QWizardPage * const q = q_func(); | - |
435 | completeState = q->isComplete() ? Tri_True : Tri_False; | - |
436 | } | - |
437 | | - |
438 | class QWizardAntiFlickerWidget : public QWidget | - |
439 | { | - |
440 | public: | - |
441 | QWizardAntiFlickerWidget(QWizard *wizard, QWizardPrivate *) | - |
442 | : QWidget(wizard) | - |
443 | {} | - |
444 | | - |
445 | }; | - |
446 | | - |
447 | class QWizardPrivate : public QDialogPrivate | - |
448 | { | - |
449 | inline QWizard* q_func() { return static_cast<QWizard *>(q_ptr); } inline const QWizard* q_func() const { return static_cast<const QWizard *>(q_ptr); } friend class QWizard; | - |
450 | | - |
451 | public: | - |
452 | typedef QMap<int, QWizardPage *> PageMap; | - |
453 | | - |
454 | enum Direction { | - |
455 | Backward, | - |
456 | Forward | - |
457 | }; | - |
458 | | - |
459 | inline QWizardPrivate() | - |
460 | : start(-1) | - |
461 | , startSetByUser(false) | - |
462 | , current(-1) | - |
463 | , canContinue(false) | - |
464 | , canFinish(false) | - |
465 | , disableUpdatesCount(0) | - |
466 | , wizStyle(QWizard::ClassicStyle) | - |
467 | , opts(0) | - |
468 | , buttonsHaveCustomLayout(false) | - |
469 | , titleFmt(Qt::AutoText) | - |
470 | , subTitleFmt(Qt::AutoText) | - |
471 | , placeholderWidget1(0) | - |
472 | , placeholderWidget2(0) | - |
473 | , headerWidget(0) | - |
474 | , watermarkLabel(0) | - |
475 | , sideWidget(0) | - |
476 | , pageFrame(0) | - |
477 | , titleLabel(0) | - |
478 | , subTitleLabel(0) | - |
479 | , bottomRuler(0) | - |
480 | | - |
481 | | - |
482 | | - |
483 | | - |
484 | | - |
485 | | - |
486 | | - |
487 | , minimumWidth(0) | - |
488 | , minimumHeight(0) | - |
489 | , maximumWidth(((1<<24)-1)) | - |
490 | , maximumHeight(((1<<24)-1)) | - |
491 | { | - |
492 | std::fill(btns, btns + QWizard::NButtons, static_cast<QAbstractButton *>(0)); | - |
493 | | - |
494 | | - |
495 | | - |
496 | | - |
497 | | - |
498 | | - |
499 | } | - |
500 | | - |
501 | void init(); | - |
502 | void reset(); | - |
503 | void cleanupPagesNotInHistory(); | - |
504 | void addField(const QWizardField &field); | - |
505 | void removeFieldAt(int index); | - |
506 | void switchToPage(int newId, Direction direction); | - |
507 | QWizardLayoutInfo layoutInfoForCurrentPage(); | - |
508 | void recreateLayout(const QWizardLayoutInfo &info); | - |
509 | void updateLayout(); | - |
510 | void updateMinMaxSizes(const QWizardLayoutInfo &info); | - |
511 | void updateCurrentPage(); | - |
512 | bool ensureButton(QWizard::WizardButton which) const; | - |
513 | void connectButton(QWizard::WizardButton which) const; | - |
514 | void updateButtonTexts(); | - |
515 | void updateButtonLayout(); | - |
516 | void setButtonLayout(const QWizard::WizardButton *array, int size); | - |
517 | bool buttonLayoutContains(QWizard::WizardButton which); | - |
518 | void updatePixmap(QWizard::WizardPixmap which); | - |
519 | | - |
520 | | - |
521 | | - |
522 | | - |
523 | | - |
524 | bool isVistaThemeEnabled() const; | - |
525 | void disableUpdates(); | - |
526 | void enableUpdates(); | - |
527 | void _q_emitCustomButtonClicked(); | - |
528 | void _q_updateButtonStates(); | - |
529 | void _q_handleFieldObjectDestroyed(QObject *); | - |
530 | void setStyle(QStyle *style); | - |
531 | | - |
532 | | - |
533 | | - |
534 | | - |
535 | PageMap pageMap; | - |
536 | QVector<QWizardField> fields; | - |
537 | QMap<QString, int> fieldIndexMap; | - |
538 | QVector<QWizardDefaultProperty> defaultPropertyTable; | - |
539 | QList<int> history; | - |
540 | QSet<int> initialized; | - |
541 | int start; | - |
542 | bool startSetByUser; | - |
543 | int current; | - |
544 | bool canContinue; | - |
545 | bool canFinish; | - |
546 | QWizardLayoutInfo layoutInfo; | - |
547 | int disableUpdatesCount; | - |
548 | | - |
549 | QWizard::WizardStyle wizStyle; | - |
550 | QWizard::WizardOptions opts; | - |
551 | QMap<int, QString> buttonCustomTexts; | - |
552 | bool buttonsHaveCustomLayout; | - |
553 | QList<QWizard::WizardButton> buttonsCustomLayout; | - |
554 | Qt::TextFormat titleFmt; | - |
555 | Qt::TextFormat subTitleFmt; | - |
556 | mutable QPixmap defaultPixmaps[QWizard::NPixmaps]; | - |
557 | | - |
558 | union { | - |
559 | | - |
560 | mutable struct { | - |
561 | QAbstractButton *back; | - |
562 | QAbstractButton *next; | - |
563 | QAbstractButton *commit; | - |
564 | QAbstractButton *finish; | - |
565 | QAbstractButton *cancel; | - |
566 | QAbstractButton *help; | - |
567 | } btn; | - |
568 | mutable QAbstractButton *btns[QWizard::NButtons]; | - |
569 | }; | - |
570 | QWizardAntiFlickerWidget *antiFlickerWidget; | - |
571 | QWidget *placeholderWidget1; | - |
572 | QWidget *placeholderWidget2; | - |
573 | QWizardHeader *headerWidget; | - |
574 | QWatermarkLabel *watermarkLabel; | - |
575 | QWidget *sideWidget; | - |
576 | QFrame *pageFrame; | - |
577 | QLabel *titleLabel; | - |
578 | QLabel *subTitleLabel; | - |
579 | QWizardRuler *bottomRuler; | - |
580 | | - |
581 | QVBoxLayout *pageVBoxLayout; | - |
582 | QHBoxLayout *buttonLayout; | - |
583 | QGridLayout *mainLayout; | - |
584 | int minimumWidth; | - |
585 | int minimumHeight; | - |
586 | int maximumWidth; | - |
587 | int maximumHeight; | - |
588 | }; | - |
589 | | - |
590 | static QString buttonDefaultText(int wstyle, int which, const QWizardPrivate *wizardPrivate) | - |
591 | { | - |
592 | | - |
593 | (void)wizardPrivate;; | - |
594 | | - |
595 | const bool macStyle = (wstyle == QWizard::MacStyle); | - |
596 | switch (which) { | - |
597 | case QWizard::BackButton: | - |
598 | return macStyle ? QWizard::tr("Go Back") : QWizard::tr("< &Back"); | - |
599 | case QWizard::NextButton: | - |
600 | if (macStyle) | - |
601 | return QWizard::tr("Continue"); | - |
602 | else | - |
603 | return wizardPrivate->isVistaThemeEnabled() | - |
604 | ? QWizard::tr("&Next") : QWizard::tr("&Next >"); | - |
605 | case QWizard::CommitButton: | - |
606 | return QWizard::tr("Commit"); | - |
607 | case QWizard::FinishButton: | - |
608 | return macStyle ? QWizard::tr("Done") : QWizard::tr("&Finish"); | - |
609 | case QWizard::CancelButton: | - |
610 | return QWizard::tr("Cancel"); | - |
611 | case QWizard::HelpButton: | - |
612 | return macStyle ? QWizard::tr("Help") : QWizard::tr("&Help"); | - |
613 | default: | - |
614 | return QString(); | - |
615 | } | - |
616 | } | - |
617 | | - |
618 | void QWizardPrivate::init() | - |
619 | { | - |
620 | QWizard * const q = q_func(); | - |
621 | | - |
622 | antiFlickerWidget = new QWizardAntiFlickerWidget(q, this); | - |
623 | wizStyle = QWizard::WizardStyle(q->style()->styleHint(QStyle::SH_WizardStyle, 0, q)); | - |
624 | if (wizStyle == QWizard::MacStyle) { | - |
625 | opts = (QWizard::NoDefaultButton | QWizard::NoCancelButton); | - |
626 | } else if (wizStyle == QWizard::ModernStyle) { | - |
627 | opts = QWizard::HelpButtonOnRight; | - |
628 | } | - |
629 | | - |
630 | | - |
631 | | - |
632 | | - |
633 | | - |
634 | | - |
635 | ensureButton(QWizard::BackButton); | - |
636 | ensureButton(QWizard::NextButton); | - |
637 | ensureButton(QWizard::CommitButton); | - |
638 | ensureButton(QWizard::FinishButton); | - |
639 | | - |
640 | pageFrame = new QFrame(antiFlickerWidget); | - |
641 | pageFrame->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); | - |
642 | | - |
643 | pageVBoxLayout = new QVBoxLayout(pageFrame); | - |
644 | pageVBoxLayout->setSpacing(0); | - |
645 | pageVBoxLayout->addSpacing(0); | - |
646 | QSpacerItem *spacerItem = new QSpacerItem(0, 0, QSizePolicy::Ignored, QSizePolicy::MinimumExpanding); | - |
647 | pageVBoxLayout->addItem(spacerItem); | - |
648 | | - |
649 | buttonLayout = new QHBoxLayout; | - |
650 | mainLayout = new QGridLayout(antiFlickerWidget); | - |
651 | mainLayout->setSizeConstraint(QLayout::SetNoConstraint); | - |
652 | | - |
653 | updateButtonLayout(); | - |
654 | | - |
655 | defaultPropertyTable.reserve(NFallbackDefaultProperties); | - |
656 | for (uint i = 0; i < NFallbackDefaultProperties; ++i) | - |
657 | defaultPropertyTable.append(QWizardDefaultProperty(fallbackProperties[i].className, | - |
658 | fallbackProperties[i].property, | - |
659 | changed_signal(i))); | - |
660 | } | - |
661 | | - |
662 | void QWizardPrivate::reset() | - |
663 | { | - |
664 | QWizard * const q = q_func(); | - |
665 | if (current != -1) { | - |
666 | q->currentPage()->hide(); | - |
667 | cleanupPagesNotInHistory(); | - |
668 | for (int i = history.count() - 1; i >= 0; --i) | - |
669 | q->cleanupPage(history.at(i)); | - |
670 | history.clear(); | - |
671 | initialized.clear(); | - |
672 | | - |
673 | current = -1; | - |
674 | q->currentIdChanged(-1); | - |
675 | } | - |
676 | } | - |
677 | | - |
678 | void QWizardPrivate::cleanupPagesNotInHistory() | - |
679 | { | - |
680 | QWizard * const q = q_func(); | - |
681 | | - |
682 | const QSet<int> original = initialized; | - |
683 | QSet<int>::const_iterator i = original.constBegin(); | - |
684 | QSet<int>::const_iterator end = original.constEnd(); | - |
685 | | - |
686 | for (; i != end; ++i) { | - |
687 | if (!history.contains(*i)) { | - |
688 | q->cleanupPage(*i); | - |
689 | initialized.remove(*i); | - |
690 | } | - |
691 | } | - |
692 | } | - |
693 | | - |
694 | void QWizardPrivate::addField(const QWizardField &field) | - |
695 | { | - |
696 | QWizard * const q = q_func(); | - |
697 | | - |
698 | QWizardField myField = field; | - |
699 | myField.resolve(defaultPropertyTable); | - |
700 | | - |
701 | if (__builtin_expect(!!(TRUE | never evaluated | FALSE | never evaluated |
fieldIndexMap.contains(myField.name)), false)TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
702 | QMessageLogger(__FILE__, 803809, __PRETTY_FUNCTION__).warning("QWizardPage::addField: Duplicate field '%s'"'%ls'", static_cast<const wchar_t*>(static_cast<const void*>(QString(myField.name).toLocal8Bit().constData());utf16()))); | - |
703 | return; never executed: return; | 0 |
704 | } | - |
705 | | - |
706 | fieldIndexMap.insert(myField.name, fields.count()); | - |
707 | fields += myField; | - |
708 | if (myField.mandatoryTRUE | never evaluated | FALSE | never evaluated |
&& !myField.changedSignal.isEmpty()TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
709 | QObject::connect(myField.object, myField.changedSignal, never executed: QObject::connect(myField.object, myField.changedSignal, myField.page, qFlagLocation("1""_q_maybeEmitCompleteChanged()" "\0" __FILE__ ":" "817")); | 0 |
710 | myField.page, qFlagLocation("1""_q_maybeEmitCompleteChanged()" "\0" __FILE__ ":" "811""817")); never executed: QObject::connect(myField.object, myField.changedSignal, myField.page, qFlagLocation("1""_q_maybeEmitCompleteChanged()" "\0" __FILE__ ":" "817")); | 0 |
711 | QObject::connect( | - |
712 | myField.object, qFlagLocation("2""destroyed(QObject*)" "\0" __FILE__ ":" "813""819"), q, | - |
713 | qFlagLocation("1""_q_handleFieldObjectDestroyed(QObject*)" "\0" __FILE__ ":" "814""820")); | - |
714 | } never executed: end of block | 0 |
715 | | - |
716 | void QWizardPrivate::removeFieldAt(int index) | - |
717 | { | - |
718 | QWizard * const q = q_func(); | - |
719 | | - |
720 | const QWizardField &field = fields.at(index); | - |
721 | fieldIndexMap.remove(field.name); | - |
722 | if (field.mandatory && !field.changedSignal.isEmpty()) | - |
723 | QObject::disconnect(field.object, field.changedSignal, | - |
724 | field.page, qFlagLocation("1""_q_maybeEmitCompleteChanged()" "\0" __FILE__ ":" "825""831")); | - |
725 | QObject::disconnect( | - |
726 | field.object, qFlagLocation("2""destroyed(QObject*)" "\0" __FILE__ ":" "827""833"), q, | - |
727 | qFlagLocation("1""_q_handleFieldObjectDestroyed(QObject*)" "\0" __FILE__ ":" "828""834")); | - |
728 | fields.remove(index); | - |
729 | } | - |
730 | | - |
731 | void QWizardPrivate::switchToPage(int newId, Direction direction) | - |
732 | { | - |
733 | QWizard * const q = q_func(); | - |
734 | | - |
735 | disableUpdates(); | - |
736 | | - |
737 | int oldId = current; | - |
738 | if (QWizardPage *oldPage = q->currentPage()TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
739 | oldPage->hide(); | - |
740 | | - |
741 | if (direction == BackwardTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
742 | if (!(opts & QWizard::IndependentPages)TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
743 | q->cleanupPage(oldId); | - |
744 | initialized.remove(oldId); | - |
745 | } never executed: end of block | 0 |
746 | ((!(history.lastconstLast() == oldId)) ? qt_assert("history.lastconstLast() == oldId",__FILE__,847853) : qt_noop()); | - |
747 | history.removeLast(); | - |
748 | ((!(history.lastconstLast() == newId)) ? qt_assert("history.lastconstLast() == newId",__FILE__,849855) : qt_noop()); | - |
749 | } never executed: end of block | 0 |
750 | } never executed: end of block | 0 |
751 | | - |
752 | current = newId; | - |
753 | | - |
754 | QWizardPage *newPage = q->currentPage(); | - |
755 | if (newPageTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
756 | if (direction == ForwardTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
757 | if (!initialized.contains(current)TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
758 | initialized.insert(current); | - |
759 | q->initializePage(current); | - |
760 | } never executed: end of block | 0 |
761 | history.append(current); | - |
762 | } never executed: end of block | 0 |
763 | newPage->show(); | - |
764 | } never executed: end of block | 0 |
765 | | - |
766 | canContinue = (q->nextId() != -1); | - |
767 | canFinish = (newPageTRUE | never evaluated | FALSE | never evaluated |
&& newPage->isFinalPage()TRUE | never evaluated | FALSE | never evaluated |
); | 0 |
768 | | - |
769 | _q_updateButtonStates(); | - |
770 | updateButtonTexts(); | - |
771 | | - |
772 | const QWizard::WizardButton nextOrCommit = | - |
773 | newPageTRUE | never evaluated | FALSE | never evaluated |
&& newPage->isCommitPage()TRUE | never evaluated | FALSE | never evaluated |
? QWizard::CommitButton : QWizard::NextButton; | 0 |
774 | QAbstractButton *nextOrFinishButton = | - |
775 | btns[canContinue ? nextOrCommit : QWizard::FinishButton]; | - |
776 | QWidget *candidate = 0; | - |
777 | if ((TRUE | never evaluated | FALSE | never evaluated |
opts & QWizard::NoDefaultButton)TRUE | never evaluated | FALSE | never evaluated |
&& nextOrFinishButton->isEnabled()TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
778 | candidate = nextOrFinishButton; | - |
779 | } never executed: end of block else if (newPageTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
780 | candidate = iWantTheFocus(newPage); | - |
781 | } never executed: end of block | 0 |
782 | if (!candidateTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
783 | candidate = nextOrFinishButton; never executed: candidate = nextOrFinishButton; | 0 |
784 | candidate->setFocus(); | - |
785 | | - |
786 | if (wizStyle == QWizard::MacStyleTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
787 | q->updateGeometry(); never executed: q->updateGeometry(); | 0 |
788 | | - |
789 | enableUpdates(); | - |
790 | updateLayout(); | - |
791 | | - |
792 | q->currentIdChanged(current); | - |
793 | } never executed: end of block | 0 |
794 | | - |
795 | | - |
796 | static const char * buttonSlots(QWizard::WizardButton which) | - |
797 | { | - |
798 | switch (which) { | - |
799 | case QWizard::BackButton: | - |
800 | return qFlagLocation("1""back()" "\0" __FILE__ ":" "911""917"); | - |
801 | case QWizard::NextButton: | - |
802 | case QWizard::CommitButton: | - |
803 | return qFlagLocation("1""next()" "\0" __FILE__ ":" "914""920"); | - |
804 | case QWizard::FinishButton: | - |
805 | return qFlagLocation("1""accept()" "\0" __FILE__ ":" "916""922"); | - |
806 | case QWizard::CancelButton: | - |
807 | return qFlagLocation("1""reject()" "\0" __FILE__ ":" "918""924"); | - |
808 | case QWizard::HelpButton: | - |
809 | return qFlagLocation("2""helpRequested()" "\0" __FILE__ ":" "920""926"); | - |
810 | case QWizard::CustomButton1: | - |
811 | case QWizard::CustomButton2: | - |
812 | case QWizard::CustomButton3: | - |
813 | case QWizard::Stretch: | - |
814 | case QWizard::NoButton: | - |
815 | do { ((!(false)) ? qt_assert_x("Q_UNREACHABLE()", "Q_UNREACHABLE was reached",__FILE__,926932) : qt_noop()); __builtin_unreachable(); } while (0); | - |
816 | }; | - |
817 | return 0; | - |
818 | }; | - |
819 | | - |
820 | QWizardLayoutInfo QWizardPrivate::layoutInfoForCurrentPage() | - |
821 | { | - |
822 | QWizard * const q = q_func(); | - |
823 | QStyle *style = q->style(); | - |
824 | | - |
825 | QWizardLayoutInfo info; | - |
826 | | - |
827 | const int layoutHorizontalSpacing = style->pixelMetric(QStyle::PM_LayoutHorizontalSpacing); | - |
828 | info.topLevelMarginLeft = style->pixelMetric(QStyle::PM_LayoutLeftMargin, 0, q); | - |
829 | info.topLevelMarginRight = style->pixelMetric(QStyle::PM_LayoutRightMargin, 0, q); | - |
830 | info.topLevelMarginTop = style->pixelMetric(QStyle::PM_LayoutTopMargin, 0, q); | - |
831 | info.topLevelMarginBottom = style->pixelMetric(QStyle::PM_LayoutBottomMargin, 0, q); | - |
832 | info.childMarginLeft = style->pixelMetric(QStyle::PM_LayoutLeftMargin, 0, titleLabel); | - |
833 | info.childMarginRight = style->pixelMetric(QStyle::PM_LayoutRightMargin, 0, titleLabel); | - |
834 | info.childMarginTop = style->pixelMetric(QStyle::PM_LayoutTopMargin, 0, titleLabel); | - |
835 | info.childMarginBottom = style->pixelMetric(QStyle::PM_LayoutBottomMargin, 0, titleLabel); | - |
836 | info.hspacing = (layoutHorizontalSpacing == -1) | - |
837 | ? style->layoutSpacing(QSizePolicy::DefaultType, QSizePolicy::DefaultType, Qt::Horizontal) | - |
838 | : layoutHorizontalSpacing; | - |
839 | info.vspacing = style->pixelMetric(QStyle::PM_LayoutVerticalSpacing); | - |
840 | info.buttonSpacing = (layoutHorizontalSpacing == -1) | - |
841 | ? style->layoutSpacing(QSizePolicy::PushButton, QSizePolicy::PushButton, Qt::Horizontal) | - |
842 | : layoutHorizontalSpacing; | - |
843 | | - |
844 | if (wizStyle == QWizard::MacStyle) | - |
845 | info.buttonSpacing = 12; | - |
846 | | - |
847 | info.wizStyle = wizStyle; | - |
848 | if (info.wizStyle == QWizard::AeroStyle | - |
849 | | - |
850 | | - |
851 | | - |
852 | ) | - |
853 | info.wizStyle = QWizard::ModernStyle; | - |
854 | | - |
855 | QString titleText; | - |
856 | QString subTitleText; | - |
857 | QPixmap backgroundPixmap; | - |
858 | QPixmap watermarkPixmap; | - |
859 | | - |
860 | if (QWizardPage *page = q->currentPage()) { | - |
861 | titleText = page->title(); | - |
862 | subTitleText = page->subTitle(); | - |
863 | backgroundPixmap = page->pixmap(QWizard::BackgroundPixmap); | - |
864 | watermarkPixmap = page->pixmap(QWizard::WatermarkPixmap); | - |
865 | } | - |
866 | | - |
867 | info.header = (info.wizStyle == QWizard::ClassicStyle || info.wizStyle == QWizard::ModernStyle) | - |
868 | && !(opts & QWizard::IgnoreSubTitles) && !subTitleText.isEmpty(); | - |
869 | info.sideWidget = sideWidget; | - |
870 | info.watermark = (info.wizStyle != QWizard::MacStyle) && (info.wizStyle != QWizard::AeroStyle) | - |
871 | && !watermarkPixmap.isNull(); | - |
872 | info.title = !info.header && !titleText.isEmpty(); | - |
873 | info.subTitle = !(opts & QWizard::IgnoreSubTitles) && !info.header && !subTitleText.isEmpty(); | - |
874 | info.extension = (info.watermark || info.sideWidget) && (opts & QWizard::ExtendedWatermarkPixmap); | - |
875 | | - |
876 | return info; | - |
877 | } | - |
878 | | - |
879 | void QWizardPrivate::recreateLayout(const QWizardLayoutInfo &info) | - |
880 | { | - |
881 | QWizard * const q = q_func(); | - |
882 | | - |
883 | | - |
884 | | - |
885 | | - |
886 | for (int i = mainLayout->count() - 1; i >= 0; --i) { | - |
887 | QLayoutItem *item = mainLayout->takeAt(i); | - |
888 | if (item->layout()) { | - |
889 | item->layout()->setParent(0); | - |
890 | } else { | - |
891 | delete item; | - |
892 | } | - |
893 | } | - |
894 | for (int i = mainLayout->columnCount() - 1; i >= 0; --i) | - |
895 | mainLayout->setColumnMinimumWidth(i, 0); | - |
896 | for (int i = mainLayout->rowCount() - 1; i >= 0; --i) | - |
897 | mainLayout->setRowMinimumHeight(i, 0); | - |
898 | | - |
899 | | - |
900 | | - |
901 | | - |
902 | | - |
903 | bool mac = (info.wizStyle == QWizard::MacStyle); | - |
904 | bool classic = (info.wizStyle == QWizard::ClassicStyle); | - |
905 | bool modern = (info.wizStyle == QWizard::ModernStyle); | - |
906 | bool aero = (info.wizStyle == QWizard::AeroStyle); | - |
907 | int deltaMarginLeft = info.topLevelMarginLeft - info.childMarginLeft; | - |
908 | int deltaMarginRight = info.topLevelMarginRight - info.childMarginRight; | - |
909 | int deltaMarginTop = info.topLevelMarginTop - info.childMarginTop; | - |
910 | int deltaMarginBottom = info.topLevelMarginBottom - info.childMarginBottom; | - |
911 | int deltaVSpacing = info.topLevelMarginBottom - info.vspacing; | - |
912 | | - |
913 | int row = 0; | - |
914 | int numColumns; | - |
915 | if (mac) { | - |
916 | numColumns = 3; | - |
917 | } else if (info.watermark || info.sideWidget) { | - |
918 | numColumns = 2; | - |
919 | } else { | - |
920 | numColumns = 1; | - |
921 | } | - |
922 | int pageColumn = qMin(1, numColumns - 1); | - |
923 | | - |
924 | if (mac) { | - |
925 | mainLayout->setMargin(0); | - |
926 | mainLayout->setSpacing(0); | - |
927 | buttonLayout->setContentsMargins(MacLayoutLeftMargin, MacButtonTopMargin, MacLayoutRightMargin, MacLayoutBottomMargin); | - |
928 | pageVBoxLayout->setMargin(7); | - |
929 | } else { | - |
930 | if (modern) { | - |
931 | mainLayout->setMargin(0); | - |
932 | mainLayout->setSpacing(0); | - |
933 | pageVBoxLayout->setContentsMargins(deltaMarginLeft, deltaMarginTop, | - |
934 | deltaMarginRight, deltaMarginBottom); | - |
935 | buttonLayout->setContentsMargins(info.topLevelMarginLeft, info.topLevelMarginTop, | - |
936 | info.topLevelMarginRight, info.topLevelMarginBottom); | - |
937 | } else { | - |
938 | mainLayout->setContentsMargins(info.topLevelMarginLeft, info.topLevelMarginTop, | - |
939 | info.topLevelMarginRight, info.topLevelMarginBottom); | - |
940 | mainLayout->setHorizontalSpacing(info.hspacing); | - |
941 | mainLayout->setVerticalSpacing(info.vspacing); | - |
942 | pageVBoxLayout->setContentsMargins(0, 0, 0, 0); | - |
943 | buttonLayout->setContentsMargins(0, 0, 0, 0); | - |
944 | } | - |
945 | } | - |
946 | buttonLayout->setSpacing(info.buttonSpacing); | - |
947 | | - |
948 | if (info.header) { | - |
949 | if (!headerWidget) | - |
950 | headerWidget = new QWizardHeader(antiFlickerWidget); | - |
951 | headerWidget->setAutoFillBackground(modern); | - |
952 | mainLayout->addWidget(headerWidget, row++, 0, 1, numColumns); | - |
953 | } | - |
954 | if (headerWidget) | - |
955 | headerWidget->setVisible(info.header); | - |
956 | | - |
957 | int watermarkStartRow = row; | - |
958 | | - |
959 | if (mac) | - |
960 | mainLayout->setRowMinimumHeight(row++, 10); | - |
961 | | - |
962 | if (info.title) { | - |
963 | if (!titleLabel) { | - |
964 | titleLabel = new QLabel(antiFlickerWidget); | - |
965 | titleLabel->setBackgroundRole(QPalette::Base); | - |
966 | titleLabel->setWordWrap(true); | - |
967 | } | - |
968 | | - |
969 | QFont titleFont = q->font(); | - |
970 | titleFont.setPointSize(titleFont.pointSize() + (mac ? 3 : 4)); | - |
971 | titleFont.setBold(true); | - |
972 | titleLabel->setPalette(QPalette()); | - |
973 | | - |
974 | if (aero) { | - |
975 | | - |
976 | titleFont = QFont(QLatin1String("Segoe UI"), 12); | - |
977 | QPalette pal(titleLabel->palette()); | - |
978 | pal.setColor(QPalette::Text, "#003399"); | - |
979 | titleLabel->setPalette(pal); | - |
980 | } | - |
981 | | - |
982 | titleLabel->setFont(titleFont); | - |
983 | const int aeroTitleIndent = 25; | - |
984 | if (aero) | - |
985 | titleLabel->setIndent(aeroTitleIndent); | - |
986 | else if (mac) | - |
987 | titleLabel->setIndent(2); | - |
988 | else if (classic) | - |
989 | titleLabel->setIndent(info.childMarginLeft); | - |
990 | else | - |
991 | titleLabel->setIndent(info.topLevelMarginLeft); | - |
992 | if (modern) { | - |
993 | if (!placeholderWidget1) { | - |
994 | placeholderWidget1 = new QWidget(antiFlickerWidget); | - |
995 | placeholderWidget1->setBackgroundRole(QPalette::Base); | - |
996 | } | - |
997 | placeholderWidget1->setFixedHeight(info.topLevelMarginLeft + 2); | - |
998 | mainLayout->addWidget(placeholderWidget1, row++, pageColumn); | - |
999 | } | - |
1000 | mainLayout->addWidget(titleLabel, row++, pageColumn); | - |
1001 | if (modern) { | - |
1002 | if (!placeholderWidget2) { | - |
1003 | placeholderWidget2 = new QWidget(antiFlickerWidget); | - |
1004 | placeholderWidget2->setBackgroundRole(QPalette::Base); | - |
1005 | } | - |
1006 | placeholderWidget2->setFixedHeight(5); | - |
1007 | mainLayout->addWidget(placeholderWidget2, row++, pageColumn); | - |
1008 | } | - |
1009 | if (mac) | - |
1010 | mainLayout->setRowMinimumHeight(row++, 7); | - |
1011 | } | - |
1012 | if (placeholderWidget1) | - |
1013 | placeholderWidget1->setVisible(info.title && modern); | - |
1014 | if (placeholderWidget2) | - |
1015 | placeholderWidget2->setVisible(info.title && modern); | - |
1016 | | - |
1017 | if (info.subTitle) { | - |
1018 | if (!subTitleLabel) { | - |
1019 | subTitleLabel = new QLabel(pageFrame); | - |
1020 | subTitleLabel->setWordWrap(true); | - |
1021 | | - |
1022 | subTitleLabel->setContentsMargins(info.childMarginLeft , 0, | - |
1023 | info.childMarginRight , 0); | - |
1024 | | - |
1025 | pageVBoxLayout->insertWidget(1, subTitleLabel); | - |
1026 | } | - |
1027 | } | - |
1028 | | - |
1029 | | - |
1030 | changeSpacerSize(pageVBoxLayout, 0, 0, info.subTitle ? info.childMarginLeft : 0); | - |
1031 | | - |
1032 | int hMargin = mac ? 1 : 0; | - |
1033 | int vMargin = hMargin; | - |
1034 | | - |
1035 | pageFrame->setFrameStyle(mac ? (QFrame::Box | QFrame::Raised) : QFrame::NoFrame); | - |
1036 | pageFrame->setLineWidth(0); | - |
1037 | pageFrame->setMidLineWidth(hMargin); | - |
1038 | | - |
1039 | if (info.header) { | - |
1040 | if (modern) { | - |
1041 | hMargin = info.topLevelMarginLeft; | - |
1042 | vMargin = deltaMarginBottom; | - |
1043 | } else if (classic) { | - |
1044 | hMargin = deltaMarginLeft + ClassicHMargin; | - |
1045 | vMargin = 0; | - |
1046 | } | - |
1047 | } | - |
1048 | | - |
1049 | if (aero) { | - |
1050 | int leftMargin = 18; | - |
1051 | int topMargin = vMargin; | - |
1052 | int rightMargin = hMargin; | - |
1053 | int bottomMargin = vMargin; | - |
1054 | pageFrame->setContentsMargins(leftMargin, topMargin, rightMargin, bottomMargin); | - |
1055 | } else { | - |
1056 | pageFrame->setContentsMargins(hMargin, vMargin, hMargin, vMargin); | - |
1057 | } | - |
1058 | | - |
1059 | if ((info.watermark || info.sideWidget) && !watermarkLabel) { | - |
1060 | watermarkLabel = new QWatermarkLabel(antiFlickerWidget, sideWidget); | - |
1061 | watermarkLabel->setBackgroundRole(QPalette::Base); | - |
1062 | watermarkLabel->setMinimumHeight(1); | - |
1063 | watermarkLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding); | - |
1064 | watermarkLabel->setAlignment(Qt::AlignLeft | Qt::AlignTop); | - |
1065 | } | - |
1066 | | - |
1067 | | - |
1068 | const bool wasSemiTransparent = | - |
1069 | pageFrame->palette().brush(QPalette::Window).color().alpha() < 255 | - |
1070 | || pageFrame->palette().brush(QPalette::Base).color().alpha() < 255; | - |
1071 | if (mac) { | - |
1072 | if (!wasSemiTransparent) { | - |
1073 | QPalette pal = pageFrame->palette(); | - |
1074 | pal.setBrush(QPalette::Window, QColor(255, 255, 255, 153)); | - |
1075 | | - |
1076 | | - |
1077 | pal.setBrush(QPalette::Base, QColor(255, 255, 255, 153)); | - |
1078 | pageFrame->setPalette(pal); | - |
1079 | pageFrame->setAutoFillBackground(true); | - |
1080 | antiFlickerWidget->setAutoFillBackground(false); | - |
1081 | } | - |
1082 | } else { | - |
1083 | if (wasSemiTransparent) | - |
1084 | pageFrame->setPalette(QPalette()); | - |
1085 | | - |
1086 | bool baseBackground = (modern && !info.header); | - |
1087 | pageFrame->setBackgroundRole(baseBackground ? QPalette::Base : QPalette::Window); | - |
1088 | | - |
1089 | if (titleLabel) | - |
1090 | titleLabel->setAutoFillBackground(baseBackground); | - |
1091 | pageFrame->setAutoFillBackground(baseBackground); | - |
1092 | if (watermarkLabel) | - |
1093 | watermarkLabel->setAutoFillBackground(baseBackground); | - |
1094 | if (placeholderWidget1) | - |
1095 | placeholderWidget1->setAutoFillBackground(baseBackground); | - |
1096 | if (placeholderWidget2) | - |
1097 | placeholderWidget2->setAutoFillBackground(baseBackground); | - |
1098 | | - |
1099 | if (aero) { | - |
1100 | QPalette pal = pageFrame->palette(); | - |
1101 | pal.setBrush(QPalette::Window, QColor(255, 255, 255)); | - |
1102 | pageFrame->setPalette(pal); | - |
1103 | pageFrame->setAutoFillBackground(true); | - |
1104 | pal = antiFlickerWidget->palette(); | - |
1105 | pal.setBrush(QPalette::Window, QColor(255, 255, 255)); | - |
1106 | antiFlickerWidget->setPalette(pal); | - |
1107 | antiFlickerWidget->setAutoFillBackground(true); | - |
1108 | } | - |
1109 | } | - |
1110 | | - |
1111 | mainLayout->addWidget(pageFrame, row++, pageColumn); | - |
1112 | | - |
1113 | int watermarkEndRow = row; | - |
1114 | if (classic) | - |
1115 | mainLayout->setRowMinimumHeight(row++, deltaVSpacing); | - |
1116 | | - |
1117 | if (aero) { | - |
1118 | buttonLayout->setContentsMargins(9, 9, 9, 9); | - |
1119 | mainLayout->setContentsMargins(0, 11, 0, 0); | - |
1120 | } | - |
1121 | | - |
1122 | int buttonStartColumn = info.extension ? 1 : 0; | - |
1123 | int buttonNumColumns = info.extension ? 1 : numColumns; | - |
1124 | | - |
1125 | if (classic || modern) { | - |
1126 | if (!bottomRuler) | - |
1127 | bottomRuler = new QWizardRuler(antiFlickerWidget); | - |
1128 | mainLayout->addWidget(bottomRuler, row++, buttonStartColumn, 1, buttonNumColumns); | - |
1129 | } | - |
1130 | | - |
1131 | if (classic) | - |
1132 | mainLayout->setRowMinimumHeight(row++, deltaVSpacing); | - |
1133 | | - |
1134 | mainLayout->addLayout(buttonLayout, row++, buttonStartColumn, 1, buttonNumColumns); | - |
1135 | | - |
1136 | if (info.watermark || info.sideWidget) { | - |
1137 | if (info.extension) | - |
1138 | watermarkEndRow = row; | - |
1139 | mainLayout->addWidget(watermarkLabel, watermarkStartRow, 0, | - |
1140 | watermarkEndRow - watermarkStartRow, 1); | - |
1141 | } | - |
1142 | | - |
1143 | mainLayout->setColumnMinimumWidth(0, mac && !info.watermark ? 181 : 0); | - |
1144 | if (mac) | - |
1145 | mainLayout->setColumnMinimumWidth(2, 21); | - |
1146 | | - |
1147 | if (headerWidget) | - |
1148 | headerWidget->setVisible(info.header); | - |
1149 | if (titleLabel) | - |
1150 | titleLabel->setVisible(info.title); | - |
1151 | if (subTitleLabel) | - |
1152 | subTitleLabel->setVisible(info.subTitle); | - |
1153 | if (bottomRuler) | - |
1154 | bottomRuler->setVisible(classic || modern); | - |
1155 | if (watermarkLabel) | - |
1156 | watermarkLabel->setVisible(info.watermark || info.sideWidget); | - |
1157 | | - |
1158 | layoutInfo = info; | - |
1159 | } | - |
1160 | | - |
1161 | void QWizardPrivate::updateLayout() | - |
1162 | { | - |
1163 | QWizard * const q = q_func(); | - |
1164 | | - |
1165 | disableUpdates(); | - |
1166 | | - |
1167 | QWizardLayoutInfo info = layoutInfoForCurrentPage(); | - |
1168 | if (layoutInfo != info) | - |
1169 | recreateLayout(info); | - |
1170 | QWizardPage *page = q->currentPage(); | - |
1171 | | - |
1172 | | - |
1173 | | - |
1174 | | - |
1175 | | - |
1176 | | - |
1177 | if (page) { | - |
1178 | bool expandPage = !page->layout(); | - |
1179 | if (!expandPage) { | - |
1180 | const QLayoutItem *pageItem = pageVBoxLayout->itemAt(pageVBoxLayout->indexOf(page)); | - |
1181 | expandPage = pageItem->expandingDirections() & Qt::Vertical; | - |
1182 | } | - |
1183 | QSpacerItem *bottomSpacer = pageVBoxLayout->itemAt(pageVBoxLayout->count() - 1)->spacerItem(); | - |
1184 | ((!(bottomSpacer)) ? qt_assert("bottomSpacer",__FILE__,12951301) : qt_noop()); | - |
1185 | bottomSpacer->changeSize(0, 0, QSizePolicy::Ignored, expandPage ? QSizePolicy::Ignored : QSizePolicy::MinimumExpanding); | - |
1186 | pageVBoxLayout->invalidate(); | - |
1187 | } | - |
1188 | | - |
1189 | if (info.header) { | - |
1190 | ((!(page)) ? qt_assert("page",__FILE__,13011307) : qt_noop()); | - |
1191 | headerWidget->setup(info, page->title(), page->subTitle(), | - |
1192 | page->pixmap(QWizard::LogoPixmap), page->pixmap(QWizard::BannerPixmap), | - |
1193 | titleFmt, subTitleFmt); | - |
1194 | } | - |
1195 | | - |
1196 | if (info.watermark || info.sideWidget) { | - |
1197 | QPixmap pix; | - |
1198 | if (info.watermark) { | - |
1199 | if (page) | - |
1200 | pix = page->pixmap(QWizard::WatermarkPixmap); | - |
1201 | else | - |
1202 | pix = q->pixmap(QWizard::WatermarkPixmap); | - |
1203 | } | - |
1204 | watermarkLabel->setPixmap(pix); | - |
1205 | } | - |
1206 | | - |
1207 | if (info.title) { | - |
1208 | ((!(page)) ? qt_assert("page",__FILE__,13191325) : qt_noop()); | - |
1209 | titleLabel->setTextFormat(titleFmt); | - |
1210 | titleLabel->setText(page->title()); | - |
1211 | } | - |
1212 | if (info.subTitle) { | - |
1213 | ((!(page)) ? qt_assert("page",__FILE__,13241330) : qt_noop()); | - |
1214 | subTitleLabel->setTextFormat(subTitleFmt); | - |
1215 | subTitleLabel->setText(page->subTitle()); | - |
1216 | } | - |
1217 | | - |
1218 | enableUpdates(); | - |
1219 | updateMinMaxSizes(info); | - |
1220 | } | - |
1221 | | - |
1222 | void QWizardPrivate::updateMinMaxSizes(const QWizardLayoutInfo &info) | - |
1223 | { | - |
1224 | QWizard * const q = q_func(); | - |
1225 | | - |
1226 | int extraHeight = 0; | - |
1227 | | - |
1228 | | - |
1229 | | - |
1230 | | - |
1231 | QSize minimumSize = mainLayout->totalMinimumSize() + QSize(0, extraHeight); | - |
1232 | QSize maximumSize = mainLayout->totalMaximumSize(); | - |
1233 | if (info.header && headerWidget->maximumWidth() != ((1<<24)-1)) { | - |
1234 | minimumSize.setWidth(headerWidget->maximumWidth()); | - |
1235 | maximumSize.setWidth(headerWidget->maximumWidth()); | - |
1236 | } | - |
1237 | if (info.watermark && !info.sideWidget) { | - |
1238 | minimumSize.setHeight(mainLayout->totalSizeHint().height()); | - |
1239 | } | - |
1240 | if (q->minimumWidth() == minimumWidth) { | - |
1241 | minimumWidth = minimumSize.width(); | - |
1242 | q->setMinimumWidth(minimumWidth); | - |
1243 | } | - |
1244 | if (q->minimumHeight() == minimumHeight) { | - |
1245 | minimumHeight = minimumSize.height(); | - |
1246 | q->setMinimumHeight(minimumHeight); | - |
1247 | } | - |
1248 | if (q->maximumWidth() == maximumWidth) { | - |
1249 | maximumWidth = maximumSize.width(); | - |
1250 | q->setMaximumWidth(maximumWidth); | - |
1251 | } | - |
1252 | if (q->maximumHeight() == maximumHeight) { | - |
1253 | maximumHeight = maximumSize.height(); | - |
1254 | q->setMaximumHeight(maximumHeight); | - |
1255 | } | - |
1256 | } | - |
1257 | | - |
1258 | void QWizardPrivate::updateCurrentPage() | - |
1259 | { | - |
1260 | QWizard * const q = q_func(); | - |
1261 | if (q->currentPage()) { | - |
1262 | canContinue = (q->nextId() != -1); | - |
1263 | canFinish = q->currentPage()->isFinalPage(); | - |
1264 | } else { | - |
1265 | canContinue = false; | - |
1266 | canFinish = false; | - |
1267 | } | - |
1268 | _q_updateButtonStates(); | - |
1269 | updateButtonTexts(); | - |
1270 | } | - |
1271 | | - |
1272 | static QString object_name_for_button(QWizard::WizardButton which) | - |
1273 | { | - |
1274 | switch (which) { | - |
1275 | case QWizard::CommitButton: | - |
1276 | return QLatin1String("qt_wizard_") + QLatin1String("commit"); | - |
1277 | case QWizard::FinishButton: | - |
1278 | return QLatin1String("qt_wizard_") + QLatin1String("finish"); | - |
1279 | case QWizard::CancelButton: | - |
1280 | return QLatin1String("qt_wizard_") + QLatin1String("cancel"); | - |
1281 | case QWizard::BackButton: | - |
1282 | case QWizard::NextButton: | - |
1283 | case QWizard::HelpButton: | - |
1284 | case QWizard::CustomButton1: | - |
1285 | case QWizard::CustomButton2: | - |
1286 | case QWizard::CustomButton3: | - |
1287 | | - |
1288 | return QLatin1String("__qt__passive_wizardbutton") + QString::number(which); | - |
1289 | case QWizard::Stretch: | - |
1290 | case QWizard::NoButton: | - |
1291 | | - |
1292 | | - |
1293 | ; | - |
1294 | } | - |
1295 | do { ((!(false)) ? qt_assert_x("Q_UNREACHABLE()", "Q_UNREACHABLE was reached",__FILE__,14061412) : qt_noop()); __builtin_unreachable(); } while (0); | - |
1296 | return QString(); | - |
1297 | } | - |
1298 | | - |
1299 | bool QWizardPrivate::ensureButton(QWizard::WizardButton which) const | - |
1300 | { | - |
1301 | const QWizard * const q = q_func(); | - |
1302 | if (uint(which) >= QWizard::NButtons) | - |
1303 | return false; | - |
1304 | | - |
1305 | if (!btns[which]) { | - |
1306 | QPushButton *pushButton = new QPushButton(antiFlickerWidget); | - |
1307 | QStyle *style = q->style(); | - |
1308 | if (style != QApplication::style()) | - |
1309 | pushButton->setStyle(style); | - |
1310 | pushButton->setObjectName(object_name_for_button(which)); | - |
1311 | | - |
1312 | | - |
1313 | | - |
1314 | pushButton->hide(); | - |
1315 | | - |
1316 | | - |
1317 | | - |
1318 | btns[which] = pushButton; | - |
1319 | | - |
1320 | if (which < QWizard::NStandardButtons) | - |
1321 | pushButton->setText(buttonDefaultText(wizStyle, which, this)); | - |
1322 | | - |
1323 | connectButton(which); | - |
1324 | } | - |
1325 | return true; | - |
1326 | } | - |
1327 | | - |
1328 | void QWizardPrivate::connectButton(QWizard::WizardButton which) const | - |
1329 | { | - |
1330 | const QWizard * const q = q_func(); | - |
1331 | if (which < QWizard::NStandardButtons) { | - |
1332 | QObject::connect(btns[which], qFlagLocation("2""clicked()" "\0" __FILE__ ":" "1443""1449"), q, buttonSlots(which)); | - |
1333 | } else { | - |
1334 | QObject::connect(btns[which], qFlagLocation("2""clicked()" "\0" __FILE__ ":" "1445""1451"), q, qFlagLocation("1""_q_emitCustomButtonClicked()" "\0" __FILE__ ":" "1445""1451")); | - |
1335 | } | - |
1336 | } | - |
1337 | | - |
1338 | void QWizardPrivate::updateButtonTexts() | - |
1339 | { | - |
1340 | QWizard * const q = q_func(); | - |
1341 | for (int i = 0; i < QWizard::NButtons; ++i) { | - |
1342 | if (btns[i]) { | - |
1343 | if (q->currentPage() && (q->currentPage()->d_func()->buttonCustomTexts.contains(i))) | - |
1344 | btns[i]->setText(q->currentPage()->d_func()->buttonCustomTexts.value(i)); | - |
1345 | else if (buttonCustomTexts.contains(i)) | - |
1346 | btns[i]->setText(buttonCustomTexts.value(i)); | - |
1347 | else if (i < QWizard::NStandardButtons) | - |
1348 | btns[i]->setText(buttonDefaultText(wizStyle, i, this)); | - |
1349 | } | - |
1350 | } | - |
1351 | | - |
1352 | | - |
1353 | | - |
1354 | if (btns[QWizard::NextButton]) | - |
1355 | btns[QWizard::NextButton]->setShortcut(isVistaThemeEnabled() ? QKeySequence(Qt::ALT | Qt::Key_Right) : QKeySequence()); | - |
1356 | } | - |
1357 | | - |
1358 | void QWizardPrivate::updateButtonLayout() | - |
1359 | { | - |
1360 | if (buttonsHaveCustomLayout) { | - |
1361 | QVarLengthArray<QWizard::WizardButton, QWizard::NButtons> array(buttonsCustomLayout.count()); | - |
1362 | for (int i = 0; i < buttonsCustomLayout.count(); ++i) | - |
1363 | array[i] = buttonsCustomLayout.at(i); | - |
1364 | setButtonLayout(array.constData(), array.count()); | - |
1365 | } else { | - |
1366 | | - |
1367 | | - |
1368 | | - |
1369 | const int ArraySize = 12; | - |
1370 | QWizard::WizardButton array[ArraySize]; | - |
1371 | memset(array, -1, sizeof(array)); | - |
1372 | ((!(array[0] == QWizard::NoButton)) ? qt_assert("array[0] == QWizard::NoButton",__FILE__,14831489) : qt_noop()); | - |
1373 | | - |
1374 | if (opts & QWizard::HaveHelpButton) { | - |
1375 | int i = (opts & QWizard::HelpButtonOnRight) ? 11 : 0; | - |
1376 | array[i] = QWizard::HelpButton; | - |
1377 | } | - |
1378 | array[1] = QWizard::Stretch; | - |
1379 | if (opts & QWizard::HaveCustomButton1) | - |
1380 | array[2] = QWizard::CustomButton1; | - |
1381 | if (opts & QWizard::HaveCustomButton2) | - |
1382 | array[3] = QWizard::CustomButton2; | - |
1383 | if (opts & QWizard::HaveCustomButton3) | - |
1384 | array[4] = QWizard::CustomButton3; | - |
1385 | | - |
1386 | if (!(opts & QWizard::NoCancelButton)) { | - |
1387 | int i = (opts & QWizard::CancelButtonOnLeft) ? 5 : 10; | - |
1388 | array[i] = QWizard::CancelButton; | - |
1389 | } | - |
1390 | array[6] = QWizard::BackButton; | - |
1391 | array[7] = QWizard::NextButton; | - |
1392 | array[8] = QWizard::CommitButton; | - |
1393 | array[9] = QWizard::FinishButton; | - |
1394 | | - |
1395 | setButtonLayout(array, ArraySize); | - |
1396 | } | - |
1397 | } | - |
1398 | | - |
1399 | void QWizardPrivate::setButtonLayout(const QWizard::WizardButton *array, int size) | - |
1400 | { | - |
1401 | QWidget *prev = pageFrame; | - |
1402 | | - |
1403 | for (int i = buttonLayout->count() - 1; i >= 0; --i) { | - |
1404 | QLayoutItem *item = buttonLayout->takeAt(i); | - |
1405 | if (QWidget *widget = item->widget()) | - |
1406 | widget->hide(); | - |
1407 | delete item; | - |
1408 | } | - |
1409 | | - |
1410 | for (int i = 0; i < size; ++i) { | - |
1411 | QWizard::WizardButton which = array[i]; | - |
1412 | if (which == QWizard::Stretch) { | - |
1413 | buttonLayout->addStretch(1); | - |
1414 | } else if (which != QWizard::NoButton) { | - |
1415 | ensureButton(which); | - |
1416 | buttonLayout->addWidget(btns[which]); | - |
1417 | | - |
1418 | | - |
1419 | if (which != QWizard::BackButton && which != QWizard::NextButton | - |
1420 | && which != QWizard::CommitButton && which != QWizard::FinishButton) | - |
1421 | btns[which]->show(); | - |
1422 | | - |
1423 | if (prev) | - |
1424 | QWidget::setTabOrder(prev, btns[which]); | - |
1425 | prev = btns[which]; | - |
1426 | } | - |
1427 | } | - |
1428 | | - |
1429 | _q_updateButtonStates(); | - |
1430 | } | - |
1431 | | - |
1432 | bool QWizardPrivate::buttonLayoutContains(QWizard::WizardButton which) | - |
1433 | { | - |
1434 | return !buttonsHaveCustomLayout || buttonsCustomLayout.contains(which); | - |
1435 | } | - |
1436 | | - |
1437 | void QWizardPrivate::updatePixmap(QWizard::WizardPixmap which) | - |
1438 | { | - |
1439 | QWizard * const q = q_func(); | - |
1440 | if (which == QWizard::BackgroundPixmap) { | - |
1441 | if (wizStyle == QWizard::MacStyle) { | - |
1442 | q->update(); | - |
1443 | q->updateGeometry(); | - |
1444 | } | - |
1445 | } else { | - |
1446 | updateLayout(); | - |
1447 | } | - |
1448 | } | - |
1449 | bool QWizardPrivate::isVistaThemeEnabled() const | - |
1450 | { | - |
1451 | | - |
1452 | | - |
1453 | | - |
1454 | | - |
1455 | return false; | - |
1456 | | - |
1457 | } | - |
1458 | | - |
1459 | void QWizardPrivate::disableUpdates() | - |
1460 | { | - |
1461 | QWizard * const q = q_func(); | - |
1462 | if (disableUpdatesCount++ == 0) { | - |
1463 | q->setUpdatesEnabled(false); | - |
1464 | antiFlickerWidget->hide(); | - |
1465 | } | - |
1466 | } | - |
1467 | | - |
1468 | void QWizardPrivate::enableUpdates() | - |
1469 | { | - |
1470 | QWizard * const q = q_func(); | - |
1471 | if (--disableUpdatesCount == 0) { | - |
1472 | antiFlickerWidget->show(); | - |
1473 | q->setUpdatesEnabled(true); | - |
1474 | } | - |
1475 | } | - |
1476 | | - |
1477 | void QWizardPrivate::_q_emitCustomButtonClicked() | - |
1478 | { | - |
1479 | QWizard * const q = q_func(); | - |
1480 | QObject *button = q->sender(); | - |
1481 | for (int i = QWizard::NStandardButtons; i < QWizard::NButtons; ++i) { | - |
1482 | if (btns[i] == button) { | - |
1483 | q->customButtonClicked(QWizard::WizardButton(i)); | - |
1484 | break; | - |
1485 | } | - |
1486 | } | - |
1487 | } | - |
1488 | | - |
1489 | void QWizardPrivate::_q_updateButtonStates() | - |
1490 | { | - |
1491 | QWizard * const q = q_func(); | - |
1492 | | - |
1493 | disableUpdates(); | - |
1494 | | - |
1495 | const QWizardPage *page = q->currentPage(); | - |
1496 | bool complete = page && page->isComplete(); | - |
1497 | | - |
1498 | btn.back->setEnabled(history.count() > 1 | - |
1499 | && !q->page(history.at(history.count() - 2))->isCommitPage() | - |
1500 | && (!canFinish || !(opts & QWizard::DisabledBackButtonOnLastPage))); | - |
1501 | btn.next->setEnabled(canContinue && complete); | - |
1502 | btn.commit->setEnabled(canContinue && complete); | - |
1503 | btn.finish->setEnabled(canFinish && complete); | - |
1504 | | - |
1505 | const bool backButtonVisible = buttonLayoutContains(QWizard::BackButton) | - |
1506 | && (history.count() > 1 || !(opts & QWizard::NoBackButtonOnStartPage)) | - |
1507 | && (canContinue || !(opts & QWizard::NoBackButtonOnLastPage)); | - |
1508 | bool commitPage = page && page->isCommitPage(); | - |
1509 | btn.back->setVisible(backButtonVisible); | - |
1510 | btn.next->setVisible(buttonLayoutContains(QWizard::NextButton) && !commitPage | - |
1511 | && (canContinue || (opts & QWizard::HaveNextButtonOnLastPage))); | - |
1512 | btn.commit->setVisible(buttonLayoutContains(QWizard::CommitButton) && commitPage | - |
1513 | && canContinue); | - |
1514 | btn.finish->setVisible(buttonLayoutContains(QWizard::FinishButton) | - |
1515 | && (canFinish || (opts & QWizard::HaveFinishButtonOnEarlyPages))); | - |
1516 | | - |
1517 | if (!(opts & QWizard::NoCancelButton)) | - |
1518 | btn.cancel->setVisible(buttonLayoutContains(QWizard::CancelButton) | - |
1519 | && (canContinue || !(opts & QWizard::NoCancelButtonOnLastPage))); | - |
1520 | | - |
1521 | bool useDefault = !(opts & QWizard::NoDefaultButton); | - |
1522 | if (QPushButton *nextPush = qobject_cast<QPushButton *>(btn.next)) | - |
1523 | nextPush->setDefault(canContinue && useDefault && !commitPage); | - |
1524 | if (QPushButton *commitPush = qobject_cast<QPushButton *>(btn.commit)) | - |
1525 | commitPush->setDefault(canContinue && useDefault && commitPage); | - |
1526 | if (QPushButton *finishPush = qobject_cast<QPushButton *>(btn.finish)) | - |
1527 | finishPush->setDefault(!canContinue && useDefault); | - |
1528 | enableUpdates(); | - |
1529 | } | - |
1530 | | - |
1531 | void QWizardPrivate::_q_handleFieldObjectDestroyed(QObject *object) | - |
1532 | { | - |
1533 | int destroyed_index = -1; | - |
1534 | QVector<QWizardField>::iterator it = fields.begin(); | - |
1535 | while (it != fields.end()) { | - |
1536 | const QWizardField &field = *it; | - |
1537 | if (field.object == object) { | - |
1538 | destroyed_index = fieldIndexMap.value(field.name, -1); | - |
1539 | fieldIndexMap.remove(field.name); | - |
1540 | it = fields.erase(it); | - |
1541 | } else { | - |
1542 | ++it; | - |
1543 | } | - |
1544 | } | - |
1545 | if (destroyed_index != -1) { | - |
1546 | QMap<QString, int>::iterator it2 = fieldIndexMap.begin(); | - |
1547 | while (it2 != fieldIndexMap.end()) { | - |
1548 | int index = it2.value(); | - |
1549 | if (index > destroyed_index) { | - |
1550 | QString field_name = it2.key(); | - |
1551 | fieldIndexMap.insert(field_name, index-1); | - |
1552 | } | - |
1553 | ++it2; | - |
1554 | } | - |
1555 | } | - |
1556 | } | - |
1557 | | - |
1558 | void QWizardPrivate::setStyle(QStyle *style) | - |
1559 | { | - |
1560 | for (int i = 0; i < QWizard::NButtons; i++) | - |
1561 | if (btns[i]) | - |
1562 | btns[i]->setStyle(style); | - |
1563 | const PageMap::const_iterator pcend = pageMap.constEnd(); | - |
1564 | for (PageMap::const_iterator it = pageMap.constBegin(); it != pcend; ++it) | - |
1565 | it.value()->setStyle(style); | - |
1566 | } | - |
1567 | QWizard::QWizard(QWidget *parent, Qt::WindowFlags flags) | - |
1568 | : QDialog(*new QWizardPrivate, parent, flags) | - |
1569 | { | - |
1570 | QWizardPrivate * const d = d_func(); | - |
1571 | d->init(); | - |
1572 | | - |
1573 | | - |
1574 | | - |
1575 | | - |
1576 | } | - |
1577 | | - |
1578 | | - |
1579 | | - |
1580 | | - |
1581 | QWizard::~QWizard() | - |
1582 | { | - |
1583 | QWizardPrivate * const d = d_func(); | - |
1584 | delete d->buttonLayout; | - |
1585 | } | - |
1586 | int QWizard::addPage(QWizardPage *page) | - |
1587 | { | - |
1588 | QWizardPrivate * const d = d_func(); | - |
1589 | int theid = 0; | - |
1590 | if (!d->pageMap.isEmpty()) | - |
1591 | theid = (d->pageMap.constEnd() - 1).key() + 1; | - |
1592 | setPage(theid, page); | - |
1593 | return theid; | - |
1594 | } | - |
1595 | void QWizard::setPage(int theid, QWizardPage *page) | - |
1596 | { | - |
1597 | QWizardPrivate * const d = d_func(); | - |
1598 | | - |
1599 | if (!(__builtin_expect(!!(!TRUE | never evaluated | FALSE | never evaluated |
page)), false)TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
1600 | QMessageLogger(__FILE__, 22602266, __PRETTY_FUNCTION__).warning("QWizard::setPage: Cannot insert null page"); | - |
1601 | return; never executed: return; | 0 |
1602 | } | - |
1603 | | - |
1604 | if (__builtin_expect(!!(TRUE | never evaluated | FALSE | never evaluated |
theid == -1)), false)TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
1605 | QMessageLogger(__FILE__, 22652271, __PRETTY_FUNCTION__).warning("QWizard::setPage: Cannot insert page with ID -1"); | - |
1606 | return; never executed: return; | 0 |
1607 | } | - |
1608 | | - |
1609 | if (__builtin_expect(!!(TRUE | never evaluated | FALSE | never evaluated |
d->pageMap.contains(theid)), false)TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
1610 | QMessageLogger(__FILE__, 22702276, __PRETTY_FUNCTION__).warning("QWizard::setPage: Page with duplicate ID %d ignored", theid); | - |
1611 | return; never executed: return; | 0 |
1612 | } | - |
1613 | | - |
1614 | page->setParent(d->pageFrame); | - |
1615 | | - |
1616 | QVector<QWizardField> &pendingFields = page->d_func()->pendingFields; | - |
1617 | for (int i = 0; i < pendingFields.count()TRUE | never evaluated | FALSE | never evaluated |
; ++i) | 0 |
1618 | d->addField(pendingFields.at(i)); never executed: d->addField(pendingFields.at(i)); | 0 |
1619 | pendingFields.clear(); | - |
1620 | | - |
1621 | connect(page, qFlagLocation("2""completeChanged()" "\0" __FILE__ ":" "2281""2287"), this, qFlagLocation("1""_q_updateButtonStates()" "\0" __FILE__ ":" "2281""2287")); | - |
1622 | | - |
1623 | d->pageMap.insert(theid, page); | - |
1624 | page->d_func()->wizard = this; | - |
1625 | | - |
1626 | int n = d->pageVBoxLayout->count(); | - |
1627 | | - |
1628 | | - |
1629 | bool pageVBoxLayoutEnabled = d->pageVBoxLayout->isEnabled(); | - |
1630 | d->pageVBoxLayout->setEnabled(false); | - |
1631 | | - |
1632 | d->pageVBoxLayout->insertWidget(n - 1, page); | - |
1633 | | - |
1634 | | - |
1635 | page->hide(); | - |
1636 | d->pageVBoxLayout->setEnabled(pageVBoxLayoutEnabled); | - |
1637 | | - |
1638 | if (!d->startSetByUserTRUE | never evaluated | FALSE | never evaluated |
&& d->pageMap.constBegin().key() == theidTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1639 | d->start = theid; never executed: d->start = theid; | 0 |
1640 | pageAdded(theid); | - |
1641 | } never executed: end of block | 0 |
1642 | void QWizard::removePage(int id) | - |
1643 | { | - |
1644 | QWizardPrivate * const d = d_func(); | - |
1645 | | - |
1646 | QWizardPage *removedPage = 0; | - |
1647 | | - |
1648 | | - |
1649 | if (d->pageMap.count() > 0) { | - |
1650 | if (d->start == id) { | - |
1651 | const int firstId = d->pageMap.constBegin().key(); | - |
1652 | if (firstId == id) { | - |
1653 | if (d->pageMap.count() > 1) | - |
1654 | d->start = (++d->pageMap.constBegin()).key(); | - |
1655 | else | - |
1656 | d->start = -1; | - |
1657 | } else { | - |
1658 | d->start = firstId; | - |
1659 | } | - |
1660 | d->startSetByUser = false; | - |
1661 | } | - |
1662 | } | - |
1663 | | - |
1664 | if (d->pageMap.contains(id)) | - |
1665 | pageRemoved(id); | - |
1666 | | - |
1667 | if (!d->history.contains(id)) { | - |
1668 | | - |
1669 | removedPage = d->pageMap.take(id); | - |
1670 | d->updateCurrentPage(); | - |
1671 | } else if (id != d->current) { | - |
1672 | | - |
1673 | removedPage = d->pageMap.take(id); | - |
1674 | d->history.removeOne(id); | - |
1675 | d->_q_updateButtonStates(); | - |
1676 | } else if (d->history.count() == 1) { | - |
1677 | | - |
1678 | d->reset(); | - |
1679 | removedPage = d->pageMap.take(id); | - |
1680 | if (d->pageMap.isEmpty()) | - |
1681 | d->updateCurrentPage(); | - |
1682 | else | - |
1683 | restart(); | - |
1684 | } else { | - |
1685 | | - |
1686 | back(); | - |
1687 | removedPage = d->pageMap.take(id); | - |
1688 | d->updateCurrentPage(); | - |
1689 | } | - |
1690 | | - |
1691 | if (removedPage) { | - |
1692 | if (d->initialized.contains(id)) { | - |
1693 | cleanupPage(id); | - |
1694 | d->initialized.remove(id); | - |
1695 | } | - |
1696 | | - |
1697 | d->pageVBoxLayout->removeWidget(removedPage); | - |
1698 | | - |
1699 | for (int i = d->fields.count() - 1; i >= 0; --i) { | - |
1700 | if (d->fields.at(i).page == removedPage) { | - |
1701 | removedPage->d_func()->pendingFields += d->fields.at(i); | - |
1702 | d->removeFieldAt(i); | - |
1703 | } | - |
1704 | } | - |
1705 | } | - |
1706 | } | - |
1707 | QWizardPage *QWizard::page(int theid) const | - |
1708 | { | - |
1709 | const QWizardPrivate * const d = d_func(); | - |
1710 | return d->pageMap.value(theid); | - |
1711 | } | - |
1712 | bool QWizard::hasVisitedPage(int theid) const | - |
1713 | { | - |
1714 | const QWizardPrivate * const d = d_func(); | - |
1715 | return d->history.contains(theid); | - |
1716 | } | - |
1717 | QList<int> QWizard::visitedPages() const | - |
1718 | { | - |
1719 | const QWizardPrivate * const d = d_func(); | - |
1720 | return d->history; | - |
1721 | } | - |
1722 | | - |
1723 | | - |
1724 | | - |
1725 | | - |
1726 | | - |
1727 | QList<int> QWizard::pageIds() const | - |
1728 | { | - |
1729 | const QWizardPrivate * const d = d_func(); | - |
1730 | return d->pageMap.keys(); | - |
1731 | } | - |
1732 | void QWizard::setStartId(int theid) | - |
1733 | { | - |
1734 | QWizardPrivate * const d = d_func(); | - |
1735 | int newStart = theid; | - |
1736 | if (theid == -1TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1737 | newStart = d->pageMap.count()TRUE | never evaluated | FALSE | never evaluated |
? d->pageMap.constBegin().key() : -1;never executed: newStart = d->pageMap.count() ? d->pageMap.constBegin().key() : -1; | 0 |
1738 | | - |
1739 | if (d->start == newStartTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
1740 | d->startSetByUser = theid != -1; | - |
1741 | return; never executed: return; | 0 |
1742 | } | - |
1743 | | - |
1744 | if (!(__builtin_expect(!!(!TRUE | never evaluated | FALSE | never evaluated |
d->pageMap.contains(newStart)), false)TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
1745 | QMessageLogger(__FILE__, 24542460, __PRETTY_FUNCTION__).warning("QWizard::setStartId: Invalid page ID %d", newStart); | - |
1746 | return; never executed: return; | 0 |
1747 | } | - |
1748 | d->start = newStart; | - |
1749 | d->startSetByUser = theid != -1; | - |
1750 | } never executed: end of block | 0 |
1751 | | - |
1752 | int QWizard::startId() const | - |
1753 | { | - |
1754 | const QWizardPrivate * const d = d_func(); | - |
1755 | return d->start; | - |
1756 | } | - |
1757 | QWizardPage *QWizard::currentPage() const | - |
1758 | { | - |
1759 | const QWizardPrivate * const d = d_func(); | - |
1760 | return page(d->current); | - |
1761 | } | - |
1762 | int QWizard::currentId() const | - |
1763 | { | - |
1764 | const QWizardPrivate * const d = d_func(); | - |
1765 | return d->current; | - |
1766 | } | - |
1767 | void QWizard::setField(const QString &name, const QVariant &value) | - |
1768 | { | - |
1769 | QWizardPrivate * const d = d_func(); | - |
1770 | | - |
1771 | int index = d->fieldIndexMap.value(name, -1); | - |
1772 | if (__builtin_expect(!!(TRUE | never evaluated | FALSE | never evaluated |
index !=== -1)), false)TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
1773 | QMessageLogger(__FILE__, 2518, __PRETTY_FUNCTION__).warning("QWizard::setField: No such field '%ls'", static_cast<const wchar_t*>(static_cast<const void*>(QString(name).utf16()))); | - |
1774 | return; never executed: return; | 0 |
1775 | } | - |
1776 | | - |
1777 | const QWizardField &field = d->fields.at(index); | - |
1778 | if (!(__builtin_expect(!!(!TRUE | never evaluated | FALSE | never evaluated |
field.object->setProperty(field.property, value)), false)TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1779 | QMessageLogger(__FILE__, 25142524, __PRETTY_FUNCTION__).warning("QWizard::setField: Couldn't write to property '%s'", never executed: QMessageLogger(__FILE__, 2524, __PRETTY_FUNCTION__).warning("QWizard::setField: Couldn't write to property '%s'", field.property.constData()); | 0 |
1780 | field.property.constData()); never executed: QMessageLogger(__FILE__, 2524, __PRETTY_FUNCTION__).warning("QWizard::setField: Couldn't write to property '%s'", field.property.constData()); | 0 |
| return; never executed: QMessageLogger(__FILE__, 2524, __PRETTY_FUNCTION__).warning("QWizard::setField: Couldn't write to property '%s'", field.property.constData()); | |
| } never executed: QMessageLogger(__FILE__, 2524, __PRETTY_FUNCTION__).warning("QWizard::setField: Couldn't write to property '%s'", field.property.constData()); | |
| | |
| QMessageLogger(__FILE__, 2519, __PRETTY_FUNCTION__).warning("QWizard::setField: No such field '%s'", QString(name).toLocal8Bit(). never executed: QMessageLogger(__FILE__, 2524, __PRETTY_FUNCTION__).warning("QWizard::setField: Couldn't write to property '%s'", field.property.constData()); never executed: QMessageLogger(__FILE__, 2524, __PRETTY_FUNCTION__).warning("QWizard::setField: Couldn't write to property '%s'", field.property.constData()); constData());never executed: QMessageLogger(__FILE__, 2524, __PRETTY_FUNCTION__).warning("QWizard::setField: Couldn't write to property '%s'", field.property.constData()); | |
1781 | } never executed: end of block | 0 |
1782 | QVariant QWizard::field(const QString &name) const | - |
1783 | { | - |
1784 | const QWizardPrivate * const d = d_func(); | - |
1785 | | - |
1786 | int index = d->fieldIndexMap.value(name, -1); | - |
1787 | if (__builtin_expect(!!(TRUE | never evaluated | FALSE | never evaluated |
index !=== -1)), false)TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
1788 | const QWizardField &field = d->fields.at(index); | - |
| return field.object->property(field.property); | |
| }QMessageLogger(__FILE__, 25392541, __PRETTY_FUNCTION__).warning("QWizard::field: No such field '%s'"'%ls'", static_cast<const wchar_t*>(static_cast<const void*>(QString(name).toLocal8Bit().constData());utf16()))); | |
1789 | return never executed: return QVariant(); QVariant();never executed: return QVariant(); | 0 |
1790 | } | - |
1791 | | - |
1792 | const QWizardField &field = d->fields.at(index); | - |
1793 | return never executed: return field.object->property(field.property); field.object->property(field.property);never executed: return field.object->property(field.property); | 0 |
1794 | } | - |
1795 | void QWizard::setWizardStyle(WizardStyle style) | - |
1796 | { | - |
1797 | QWizardPrivate * const d = d_func(); | - |
1798 | | - |
1799 | const bool styleChange = style != d->wizStyle; | - |
1800 | if (styleChange | - |
1801 | | - |
1802 | | - |
1803 | | - |
1804 | ) { | - |
1805 | d->disableUpdates(); | - |
1806 | d->wizStyle = style; | - |
1807 | d->updateButtonTexts(); | - |
1808 | d->updateLayout(); | - |
1809 | updateGeometry(); | - |
1810 | d->enableUpdates(); | - |
1811 | | - |
1812 | | - |
1813 | | - |
1814 | | - |
1815 | | - |
1816 | } | - |
1817 | } | - |
1818 | | - |
1819 | QWizard::WizardStyle QWizard::wizardStyle() const | - |
1820 | { | - |
1821 | const QWizardPrivate * const d = d_func(); | - |
1822 | return d->wizStyle; | - |
1823 | } | - |
1824 | | - |
1825 | | - |
1826 | | - |
1827 | | - |
1828 | | - |
1829 | | - |
1830 | | - |
1831 | void QWizard::setOption(WizardOption option, bool on) | - |
1832 | { | - |
1833 | QWizardPrivate * const d = d_func(); | - |
1834 | if (!(d->opts & option) != !on) | - |
1835 | setOptions(d->opts ^ option); | - |
1836 | } | - |
1837 | | - |
1838 | | - |
1839 | | - |
1840 | | - |
1841 | | - |
1842 | | - |
1843 | | - |
1844 | bool QWizard::testOption(WizardOption option) const | - |
1845 | { | - |
1846 | const QWizardPrivate * const d = d_func(); | - |
1847 | return (d->opts & option) != 0; | - |
1848 | } | - |
1849 | void QWizard::setOptions(WizardOptions options) | - |
1850 | { | - |
1851 | QWizardPrivate * const d = d_func(); | - |
1852 | | - |
1853 | WizardOptions changed = (options ^ d->opts); | - |
1854 | if (!changed) | - |
1855 | return; | - |
1856 | | - |
1857 | d->disableUpdates(); | - |
1858 | | - |
1859 | d->opts = options; | - |
1860 | if ((changed & IndependentPages) && !(d->opts & IndependentPages)) | - |
1861 | d->cleanupPagesNotInHistory(); | - |
1862 | | - |
1863 | if (changed & (NoDefaultButton | HaveHelpButton | HelpButtonOnRight | NoCancelButton | - |
1864 | | CancelButtonOnLeft | HaveCustomButton1 | HaveCustomButton2 | - |
1865 | | HaveCustomButton3)) { | - |
1866 | d->updateButtonLayout(); | - |
1867 | } else if (changed & (NoBackButtonOnStartPage | NoBackButtonOnLastPage | - |
1868 | | HaveNextButtonOnLastPage | HaveFinishButtonOnEarlyPages | - |
1869 | | DisabledBackButtonOnLastPage | NoCancelButtonOnLastPage)) { | - |
1870 | d->_q_updateButtonStates(); | - |
1871 | } | - |
1872 | | - |
1873 | d->enableUpdates(); | - |
1874 | d->updateLayout(); | - |
1875 | } | - |
1876 | | - |
1877 | QWizard::WizardOptions QWizard::options() const | - |
1878 | { | - |
1879 | const QWizardPrivate * const d = d_func(); | - |
1880 | return d->opts; | - |
1881 | } | - |
1882 | void QWizard::setButtonText(WizardButton which, const QString &text) | - |
1883 | { | - |
1884 | QWizardPrivate * const d = d_func(); | - |
1885 | | - |
1886 | if (!d->ensureButton(which)) | - |
1887 | return; | - |
1888 | | - |
1889 | d->buttonCustomTexts.insert(which, text); | - |
1890 | | - |
1891 | if (!currentPage() || !currentPage()->d_func()->buttonCustomTexts.contains(which)) | - |
1892 | d->btns[which]->setText(text); | - |
1893 | } | - |
1894 | QString QWizard::buttonText(WizardButton which) const | - |
1895 | { | - |
1896 | const QWizardPrivate * const d = d_func(); | - |
1897 | | - |
1898 | if (!d->ensureButton(which)) | - |
1899 | return QString(); | - |
1900 | | - |
1901 | if (d->buttonCustomTexts.contains(which)) | - |
1902 | return d->buttonCustomTexts.value(which); | - |
1903 | | - |
1904 | const QString defText = buttonDefaultText(d->wizStyle, which, d); | - |
1905 | if(!defText.isNull()) | - |
1906 | return defText; | - |
1907 | | - |
1908 | return d->btns[which]->text(); | - |
1909 | } | - |
1910 | void QWizard::setButtonLayout(const QList<WizardButton> &layout) | - |
1911 | { | - |
1912 | QWizardPrivate * const d = d_func(); | - |
1913 | | - |
1914 | for (int i = 0; i < layout.count()TRUE | never evaluated | FALSE | never evaluated |
; ++i) { | 0 |
1915 | WizardButton button1 = layout.at(i); | - |
1916 | | - |
1917 | if (button1 == NoButtonTRUE | never evaluated | FALSE | never evaluated |
|| button1 == StretchTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1918 | continue; never executed: continue; | 0 |
1919 | if (!d->ensureButton(button1)TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1920 | return; never executed: return; | 0 |
1921 | | - |
1922 | | - |
1923 | for (int j = 0; j < iTRUE | never evaluated | FALSE | never evaluated |
; ++j) { | 0 |
1924 | WizardButton button2 = layout.at(j); | - |
1925 | if (__builtin_expect(!!(TRUE | never evaluated | FALSE | never evaluated |
button2 == button1)), false)TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
1926 | QMessageLogger(__FILE__, 27672773, __PRETTY_FUNCTION__).warning("QWizard::setButtonLayout: Duplicate button in layout"); | - |
1927 | return; never executed: return; | 0 |
1928 | } | - |
1929 | } never executed: end of block | 0 |
1930 | } never executed: end of block | 0 |
1931 | | - |
1932 | d->buttonsHaveCustomLayout = true; | - |
1933 | d->buttonsCustomLayout = layout; | - |
1934 | d->updateButtonLayout(); | - |
1935 | } never executed: end of block | 0 |
1936 | void QWizard::setButton(WizardButton which, QAbstractButton *button) | - |
1937 | { | - |
1938 | QWizardPrivate * const d = d_func(); | - |
1939 | | - |
1940 | if (uint(which) >= NButtons || d->btns[which] == button) | - |
1941 | return; | - |
1942 | | - |
1943 | if (QAbstractButton *oldButton = d->btns[which]) { | - |
1944 | d->buttonLayout->removeWidget(oldButton); | - |
1945 | delete oldButton; | - |
1946 | } | - |
1947 | | - |
1948 | d->btns[which] = button; | - |
1949 | if (button) { | - |
1950 | button->setParent(d->antiFlickerWidget); | - |
1951 | d->buttonCustomTexts.insert(which, button->text()); | - |
1952 | d->connectButton(which); | - |
1953 | } else { | - |
1954 | d->buttonCustomTexts.remove(which); | - |
1955 | d->ensureButton(which); | - |
1956 | } | - |
1957 | | - |
1958 | d->updateButtonLayout(); | - |
1959 | } | - |
1960 | | - |
1961 | | - |
1962 | | - |
1963 | | - |
1964 | | - |
1965 | | - |
1966 | QAbstractButton *QWizard::button(WizardButton which) const | - |
1967 | { | - |
1968 | const QWizardPrivate * const d = d_func(); | - |
1969 | | - |
1970 | | - |
1971 | | - |
1972 | | - |
1973 | if (!d->ensureButton(which)) | - |
1974 | return 0; | - |
1975 | return d->btns[which]; | - |
1976 | } | - |
1977 | void QWizard::setTitleFormat(Qt::TextFormat format) | - |
1978 | { | - |
1979 | QWizardPrivate * const d = d_func(); | - |
1980 | d->titleFmt = format; | - |
1981 | d->updateLayout(); | - |
1982 | } | - |
1983 | | - |
1984 | Qt::TextFormat QWizard::titleFormat() const | - |
1985 | { | - |
1986 | const QWizardPrivate * const d = d_func(); | - |
1987 | return d->titleFmt; | - |
1988 | } | - |
1989 | void QWizard::setSubTitleFormat(Qt::TextFormat format) | - |
1990 | { | - |
1991 | QWizardPrivate * const d = d_func(); | - |
1992 | d->subTitleFmt = format; | - |
1993 | d->updateLayout(); | - |
1994 | } | - |
1995 | | - |
1996 | Qt::TextFormat QWizard::subTitleFormat() const | - |
1997 | { | - |
1998 | const QWizardPrivate * const d = d_func(); | - |
1999 | return d->subTitleFmt; | - |
2000 | } | - |
2001 | void QWizard::setPixmap(WizardPixmap which, const QPixmap &pixmap) | - |
2002 | { | - |
2003 | QWizardPrivate * const d = d_func(); | - |
2004 | ((!(uint(which) < NPixmaps)) ? qt_assert("uint(which) < NPixmaps",__FILE__,28872893) : qt_noop()); | - |
2005 | d->defaultPixmaps[which] = pixmap; | - |
2006 | d->updatePixmap(which); | - |
2007 | } | - |
2008 | QPixmap QWizard::pixmap(WizardPixmap which) const | - |
2009 | { | - |
2010 | const QWizardPrivate * const d = d_func(); | - |
2011 | ((!(uint(which) < NPixmaps)) ? qt_assert("uint(which) < NPixmaps",__FILE__,29032909) : qt_noop()); | - |
2012 | | - |
2013 | | - |
2014 | | - |
2015 | | - |
2016 | return d->defaultPixmaps[which]; | - |
2017 | } | - |
2018 | void QWizard::setDefaultProperty(const char *className, const char *property, | - |
2019 | const char *changedSignal) | - |
2020 | { | - |
2021 | QWizardPrivate * const d = d_func(); | - |
2022 | for (int i = d->defaultPropertyTable.count() - 1; i >= 0; --i) { | - |
2023 | if (qstrcmp(d->defaultPropertyTable.at(i).className, className) == 0) { | - |
2024 | d->defaultPropertyTable.remove(i); | - |
2025 | break; | - |
2026 | } | - |
2027 | } | - |
2028 | d->defaultPropertyTable.append(QWizardDefaultProperty(className, property, changedSignal)); | - |
2029 | } | - |
2030 | void QWizard::setSideWidget(QWidget *widget) | - |
2031 | { | - |
2032 | QWizardPrivate * const d = d_func(); | - |
2033 | | - |
2034 | d->sideWidget = widget; | - |
2035 | if (d->watermarkLabel) { | - |
2036 | d->watermarkLabel->setSideWidget(widget); | - |
2037 | d->updateLayout(); | - |
2038 | } | - |
2039 | } | - |
2040 | QWidget *QWizard::sideWidget() const | - |
2041 | { | - |
2042 | const QWizardPrivate * const d = d_func(); | - |
2043 | | - |
2044 | return d->sideWidget; | - |
2045 | } | - |
2046 | | - |
2047 | | - |
2048 | | - |
2049 | | - |
2050 | void QWizard::setVisible(bool visible) | - |
2051 | { | - |
2052 | QWizardPrivate * const d = d_func(); | - |
2053 | if (visible) { | - |
2054 | if (d->current == -1) | - |
2055 | restart(); | - |
2056 | } | - |
2057 | QDialog::setVisible(visible); | - |
2058 | } | - |
2059 | | - |
2060 | | - |
2061 | | - |
2062 | | - |
2063 | QSize QWizard::sizeHint() const | - |
2064 | { | - |
2065 | const QWizardPrivate * const d = d_func(); | - |
2066 | QSize result = d->mainLayout->totalSizeHint(); | - |
2067 | QSize extra(500, 360); | - |
2068 | if (d->wizStyle == MacStyle && d->current != -1) { | - |
2069 | QSize pixmap(currentPage()->pixmap(BackgroundPixmap).size()); | - |
2070 | extra.setWidth(616); | - |
2071 | if (!pixmap.isNull()) { | - |
2072 | extra.setHeight(pixmap.height()); | - |
2073 | | - |
2074 | | - |
2075 | | - |
2076 | | - |
2077 | | - |
2078 | | - |
2079 | | - |
2080 | if (pixmap.width() >= pixmap.height()) | - |
2081 | extra.setWidth(pixmap.width()); | - |
2082 | } | - |
2083 | } | - |
2084 | return result.expandedTo(extra); | - |
2085 | } | - |
2086 | void QWizard::back() | - |
2087 | { | - |
2088 | QWizardPrivate * const d = d_func(); | - |
2089 | int n = d->history.count() - 2; | - |
2090 | if (n < 0) | - |
2091 | return; | - |
2092 | d->switchToPage(d->history.at(n), QWizardPrivate::Backward); | - |
2093 | } | - |
2094 | void QWizard::next() | - |
2095 | { | - |
2096 | QWizardPrivate * const d = d_func(); | - |
2097 | | - |
2098 | if (d->current == -1TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
2099 | return; never executed: return; | 0 |
2100 | | - |
2101 | if (validateCurrentPage()TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
2102 | int next = nextId(); | - |
2103 | if (next != -1TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
2104 | if (__builtin_expect(!!(TRUE | never evaluated | FALSE | never evaluated |
d->history.contains(next)), false)TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
2105 | QMessageLogger(__FILE__, 31443150, __PRETTY_FUNCTION__).warning("QWizard::next: Page %d already met", next); | - |
2106 | return; never executed: return; | 0 |
2107 | } | - |
2108 | if (!(__builtin_expect(!!(!TRUE | never evaluated | FALSE | never evaluated |
d->pageMap.contains(next)), false)TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
2109 | QMessageLogger(__FILE__, 31483154, __PRETTY_FUNCTION__).warning("QWizard::next: No such page %d", next); | - |
2110 | return; never executed: return; | 0 |
2111 | } | - |
2112 | d->switchToPage(next, QWizardPrivate::Forward); | - |
2113 | } never executed: end of block | 0 |
2114 | } never executed: end of block | 0 |
2115 | } never executed: end of block | 0 |
2116 | | - |
2117 | | - |
2118 | | - |
2119 | | - |
2120 | | - |
2121 | | - |
2122 | | - |
2123 | void QWizard::restart() | - |
2124 | { | - |
2125 | QWizardPrivate * const d = d_func(); | - |
2126 | d->disableUpdates(); | - |
2127 | d->reset(); | - |
2128 | d->switchToPage(startId(), QWizardPrivate::Forward); | - |
2129 | d->enableUpdates(); | - |
2130 | } | - |
2131 | | - |
2132 | | - |
2133 | | - |
2134 | | - |
2135 | bool QWizard::event(QEvent *event) | - |
2136 | { | - |
2137 | QWizardPrivate * const d = d_func(); | - |
2138 | if (event->type() == QEvent::StyleChange) { | - |
2139 | d->setStyle(style()); | - |
2140 | d->updateLayout(); | - |
2141 | } | - |
2142 | return QDialog::event(event); | - |
2143 | } | - |
2144 | | - |
2145 | | - |
2146 | | - |
2147 | | - |
2148 | void QWizard::resizeEvent(QResizeEvent *event) | - |
2149 | { | - |
2150 | QWizardPrivate * const d = d_func(); | - |
2151 | int heightOffset = 0; | - |
2152 | | - |
2153 | | - |
2154 | | - |
2155 | | - |
2156 | | - |
2157 | | - |
2158 | | - |
2159 | d->antiFlickerWidget->resize(event->size().width(), event->size().height() - heightOffset); | - |
2160 | | - |
2161 | | - |
2162 | | - |
2163 | | - |
2164 | QDialog::resizeEvent(event); | - |
2165 | } | - |
2166 | | - |
2167 | | - |
2168 | | - |
2169 | | - |
2170 | void QWizard::paintEvent(QPaintEvent * event) | - |
2171 | { | - |
2172 | QWizardPrivate * const d = d_func(); | - |
2173 | if (d->wizStyle == MacStyle && currentPage()) { | - |
2174 | QPixmap backgroundPixmap = currentPage()->pixmap(BackgroundPixmap); | - |
2175 | if (backgroundPixmap.isNull()) | - |
2176 | return; | - |
2177 | | - |
2178 | QPainter painter(this); | - |
2179 | painter.drawPixmap(0, (height() - backgroundPixmap.height()) / 2, backgroundPixmap); | - |
2180 | } | - |
2181 | (void)event;; | - |
2182 | | - |
2183 | } | - |
2184 | void QWizard::done(int result) | - |
2185 | { | - |
2186 | QWizardPrivate * const d = d_func(); | - |
2187 | | - |
2188 | if (result == Rejected) { | - |
2189 | d->reset(); | - |
2190 | } else { | - |
2191 | if (!validateCurrentPage()) | - |
2192 | return; | - |
2193 | } | - |
2194 | QDialog::done(result); | - |
2195 | } | - |
2196 | void QWizard::initializePage(int theid) | - |
2197 | { | - |
2198 | QWizardPage *page = this->page(theid); | - |
2199 | if (page) | - |
2200 | page->initializePage(); | - |
2201 | } | - |
2202 | void QWizard::cleanupPage(int theid) | - |
2203 | { | - |
2204 | QWizardPage *page = this->page(theid); | - |
2205 | if (page) | - |
2206 | page->cleanupPage(); | - |
2207 | } | - |
2208 | bool QWizard::validateCurrentPage() | - |
2209 | { | - |
2210 | QWizardPage *page = currentPage(); | - |
2211 | if (!page) | - |
2212 | return true; | - |
2213 | | - |
2214 | return page->validatePage(); | - |
2215 | } | - |
2216 | int QWizard::nextId() const | - |
2217 | { | - |
2218 | const QWizardPage *page = currentPage(); | - |
2219 | if (!page) | - |
2220 | return -1; | - |
2221 | | - |
2222 | return page->nextId(); | - |
2223 | } | - |
2224 | QWizardPage::QWizardPage(QWidget *parent) | - |
2225 | : QWidget(*new QWizardPagePrivate, parent, 0) | - |
2226 | { | - |
2227 | connect(this, qFlagLocation("2""completeChanged()" "\0" __FILE__ ":" "3472""3478"), this, qFlagLocation("1""_q_updateCachedCompleteState()" "\0" __FILE__ ":" "3472""3478")); | - |
2228 | } | - |
2229 | | - |
2230 | | - |
2231 | | - |
2232 | | - |
2233 | QWizardPage::~QWizardPage() | - |
2234 | { | - |
2235 | } | - |
2236 | void QWizardPage::setTitle(const QString &title) | - |
2237 | { | - |
2238 | QWizardPagePrivate * const d = d_func(); | - |
2239 | d->title = title; | - |
2240 | if (d->wizard && d->wizard->currentPage() == this) | - |
2241 | d->wizard->d_func()->updateLayout(); | - |
2242 | } | - |
2243 | | - |
2244 | QString QWizardPage::title() const | - |
2245 | { | - |
2246 | const QWizardPagePrivate * const d = d_func(); | - |
2247 | return d->title; | - |
2248 | } | - |
2249 | void QWizardPage::setSubTitle(const QString &subTitle) | - |
2250 | { | - |
2251 | QWizardPagePrivate * const d = d_func(); | - |
2252 | d->subTitle = subTitle; | - |
2253 | if (d->wizard && d->wizard->currentPage() == this) | - |
2254 | d->wizard->d_func()->updateLayout(); | - |
2255 | } | - |
2256 | | - |
2257 | QString QWizardPage::subTitle() const | - |
2258 | { | - |
2259 | const QWizardPagePrivate * const d = d_func(); | - |
2260 | return d->subTitle; | - |
2261 | } | - |
2262 | void QWizardPage::setPixmap(QWizard::WizardPixmap which, const QPixmap &pixmap) | - |
2263 | { | - |
2264 | QWizardPagePrivate * const d = d_func(); | - |
2265 | ((!(uint(which) < QWizard::NPixmaps)) ? qt_assert("uint(which) < QWizard::NPixmaps",__FILE__,35593565) : qt_noop()); | - |
2266 | d->pixmaps[which] = pixmap; | - |
2267 | if (d->wizard && d->wizard->currentPage() == this) | - |
2268 | d->wizard->d_func()->updatePixmap(which); | - |
2269 | } | - |
2270 | QPixmap QWizardPage::pixmap(QWizard::WizardPixmap which) const | - |
2271 | { | - |
2272 | const QWizardPagePrivate * const d = d_func(); | - |
2273 | ((!(uint(which) < QWizard::NPixmaps)) ? qt_assert("uint(which) < QWizard::NPixmaps",__FILE__,35773583) : qt_noop()); | - |
2274 | | - |
2275 | const QPixmap &pixmap = d->pixmaps[which]; | - |
2276 | if (!pixmap.isNull()) | - |
2277 | return pixmap; | - |
2278 | | - |
2279 | if (wizard()) | - |
2280 | return wizard()->pixmap(which); | - |
2281 | | - |
2282 | return pixmap; | - |
2283 | } | - |
2284 | void QWizardPage::initializePage() | - |
2285 | { | - |
2286 | } | - |
2287 | void QWizardPage::cleanupPage() | - |
2288 | { | - |
2289 | QWizardPagePrivate * const d = d_func(); | - |
2290 | if (d->wizardTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
2291 | const QVector<QWizardField> &fields = d->wizard->d_func()->fields; | - |
2292 | for (int i = 0; i < fields.count(); ++i) {const QWizardFieldauto &field =: fields.at(i);) { | - |
2293 | if (field.page == thisTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
2294 | field.object->setProperty(field.property, field.initialValue); never executed: field.object->setProperty(field.property, field.initialValue); | 0 |
2295 | } never executed: end of block | 0 |
2296 | } never executed: end of block | 0 |
2297 | } never executed: end of block | 0 |
2298 | bool QWizardPage::validatePage() | - |
2299 | { | - |
2300 | return true; | - |
2301 | } | - |
2302 | bool QWizardPage::isComplete() const | - |
2303 | { | - |
2304 | const QWizardPagePrivate * const d = d_func(); | - |
2305 | | - |
2306 | if (!d->wizard) | - |
2307 | return true; | - |
2308 | | - |
2309 | const QVector<QWizardField> &wizardFields = d->wizard->d_func()->fields; | - |
2310 | for (int i = wizardFields.count() - 1; i >= 0; --i) { | - |
2311 | const QWizardField &field = wizardFields.at(i); | - |
2312 | if (field.page == this && field.mandatory) { | - |
2313 | QVariant value = field.object->property(field.property); | - |
2314 | if (value == field.initialValue) | - |
2315 | return false; | - |
2316 | | - |
2317 | | - |
2318 | if (QLineEdit *lineEdit = qobject_cast<QLineEdit *>(field.object)) { | - |
2319 | if (!lineEdit->hasAcceptableInput()) | - |
2320 | return false; | - |
2321 | } | - |
2322 | | - |
2323 | | - |
2324 | if (QAbstractSpinBox *spinBox = qobject_cast<QAbstractSpinBox *>(field.object)) { | - |
2325 | if (!spinBox->hasAcceptableInput()) | - |
2326 | return false; | - |
2327 | } | - |
2328 | | - |
2329 | } | - |
2330 | } | - |
2331 | return true; | - |
2332 | } | - |
2333 | void QWizardPage::setFinalPage(bool finalPage) | - |
2334 | { | - |
2335 | QWizardPagePrivate * const d = d_func(); | - |
2336 | d->explicitlyFinal = finalPage; | - |
2337 | QWizard *wizard = this->wizard(); | - |
2338 | if (wizard && wizard->currentPage() == this) | - |
2339 | wizard->d_func()->updateCurrentPage(); | - |
2340 | } | - |
2341 | bool QWizardPage::isFinalPage() const | - |
2342 | { | - |
2343 | const QWizardPagePrivate * const d = d_func(); | - |
2344 | if (d->explicitlyFinal) | - |
2345 | return true; | - |
2346 | | - |
2347 | QWizard *wizard = this->wizard(); | - |
2348 | if (wizard && wizard->currentPage() == this) { | - |
2349 | | - |
2350 | return wizard->nextId() == -1; | - |
2351 | } else { | - |
2352 | return nextId() == -1; | - |
2353 | } | - |
2354 | } | - |
2355 | void QWizardPage::setCommitPage(bool commitPage) | - |
2356 | { | - |
2357 | QWizardPagePrivate * const d = d_func(); | - |
2358 | d->commit = commitPage; | - |
2359 | QWizard *wizard = this->wizard(); | - |
2360 | if (wizard && wizard->currentPage() == this) | - |
2361 | wizard->d_func()->updateCurrentPage(); | - |
2362 | } | - |
2363 | | - |
2364 | | - |
2365 | | - |
2366 | | - |
2367 | | - |
2368 | | - |
2369 | bool QWizardPage::isCommitPage() const | - |
2370 | { | - |
2371 | const QWizardPagePrivate * const d = d_func(); | - |
2372 | return d->commit; | - |
2373 | } | - |
2374 | void QWizardPage::setButtonText(QWizard::WizardButton which, const QString &text) | - |
2375 | { | - |
2376 | QWizardPagePrivate * const d = d_func(); | - |
2377 | d->buttonCustomTexts.insert(which, text); | - |
2378 | if (wizard() && wizard()->currentPage() == this && wizard()->d_func()->btns[which]) | - |
2379 | wizard()->d_func()->btns[which]->setText(text); | - |
2380 | } | - |
2381 | QString QWizardPage::buttonText(QWizard::WizardButton which) const | - |
2382 | { | - |
2383 | const QWizardPagePrivate * const d = d_func(); | - |
2384 | | - |
2385 | if (d->buttonCustomTexts.contains(which)) | - |
2386 | return d->buttonCustomTexts.value(which); | - |
2387 | | - |
2388 | if (wizard()) | - |
2389 | return wizard()->buttonText(which); | - |
2390 | | - |
2391 | return QString(); | - |
2392 | } | - |
2393 | int QWizardPage::nextId() const | - |
2394 | { | - |
2395 | const QWizardPagePrivate * const d = d_func(); | - |
2396 | | - |
2397 | if (!d->wizard) | - |
2398 | return -1; | - |
2399 | | - |
2400 | bool foundCurrentPage = false; | - |
2401 | | - |
2402 | const QWizardPrivate::PageMap &pageMap = d->wizard->d_func()->pageMap; | - |
2403 | QWizardPrivate::PageMap::const_iterator i = pageMap.constBegin(); | - |
2404 | QWizardPrivate::PageMap::const_iterator end = pageMap.constEnd(); | - |
2405 | | - |
2406 | for (; i != end; ++i) { | - |
2407 | if (i.value() == this) { | - |
2408 | foundCurrentPage = true; | - |
2409 | } else if (foundCurrentPage) { | - |
2410 | return i.key(); | - |
2411 | } | - |
2412 | } | - |
2413 | return -1; | - |
2414 | } | - |
2415 | void QWizardPage::setField(const QString &name, const QVariant &value) | - |
2416 | { | - |
2417 | QWizardPagePrivate * const d = d_func(); | - |
2418 | if (!d->wizard) | - |
2419 | return; | - |
2420 | d->wizard->setField(name, value); | - |
2421 | } | - |
2422 | QVariant QWizardPage::field(const QString &name) const | - |
2423 | { | - |
2424 | const QWizardPagePrivate * const d = d_func(); | - |
2425 | if (!d->wizard) | - |
2426 | return QVariant(); | - |
2427 | return d->wizard->field(name); | - |
2428 | } | - |
2429 | void QWizardPage::registerField(const QString &name, QWidget *widget, const char *property, | - |
2430 | const char *changedSignal) | - |
2431 | { | - |
2432 | QWizardPagePrivate * const d = d_func(); | - |
2433 | QWizardField field(this, name, widget, property, changedSignal); | - |
2434 | if (d->wizard) { | - |
2435 | d->wizard->d_func()->addField(field); | - |
2436 | } else { | - |
2437 | d->pendingFields += field; | - |
2438 | } | - |
2439 | } | - |
2440 | | - |
2441 | | - |
2442 | | - |
2443 | | - |
2444 | | - |
2445 | | - |
2446 | | - |
2447 | QWizard *QWizardPage::wizard() const | - |
2448 | { | - |
2449 | const QWizardPagePrivate * const d = d_func(); | - |
2450 | return d->wizard; | - |
2451 | } | - |
2452 | | - |
2453 | | - |
2454 | | - |
| | |