summaryrefslogtreecommitdiffstats
path: root/src/widgets/dialogs/qwizard.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets/dialogs/qwizard.cpp')
-rw-r--r--src/widgets/dialogs/qwizard.cpp83
1 files changed, 44 insertions, 39 deletions
diff --git a/src/widgets/dialogs/qwizard.cpp b/src/widgets/dialogs/qwizard.cpp
index b9906f13da..53f947354c 100644
--- a/src/widgets/dialogs/qwizard.cpp
+++ b/src/widgets/dialogs/qwizard.cpp
@@ -1,31 +1,37 @@
/****************************************************************************
**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtWidgets module of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL21$
+** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
@@ -799,8 +805,8 @@ void QWizardPrivate::addField(const QWizardField &field)
QWizardField myField = field;
myField.resolve(defaultPropertyTable);
- if (fieldIndexMap.contains(myField.name)) {
- qWarning("QWizardPage::addField: Duplicate field '%s'", qPrintable(myField.name));
+ if (Q_UNLIKELY(fieldIndexMap.contains(myField.name))) {
+ qWarning("QWizardPage::addField: Duplicate field '%ls'", qUtf16Printable(myField.name));
return;
}
@@ -844,9 +850,9 @@ void QWizardPrivate::switchToPage(int newId, Direction direction)
q->cleanupPage(oldId);
initialized.remove(oldId);
}
- Q_ASSERT(history.last() == oldId);
+ Q_ASSERT(history.constLast() == oldId);
history.removeLast();
- Q_ASSERT(history.last() == newId);
+ Q_ASSERT(history.constLast() == newId);
}
}
@@ -2256,17 +2262,17 @@ void QWizard::setPage(int theid, QWizardPage *page)
{
Q_D(QWizard);
- if (!page) {
+ if (Q_UNLIKELY(!page)) {
qWarning("QWizard::setPage: Cannot insert null page");
return;
}
- if (theid == -1) {
+ if (Q_UNLIKELY(theid == -1)) {
qWarning("QWizard::setPage: Cannot insert page with ID -1");
return;
}
- if (d->pageMap.contains(theid)) {
+ if (Q_UNLIKELY(d->pageMap.contains(theid))) {
qWarning("QWizard::setPage: Page with duplicate ID %d ignored", theid);
return;
}
@@ -2450,7 +2456,7 @@ void QWizard::setStartId(int theid)
return;
}
- if (!d->pageMap.contains(newStart)) {
+ if (Q_UNLIKELY(!d->pageMap.contains(newStart))) {
qWarning("QWizard::setStartId: Invalid page ID %d", newStart);
return;
}
@@ -2508,15 +2514,15 @@ void QWizard::setField(const QString &name, const QVariant &value)
Q_D(QWizard);
int index = d->fieldIndexMap.value(name, -1);
- if (index != -1) {
- const QWizardField &field = d->fields.at(index);
- if (!field.object->setProperty(field.property, value))
- qWarning("QWizard::setField: Couldn't write to property '%s'",
- field.property.constData());
+ if (Q_UNLIKELY(index == -1)) {
+ qWarning("QWizard::setField: No such field '%ls'", qUtf16Printable(name));
return;
}
- qWarning("QWizard::setField: No such field '%s'", qPrintable(name));
+ const QWizardField &field = d->fields.at(index);
+ if (Q_UNLIKELY(!field.object->setProperty(field.property, value)))
+ qWarning("QWizard::setField: Couldn't write to property '%s'",
+ field.property.constData());
}
/*!
@@ -2531,13 +2537,13 @@ QVariant QWizard::field(const QString &name) const
Q_D(const QWizard);
int index = d->fieldIndexMap.value(name, -1);
- if (index != -1) {
- const QWizardField &field = d->fields.at(index);
- return field.object->property(field.property);
+ if (Q_UNLIKELY(index == -1)) {
+ qWarning("QWizard::field: No such field '%ls'", qUtf16Printable(name));
+ return QVariant();
}
- qWarning("QWizard::field: No such field '%s'", qPrintable(name));
- return QVariant();
+ const QWizardField &field = d->fields.at(index);
+ return field.object->property(field.property);
}
/*!
@@ -2763,7 +2769,7 @@ void QWizard::setButtonLayout(const QList<WizardButton> &layout)
// O(n^2), but n is very small
for (int j = 0; j < i; ++j) {
WizardButton button2 = layout.at(j);
- if (button2 == button1) {
+ if (Q_UNLIKELY(button2 == button1)) {
qWarning("QWizard::setButtonLayout: Duplicate button in layout");
return;
}
@@ -3140,11 +3146,11 @@ void QWizard::next()
if (validateCurrentPage()) {
int next = nextId();
if (next != -1) {
- if (d->history.contains(next)) {
+ if (Q_UNLIKELY(d->history.contains(next))) {
qWarning("QWizard::next: Page %d already met", next);
return;
}
- if (!d->pageMap.contains(next)) {
+ if (Q_UNLIKELY(!d->pageMap.contains(next))) {
qWarning("QWizard::next: No such page %d", next);
return;
}
@@ -3622,9 +3628,8 @@ void QWizardPage::cleanupPage()
{
Q_D(QWizardPage);
if (d->wizard) {
- QVector<QWizardField> &fields = d->wizard->d_func()->fields;
- for (int i = 0; i < fields.count(); ++i) {
- const QWizardField &field = fields.at(i);
+ const QVector<QWizardField> &fields = d->wizard->d_func()->fields;
+ for (const auto &field : fields) {
if (field.page == this)
field.object->setProperty(field.property, field.initialValue);
}