author | ulf69 <ulf69> | 2004-10-07 01:10:30 (UTC) |
---|---|---|
committer | ulf69 <ulf69> | 2004-10-07 01:10:30 (UTC) |
commit | f434ef382b60c1a420dd0e037d119d082e478491 (patch) (side-by-side diff) | |
tree | c68247486b6f714d0d8e01d8b503a4d36c9325e3 | |
parent | 3338b7239dc2e5cdff95ebc76b6905e6385a5833 (diff) | |
download | kdepimpi-f434ef382b60c1a420dd0e037d119d082e478491.zip kdepimpi-f434ef382b60c1a420dd0e037d119d082e478491.tar.gz kdepimpi-f434ef382b60c1a420dd0e037d119d082e478491.tar.bz2 |
added methods to collect birthday data via QCop (from kopi)
-rw-r--r-- | kaddressbook/kabcore.cpp | 69 | ||||
-rw-r--r-- | kaddressbook/kabcore.h | 1 |
2 files changed, 70 insertions, 0 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index 9041e45..d9eb391 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp @@ -294,4 +294,5 @@ KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&))); + connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&))); @@ -2156,4 +2157,72 @@ void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QSt } +/* this method will be called through the QCop interface from Ko/Pi to select birthdays + * to put them into the calendar. + */ +void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) +{ + // qDebug("KABCore::requestForBirthdayList"); + QStringList birthdayList; + QStringList anniversaryList; + QStringList realNameList; + QStringList preferredEmailList; + QStringList assembledNameList; + QStringList uidList; + + KABC::AddressBook::Iterator it; + + int count = 0; + for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { + ++count; + } + QProgressBar bar(count,0 ); + int w = 300; + if ( QApplication::desktop()->width() < 320 ) + w = 220; + int h = bar.sizeHint().height() ; + int dw = QApplication::desktop()->width(); + int dh = QApplication::desktop()->height(); + bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); + bar.show(); + bar.setCaption (i18n("collecting birthdays - close to abort!") ); + qApp->processEvents(); + + QDate bday; + QString anni; + QString formattedbday; + + for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) + { + if ( ! bar.isVisible() ) + return; + bar.setProgress( count++ ); + qApp->processEvents(); + bday = (*it).birthday().date(); + anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); + + if ( bday.isValid() || !anni.isEmpty()) + { + if (bday.isValid()) + formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); + else + formattedbday = "NOTVALID"; + if (anni.isEmpty()) + anni = "INVALID"; + + birthdayList.append(formattedbday); + anniversaryList.append(anni); //should be ISODate + realNameList.append((*it).realName()); + preferredEmailList.append((*it).preferredEmail()); + assembledNameList.append((*it).assembledName()); + uidList.append((*it).uid()); + + qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() ); + } + } + + bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); + +} + /* this method will be called through the QCop interface from other apps to show details of a contact. */ diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h index e6f286b..c9c0d38 100644 --- a/kaddressbook/kabcore.h +++ b/kaddressbook/kabcore.h @@ -336,4 +336,5 @@ class KABCore : public QWidget, public KSyncInterface void requestForNameEmailUidList(const QString& sourceChannel, const QString& sessionuid); void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid); + void requestForBirthdayList(const QString& sourceChannel, const QString& sessionuid); |