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