author | zautrix <zautrix> | 2004-07-03 23:38:18 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-07-03 23:38:18 (UTC) |
commit | 260befadfaa64d94de7d38d7f6cad0d22f52c226 (patch) (side-by-side diff) | |
tree | 96923d1ac1304e8f07028941e830437465bb9558 | |
parent | 00fe3539778c859d22f595e516733b3cc792e167 (diff) | |
download | kdepimpi-260befadfaa64d94de7d38d7f6cad0d22f52c226.zip kdepimpi-260befadfaa64d94de7d38d7f6cad0d22f52c226.tar.gz kdepimpi-260befadfaa64d94de7d38d7f6cad0d22f52c226.tar.bz2 |
fixed distribution lists
-rw-r--r-- | kabc/distributionlist.cpp | 32 | ||||
-rw-r--r-- | kabc/distributionlisteditor.cpp | 1 |
2 files changed, 20 insertions, 13 deletions
diff --git a/kabc/distributionlist.cpp b/kabc/distributionlist.cpp index 45b9dda..0735aba 100644 --- a/kabc/distributionlist.cpp +++ b/kabc/distributionlist.cpp @@ -45,29 +45,31 @@ void DistributionList::setName( const QString &name ) QString DistributionList::name() const { return mName; } void DistributionList::insertEntry( const Addressee &a, const QString &email ) { - Entry e( a, email ); - + QString em = email; + if (em.isNull() ) + em = a.preferredEmail(); + Entry e( a, em ); QValueList<Entry>::Iterator it; for( it = mEntries.begin(); it != mEntries.end(); ++it ) { if ( (*it).addressee.uid() == a.uid() ) { /** We have to check if both email addresses contains no data, a simple 'email1 == email2' wont work here */ - if ( ( (*it).email.isNull() && email.isEmpty() ) || - ( (*it).email.isEmpty() && email.isNull() ) || - ( (*it).email == email ) ) { - *it = e; + if ( ( (*it).email.isNull() && em.isEmpty() ) || + ( (*it).email.isEmpty() && em.isNull() ) || + ( (*it).email == em ) ) { + //*it = e; return; } } } mEntries.append( e ); } void DistributionList::removeEntry( const Addressee &a, const QString &email ) @@ -173,82 +175,86 @@ bool DistributionListManager::load() cfg.setGroup( mAddressBook->identifier() ); QMap<QString,QString>::ConstIterator it; for( it = entryMap.begin(); it != entryMap.end(); ++it ) { QString name = it.key(); */ cfg.setGroup( mAddressBook->identifier() ); //US we work in microkde with a list of distributionlists - QStringList distlists = cfg.readListEntry( "Lists" ); + QStringList distlists = cfg.readListEntry( "__Lists__List__" ); if ( distlists.isEmpty() ) { - kdDebug(5700) << "No distlists for '" << mAddressBook->identifier() << "'" << endl; + qDebug("no distlist for AB "); return false; } QStringList::ConstIterator it; for( it = distlists.begin(); it != distlists.end(); ++it ) { QString name = *it; QStringList value = cfg.readListEntry( name ); - kdDebug(5700) << "DLM::load(): " << name << ": " << value.join(",") << endl; + DistributionList *list = new DistributionList( this, name ); QStringList::ConstIterator it2 = value.begin(); while( it2 != value.end() ) { QString id = *it2++; QString email = *it2; - kdDebug(5700) << "----- Entry " << id << endl; + Addressee a = mAddressBook->findByUid( id ); if ( !a.isEmpty() ) { list->insertEntry( a, email ); } if ( it2 == value.end() ) break; ++it2; } } return true; } bool DistributionListManager::save() { - kdDebug(5700) << "DistListManager::save()" << endl; + KSimpleConfig cfg( locateLocal( "data", "kabc/distlists" ) ); cfg.deleteGroup( mAddressBook->identifier() ); cfg.setGroup( mAddressBook->identifier() ); DistributionList *list; for( list = mLists.first(); list; list = mLists.next() ) { kdDebug(5700) << " Saving '" << list->name() << "'" << endl; QStringList value; DistributionList::Entry::List entries = list->entries(); DistributionList::Entry::List::ConstIterator it; for( it = entries.begin(); it != entries.end(); ++it ) { value.append( (*it).addressee.uid() ); - value.append( (*it).email ); + if (( *it).email.isEmpty()) + value.append( " " ); + else + value.append( (*it).email ); + // qDebug("uid *%s* email *%s* ", (*it).addressee.uid().latin1(),(*it).email.latin1() ); } cfg.writeEntry( list->name(), value ); } //US for microKDE we have not yet sophisticated methods to load maps. // Because of that we store also a list of all distributionlists. QStringList namelist; for( list = mLists.first(); list; list = mLists.next() ) { namelist.append( list->name() ); } - cfg.writeEntry( "Lists", namelist ); + cfg.writeEntry( "__Lists__List__", namelist ); cfg.sync(); diff --git a/kabc/distributionlisteditor.cpp b/kabc/distributionlisteditor.cpp index 8b485d8..bad1efc 100644 --- a/kabc/distributionlisteditor.cpp +++ b/kabc/distributionlisteditor.cpp @@ -65,16 +65,17 @@ QString EmailSelectDialog::selected() QButton *button = mButtonGroup->selected(); if ( button ) return button->text(); return QString::null; } QString EmailSelectDialog::getEmail( const QStringList &emails, const QString ¤t, QWidget *parent ) { + EmailSelectDialog *dlg = new EmailSelectDialog( emails, current, parent ); dlg->exec(); QString result = dlg->selected(); delete dlg; return result; |