summaryrefslogtreecommitdiffabout
path: root/kmicromail/addresspicker.cpp
authorzautrix <zautrix>2004-07-03 16:33:12 (UTC)
committer zautrix <zautrix>2004-07-03 16:33:12 (UTC)
commite3b89230f065c48c84b48c88edb6eb088374c487 (patch) (side-by-side diff)
tree162ea2ef909a6f82ccfcedf45d80d6c821174912 /kmicromail/addresspicker.cpp
parent2dd6ac0b2d24c91d35ce674a6c26351352df2b15 (diff)
downloadkdepimpi-e3b89230f065c48c84b48c88edb6eb088374c487.zip
kdepimpi-e3b89230f065c48c84b48c88edb6eb088374c487.tar.gz
kdepimpi-e3b89230f065c48c84b48c88edb6eb088374c487.tar.bz2
Initial revision
Diffstat (limited to 'kmicromail/addresspicker.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/addresspicker.cpp116
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 @@
+
+#include "composemail.h"
+
+/* OPIE */
+//#include <opie2/ocontactaccess.h>
+//#include <opie2/opimcontact.h>
+#include <qpe/resource.h>
+#include <qpe/qpeapplication.h>
+
+/* QT */
+#include <qpushbutton.h>
+#include <qmessagebox.h>
+#include <qlistbox.h>
+
+/* STD */
+#include <stdlib.h>
+
+AddressPicker::AddressPicker( QWidget *parent, const char *name, bool modal, WFlags flags )
+ : AddressPickerUI( parent, name, modal, flags )
+{
+ okButton->setIconSet( Resource::loadPixmap( "enter" ) );
+ cancelButton->setIconSet( Resource::loadPixmap( "editdelete" ) );
+
+ connect(okButton, SIGNAL(clicked()), SLOT(accept()));
+ connect(cancelButton, SIGNAL(clicked()), SLOT(close()));
+ qDebug("AddressPicker::AddressPicker pending access KA/PI ");
+#if 0
+ Opie::OPimContactAccess::List::Iterator it;
+
+ QString lineEmail, lineName, contactLine;
+ /* what name has to set here???? */
+ Opie::OPimContactAccess m_contactdb("opiemail");
+
+ QStringList mails;
+ QString pre,suf;
+ Opie::OPimContactAccess::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).firstName()+" "+(*it).lastName()+"\" <";
+ suf = ">";
+ }
+ else
+ {
+ pre = "";
+ suf = "";
+ }
+ QStringList::ConstIterator sit = mails.begin();
+ for (;sit!=mails.end();++sit)
+ {
+ contactLine=pre+(*sit)+suf;
+ addressList->insertItem(contactLine);
+ }
+ }
+ }
+ 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();
+ }
+#endif
+}
+
+void AddressPicker::accept()
+{
+ QListBoxItem *item = addressList->firstItem();
+ QString names;
+
+ while ( item )
+ {
+ if ( item->selected() )
+ names += item->text() + ", ";
+ item = item->next();
+ }
+ names.replace( names.length() - 2, 2, "" );
+
+ if ( names.isEmpty() )
+ {
+ QMessageBox::information(this, tr("Error"), tr("<p>You have to select"
+ " at least one address entry.</p>"), tr("Ok"));
+ return;
+ }
+
+ selectedNames = names;
+ QDialog::accept();
+}
+
+QString AddressPicker::getNames()
+{
+ QString names = 0;
+
+ AddressPicker picker(0, 0, true);
+
+ picker.showMaximized();
+ int ret = picker.exec();
+ if ( QDialog::Accepted == ret )
+ {
+ return picker.selectedNames;
+ }
+
+ return 0;
+}
+