From 3b37149813d940535b12ba3b1edd938c41804a1b Mon Sep 17 00:00:00 2001 From: harlekin Date: Mon, 08 Dec 2003 13:37:32 +0000 Subject: beginning of the new mailer --- (limited to 'noncore/net/mail/addresspicker.cpp') diff --git a/noncore/net/mail/addresspicker.cpp b/noncore/net/mail/addresspicker.cpp new file mode 100644 index 0000000..2c15bb4 --- a/dev/null +++ b/noncore/net/mail/addresspicker.cpp @@ -0,0 +1,130 @@ +#include +#include +#include +#include +#include + +#include + +#include + +#include "composemail.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())); + + QFile f((QString) getenv("HOME") + "/Applications/" + + "addressbook/addressbook.xml"); + + if ( f.open( IO_ReadOnly ) ) { + QTextStream stream( &f ); + stream.setEncoding( QTextStream::UnicodeUTF8 ); + QString content; + while ( !f.atEnd() ) { + content += stream.readLine() + "\n"; + } + QStringList lines = QStringList::split( QRegExp( "\\n" ), content ); + QStringList::Iterator it; + for ( it = lines.begin(); it != lines.end(); it++ ) { + if ( (*it).find( QRegExp( "^"); + } + if ( !email.isEmpty() ) { + addressList->insertItem( tname + temail ); + } + } + } + } + if ( addressList->count() <= 0 ) { + addressList->insertItem( + tr( "There are no entries in the addressbook." ) ); + addressList->setEnabled( false ); + okButton->setEnabled( false ); + } +} + +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("

You have to select" + " at least one address entry.

"), tr("Ok")); + return; + } + + selectedNames = names; + QDialog::accept(); +} + +QString AddressPicker::getNames() +{ + QString names = 0; + + AddressPicker picker(0, 0, true); + picker.showMaximized(); + picker.show(); + + int ret = picker.exec(); + if ( QDialog::Accepted == ret ) { + return picker.selectedNames; + } + + return 0; +} + -- cgit v0.9.0.2