1
/* This file is part of the KDE project
2
Copyright (C) 2011-2013 Jarosław Staniek <staniek@kde.org>
4
This program is free software; you can redistribute it and/or
5
modify it under the terms of the GNU Library General Public
6
License as published by the Free Software Foundation; either
7
version 2 of the License, or (at your option) any later version.
9
This program is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
Library General Public License for more details.
14
You should have received a copy of the GNU Library General Public License
15
along with this program; see the file COPYING. If not, write to
16
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17
* Boston, MA 02110-1301, USA.
20
#include "KexiAssistantWidget.h"
21
#include "KexiAssistantPage.h"
22
#include "KexiAnimatedLayout.h"
23
#include <kexiutils/utils.h>
30
class KexiAssistantWidget::Private
33
explicit Private(KexiAssistantWidget *qq)
42
void addPage(KexiAssistantPage* page) {
44
connect(page, SIGNAL(back(KexiAssistantPage*)), q, SLOT(previousPageRequested(KexiAssistantPage*)));
45
connect(page, SIGNAL(next(KexiAssistantPage*)), q, SLOT(nextPageRequested(KexiAssistantPage*)));
46
connect(page, SIGNAL(cancelled(KexiAssistantPage*)), q, SLOT(cancelRequested(KexiAssistantPage*)));
49
KexiAnimatedLayout *lyr;
50
QStack< QPointer<KexiAssistantPage> > stack;
53
KexiAssistantWidget* q;
58
KexiAssistantWidget::KexiAssistantWidget(QWidget* parent)
60
, d(new Private(this))
62
QVBoxLayout *mainLyr = new QVBoxLayout(this);
63
d->lyr = new KexiAnimatedLayout;
64
mainLyr->addLayout(d->lyr);
65
int margin = style()->pixelMetric(QStyle::PM_MenuPanelWidth, 0, 0)
66
+ KexiUtils::marginHint();
67
mainLyr->setContentsMargins(margin, margin, margin, margin);
70
KexiAssistantWidget::~KexiAssistantWidget()
75
void KexiAssistantWidget::addPage(KexiAssistantPage* page)
80
void KexiAssistantWidget::previousPageRequested(KexiAssistantPage* page)
83
if (d->stack.count() < 2) {
84
qWarning() << "Page stack's' count < 2";
88
setCurrentPage(d->stack.top());
91
void KexiAssistantWidget::nextPageRequested(KexiAssistantPage* page)
96
void KexiAssistantWidget::cancelRequested(KexiAssistantPage* page)
101
KexiAssistantPage* KexiAssistantWidget::currentPage() const
103
return dynamic_cast<KexiAssistantPage*>(d->lyr->currentWidget());
106
void KexiAssistantWidget::setCurrentPage(KexiAssistantPage* page)
109
qWarning() << "!page";
112
d->lyr->setCurrentWidget(page);
113
if (page->focusWidget()) {
114
page->focusWidget()->setFocus();
116
if (d->stack.isEmpty() || d->stack.top() != page) {
117
int index = d->stack.indexOf(page);
119
d->stack.remove(index);