File indexing completed on 2024-06-09 05:03:30
0001 /* 0002 SPDX-FileCopyrightText: 2010 Fernando Vilas <kmymoney-devel@kde.org> 0003 SPDX-License-Identifier: GPL-2.0-or-later 0004 */ 0005 0006 #include "effectivedatewizardpage.h" 0007 0008 // ---------------------------------------------------------------------------- 0009 // QT Includes 0010 0011 0012 // ---------------------------------------------------------------------------- 0013 // KDE Includes 0014 0015 #include <KLocalizedString> 0016 0017 // ---------------------------------------------------------------------------- 0018 // Project Includes 0019 0020 #include "ui_effectivedatewizardpage.h" 0021 0022 #include "knewloanwizard.h" 0023 #include "mymoneyaccountloan.h" 0024 #include "mymoneyutils.h" 0025 0026 EffectiveDateWizardPage::EffectiveDateWizardPage(QWidget *parent) 0027 : QWizardPage(parent), 0028 ui(new Ui::EffectiveDateWizardPage) 0029 { 0030 ui->setupUi(this); 0031 // Register the fields with the QWizard and connect the 0032 // appropriate signals to update the "Next" button correctly 0033 registerField("effectiveChangeDateEdit", ui->m_effectiveChangeDateEdit, "date", SIGNAL(dateChanged(QDate))); 0034 connect(ui->m_effectiveChangeDateEdit, &KMyMoneyDateEdit::dateChanged, this, &QWizardPage::completeChanged); 0035 } 0036 0037 EffectiveDateWizardPage::~EffectiveDateWizardPage() 0038 { 0039 delete ui; 0040 } 0041 0042 void EffectiveDateWizardPage::initializePage() 0043 { 0044 ui->m_effectiveDateLabel->setText(QString("\n") 0045 + i18n("Please enter the date from which on the following changes will be effective. " 0046 "The date entered must be later than the opening date of this account (%1), but must " 0047 "not be in the future. The default will be today.", 0048 MyMoneyUtils::formatDate(qobject_cast<KNewLoanWizard*>(wizard())->account().openingDate(), QLocale::LongFormat))); 0049 } 0050 0051 /** 0052 * Update the "Next" button 0053 */ 0054 bool EffectiveDateWizardPage::isComplete() const 0055 { 0056 if (!ui->m_effectiveChangeDateEdit->isValid()) 0057 return false; 0058 return !(ui->m_effectiveChangeDateEdit->date() < qobject_cast<KNewLoanWizard*>(wizard())->account().openingDate() 0059 || ui->m_effectiveChangeDateEdit->date() > QDate::currentDate()); 0060 return true; 0061 }