File indexing completed on 2024-05-26 05:10:17

0001 /*
0002     SPDX-FileCopyrightText: 2006 Thomas Baumgart <ipwizard@users.sourceforge.net>
0003     SPDX-FileCopyrightText: 2017 Łukasz Wojniłowicz <lukasz.wojnilowicz@gmail.com>
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #include "kaccountpage.h"
0008 #include "kaccountpage_p.h"
0009 
0010 // ----------------------------------------------------------------------------
0011 // QT Includes
0012 
0013 #include <QCheckBox>
0014 #include <QDate>
0015 
0016 // ----------------------------------------------------------------------------
0017 // KDE Includes
0018 
0019 #include <KLineEdit>
0020 
0021 // ----------------------------------------------------------------------------
0022 // Project Includes
0023 
0024 #include "ui_kaccountpage.h"
0025 
0026 #include "knewuserwizard.h"
0027 #include "knewuserwizard_p.h"
0028 #include "kcategoriespage.h"
0029 #include "wizardpage.h"
0030 #include "kguiutils.h"
0031 
0032 namespace NewUserWizard
0033 {
0034 AccountPage::AccountPage(Wizard* wizard) :
0035     QWidget(wizard),
0036     WizardPage<Wizard>(*new AccountPagePrivate(wizard), stepCount, this, wizard)       // don't inc. the step count here
0037 {
0038     Q_D(AccountPage);
0039     d->ui->setupUi(this);
0040     d->m_mandatoryGroup->add(d->ui->m_accountNameEdit);
0041     connect(d->m_mandatoryGroup, static_cast<void (KMandatoryFieldGroup::*)()>(&KMandatoryFieldGroup::stateChanged), object(), &KMyMoneyWizardPagePrivate::completeStateChanged);
0042     connect(d->ui->m_haveCheckingAccountButton, &QAbstractButton::toggled, object(), &KMyMoneyWizardPagePrivate::completeStateChanged);
0043     d->ui->m_openingDateEdit->setDate(QDate(QDate::currentDate().year(), 1, 1));
0044 }
0045 
0046 AccountPage::~AccountPage()
0047 {
0048 }
0049 
0050 void AccountPage::enterPage()
0051 {
0052     Q_D(AccountPage);
0053     d->ui->m_accountNameEdit->setFocus();
0054 }
0055 
0056 KMyMoneyWizardPage* AccountPage::nextPage() const
0057 {
0058     Q_D(const AccountPage);
0059     return d->m_wizard->d_func()->m_categoriesPage;
0060 }
0061 
0062 bool AccountPage::isComplete() const
0063 {
0064     Q_D(const AccountPage);
0065     return !d->ui->m_haveCheckingAccountButton->isChecked() || d->m_mandatoryGroup->isEnabled();
0066 }
0067 
0068 }