23 #include "kmaddrbook.h"
24 #include "kcursorsaver.h"
26 #include <tdeapplication.h>
28 #include <tdelocale.h>
29 #include <tdemessagebox.h>
30 #include <tdeabc/stdaddressbook.h>
31 #include <tdeabc/distributionlist.h>
36 void KabcBridge::addresses(TQStringList& result)
40 TDEABC::AddressBook *addressBook = TDEABC::StdAddressBook::self(
true );
41 TDEABC::AddressBook::ConstIterator it;
42 for( it = addressBook->begin(); it != addressBook->end(); ++it ) {
43 const TQStringList emails = (*it).emails();
44 TQString n = (*it).prefix() +
" " +
45 (*it).givenName() +
" " +
46 (*it).additionalName() +
" " +
47 (*it).familyName() +
" " +
49 n = n.simplifyWhiteSpace();
51 TQRegExp needQuotes(
"[^ 0-9A-Za-z\\x0080-\\xFFFF]");
52 TQString endQuote =
"\" ";
53 TQStringList::ConstIterator mit;
56 for ( mit = emails.begin(); mit != emails.end(); ++mit ) {
58 if (!email.isEmpty()) {
59 if (n.isEmpty() || (email.find(
'<' ) != -1))
62 if (n.find(needQuotes) != -1)
63 addr =
'"' + n + endQuote;
68 if (!addr.isEmpty() && (email.find(
'<' ) == -1)
69 && (email.find(
'>' ) == -1)
70 && (email.find(
',' ) == -1))
71 addr +=
'<' + email +
'>';
74 addr = addr.stripWhiteSpace();
75 result.append( addr );
79 TDEABC::DistributionListManager manager( addressBook );
81 result += manager.listNames();
86 TQStringList KabcBridge::addresses()
89 TDEABC::AddressBook::ConstIterator it;
91 const TDEABC::AddressBook *addressBook = TDEABC::StdAddressBook::self(
true );
92 for( it = addressBook->begin(); it != addressBook->end(); ++it ) {
93 entries += (*it).fullEmail();
99 TQString KabcBridge::expandNickName(
const TQString& nickName )
101 if ( nickName.isEmpty() )
104 const TQString lowerNickName = nickName.lower();
105 const TDEABC::AddressBook *addressBook = TDEABC::StdAddressBook::self(
true );
106 for( TDEABC::AddressBook::ConstIterator it = addressBook->begin();
107 it != addressBook->end(); ++it ) {
108 if ( (*it).nickName().lower() == lowerNickName )
109 return (*it).fullEmail();
117 TQStringList KabcBridge::categories()
119 TDEABC::AddressBook *addressBook = TDEABC::StdAddressBook::self(
true );
120 TDEABC::Addressee::List addresses = addressBook->allAddressees();
121 TQStringList allcategories, aux;
123 for ( TDEABC::Addressee::List::Iterator it = addresses.begin();
124 it != addresses.end(); ++it ) {
125 aux = ( *it ).categories();
126 for ( TQStringList::ConstIterator itAux = aux.begin();
127 itAux != aux.end(); ++itAux ) {
129 if ( allcategories.find( *itAux ) == allcategories.end() )
130 allcategories += *itAux;
133 return allcategories;
sets a cursor and makes sure it's restored on destruction Create a KCursorSaver object when you want ...