From bcb704366cb5e333a626c18c308c7e0448a8e69f Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdenetwork@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- .../protocols/oscar/icq/ui/icqaddcontactpage.cpp | 126 +++++++++++++++++++++ 1 file changed, 126 insertions(+) create mode 100644 kopete/protocols/oscar/icq/ui/icqaddcontactpage.cpp (limited to 'kopete/protocols/oscar/icq/ui/icqaddcontactpage.cpp') diff --git a/kopete/protocols/oscar/icq/ui/icqaddcontactpage.cpp b/kopete/protocols/oscar/icq/ui/icqaddcontactpage.cpp new file mode 100644 index 00000000..b1ab2eb4 --- /dev/null +++ b/kopete/protocols/oscar/icq/ui/icqaddcontactpage.cpp @@ -0,0 +1,126 @@ + /* + icqaddcontactpage.cpp - ICQ Protocol Plugin + + Copyright (c) 2002 by Stefan Gehn + Kopete (c) 2002-2003 by the Kopete developers + + ************************************************************************* + * * + * 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 "icqaddcontactpage.h" + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include "icqadd.h" +#include "icqaccount.h" +#include "icqprotocol.h" +#include "icqsearchdialog.h" + + +ICQAddContactPage::ICQAddContactPage(ICQAccount *owner, QWidget *parent, const char *name) + : AddContactPage(parent,name) +{ + kdDebug(14153) << k_funcinfo << "called" << endl; + mAccount = owner; + m_searchDialog = 0L; + + (new QVBoxLayout(this))->setAutoAdd(true); + addUI = new icqAddUI(this); + connect( addUI->searchButton, SIGNAL( clicked() ), this, SLOT( showSearchDialog() ) ); +} + +ICQAddContactPage::~ICQAddContactPage() +{ +} + +void ICQAddContactPage::setUINFromSearch( const QString& uin ) +{ + addUI->uinEdit->setText( uin ); +} + +void ICQAddContactPage::showEvent(QShowEvent *e) +{ +// slotSelectionChanged(); + AddContactPage::showEvent(e); +} + +bool ICQAddContactPage::apply(Kopete::Account* , Kopete::MetaContact *parentContact ) +{ + kdDebug(14153) << k_funcinfo << "called; adding contact..." << endl; + + QString contactId = addUI->uinEdit->text(); + kdDebug(14153) << k_funcinfo << "uin=" << contactId << endl; + return mAccount->addContact(contactId, parentContact, Kopete::Account::ChangeKABC ); + +} + +bool ICQAddContactPage::validateData() +{ + if(!mAccount->isConnected()) + { + // Account currently offline + addUI->searchButton->setEnabled( false ); + addUI->uinEdit->setEnabled( false ); + KMessageBox::sorry( this, i18n("You must be online to add a contact."), i18n("ICQ Plugin") ); + return false; + } + + Q_ULONG uin = addUI->uinEdit->text().toULong(); + if ( uin < 1000 ) + { + // Invalid (or missing) UIN + KMessageBox::sorry( this, i18n("You must enter a valid UIN."), i18n("ICQ Plugin") ); + return false; + } + else + { + // UIN is valid + return true; + } +} + +void ICQAddContactPage::showSearchDialog() +{ + if ( m_searchDialog ) + m_searchDialog->raise(); + else + { + m_searchDialog = new ICQSearchDialog( mAccount, this, "icqSearchDialog" ); + m_searchDialog->show(); + connect( m_searchDialog, SIGNAL( finished() ), this, SLOT( searchDialogDestroyed() ) ); + } +} + +void ICQAddContactPage::searchDialogDestroyed() +{ + QObject::disconnect( this, 0, m_searchDialog, 0 ); + m_searchDialog->delayedDestruct(); + m_searchDialog = NULL; +} + + +#include "icqaddcontactpage.moc" +// vim: set noet ts=4 sts=4 sw=4: +// kate: indent-mode csands; space-indent off; replace-tabs off; -- cgit v1.2.1