Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 1bf4d17b authored by R. Harish Navnit's avatar R. Harish Navnit Committed by Pali Rohár

Port kabc to kcontacts

parent dfbcebeb
......@@ -21,13 +21,15 @@
#include <QList>
#include <QTimer>
#include <kcontacts/addressee.h>
#include "kopetegroup.h"
#include "kopetemetacontact.h"
#include "kopetecontactlist.h"
#include "kopetecontact.h"
#include "kopeteappearancesettings.h"
#include "kopeteitembase.h"
#include <kabc/stdaddressbook.h>
namespace Kopete {
......@@ -272,7 +274,8 @@ bool ContactListProxyModel::searchContactInfo(Kopete::MetaContact *mc, QRegExp s
return true;
// Check the address book
KABC::Addressee addressee = KABC::StdAddressBook::self()->findByUid( mc->kabcId() );
//DEPRECATED: KContacts::Addressee addressee = KContacts::StdAddressBook::self()->findByUid( mc->kabcId() );
KContacts::Addressee addressee = KContacts::Addressee();
if ( !addressee.isEmpty() )
{
QString emailAddr = addressee.fullEmail();
......
......@@ -26,12 +26,9 @@
#include <klocale.h>
#include <kmessagebox.h>
#include <kabc/addressee.h>
#include <kabc/addressbook.h>
#include <kabc/phonenumber.h>
#include <kabc/picture.h>
#include <kabc/resource.h>
#include <kabc/stdaddressbook.h>
#include <kcontacts/picture.h>
#include <kcontacts/addressee.h>
#include <kcontacts/phonenumber.h>
#include <kabcpersistence.h>
#include <kopetecontact.h>
......@@ -71,15 +68,15 @@ KabcExportWizard::KabcExportWizard( QWidget *parent )
connect( m_page2.btnDeselectAll, SIGNAL(clicked()), SLOT(slotDeselectAll()) );
// fill resource selector
m_addressBook = Kopete::KABCPersistence::self()->addressBook();
//DEPRECATED: m_addressBook = Kopete::KABCPersistence::self()->addressBook();
QList<KABC::Resource*> kabcResources = m_addressBook->resources();
//DEPRECATED: QList<KContacts::Resource*> kabcResources = m_addressBook->resources();
QListIterator<KABC::Resource*> resIt( kabcResources );
KABC::Resource *resource;
//DEPRECATED: QListIterator<KContacts::Resource*> resIt( kabcResources );
//DEPRECATED: KContacts::Resource *resource;
uint counter = 0;
while ( resIt.hasNext() )
/*while ( resIt.hasNext() )
{
resource = resIt.next();
if ( !resource->readOnly() )
......@@ -88,7 +85,7 @@ KabcExportWizard::KabcExportWizard( QWidget *parent )
m_page1.addrBooks->addItem( resource->resourceName() );
counter++;
}
}
}*/
setValid(m_page1WidgetItem,false);
......@@ -116,7 +113,7 @@ KabcExportWizard::KabcExportWizard( QWidget *parent )
mc->displayName() );
lvi->setCheckState( Qt::Unchecked );
const QString &kabcId = mc->kabcId();
if ( kabcId.isEmpty() || m_addressBook->findByUid(kabcId).isEmpty() )
if ( kabcId.isEmpty() /*|| m_addressBook->findByUid(kabcId).isEmpty()*/ )
{
lvi->setCheckState( Qt::Checked );
lvi->setFlags(Qt::ItemIsUserCheckable|Qt::ItemIsEnabled);
......@@ -164,8 +161,7 @@ void KabcExportWizard::accept()
{
// first add an addressee to the selected resource
// then set the metacontactId of each MC to that of the new addressee
KABC::Resource * selectedResource =
m_resourceMap[ ( m_page1.addrBooks->currentRow() ) ];
//DEPRECATED: KContacts::Resource * selectedResource = m_resourceMap[ ( m_page1.addrBooks->currentRow() ) ];
// for each item checked
{
for(int i=0;i<m_page2.contactList->count();i++)
......@@ -174,13 +170,13 @@ void KabcExportWizard::accept()
// if it is checked and enabled
if ( item->flags() & Qt::ItemIsEnabled && item->checkState() & Qt::Checked)
{
KABC::Addressee addr;
addr = m_addressBook->findByUid( item->mc->kabcId() );
KContacts::Addressee addr = KContacts::Addressee();
//DEPRECATED: addr = m_addressBook->findByUid( item->mc->kabcId() );
if ( addr.isEmpty() ) // unassociated contact
{
kDebug( 14000 ) << "creating addressee " << item->mc->displayName() << " in address book " << selectedResource->resourceName();
//DEPRECATED: kDebug( 14000 ) << "creating addressee " << item->mc->displayName() << " in address book " << selectedResource->resourceName();
// create a new addressee in the selected resource
addr.setResource( selectedResource );
//DEPRECATED: addr.setResource( selectedResource );
// set name
QList<Kopete::Contact*> contacts = item->mc->contacts();
......@@ -199,7 +195,7 @@ void KabcExportWizard::accept()
// set details
exportDetails( item->mc, addr );
m_addressBook->insertAddressee( addr );
//DEPRECATED: m_addressBook->insertAddressee( addr );
// set the metacontact's id to that of the new addressee
// - this causes the addressbook to be written by libkopete
item->mc->setKabcId( addr.uid() );
......@@ -207,17 +203,17 @@ void KabcExportWizard::accept()
else
{
exportDetails( item->mc, addr );
m_addressBook->insertAddressee( addr );
//DEPRECATED: m_addressBook->insertAddressee( addr );
}
}
}
}
// request a write in case we only changed details on existing linked addressee
Kopete::KABCPersistence::self()->writeAddressBook( selectedResource );
//DEPRECATED: Kopete::KABCPersistence::self()->writeAddressBook( selectedResource );
QDialog::accept();
}
void KabcExportWizard::exportDetails( Kopete::MetaContact * mc, KABC::Addressee & addr )
void KabcExportWizard::exportDetails( Kopete::MetaContact * mc, KContacts::Addressee & addr )
{
QList<Kopete::Contact*> contacts = mc->contacts();
QList<Kopete::Contact*>::iterator cit, citEnd = contacts.begin();
......@@ -232,17 +228,17 @@ void KabcExportWizard::exportDetails( Kopete::MetaContact * mc, KABC::Addressee
prop = (*cit)->property( Kopete::Global::Properties::self()->privatePhone() );
if ( !prop.isNull() )
{
addr.insertPhoneNumber( KABC::PhoneNumber( prop.value().toString(), KABC::PhoneNumber::Home ) );
addr.insertPhoneNumber( KContacts::PhoneNumber( prop.value().toString(), KContacts::PhoneNumber::Home ) );
}
prop = (*cit)->property( Kopete::Global::Properties::self()->workPhone() );
if ( !prop.isNull() )
{
addr.insertPhoneNumber( KABC::PhoneNumber( prop.value().toString(), KABC::PhoneNumber::Work ) );
addr.insertPhoneNumber( KContacts::PhoneNumber( prop.value().toString(), KContacts::PhoneNumber::Work ) );
}
prop = (*cit)->property( Kopete::Global::Properties::self()->privateMobilePhone() );
if ( !prop.isNull() )
{
addr.insertPhoneNumber( KABC::PhoneNumber( prop.value().toString(), KABC::PhoneNumber::Cell ) );
addr.insertPhoneNumber( KContacts::PhoneNumber( prop.value().toString(), KContacts::PhoneNumber::Cell ) );
}
}
......@@ -250,7 +246,7 @@ void KabcExportWizard::exportDetails( Kopete::MetaContact * mc, KABC::Addressee
if( !mc->picture().isNull() )
{
QImage photo = mc->picture().image();
addr.setPhoto( KABC::Picture( photo ) );
addr.setPhoto( KContacts::Picture( photo ) );
}
}
......
......@@ -21,14 +21,14 @@
#include <kassistantdialog.h>
#include <kopete_export.h>
#include <kabc/resource.h>
#include "ui_kabcexport_page1.h"
#include "ui_kabcexport_page2.h"
namespace KABC {
class AddressBook;
namespace KContacts {
class Address;
class Addressee;
}
......@@ -53,10 +53,10 @@ Q_OBJECT
void slotSelectAll();
void slotResourceSelectionChanged( QListWidgetItem * lbi );
protected:
void exportDetails( Kopete::MetaContact * mc, KABC::Addressee & addr );
void exportDetails( Kopete::MetaContact * mc, KContacts::Addressee & addr );
private:
KABC::AddressBook* m_addressBook;
QMap<int, KABC::Resource*> m_resourceMap;
//DEPRECATED: KContacts::AddressBook* m_addressBook;
//DEPRECATED: QMap<int, KContacts::Resource*> m_resourceMap;
QMap<int, Kopete::MetaContact*> m_contactMap;
Ui::KabcExportWizardPage1 m_page1;
KPageWidgetItem *m_page1WidgetItem;
......
......@@ -20,9 +20,10 @@
#include "kopeteaddrbookexport.h"
#include <kabc/phonenumber.h>
#include <qcombobox.h>
#include <qlabel.h>
#include <kcontacts/phonenumber.h>
#include <QComboBox>
#include <QLabel>
#include <QDialog>
#include <QPixmap>
#include <kdialog.h>
......@@ -38,7 +39,7 @@ KopeteAddressBookExport::KopeteAddressBookExport( QWidget *parent, Kopete::MetaC
{
// instantiate dialog and populate widgets
mParent = parent;
mAddressBook = KABC::StdAddressBook::self();
//DEPRECATED: mAddressBook = KContacts::StdAddressBook::self();
mMetaContact = mc;
mWorkPhones->setSelectionMode(QAbstractItemView::ExtendedSelection);
......@@ -110,17 +111,17 @@ void KopeteAddressBookExport::fetchKABCData()
}
// phone numbers
fetchPhoneNumbers( mHomePhones, KABC::PhoneNumber::Home, numHomePhones );
fetchPhoneNumbers( mWorkPhones, KABC::PhoneNumber::Work, numWorkPhones );
fetchPhoneNumbers( mMobilePhones, KABC::PhoneNumber::Cell, numMobilePhones );
fetchPhoneNumbers( mHomePhones, KContacts::PhoneNumber::Home, numHomePhones );
fetchPhoneNumbers( mWorkPhones, KContacts::PhoneNumber::Work, numWorkPhones );
fetchPhoneNumbers( mMobilePhones, KContacts::PhoneNumber::Cell, numMobilePhones );
}
}
void KopeteAddressBookExport::fetchPhoneNumbers( QListWidget * listBox, KABC::PhoneNumber::Type type, uint& counter )
void KopeteAddressBookExport::fetchPhoneNumbers( QListWidget * listBox, KContacts::PhoneNumber::Type type, uint& counter )
{
KABC::PhoneNumber::List phones = mAddressee.phoneNumbers( type );
KContacts::PhoneNumber::List phones = mAddressee.phoneNumbers( type );
counter = phones.count();
KABC::PhoneNumber::List::Iterator it;
KContacts::PhoneNumber::List::Iterator it;
unsigned int rowCount = 0;
for ( it = phones.begin(); it != phones.end(); ++it ) {
listBox->item(rowCount)->setIcon(QIcon(mAddrBookIcon));
......@@ -182,7 +183,7 @@ void KopeteAddressBookExport::populateIM( const Kopete::Contact *contact, const
int KopeteAddressBookExport::showDialog()
{
mAddressee = mAddressBook->findByUid( mMetaContact->kabcId() );
//DEPRECATED: mAddressee = mAddressBook->findByUid( mMetaContact->kabcId() );
if ( !mAddressee.isEmpty() )
{
numEmails = 0;
......@@ -248,29 +249,30 @@ void KopeteAddressBookExport::exportData()
for ( QStringList::Iterator it = newVals.begin(); it != newVals.end(); ++it )
{
dirty = true;
mAddressee.insertPhoneNumber( KABC::PhoneNumber( *it, KABC::PhoneNumber::Home ) );
mAddressee.insertPhoneNumber( KContacts::PhoneNumber( *it, KContacts::PhoneNumber::Home ) );
}
// work phone
newVals = newValues( mWorkPhones, numWorkPhones );
for ( QStringList::Iterator it = newVals.begin(); it != newVals.end(); ++it )
{
dirty = true;
mAddressee.insertPhoneNumber( KABC::PhoneNumber( *it, KABC::PhoneNumber::Work ) );
mAddressee.insertPhoneNumber( KContacts::PhoneNumber( *it, KContacts::PhoneNumber::Work ) );
}
// mobile
newVals = newValues( mMobilePhones, numMobilePhones );
for ( QStringList::Iterator it = newVals.begin(); it != newVals.end(); ++it )
{
dirty = true;
mAddressee.insertPhoneNumber( KABC::PhoneNumber( *it, KABC::PhoneNumber::Cell ) );
mAddressee.insertPhoneNumber( KContacts::PhoneNumber( *it, KContacts::PhoneNumber::Cell ) );
}
if ( dirty )
{
/** DEPRECATED : Skipping addressbook updation for the moment
// write the changed addressbook
mAddressBook->insertAddressee( mAddressee );
KABC::Ticket *ticket = mAddressBook->requestSaveTicket();
KContacts::Ticket *ticket = mAddressBook->requestSaveTicket();
if ( !ticket )
kWarning( 14000 ) << "WARNING: Resource is locked by other application!";
else
......@@ -282,6 +284,7 @@ void KopeteAddressBookExport::exportData()
}
}
kDebug( 14000 ) << "Finished writing KABC";
*/
}
}
......
......@@ -21,8 +21,8 @@
#ifndef KOPETEADDRBOOKEXPORT_H
#define KOPETEADDRBOOKEXPORT_H
#include <kabc/stdaddressbook.h>
#include <kabc/addressee.h>
#include <kcontacts/addressee.h>
#include "kopeteproperty.h"
#include "ui_kopeteaddrbookexportui.h"
......@@ -67,7 +67,7 @@ protected:
/**
* Populate a listbox with a given type of phone number
*/
void fetchPhoneNumbers( QListWidget * listBox, KABC::PhoneNumber::Type type, uint& counter );
void fetchPhoneNumbers( QListWidget * listBox, KContacts::PhoneNumber::Type type, uint& counter );
/**
* Populate the GUI with data from IM systems
*/
......@@ -93,8 +93,8 @@ protected:
QPixmap mAddrBookIcon;
AddressBookExportUI *mUI;
Kopete::MetaContact *mMetaContact;
KABC::AddressBook *mAddressBook;
KABC::Addressee mAddressee;
//DEPRECATED: KContacts::AddressBook *mAddressBook;
KContacts::Addressee mAddressee;
// counters tracking the number of KABC values where multiple values are possible in a single key
uint numEmails, numHomePhones, numWorkPhones, numMobilePhones;
......
......@@ -41,7 +41,7 @@
#include <kmessagebox_queued.h>
#include <KToolInvocation>
#include <kxmlguifactory.h>
#include <kabc/stdaddressbook.h>
#include "kopeteuiglobal.h"
#include "kopetecontactlistelement.h"
......@@ -533,7 +533,8 @@ void KopeteContactListView::sendEmail()
Kopete::MetaContact* metaContact = metaContactFromIndex( currentIndex() );
if ( metaContact )
{
KABC::Addressee addressee = KABC::StdAddressBook::self()->findByUid( metaContact->kabcId() );
//DEPRECATED: KContacts::Addressee addressee = KContacts::StdAddressBook::self()->findByUid( metaContact->kabcId() );
KContacts::Addressee addressee = KContacts::Addressee();
if ( !addressee.isEmpty() )
{
QString emailAddr = addressee.fullEmail();
......
......@@ -46,9 +46,9 @@
#include <KStandardDirs>
#include <KMessageBox>
#include <kmessagebox_queued.h>
#include <kabc/addresseedialog.h>
#include <kabc/stdaddressbook.h>
#include <kabc/addressee.h>
#include <kcontacts/addressee.h>
#include "kabcpersistence.h"
#include "kopeteaddrbookexport.h"
......@@ -212,7 +212,7 @@ KopeteMetaLVIProps::KopeteMetaLVIProps(Kopete::MetaContact *metaContact, QWidget
ui_mainWidget->btnClearPhoto->setIcon( QIcon::fromTheme( (QApplication::layoutDirection() == Qt::RightToLeft) ? "edit-clear-locationbar-ltr" : "edit-clear-locationbar-rtl" ) );
connect( ui_mainWidget->btnClearPhoto, SIGNAL(clicked()), this, SLOT(slotClearPhotoClicked()) );
connect( ui_mainWidget->widAddresseeLink, SIGNAL(addresseeChanged(KABC::Addressee)), SLOT(slotAddresseeChanged(KABC::Addressee)) );
connect( ui_mainWidget->widAddresseeLink, SIGNAL(addresseeChanged(KContacts::Addressee)), SLOT(slotAddresseeChanged(KContacts::Addressee)) );
connect( ui_mainWidget->btnChoosePhoto, SIGNAL(clicked()), this, SLOT(slotSelectPhoto()));
ui_mainWidget->chkUseCustomIcons->setChecked( mMetaContact->useCustomIcon() );
......@@ -245,8 +245,8 @@ KopeteMetaLVIProps::KopeteMetaLVIProps(Kopete::MetaContact *metaContact, QWidget
if ( !mAddressBookUid.isEmpty() )
{
KABC::AddressBook *ab = Kopete::KABCPersistence::self()->addressBook();
KABC::Addressee a = ab->findByUid( mAddressBookUid );
//DEPRECATED: KContacts::AddressBook *ab = Kopete::KABCPersistence::self()->addressBook();
KContacts::Addressee a = KContacts::Addressee();
ui_mainWidget->widAddresseeLink->setAddressee( a );
if ( !a.isEmpty() )
......@@ -381,8 +381,8 @@ void KopeteMetaLVIProps::slotSelectPhoto()
void KopeteMetaLVIProps::slotEnableAndDisableWidgets()
{
KABC::AddressBook *ab = Kopete::KABCPersistence::self()->addressBook();
KABC::Addressee a = ab->findByUid( mAddressBookUid );
//DEPRECATED: KContacts::AddressBook *ab = Kopete::KABCPersistence::self()->addressBook();
KContacts::Addressee a = KContacts::Addressee();
bool validLink = ! a.isEmpty();
// kabc source requires a kabc link
ui_mainWidget->radioNameKABC->setEnabled(validLink);
......@@ -552,7 +552,7 @@ void KopeteMetaLVIProps::slotUseCustomIconsToggled(bool on)
ui_mainWidget->icnbUnknown->setEnabled( on );
}
void KopeteMetaLVIProps::slotAddresseeChanged( const KABC::Addressee & a )
void KopeteMetaLVIProps::slotAddresseeChanged( const KContacts::Addressee & a )
{
if ( !a.isEmpty() )
{
......
......@@ -21,7 +21,7 @@
#define KOPETELVIPROPS_H
#include <kdialog.h>
#include <kabc/sound.h>
#include <kcontacts/sound.h>
#include "kopetemetacontact.h"
......@@ -33,7 +33,7 @@ class CustomNotificationProps;
class KopeteAddressBookExport;
class KUrlRequester;
namespace KABC { class Addressee; }
namespace KContacts { class Addressee; }
namespace Kopete {
class Contact;
class Group;
......@@ -77,7 +77,7 @@ class KopeteMetaLVIProps: public KDialog
AddressBookLinkWidget *linkWidget;
Kopete::MetaContact *mMetaContact;
KopeteAddressBookExport *mExport;
KABC::Sound mSound;
KContacts::Sound mSound;
int m_countPhotoCapable;
QMap<int, Kopete::Contact *> m_withPhotoContacts;
QString mAddressBookUid; // the currently selected addressbook UID
......@@ -93,7 +93,7 @@ class KopeteMetaLVIProps: public KDialog
void slotOkClicked();
void slotUseCustomIconsToggled( bool on );
void slotClearPhotoClicked();
void slotAddresseeChanged( const KABC::Addressee & );
void slotAddresseeChanged( const KContacts::Addressee & );
void slotExportClicked();
void slotImportClicked();
void slotFromKABCClicked();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment