summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJarek Kobus <jkobus@trolltech.com>2010-03-19 16:32:58 (GMT)
committerJarek Kobus <jkobus@trolltech.com>2010-03-19 16:40:20 (GMT)
commit935240ce8a06a67cab4ed15311f4c89ca8d17b77 (patch)
tree9559475489f4625cd8fcb430ef9263e592b6e0df
parent1d506981bcc3d2b8aad67989fd7946a0ad826856 (diff)
downloadQt-935240ce8a06a67cab4ed15311f4c89ca8d17b77.zip
Qt-935240ce8a06a67cab4ed15311f4c89ca8d17b77.tar.gz
Qt-935240ce8a06a67cab4ed15311f4c89ca8d17b77.tar.bz2
Add 2 signals, introduce side widget, make it possible to reset startId
Add pageAdded() and pageRemoved() signals. QWizard is now able to show the side widget (on the left). In Creator it will be used to implement steps pane (progress list). Passing -1 to setStartId resets id if it was set explicitly.
-rw-r--r--src/gui/dialogs/qwizard.cpp205
-rw-r--r--src/gui/dialogs/qwizard.h5
-rw-r--r--tests/auto/qwizard/tst_qwizard.cpp97
3 files changed, 279 insertions, 28 deletions
diff --git a/src/gui/dialogs/qwizard.cpp b/src/gui/dialogs/qwizard.cpp
index a58057d..8607529 100644
--- a/src/gui/dialogs/qwizard.cpp
+++ b/src/gui/dialogs/qwizard.cpp
@@ -218,8 +218,8 @@ public:
: topLevelMarginLeft(-1), topLevelMarginRight(-1), topLevelMarginTop(-1),
topLevelMarginBottom(-1), childMarginLeft(-1), childMarginRight(-1),
childMarginTop(-1), childMarginBottom(-1), hspacing(-1), vspacing(-1),
- wizStyle(QWizard::ClassicStyle), header(false), watermark(false), title(false),
- subTitle(false), extension(false) {}
+ wizStyle(QWizard::ClassicStyle), header(false), watermark(false), title(false),
+ subTitle(false), extension(false), sideWidget(false) {}
int topLevelMarginLeft;
int topLevelMarginRight;
@@ -238,6 +238,7 @@ public:
bool title;
bool subTitle;
bool extension;
+ bool sideWidget;
bool operator==(const QWizardLayoutInfo &other);
inline bool operator!=(const QWizardLayoutInfo &other) { return !operator==(other); }
@@ -261,7 +262,8 @@ bool QWizardLayoutInfo::operator==(const QWizardLayoutInfo &other)
&& watermark == other.watermark
&& title == other.title
&& subTitle == other.subTitle
- && extension == other.extension;
+ && extension == other.extension
+ && sideWidget == other.sideWidget;
}
class QWizardHeader : public QWidget
@@ -425,6 +427,40 @@ public:
: QWizardHeader(Ruler, parent) {}
};
+class QWatermarkLabel : public QLabel
+{
+public:
+ QWatermarkLabel(QWidget *parent, QWidget *sideWidget) : QLabel(parent), m_sideWidget(sideWidget) {
+ m_layout = new QVBoxLayout(this);
+ if (m_sideWidget)
+ m_layout->addWidget(m_sideWidget);
+ }
+
+ QSize minimumSizeHint() const {
+ if (!pixmap() && !pixmap()->isNull())
+ return pixmap()->size();
+ return QFrame::minimumSizeHint();
+ }
+
+ void setSideWidget(QWidget *widget) {
+ if (m_sideWidget == widget)
+ return;
+ if (m_sideWidget) {
+ m_layout->removeWidget(m_sideWidget);
+ m_sideWidget->hide();
+ }
+ m_sideWidget = widget;
+ if (m_sideWidget)
+ m_layout->addWidget(m_sideWidget);
+ }
+ QWidget *sideWidget() const {
+ return m_sideWidget;
+ }
+private:
+ QVBoxLayout *m_layout;
+ QWidget *m_sideWidget;
+};
+
class QWizardPagePrivate : public QWidgetPrivate
{
Q_DECLARE_PUBLIC(QWizardPage)
@@ -501,6 +537,7 @@ public:
inline QWizardPrivate()
: start(-1)
+ , startSetByUser(false)
, current(-1)
, canContinue(false)
, canFinish(false)
@@ -513,6 +550,7 @@ public:
, placeholderWidget2(0)
, headerWidget(0)
, watermarkLabel(0)
+ , sideWidget(0)
, titleLabel(0)
, subTitleLabel(0)
, bottomRuler(0)
@@ -581,6 +619,7 @@ public:
QList<int> history;
QSet<int> initialized; // ### remove and move bit to QWizardPage?
int start;
+ bool startSetByUser;
int current;
bool canContinue;
bool canFinish;
@@ -612,7 +651,8 @@ public:
QWidget *placeholderWidget1;
QWidget *placeholderWidget2;
QWizardHeader *headerWidget;
- QLabel *watermarkLabel;
+ QWatermarkLabel *watermarkLabel;
+ QWidget *sideWidget;
QFrame *pageFrame;
QLabel *titleLabel;
QLabel *subTitleLabel;
@@ -907,11 +947,12 @@ QWizardLayoutInfo QWizardPrivate::layoutInfoForCurrentPage()
info.header = (info.wizStyle == QWizard::ClassicStyle || info.wizStyle == QWizard::ModernStyle)
&& !(opts & QWizard::IgnoreSubTitles) && !subTitleText.isEmpty();
+ info.sideWidget = sideWidget;
info.watermark = (info.wizStyle != QWizard::MacStyle) && (info.wizStyle != QWizard::AeroStyle)
&& !watermarkPixmap.isNull();
info.title = !info.header && !titleText.isEmpty();
info.subTitle = !(opts & QWizard::IgnoreSubTitles) && !info.header && !subTitleText.isEmpty();
- info.extension = info.watermark && (opts & QWizard::ExtendedWatermarkPixmap);
+ info.extension = (info.watermark || info.sideWidget) && (opts & QWizard::ExtendedWatermarkPixmap);
return info;
}
@@ -954,7 +995,7 @@ void QWizardPrivate::recreateLayout(const QWizardLayoutInfo &info)
int numColumns;
if (mac) {
numColumns = 3;
- } else if (info.watermark) {
+ } else if (info.watermark || info.sideWidget) {
numColumns = 2;
} else {
numColumns = 1;
@@ -1096,8 +1137,8 @@ void QWizardPrivate::recreateLayout(const QWizardLayoutInfo &info)
pageFrame->setContentsMargins(hMargin, vMargin, hMargin, vMargin);
}
- if (info.watermark && !watermarkLabel) {
- watermarkLabel = new QLabel(antiFlickerWidget);
+ if ((info.watermark || info.sideWidget) && !watermarkLabel) {
+ watermarkLabel = new QWatermarkLabel(antiFlickerWidget, sideWidget);
watermarkLabel->setBackgroundRole(QPalette::Base);
watermarkLabel->setMinimumHeight(1);
watermarkLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
@@ -1173,7 +1214,7 @@ void QWizardPrivate::recreateLayout(const QWizardLayoutInfo &info)
mainLayout->addLayout(buttonLayout, row++, buttonStartColumn, 1, buttonNumColumns);
- if (info.watermark) {
+ if (info.watermark || info.sideWidget) {
if (info.extension)
watermarkEndRow = row;
mainLayout->addWidget(watermarkLabel, watermarkStartRow, 0,
@@ -1193,7 +1234,7 @@ void QWizardPrivate::recreateLayout(const QWizardLayoutInfo &info)
if (bottomRuler)
bottomRuler->setVisible(classic || modern);
if (watermarkLabel)
- watermarkLabel->setVisible(info.watermark);
+ watermarkLabel->setVisible(info.watermark || info.sideWidget);
layoutInfo = info;
}
@@ -1233,10 +1274,17 @@ void QWizardPrivate::updateLayout()
titleFmt, subTitleFmt);
}
- if (info.watermark) {
- Q_ASSERT(page);
- watermarkLabel->setPixmap(page->pixmap(QWizard::WatermarkPixmap));
+ if (info.watermark || info.sideWidget) {
+ QPixmap pix;
+ if (info.watermark) {
+ if (page)
+ pix = page->pixmap(QWizard::WatermarkPixmap);
+ else
+ pix = q->pixmap(QWizard::WatermarkPixmap);
+ }
+ watermarkLabel->setPixmap(pix); // in case there is no watermark and we show the side widget we need to clear the watermark
}
+
if (info.title) {
Q_ASSERT(page);
titleLabel->setTextFormat(titleFmt);
@@ -1267,7 +1315,7 @@ void QWizardPrivate::updateMinMaxSizes(const QWizardLayoutInfo &info)
minimumSize.setWidth(headerWidget->maximumWidth());
maximumSize.setWidth(headerWidget->maximumWidth());
}
- if (info.watermark) {
+ if (info.watermark && !info.sideWidget) {
minimumSize.setHeight(mainLayout->totalSizeHint().height());
maximumSize.setHeight(mainLayout->totalSizeHint().height());
}
@@ -2149,7 +2197,7 @@ QWizard::~QWizard()
The ID is guaranteed to be larger than any other ID in the
QWizard so far.
- \sa setPage(), page()
+ \sa setPage(), page(), pageAdded()
*/
int QWizard::addPage(QWizardPage *page)
{
@@ -2166,7 +2214,10 @@ int QWizard::addPage(QWizardPage *page)
Adds the given \a page to the wizard with the given \a id.
- \sa addPage(), page()
+ \note Adding a page may influence the value of the startId property
+ in case it was not set explicitly.
+
+ \sa addPage(), page(), pageAdded()
*/
void QWizard::setPage(int theid, QWizardPage *page)
{
@@ -2210,12 +2261,19 @@ void QWizard::setPage(int theid, QWizardPage *page)
// hide new page and reset layout to old status
page->hide();
d->pageVBoxLayout->setEnabled(pageVBoxLayoutEnabled);
+
+ if (!d->startSetByUser && d->pageMap.constBegin().key() == theid)
+ d->start = theid;
+ emit pageAdded(theid);
}
/*!
Removes the page with the given \a id. cleanupPage() will be called if necessary.
+
+ \note Removing a page may influence the value of the startId property.
+
\since 4.5
- \sa addPage(), setPage()
+ \sa addPage(), setPage(), pageRemoved(), startId()
*/
void QWizard::removePage(int id)
{
@@ -2223,8 +2281,24 @@ void QWizard::removePage(int id)
QWizardPage *removedPage = 0;
- if (d->start == id)
- d->start = -1;
+ // update startItem accordingly
+ if (d->pageMap.count() > 0) { // only if we have any pages
+ if (d->start == id) {
+ const int firstId = d->pageMap.constBegin().key();
+ if (firstId == id) {
+ if (d->pageMap.count() > 1)
+ d->start = (++d->pageMap.constBegin()).key(); // secondId
+ else
+ d->start = -1; // removing the last page
+ } else { // startSetByUser has to be "true" here
+ d->start = firstId;
+ }
+ d->startSetByUser = false;
+ }
+ }
+
+ if (d->pageMap.contains(id))
+ emit pageRemoved(id);
if (!d->history.contains(id)) {
// Case 1: removing a page not in the history
@@ -2334,21 +2408,27 @@ QList<int> QWizard::pageIds() const
void QWizard::setStartId(int theid)
{
Q_D(QWizard);
- if (!d->pageMap.contains(theid)) {
- qWarning("QWizard::setStartId: Invalid page ID %d", theid);
+ int newStart = theid;
+ if (theid == -1)
+ newStart = d->pageMap.count() ? d->pageMap.constBegin().key() : -1;
+
+ if (d->start == newStart) {
+ d->startSetByUser = theid != -1;
return;
}
- d->start = theid;
+
+ if (!d->pageMap.contains(newStart)) {
+ qWarning("QWizard::setStartId: Invalid page ID %d", newStart);
+ return;
+ }
+ d->start = newStart;
+ d->startSetByUser = theid != -1;
}
int QWizard::startId() const
{
Q_D(const QWizard);
- if (d->start != -1)
- return d->start;
- if (!d->pageMap.isEmpty())
- return d->pageMap.constBegin().key();
- return -1;
+ return d->start;
}
/*!
@@ -2825,6 +2905,55 @@ void QWizard::setDefaultProperty(const char *className, const char *property,
}
/*!
+ \since 4.7
+
+ Sets the given \a widget to be shown on the left side of the wizard.
+ For styles which use the WatermarkPixmap (ClassicStyle and ModernStyle)
+ the side widget is displayed on top of the watermark, for other styles
+ or when the watermark is not provided the side widget is displayed
+ on the left side of the wizard.
+
+ Passing 0 shows no side widget.
+
+ When the \a widget is not 0 the wizard reparents it.
+
+ Any previous side widget is hidden.
+
+ You may call setSideWidget() with the same widget at different
+ times.
+
+ All widgets set here will be deleted by the wizard when it is
+ destroyed unless you separately reparent the widget after setting
+ some other side widget (or 0).
+
+ By default, no side widget is present.
+*/
+void QWizard::setSideWidget(QWidget *widget)
+{
+ Q_D(QWizard);
+
+ d->sideWidget = widget;
+ if (d->watermarkLabel) {
+ d->watermarkLabel->setSideWidget(widget);
+ d->updateLayout();
+ }
+}
+
+/*!
+ \since 4.7
+
+ Returns the widget on the left side of the wizard or 0.
+
+ By default, no side widget is present.
+*/
+QWidget *QWizard::sideWidget() const
+{
+ Q_D(const QWizard);
+
+ return d->sideWidget;
+}
+
+/*!
\reimp
*/
void QWizard::setVisible(bool visible)
@@ -2878,6 +3007,28 @@ QSize QWizard::sizeHint() const
*/
/*!
+ \fn void QWizard::pageAdded(int id)
+
+ \since 4.7
+
+ This signal is emitted whenever a page is added to the
+ wizard. The page's \a id is passed as parameter.
+
+ \sa addPage(), setPage(), startId()
+*/
+
+/*!
+ \fn void QWizard::pageRemoved(int id)
+
+ \since 4.7
+
+ This signal is emitted whenever a page is removed from the
+ wizard. The page's \a id is passed as parameter.
+
+ \sa removePage(), startId()
+*/
+
+/*!
\fn void QWizard::helpRequested()
This signal is emitted when the user clicks the \gui Help button.
diff --git a/src/gui/dialogs/qwizard.h b/src/gui/dialogs/qwizard.h
index 58b13fe..b146147 100644
--- a/src/gui/dialogs/qwizard.h
+++ b/src/gui/dialogs/qwizard.h
@@ -165,6 +165,9 @@ public:
void setPixmap(WizardPixmap which, const QPixmap &pixmap);
QPixmap pixmap(WizardPixmap which) const;
+ void setSideWidget(QWidget *widget);
+ QWidget *sideWidget() const;
+
void setDefaultProperty(const char *className, const char *property,
const char *changedSignal);
@@ -175,6 +178,8 @@ Q_SIGNALS:
void currentIdChanged(int id);
void helpRequested();
void customButtonClicked(int which);
+ void pageAdded(int id);
+ void pageRemoved(int id);
public Q_SLOTS:
void back();
diff --git a/tests/auto/qwizard/tst_qwizard.cpp b/tests/auto/qwizard/tst_qwizard.cpp
index 764cd3e..f797227 100644
--- a/tests/auto/qwizard/tst_qwizard.cpp
+++ b/tests/auto/qwizard/tst_qwizard.cpp
@@ -104,6 +104,7 @@ private slots:
void setCommitPage();
void setWizardStyle();
void removePage();
+ void sideWidget();
// task-specific tests below me:
void task161660_buttonSpacing();
@@ -569,12 +570,16 @@ void tst_QWizard::addPage()
QWizard wizard;
const int N = 100;
QWizardPage *pages[N];
+ QSignalSpy spy(&wizard, SIGNAL(pageAdded(int)));
for (int i = 0; i < N; ++i) {
pages[i] = new QWizardPage(parent);
QCOMPARE(wizard.addPage(pages[i]), i);
QCOMPARE(pages[i]->window(), (QWidget *)&wizard);
QCOMPARE(wizard.startId(), 0);
+ QCOMPARE(spy.count(), 1);
+ QList<QVariant> arguments = spy.takeFirst();
+ QCOMPARE(arguments.at(0).toInt(), i);
}
for (int i = 0; i < N; ++i) {
@@ -585,16 +590,29 @@ void tst_QWizard::addPage()
QVERIFY(!wizard.page(N + 1));
wizard.setPage(N + 50, new QWizardPage);
+ QCOMPARE(spy.count(), 1);
+ QList<QVariant> arguments = spy.takeFirst();
+ QCOMPARE(arguments.at(0).toInt(), N + 50);
wizard.setPage(-3000, new QWizardPage);
+ QCOMPARE(spy.count(), 1);
+ arguments = spy.takeFirst();
+ QCOMPARE(arguments.at(0).toInt(), -3000);
QWizardPage *pageX = new QWizardPage;
QCOMPARE(wizard.addPage(pageX), N + 51);
QCOMPARE(wizard.page(N + 51), pageX);
+ QCOMPARE(spy.count(), 1);
+ arguments = spy.takeFirst();
+ QCOMPARE(arguments.at(0).toInt(), N + 51);
QCOMPARE(wizard.addPage(new QWizardPage), N + 52);
+ QCOMPARE(spy.count(), 1);
+ arguments = spy.takeFirst();
+ QCOMPARE(arguments.at(0).toInt(), N + 52);
QTest::ignoreMessage(QtWarningMsg,"QWizard::setPage: Cannot insert null page");
wizard.addPage(0); // generates a warning
+ QCOMPARE(spy.count(), 0);
delete parent;
}
@@ -611,6 +629,7 @@ void tst_QWizard::setPage()
QWidget *parent = new QWidget;
QWizard wizard;
QWizardPage *page;
+ QSignalSpy spy(&wizard, SIGNAL(pageAdded(int)));
QCOMPARE(wizard.startId(), -1);
QCOMPARE(wizard.currentId(), -1);
@@ -620,6 +639,7 @@ void tst_QWizard::setPage()
page = new QWizardPage(parent);
QTest::ignoreMessage(QtWarningMsg,"QWizard::setPage: Cannot insert page with ID -1");
wizard.setPage(-1, page); // gives a warning and does nothing
+ QCOMPARE(spy.count(), 0);
QVERIFY(!wizard.page(-2));
QVERIFY(!wizard.page(-1));
QVERIFY(!wizard.page(0));
@@ -631,6 +651,9 @@ void tst_QWizard::setPage()
page = new QWizardPage(parent);
wizard.setPage(0, page);
+ QCOMPARE(spy.count(), 1);
+ QList<QVariant> arguments = spy.takeFirst();
+ QCOMPARE(arguments.at(0).toInt(), 0);
QCOMPARE(page->window(), (QWidget *)&wizard);
QCOMPARE(wizard.page(0), page);
QCOMPARE(wizard.startId(), 0);
@@ -641,6 +664,9 @@ void tst_QWizard::setPage()
page = new QWizardPage(parent);
wizard.setPage(-2, page);
+ QCOMPARE(spy.count(), 1);
+ arguments = spy.takeFirst();
+ QCOMPARE(arguments.at(0).toInt(), -2);
QCOMPARE(page->window(), (QWidget *)&wizard);
QCOMPARE(wizard.page(-2), page);
QCOMPARE(wizard.startId(), -2);
@@ -659,6 +685,9 @@ void tst_QWizard::setPage()
page = new QWizardPage(parent);
wizard.setPage(2, page);
+ QCOMPARE(spy.count(), 1);
+ arguments = spy.takeFirst();
+ QCOMPARE(arguments.at(0).toInt(), 2);
QCOMPARE(wizard.page(2), page);
QCOMPARE(wizard.startId(), -2);
QCOMPARE(wizard.currentId(), -2);
@@ -675,6 +704,9 @@ void tst_QWizard::setPage()
page = new QWizardPage(parent);
wizard.setPage(-3, page);
+ QCOMPARE(spy.count(), 1);
+ arguments = spy.takeFirst();
+ QCOMPARE(arguments.at(0).toInt(), -3);
QCOMPARE(wizard.page(-3), page);
QCOMPARE(wizard.startId(), -3);
QCOMPARE(wizard.currentId(), -2);
@@ -743,6 +775,7 @@ void tst_QWizard::setPage()
QCOMPARE(wizard.nextId(), -2);
CHECK_VISITED(wizard, QList<int>() << -3);
}
+ QCOMPARE(spy.count(), 0);
delete parent;
}
@@ -766,7 +799,17 @@ void tst_QWizard::setStartId()
wizard.setPage(INT_MAX, new QWizardPage);
QCOMPARE(wizard.startId(), INT_MIN);
- QTest::ignoreMessage(QtWarningMsg,"QWizard::setStartId: Invalid page ID -1");
+ QTest::ignoreMessage(QtWarningMsg,"QWizard::setStartId: Invalid page ID 123");
+ wizard.setStartId(123);
+ QCOMPARE(wizard.startId(), INT_MIN);
+
+ wizard.setStartId(-1);
+ QCOMPARE(wizard.startId(), INT_MIN);
+
+ wizard.setStartId(-2);
+ QCOMPARE(wizard.startId(), -2);
+ QCOMPARE(wizard.nextId(), -1);
+
wizard.setStartId(-1);
QCOMPARE(wizard.startId(), INT_MIN);
@@ -2209,6 +2252,7 @@ void tst_QWizard::removePage()
QWizardPage *page1 = new QWizardPage;
QWizardPage *page2 = new QWizardPage;
QWizardPage *page3 = new QWizardPage;
+ QSignalSpy spy(&wizard, SIGNAL(pageRemoved(int)));
wizard.setPage(0, page0);
wizard.setPage(1, page1);
@@ -2218,26 +2262,36 @@ void tst_QWizard::removePage()
wizard.restart();
QCOMPARE(wizard.pageIds().size(), 4);
QCOMPARE(wizard.visitedPages().size(), 1);
+ QCOMPARE(spy.count(), 0);
// Removing a non-existent page
wizard.removePage(4);
QCOMPARE(wizard.pageIds().size(), 4);
+ QCOMPARE(spy.count(), 0);
// Removing and then reinserting a page
QCOMPARE(wizard.pageIds().size(), 4);
QVERIFY(wizard.pageIds().contains(2));
wizard.removePage(2);
+ QCOMPARE(spy.count(), 1);
+ QList<QVariant> arguments = spy.takeFirst();
+ QCOMPARE(arguments.at(0).toInt(), 2);
QCOMPARE(wizard.pageIds().size(), 3);
QVERIFY(!wizard.pageIds().contains(2));
wizard.setPage(2, page2);
+ QCOMPARE(spy.count(), 0);
QCOMPARE(wizard.pageIds().size(), 4);
QVERIFY(wizard.pageIds().contains(2));
// Removing the same page twice
wizard.removePage(2); // restore
+ QCOMPARE(spy.count(), 1);
+ arguments = spy.takeFirst();
+ QCOMPARE(arguments.at(0).toInt(), 2);
QCOMPARE(wizard.pageIds().size(), 3);
QVERIFY(!wizard.pageIds().contains(2));
wizard.removePage(2);
+ QCOMPARE(spy.count(), 0);
QCOMPARE(wizard.pageIds().size(), 3);
QVERIFY(!wizard.pageIds().contains(2));
@@ -2247,7 +2301,11 @@ void tst_QWizard::removePage()
wizard.next();
QCOMPARE(wizard.visitedPages().size(), 2);
QCOMPARE(wizard.currentPage(), page1);
+ QCOMPARE(spy.count(), 0);
wizard.removePage(2);
+ QCOMPARE(spy.count(), 1);
+ arguments = spy.takeFirst();
+ QCOMPARE(arguments.at(0).toInt(), 2);
QCOMPARE(wizard.visitedPages().size(), 2);
QVERIFY(!wizard.pageIds().contains(2));
QCOMPARE(wizard.currentPage(), page1);
@@ -2256,9 +2314,13 @@ void tst_QWizard::removePage()
wizard.setPage(2, page2); // restore
wizard.restart();
wizard.next();
+ QCOMPARE(spy.count(), 0);
QCOMPARE(wizard.visitedPages().size(), 2);
QCOMPARE(wizard.currentPage(), page1);
wizard.removePage(0);
+ QCOMPARE(spy.count(), 1);
+ arguments = spy.takeFirst();
+ QCOMPARE(arguments.at(0).toInt(), 0);
QCOMPARE(wizard.visitedPages().size(), 1);
QVERIFY(!wizard.visitedPages().contains(0));
QVERIFY(!wizard.pageIds().contains(0));
@@ -2268,9 +2330,13 @@ void tst_QWizard::removePage()
wizard.setPage(0, page0); // restore
wizard.restart();
wizard.next();
+ QCOMPARE(spy.count(), 0);
QCOMPARE(wizard.visitedPages().size(), 2);
QCOMPARE(wizard.currentPage(), page1);
wizard.removePage(1);
+ QCOMPARE(spy.count(), 1);
+ arguments = spy.takeFirst();
+ QCOMPARE(arguments.at(0).toInt(), 1);
QCOMPARE(wizard.visitedPages().size(), 1);
QVERIFY(!wizard.visitedPages().contains(1));
QVERIFY(!wizard.pageIds().contains(1));
@@ -2278,6 +2344,9 @@ void tst_QWizard::removePage()
// Remove the current page which is the first (and only) one in the history
wizard.removePage(0);
+ QCOMPARE(spy.count(), 1);
+ arguments = spy.takeFirst();
+ QCOMPARE(arguments.at(0).toInt(), 0);
QCOMPARE(wizard.visitedPages().size(), 1);
QVERIFY(!wizard.visitedPages().contains(0));
QCOMPARE(wizard.pageIds().size(), 2);
@@ -2285,6 +2354,9 @@ void tst_QWizard::removePage()
QCOMPARE(wizard.currentPage(), page2);
//
wizard.removePage(2);
+ QCOMPARE(spy.count(), 1);
+ arguments = spy.takeFirst();
+ QCOMPARE(arguments.at(0).toInt(), 2);
QCOMPARE(wizard.visitedPages().size(), 1);
QVERIFY(!wizard.visitedPages().contains(2));
QCOMPARE(wizard.pageIds().size(), 1);
@@ -2292,11 +2364,34 @@ void tst_QWizard::removePage()
QCOMPARE(wizard.currentPage(), page3);
//
wizard.removePage(3);
+ QCOMPARE(spy.count(), 1);
+ arguments = spy.takeFirst();
+ QCOMPARE(arguments.at(0).toInt(), 3);
QVERIFY(wizard.visitedPages().empty());
QVERIFY(wizard.pageIds().empty());
QCOMPARE(wizard.currentPage(), static_cast<QWizardPage *>(0));
}
+void tst_QWizard::sideWidget()
+{
+ QWizard wizard;
+
+ wizard.setSideWidget(0);
+ QVERIFY(wizard.sideWidget() == 0);
+ QWidget *w1 = new QWidget(&wizard);
+ wizard.setSideWidget(w1);
+ QVERIFY(wizard.sideWidget() == w1);
+ QWidget *w2 = new QWidget(&wizard);
+ wizard.setSideWidget(w2);
+ QVERIFY(wizard.sideWidget() == w2);
+ QVERIFY(w1->parent() != 0);
+ QCOMPARE(w1->window(), static_cast<QWidget *>(&wizard));
+ QCOMPARE(w2->window(), static_cast<QWidget *>(&wizard));
+ w1->setParent(0);
+ wizard.setSideWidget(0);
+ QVERIFY(wizard.sideWidget() == 0);
+}
+
void tst_QWizard::task161660_buttonSpacing()
{
#ifndef QT_NO_STYLE_PLASTIQUE