You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
kmymoney/kmymoney2/dialogs/knewbankdlg.cpp

106 lines
3.5 KiB

/***************************************************************************
knewbankdlg.cpp
-------------------
copyright : (C) 2000 by Michael Edwardes
email : mte@users.sourceforge.net
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
// ----------------------------------------------------------------------------
// QT Includes
#include <tqlabel.h>
#include <tqpixmap.h>
// ----------------------------------------------------------------------------
// KDE Includes
#include <tdeglobal.h>
#include <tdelocale.h>
#include <kstandarddirs.h>
#include <tdemessagebox.h>
#include <kpushbutton.h>
#include <kguiitem.h>
#include <klineedit.h>
// ----------------------------------------------------------------------------
// Project Includes
#include <kmymoney/mymoneyinstitution.h>
#include <kmymoney/kguiutils.h>
#include "knewbankdlg.h"
KNewBankDlg::KNewBankDlg(MyMoneyInstitution& institution, TQWidget *parent, const char *name)
: KNewBankDlgDecl(parent,name,true), m_institution(institution)
{
okBtn->setGuiItem(KStdGuiItem::ok());
cancelBtn->setGuiItem(KStdGuiItem::cancel());
nameEdit->setFocus();
nameEdit->setText(institution.name());
cityEdit->setText(institution.city());
streetEdit->setText(institution.street());
postcodeEdit->setText(institution.postcode());
telephoneEdit->setText(institution.telephone());
bicEdit->setText(institution.value("bic"));
sortCodeEdit->setText(institution.sortcode());
connect(okBtn, TQ_SIGNAL(clicked()), TQ_SLOT(okClicked()));
connect(cancelBtn, TQ_SIGNAL(clicked()), TQ_SLOT(reject()));
connect(nameEdit, TQ_SIGNAL(textChanged ( const TQString & )), TQ_SLOT(institutionNameChanged( const TQString &)));
institutionNameChanged( nameEdit->text());
kMandatoryFieldGroup* requiredFields = new kMandatoryFieldGroup (this);
requiredFields->setOkButton(okBtn); // button to be enabled when all fields present
requiredFields->add(nameEdit);
}
void KNewBankDlg::institutionNameChanged( const TQString &_text)
{
okBtn->setEnabled( !_text.isEmpty() );
}
KNewBankDlg::~KNewBankDlg()
{
}
void KNewBankDlg::okClicked()
{
if (nameEdit->text().isEmpty()) {
KMessageBox::information(this, i18n("The institution name field is empty. Please enter the name."), i18n("Adding New Institution"));
nameEdit->setFocus();
return;
}
m_institution.setName(nameEdit->text());
m_institution.setTown(cityEdit->text());
m_institution.setStreet(streetEdit->text());
m_institution.setPostcode(postcodeEdit->text());
m_institution.setTelephone(telephoneEdit->text());
m_institution.setValue("bic", bicEdit->text());
m_institution.setSortcode(sortCodeEdit->text());
accept();
}
const MyMoneyInstitution& KNewBankDlg::institution(void)
{
return m_institution;
}
#include "knewbankdlg.moc"