diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-07-04 22:38:03 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-07-04 22:38:03 +0000 |
commit | dadc34655c3ab961b0b0b94a10eaaba710f0b5e8 (patch) | |
tree | 99e72842fe687baea16376a147619b6048d7e441 /kmymoney2/dialogs/knewfiledlg.cpp | |
download | kmymoney-dadc34655c3ab961b0b0b94a10eaaba710f0b5e8.tar.gz kmymoney-dadc34655c3ab961b0b0b94a10eaaba710f0b5e8.zip |
Added kmymoney
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/kmymoney@1239792 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kmymoney2/dialogs/knewfiledlg.cpp')
-rw-r--r-- | kmymoney2/dialogs/knewfiledlg.cpp | 138 |
1 files changed, 138 insertions, 0 deletions
diff --git a/kmymoney2/dialogs/knewfiledlg.cpp b/kmymoney2/dialogs/knewfiledlg.cpp new file mode 100644 index 0000000..2ea043f --- /dev/null +++ b/kmymoney2/dialogs/knewfiledlg.cpp @@ -0,0 +1,138 @@ +/*************************************************************************** + knewfiledlg.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. * + * * + ***************************************************************************/ + +#include "kdecompat.h" + +// ---------------------------------------------------------------------------- +// QT Includes + +#include <qpixmap.h> +#include <qlineedit.h> +#include <qlabel.h> + +// ---------------------------------------------------------------------------- +// KDE Headers + +#include <kglobal.h> +#include <klocale.h> +#include <kstandarddirs.h> +#include <kstdguiitem.h> +#include <kpushbutton.h> +#include <kmessagebox.h> + +#if KDE_IS_VERSION(3,1,90) +#include <kabc/addressee.h> +#include <kabc/stdaddressbook.h> +#endif + +// ---------------------------------------------------------------------------- +// Project Includes + +#include "knewfiledlg.h" + +KNewFileDlg::KNewFileDlg(QWidget *parent, const char *name, const QString& title) + : KNewFileDlgDecl(parent,name,true) +{ + init(title); +} + +KNewFileDlg::KNewFileDlg(QString userName, QString userStreet, + QString userTown, QString userCounty, QString userPostcode, QString userTelephone, + QString userEmail, QWidget *parent, const char *name, const QString& title) + : KNewFileDlgDecl(parent,name,true) +{ + userNameEdit->setText(userName); + streetEdit->setText(userStreet); + townEdit->setText(userTown); + countyEdit->setText(userCounty); + postcodeEdit->setText(userPostcode); + telephoneEdit->setText(userTelephone); + emailEdit->setText(userEmail); + + init(title); +} + +void KNewFileDlg::init(const QString& title) +{ + bool showLoadButton = false; + okBtn->setGuiItem(KStdGuiItem::ok()); + cancelBtn->setGuiItem(KStdGuiItem::cancel()); + + if (!title.isEmpty()) + setCaption(title); + +#if KDE_IS_VERSION( 3, 1, 90 ) + KABC::StdAddressBook *ab = static_cast<KABC::StdAddressBook*> + ( KABC::StdAddressBook::self() ); + if ( ab && !ab->whoAmI().isEmpty() ) + showLoadButton = true; +#endif + + if(!showLoadButton) + kabcBtn->hide(); + + userNameEdit->setFocus(); + + connect(cancelBtn, SIGNAL(clicked()), this, SLOT(reject())); + connect(okBtn, SIGNAL(clicked()), this, SLOT(okClicked())); + connect(kabcBtn, SIGNAL(clicked()), this, SLOT(loadFromKABC())); +} + +KNewFileDlg::~KNewFileDlg(){ +} + +void KNewFileDlg::okClicked() +{ + userNameText = userNameEdit->text(); + userStreetText = streetEdit->text(); + userTownText = townEdit->text(); + userCountyText = countyEdit->text(); + userPostcodeText = postcodeEdit->text(); + userTelephoneText = telephoneEdit->text(); + userEmailText = emailEdit->text(); + + accept(); +} + +void KNewFileDlg::loadFromKABC(void) +{ +#if KDE_IS_VERSION( 3, 1, 90 ) + KABC::StdAddressBook *ab = static_cast<KABC::StdAddressBook*> + ( KABC::StdAddressBook::self() ); + if ( !ab ) + return; + + KABC::Addressee addr = ab->whoAmI(); + if ( addr.isEmpty() ) { + KMessageBox::sorry(this, i18n("Unable to load data, because no contact has been associated with the owner of the standard addressbook."), i18n("Addressbook import")); + return; + } + + userNameEdit->setText( addr.formattedName() ); + emailEdit->setText( addr.preferredEmail() ); + + KABC::PhoneNumber phone = addr.phoneNumber( KABC::PhoneNumber::Home ); + telephoneEdit->setText( phone.number() ); + + KABC::Address a = addr.address( KABC::Address::Home ); + countyEdit->setText( a.country() + " / " + a.region() ); + postcodeEdit->setText( a.postalCode() ); + townEdit->setText( a.locality() ); + streetEdit->setText( a.street() ); +#endif +} + +#include "knewfiledlg.moc" |