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 /kaddressbook | |
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 @@ -272,48 +272,49 @@ KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const SLOT( executeContact( const QString& ) ) ); connect( mViewManager, SIGNAL( deleteRequest( ) ), SLOT( deleteContacts( ) ) ); connect( mViewManager, SIGNAL( modified() ), SLOT( setModified() ) ); connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); connect( mXXPortManager, SIGNAL( modified() ), SLOT( setModified() ) ); connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), SLOT( incrementalSearch( const QString& ) ) ); connect( mIncSearchWidget, SIGNAL( fieldChanged() ), mJumpButtonBar, SLOT( recreateButtons() ) ); connect( mDetails, SIGNAL( sendEmail( const QString& ) ), SLOT( sendMail( const QString& ) ) ); 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&))); #ifndef KAB_EMBEDDED connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), mXXPortManager, SLOT( importVCard( const KURL& ) ) ); connect( mDetails, SIGNAL( browse( const QString& ) ), SLOT( browse( const QString& ) ) ); mAddressBookService = new KAddressBookService( this ); #endif //KAB_EMBEDDED mEditorDialog = 0; createAddresseeEditorDialog( this ); setModified( false ); } KABCore::~KABCore() { // save(); //saveSettings(); //KABPrefs::instance()->writeConfig(); delete AddresseeConfig::instance(); @@ -2134,48 +2135,116 @@ void KABCore::configureResources() /* this method will be called through the QCop interface from Ko/Pi to select addresses * for the attendees list of an event. */ void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) { QStringList nameList; QStringList emailList; QStringList uidList; KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); uint i=0; for (i=0; i < list.count(); i++) { nameList.append(list[i].realName()); emailList.append(list[i].preferredEmail()); uidList.append(list[i].uid()); } bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); } +/* 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. */ void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) { qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); QString foundUid = QString::null; if ( ! uid.isEmpty() ) { Addressee adrr = mAddressBook->findByUid( uid ); if ( !adrr.isEmpty() ) { foundUid = uid; } if ( email == "sendbacklist" ) { //qDebug("ssssssssssssssssssssssend "); QStringList nameList; QStringList emailList; QStringList uidList; nameList.append(adrr.realName()); emailList = adrr.emails(); uidList.append( adrr.preferredEmail()); bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); return; } diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h index e6f286b..c9c0d38 100644 --- a/kaddressbook/kabcore.h +++ b/kaddressbook/kabcore.h @@ -314,48 +314,49 @@ class KABCore : public QWidget, public KSyncInterface /** Launches the configuration dialog. */ void openConfigDialog(); /** Launches the ldap search dialog. */ void openLDAPDialog(); /** Creates a KAddressBookPrinter, which will display the print dialog and do the printing. */ void print(); /** Registers a new GUI client, so plugins can register its actions. */ void addGUIClient( KXMLGUIClient *client ); 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); signals: void contactSelected( const QString &name ); void contactSelected( const QPixmap &pixmap ); public slots: void setDetailsVisible( bool visible ); void setDetailsToState(); // void slotSyncMenu( int ); private slots: void setJumpButtonBarVisible( bool visible ); void importFromOL(); void extensionModified( const KABC::Addressee::List &list ); void extensionChanged( int id ); void clipboardDataChanged(); void updateActionMenu(); void configureKeyBindings(); void removeVoice(); #ifdef KAB_EMBEDDED void configureResources(); #endif //KAB_EMBEDDED void slotEditorDestroyed( const QString &uid ); void configurationChanged(); |