diff options
Diffstat (limited to 'src/widgets/dialogs/qwizard.cpp')
-rw-r--r-- | src/widgets/dialogs/qwizard.cpp | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/src/widgets/dialogs/qwizard.cpp b/src/widgets/dialogs/qwizard.cpp index a4ea7ae8de..890069ca1a 100644 --- a/src/widgets/dialogs/qwizard.cpp +++ b/src/widgets/dialogs/qwizard.cpp @@ -48,6 +48,7 @@ #include "qboxlayout.h" #include "qlayoutitem.h" #include "qdesktopwidget.h" +#include <private/qdesktopwidget_p.h> #include "qevent.h" #include "qframe.h" #include "qlabel.h" @@ -400,7 +401,7 @@ void QWizardHeader::setup(const QWizardLayoutInfo &info, const QString &title, /* There is no widthForHeight() function, so we simulate it with a loop. */ - int candidateSubTitleWidth = qMin(512, 2 * QApplication::desktop()->width() / 3); + int candidateSubTitleWidth = qMin(512, 2 * QDesktopWidgetPrivate::width() / 3); int delta = candidateSubTitleWidth >> 1; while (delta > 0) { if (subTitleLabel->heightForWidth(candidateSubTitleWidth - delta) @@ -500,6 +501,7 @@ public: mutable TriState completeState; bool explicitlyFinal; bool commit; + bool initialized = false; QMap<int, QString> buttonCustomTexts; }; @@ -635,7 +637,6 @@ public: QMap<QString, int> fieldIndexMap; QVector<QWizardDefaultProperty> defaultPropertyTable; QList<int> history; - QSet<int> initialized; // ### remove and move bit to QWizardPage? int start; bool startSetByUser; int current; @@ -774,7 +775,8 @@ void QWizardPrivate::reset() for (int i = history.count() - 1; i >= 0; --i) q->cleanupPage(history.at(i)); history.clear(); - initialized.clear(); + for (QWizardPage *page : pageMap) + page->d_func()->initialized = false; current = -1; emit q->currentIdChanged(-1); @@ -785,14 +787,12 @@ void QWizardPrivate::cleanupPagesNotInHistory() { Q_Q(QWizard); - const QSet<int> original = initialized; - QSet<int>::const_iterator i = original.constBegin(); - QSet<int>::const_iterator end = original.constEnd(); - - for (; i != end; ++i) { - if (!history.contains(*i)) { - q->cleanupPage(*i); - initialized.remove(*i); + for (auto it = pageMap.begin(), end = pageMap.end(); it != end; ++it) { + const auto idx = it.key(); + const auto page = it.value()->d_func(); + if (page->initialized && !history.contains(idx)) { + q->cleanupPage(idx); + page->initialized = false; } } } @@ -847,7 +847,7 @@ void QWizardPrivate::switchToPage(int newId, Direction direction) if (direction == Backward) { if (!(opts & QWizard::IndependentPages)) { q->cleanupPage(oldId); - initialized.remove(oldId); + oldPage->d_func()->initialized = false; } Q_ASSERT(history.constLast() == oldId); history.removeLast(); @@ -860,8 +860,8 @@ void QWizardPrivate::switchToPage(int newId, Direction direction) QWizardPage *newPage = q->currentPage(); if (newPage) { if (direction == Forward) { - if (!initialized.contains(current)) { - initialized.insert(current); + if (!newPage->d_func()->initialized) { + newPage->d_func()->initialized = true; q->initializePage(current); } history.append(current); @@ -2361,9 +2361,9 @@ void QWizard::removePage(int id) } if (removedPage) { - if (d->initialized.contains(id)) { + if (removedPage->d_func()->initialized) { cleanupPage(id); - d->initialized.remove(id); + removedPage->d_func()->initialized = false; } d->pageVBoxLayout->removeWidget(removedPage); |