summaryrefslogtreecommitdiff
authoralwin <alwin>2003-12-25 15:13:40 (UTC)
committer alwin <alwin>2003-12-25 15:13:40 (UTC)
commit67d7f0b0fc79377fba216e556785f6c630c437ad (patch) (side-by-side diff)
treeda9f4140c086c1e6e6cd8e79cfddabcba3b56671
parent25ee009ceeda1a175c4604bf5afe5434e52ee838 (diff)
downloadopie-67d7f0b0fc79377fba216e556785f6c630c437ad.zip
opie-67d7f0b0fc79377fba216e556785f6c630c437ad.tar.gz
opie-67d7f0b0fc79377fba216e556785f6c630c437ad.tar.bz2
uses the opie frontend for the list of addresses
displays not just the default email but all emails display is sorted now
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/net/mail/addresspicker.cpp91
1 files changed, 30 insertions, 61 deletions
diff --git a/noncore/net/mail/addresspicker.cpp b/noncore/net/mail/addresspicker.cpp
index 2c15bb4..581de62 100644
--- a/noncore/net/mail/addresspicker.cpp
+++ b/noncore/net/mail/addresspicker.cpp
@@ -7,2 +7,5 @@
#include <qpe/resource.h>
+#include <opie/ocontactaccess.h>
+#include <opie/ocontact.h>
+
@@ -20,63 +23,24 @@ AddressPicker::AddressPicker( QWidget *parent, const char *name, bool modal, WFl
connect(cancelButton, SIGNAL(clicked()), SLOT(close()));
-
- QFile f((QString) getenv("HOME") + "/Applications/"
- + "addressbook/addressbook.xml");
-
- if ( f.open( IO_ReadOnly ) ) {
- QTextStream stream( &f );
- stream.setEncoding( QTextStream::UnicodeUTF8 );
- QString content;
- while ( !f.atEnd() ) {
- content += stream.readLine() + "\n";
- }
- QStringList lines = QStringList::split( QRegExp( "\\n" ), content );
- QStringList::Iterator it;
- for ( it = lines.begin(); it != lines.end(); it++ ) {
- if ( (*it).find( QRegExp( "^<Contact.*" ) ) != -1 ) {
- int pos = (*it).find( "FirstName=\"" );
- QString fname;
- if ( pos != -1 ) {
- int i = 1;
- QChar c;
- while ( c != '"' ) {
- c = (*it)[pos + 10 + i];
- if ( c != '"' ) fname += c;
- i++;
- }
- }
- pos = (*it).find( "LastName=\"" );
- QString lname;
- if ( pos != -1 ) {
- int i = 1;
- QChar c;
- while ( c != '"' ) {
- c = (*it)[pos + 9 + i];
- if ( c != '"' ) lname += c;
- i++;
- }
- }
- pos = (*it).find( "DefaultEmail=\"" );
- QString email;
- if ( pos != -1 ) {
- int i = 1;
- QChar c;
- while ( c != '"' ) {
- c = (*it)[pos + 13 + i];
- if ( c != '"' ) email += c;
- i++;
- }
- }
- QString tname, temail;
- if ( !fname.isEmpty() ) {
- tname += fname;
- }
- if ( !lname.isEmpty() ) {
- tname += fname.isEmpty() ? lname : (" " + lname);
- }
- if ( !email.isEmpty() ) {
- temail += tname.isEmpty() ? email : (" <" + email + ">");
- }
- if ( !email.isEmpty() ) {
- addressList->insertItem( tname + temail );
- }
+ OContactAccess::List::Iterator it;
+
+ QString lineEmail, lineName, contactLine;
+ /* what name has to set here???? */
+ OContactAccess m_contactdb("addressbook");
+ QStringList mails;
+ QString pre,suf;
+ OContactAccess::List m_list = m_contactdb.sorted( true, 0, 0, 0 );
+ for ( it = m_list.begin(); it != m_list.end(); ++it ) {
+ if ((*it).defaultEmail().length()!=0) {
+ mails = (*it).emailList();
+ if ((*it).fileAs().length()>0) {
+ pre = "\""+(*it).fileAs()+"\" <";
+ suf = ">";
+ } else {
+ pre = "";
+ suf = "";
+ }
+ QStringList::ConstIterator sit = mails.begin();
+ for (;sit!=mails.end();++sit) {
+ contactLine=pre+(*sit)+suf;
+ addressList->insertItem(contactLine);
}
@@ -85,6 +49,11 @@ AddressPicker::AddressPicker( QWidget *parent, const char *name, bool modal, WFl
if ( addressList->count() <= 0 ) {
+#if 0
+ // makes this realy sense??
addressList->insertItem(
tr( "There are no entries in the addressbook." ) );
+#endif
addressList->setEnabled( false );
okButton->setEnabled( false );
+ } else {
+// addressList->sort();
}