summaryrefslogtreecommitdiff
path: root/noncore
authoralwin <alwin>2003-12-25 15:13:40 (UTC)
committer alwin <alwin>2003-12-25 15:13:40 (UTC)
commit67d7f0b0fc79377fba216e556785f6c630c437ad (patch) (unidiff)
treeda9f4140c086c1e6e6cd8e79cfddabcba3b56671 /noncore
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 (limited to 'noncore') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/addresspicker.cpp103
1 files changed, 36 insertions, 67 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
@@ -5,6 +5,9 @@
5#include <qfile.h> 5#include <qfile.h>
6 6
7#include <qpe/resource.h> 7#include <qpe/resource.h>
8#include <opie/ocontactaccess.h>
9#include <opie/ocontact.h>
10
8 11
9#include <stdlib.h> 12#include <stdlib.h>
10 13
@@ -13,81 +16,47 @@
13AddressPicker::AddressPicker( QWidget *parent, const char *name, bool modal, WFlags flags ) 16AddressPicker::AddressPicker( QWidget *parent, const char *name, bool modal, WFlags flags )
14 : AddressPickerUI( parent, name, modal, flags ) 17 : AddressPickerUI( parent, name, modal, flags )
15{ 18{
16 okButton->setIconSet( Resource::loadPixmap( "enter" ) ); 19 okButton->setIconSet( Resource::loadPixmap( "enter" ) );
17 cancelButton->setIconSet( Resource::loadPixmap( "editdelete" ) ); 20 cancelButton->setIconSet( Resource::loadPixmap( "editdelete" ) );
18
19 connect(okButton, SIGNAL(clicked()), SLOT(accept()));
20 connect(cancelButton, SIGNAL(clicked()), SLOT(close()));
21 21
22 QFile f((QString) getenv("HOME") + "/Applications/" 22 connect(okButton, SIGNAL(clicked()), SLOT(accept()));
23 + "addressbook/addressbook.xml"); 23 connect(cancelButton, SIGNAL(clicked()), SLOT(close()));
24 OContactAccess::List::Iterator it;
24 25
25 if ( f.open( IO_ReadOnly ) ) { 26 QString lineEmail, lineName, contactLine;
26 QTextStream stream( &f ); 27 /* what name has to set here???? */
27 stream.setEncoding( QTextStream::UnicodeUTF8 ); 28 OContactAccess m_contactdb("addressbook");
28 QString content; 29 QStringList mails;
29 while ( !f.atEnd() ) { 30 QString pre,suf;
30 content += stream.readLine() + "\n"; 31 OContactAccess::List m_list = m_contactdb.sorted( true, 0, 0, 0 );
32 for ( it = m_list.begin(); it != m_list.end(); ++it ) {
33 if ((*it).defaultEmail().length()!=0) {
34 mails = (*it).emailList();
35 if ((*it).fileAs().length()>0) {
36 pre = "\""+(*it).fileAs()+"\" <";
37 suf = ">";
38 } else {
39 pre = "";
40 suf = "";
41 }
42 QStringList::ConstIterator sit = mails.begin();
43 for (;sit!=mails.end();++sit) {
44 contactLine=pre+(*sit)+suf;
45 addressList->insertItem(contactLine);
46 }
31 } 47 }
32 QStringList lines = QStringList::split( QRegExp( "\\n" ), content ); 48 }
33 QStringList::Iterator it;
34 for ( it = lines.begin(); it != lines.end(); it++ ) {
35 if ( (*it).find( QRegExp( "^<Contact.*" ) ) != -1 ) {
36 int pos = (*it).find( "FirstName=\"" );
37 QString fname;
38 if ( pos != -1 ) {
39 int i = 1;
40 QChar c;
41 while ( c != '"' ) {
42 c = (*it)[pos + 10 + i];
43 if ( c != '"' ) fname += c;
44 i++;
45 }
46 }
47 pos = (*it).find( "LastName=\"" );
48 QString lname;
49 if ( pos != -1 ) {
50 int i = 1;
51 QChar c;
52 while ( c != '"' ) {
53 c = (*it)[pos + 9 + i];
54 if ( c != '"' ) lname += c;
55 i++;
56 }
57 }
58 pos = (*it).find( "DefaultEmail=\"" );
59 QString email;
60 if ( pos != -1 ) {
61 int i = 1;
62 QChar c;
63 while ( c != '"' ) {
64 c = (*it)[pos + 13 + i];
65 if ( c != '"' ) email += c;
66 i++;
67 }
68 }
69 QString tname, temail;
70 if ( !fname.isEmpty() ) {
71 tname += fname;
72 }
73 if ( !lname.isEmpty() ) {
74 tname += fname.isEmpty() ? lname : (" " + lname);
75 }
76 if ( !email.isEmpty() ) {
77 temail += tname.isEmpty() ? email : (" <" + email + ">");
78 }
79 if ( !email.isEmpty() ) {
80 addressList->insertItem( tname + temail );
81 }
82 }
83 }
84 }
85 if ( addressList->count() <= 0 ) { 49 if ( addressList->count() <= 0 ) {
50#if 0
51 // makes this realy sense??
86 addressList->insertItem( 52 addressList->insertItem(
87 tr( "There are no entries in the addressbook." ) ); 53 tr( "There are no entries in the addressbook." ) );
54#endif
88 addressList->setEnabled( false ); 55 addressList->setEnabled( false );
89 okButton->setEnabled( false ); 56 okButton->setEnabled( false );
90 } 57 } else {
58// addressList->sort();
59 }
91} 60}
92 61
93void AddressPicker::accept() 62void AddressPicker::accept()