summaryrefslogtreecommitdiffabout
path: root/libkabcwrap/addresseedialog.cpp
Unidiff
Diffstat (limited to 'libkabcwrap/addresseedialog.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkabcwrap/addresseedialog.cpp69
1 files changed, 69 insertions, 0 deletions
diff --git a/libkabcwrap/addresseedialog.cpp b/libkabcwrap/addresseedialog.cpp
new file mode 100644
index 0000000..e0fe354
--- a/dev/null
+++ b/libkabcwrap/addresseedialog.cpp
@@ -0,0 +1,69 @@
1#include <qlistview.h>
2#include <qmessagebox.h>
3#include <qapplication.h>
4#include "addresseedialog.h"
5#include "select_addressee_base.h"
6
7using namespace KABC;
8
9Addressee AddresseeDialog::getAddressee( QWidget *parent ) {
10
11 Addressee result;
12 if (!getInterface()) {
13 QMessageBox::warning(parent,"Plugin missing", "Plugins for Qtopia/Opie\naddressbook missing.\nPlease install\nlibqtopiakabc.so/libopiekabc.so\nunder $QPEDIR/plugins/korganizer.\nQtopia-plugin needs libqpepim.", 0L );
14 } else {
15
16 // qDebug("Start: AddresseeDialog::getAddressee");
17
18 Addressee::List list = getAddresseesFromPlugin();
19
20 SelectAddressee *selAddressee = new SelectAddressee(parent,"SelectAddressee", true);
21 QListView *contactList = selAddressee->contactList;
22 contactList->setSelectionMode(QListView::Single);
23 if (!contactList) {
24 Addressee emptyAddressee;
25 return emptyAddressee;
26 }
27
28 for (uint i=0; i < list.count(); i++) {
29 Addressee a = list[i];
30 QString fullName = a.formattedName();
31 QString defaultEmail = a.preferredEmail();
32 //qDebug("Adding " + fullName);
33 QListViewItem *item = new QListViewItem(contactList, fullName, defaultEmail);
34 }
35 if ( QApplication::desktop()->width() < 480 ) {
36 selAddressee->setMinimumWidth( 220 );
37 } else {
38 selAddressee->setMinimumWidth( 440 );
39 }
40 if (selAddressee->exec()) {
41 QListViewItem *selectedItem = contactList->selectedItem();
42 if (selectedItem) {
43 uint i=0;
44 for (i=0; i < list.count() && (list[i].formattedName() != selectedItem->text(0)); i++);
45 if (i<list.count()) {
46 result = list[i];
47 }
48 }
49 }
50 delete selAddressee;
51 //qDebug("End: AddresseeDialog::getAddressee");
52}
53 return result;
54
55}
56
57Addressee::List AddresseeDialog::getAddressees( QWidget *parent ) {
58 //qDebug("Start: AddresseeDialog::getAddressees");
59
60 KOAddressBookInterface *iface = getInterface();
61
62 Addressee::List results;
63 if (iface) {
64 Addressee a = getAddressee(parent);
65 results.append(a);
66 }
67 //qDebug("End: AddresseeDialog::getAddressees");
68 return results;
69}