summaryrefslogtreecommitdiff
path: root/noncore/net/mail/addresspicker.cpp
Unidiff
Diffstat (limited to 'noncore/net/mail/addresspicker.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/addresspicker.cpp120
1 files changed, 67 insertions, 53 deletions
diff --git a/noncore/net/mail/addresspicker.cpp b/noncore/net/mail/addresspicker.cpp
index f4f4cea..8cdabde 100644
--- a/noncore/net/mail/addresspicker.cpp
+++ b/noncore/net/mail/addresspicker.cpp
@@ -1,100 +1,114 @@
1
2#include "composemail.h"
3
4/* OPIE */
5#include <opie2/ocontactaccess.h>
6#include <opie2/ocontact.h>
7#include <qpe/resource.h>
8#include <qpe/qpeapplication.h>
9
10/* QT */
1#include <qpushbutton.h> 11#include <qpushbutton.h>
2#include <qmessagebox.h> 12#include <qmessagebox.h>
3#include <qtextstream.h> 13#include <qtextstream.h>
4#include <qlistbox.h> 14#include <qlistbox.h>
5#include <qfile.h> 15#include <qfile.h>
6 16
7#include <qpe/resource.h> 17/* STD */
8#include <opie2/ocontactaccess.h>
9#include <opie2/ocontact.h>
10
11
12#include <stdlib.h> 18#include <stdlib.h>
13 19
14#include "composemail.h" 20AddressPicker::AddressPicker( QWidget *parent, const char *name, bool modal, WFlags flags )
15 21 : AddressPickerUI( parent, name, modal, flags )
16AddressPicker::AddressPicker( QWidget *parent, const char *name, bool modal, WFlags flags )
17 : AddressPickerUI( parent, name, modal, flags )
18{ 22{
19 okButton->setIconSet( Resource::loadPixmap( "enter" ) ); 23 okButton->setIconSet( Resource::loadPixmap( "enter" ) );
20 cancelButton->setIconSet( Resource::loadPixmap( "editdelete" ) ); 24 cancelButton->setIconSet( Resource::loadPixmap( "editdelete" ) );
21 25
22 connect(okButton, SIGNAL(clicked()), SLOT(accept())); 26 connect(okButton, SIGNAL(clicked()), SLOT(accept()));
23 connect(cancelButton, SIGNAL(clicked()), SLOT(close())); 27 connect(cancelButton, SIGNAL(clicked()), SLOT(close()));
24 Opie::OContactAccess::List::Iterator it; 28 Opie::OContactAccess::List::Iterator it;
25 29
26 QString lineEmail, lineName, contactLine; 30 QString lineEmail, lineName, contactLine;
27 /* what name has to set here???? */ 31 /* what name has to set here???? */
28 Opie::OContactAccess m_contactdb("opiemail"); 32 Opie::OContactAccess m_contactdb("opiemail");
29 33
30 QStringList mails; 34 QStringList mails;
31 QString pre,suf; 35 QString pre,suf;
32 Opie::OContactAccess::List m_list = m_contactdb.sorted( true, 0, 0, 0 ); 36 Opie::OContactAccess::List m_list = m_contactdb.sorted( true, 0, 0, 0 );
33 for ( it = m_list.begin(); it != m_list.end(); ++it ) { 37 for ( it = m_list.begin(); it != m_list.end(); ++it )
34 if ((*it).defaultEmail().length()!=0) { 38 {
39 if ((*it).defaultEmail().length()!=0)
40 {
35 mails = (*it).emailList(); 41 mails = (*it).emailList();
36 if ((*it).fileAs().length()>0) { 42 if ((*it).fileAs().length()>0)
43 {
37 pre = "\""+(*it).firstName()+" "+(*it).lastName()+"\" <"; 44 pre = "\""+(*it).firstName()+" "+(*it).lastName()+"\" <";
38 suf = ">"; 45 suf = ">";
39 } else { 46 }
47 else
48 {
40 pre = ""; 49 pre = "";
41 suf = ""; 50 suf = "";
42 } 51 }
43 QStringList::ConstIterator sit = mails.begin(); 52 QStringList::ConstIterator sit = mails.begin();
44 for (;sit!=mails.end();++sit) { 53 for (;sit!=mails.end();++sit)
54 {
45 contactLine=pre+(*sit)+suf; 55 contactLine=pre+(*sit)+suf;
46 addressList->insertItem(contactLine); 56 addressList->insertItem(contactLine);
47 } 57 }
48 } 58 }
49 } 59 }
50 if ( addressList->count() <= 0 ) { 60 if ( addressList->count() <= 0 )
61 {
51#if 0 62#if 0
52 // makes this realy sense?? 63 // makes this realy sense??
53 addressList->insertItem( 64 addressList->insertItem(
54 tr( "There are no entries in the addressbook." ) ); 65 tr( "There are no entries in the addressbook." ) );
55#endif 66#endif
56 addressList->setEnabled( false ); 67 addressList->setEnabled( false );
57 okButton->setEnabled( false ); 68 okButton->setEnabled( false );
58 } else { 69 }
59// addressList->sort(); 70 else
71 {
72 // addressList->sort();
60 } 73 }
61} 74}
62 75
63void AddressPicker::accept() 76void AddressPicker::accept()
64{ 77{
65 QListBoxItem *item = addressList->firstItem(); 78 QListBoxItem *item = addressList->firstItem();
66 QString names; 79 QString names;
67 80
68 while ( item ) { 81 while ( item )
69 if ( item->selected() ) 82 {
70 names += item->text() + ", "; 83 if ( item->selected() )
71 item = item->next(); 84 names += item->text() + ", ";
72 } 85 item = item->next();
73 names.replace( names.length() - 2, 2, "" ); 86 }
74 87 names.replace( names.length() - 2, 2, "" );
75 if ( names.isEmpty() ) { 88
76 QMessageBox::information(this, tr("Error"), tr("<p>You have to select" 89 if ( names.isEmpty() )
77 " at least one address entry.</p>"), tr("Ok")); 90 {
78 return; 91 QMessageBox::information(this, tr("Error"), tr("<p>You have to select"
79 } 92 " at least one address entry.</p>"), tr("Ok"));
80 93 return;
81 selectedNames = names; 94 }
82 QDialog::accept(); 95
96 selectedNames = names;
97 QDialog::accept();
83} 98}
84 99
85QString AddressPicker::getNames() 100QString AddressPicker::getNames()
86{ 101{
87 QString names = 0; 102 QString names = 0;
88 103
89 AddressPicker picker(0, 0, true); 104 AddressPicker picker(0, 0, true);
90 picker.showMaximized(); 105
91 picker.show(); 106 int ret = QPEApplication::execDialog( &picker );
92 107 if ( QDialog::Accepted == ret )
93 int ret = picker.exec(); 108 {
94 if ( QDialog::Accepted == ret ) { 109 return picker.selectedNames;
95 return picker.selectedNames; 110 }
96 } 111
97 112 return 0;
98 return 0;
99} 113}
100 114