31 #include <Akonadi/Contact/EmailAddressSelectionDialog>
33 #include <KCalCore/Attendee>
34 #include <KCalCore/Person>
36 #include <KPIMUtils/Email>
41 setCaption( i18n(
"Select Addresses" ) );
42 setButtons( Ok|Cancel|Help );
43 setHelp( QLatin1String(
"group-scheduling"), QLatin1String(
"korganizer") );
45 widget->setObjectName( QLatin1String(
"PublishFreeBusy") );
46 mUI.setupUi( widget );
47 setMainWidget( widget );
48 mUI.mListWidget->setSelectionMode( QAbstractItemView::SingleSelection );
49 mUI.mNameLineEdit->setEnabled(
false );
50 mUI.mEmailLineEdit->setEnabled(
false );
52 setButtonToolTip( Ok, i18n(
"Send email to these recipients" ) );
53 setButtonWhatsThis( Ok, i18n(
"Clicking the <b>Ok</b> button will cause "
54 "an email to be sent to the recipients you "
56 setButtonToolTip( Cancel, i18n(
"Cancel recipient selection and the email" ) );
57 setButtonWhatsThis( Cancel, i18n(
"Clicking the <b>Cancel</b> button will "
58 "cause the email operation to be terminated." ) );
60 setButtonWhatsThis( Help, i18n(
"Click the <b>Help</b> button to read "
61 "more information about Group Scheduling." ) );
63 mUI.mAdd->setIcon( KIcon( QLatin1String(
"list-add") ) );
64 mUI.mRemove->setIcon( KIcon( QLatin1String(
"list-remove") ) );
65 mUI.mRemove->setEnabled(
false );
66 mUI.mSelectAddressee->setIcon( KIcon( QLatin1String(
"view-pim-contacts") ) );
68 connect(
mUI.mListWidget, SIGNAL(itemSelectionChanged()),
70 connect(
mUI.mAdd, SIGNAL(clicked()),
72 connect(
mUI.mRemove, SIGNAL(clicked()),
74 connect(
mUI.mSelectAddressee, SIGNAL(clicked()),
76 connect(
mUI.mNameLineEdit, SIGNAL(textChanged(QString)),
78 connect(
mUI.mEmailLineEdit, SIGNAL(textChanged(QString)),
88 mUI.mNameLineEdit->setEnabled(
true );
89 mUI.mEmailLineEdit->setEnabled(
true );
90 QListWidgetItem *item =
new QListWidgetItem(
mUI.mListWidget );
91 KCalCore::Person person( attendee->name(), attendee->email() );
92 item->setText( person.fullName() );
93 mUI.mListWidget->addItem( item );
94 mUI.mRemove->setEnabled( !
mUI.mListWidget->selectedItems().isEmpty() );
100 const int count =
mUI.mListWidget->count();
101 for (
int i=0; i<count; ++i ) {
102 const QListWidgetItem *item =
mUI.mListWidget->item( i );
103 if( !item->text().isEmpty() ) {
106 to += QLatin1String(
", ");
115 mUI.mNameLineEdit->setEnabled(
true );
116 mUI.mEmailLineEdit->setEnabled(
true );
117 QListWidgetItem *item =
new QListWidgetItem(
mUI.mListWidget );
118 mUI.mListWidget->addItem( item );
119 mUI.mListWidget->setItemSelected( item,
true );
120 mUI.mNameLineEdit->setText( i18n(
"(EmptyName)" ) );
121 mUI.mEmailLineEdit->setText( i18n(
"(EmptyEmail)" ) );
123 mUI.mRemove->setEnabled(
true );
128 if (
mUI.mListWidget->selectedItems().isEmpty() ) {
131 QListWidgetItem *item;
132 item =
mUI.mListWidget->selectedItems().first();
134 int row =
mUI.mListWidget->row( item );
135 delete mUI.mListWidget->takeItem( row );
137 if ( !
mUI.mListWidget->count() ) {
138 mUI.mNameLineEdit->setText( QString() );
139 mUI.mNameLineEdit->setEnabled(
false );
140 mUI.mEmailLineEdit->setText( QString() );
141 mUI.mEmailLineEdit->setEnabled(
false );
142 mUI.mRemove->setEnabled(
false );
149 mUI.mListWidget->setCurrentRow( row );
154 Akonadi::EmailAddressSelectionDialog dlg(
this );
159 const Akonadi::EmailAddressSelection::List selections = dlg.selectedAddresses();
160 if ( !selections.isEmpty() ) {
161 foreach (
const Akonadi::EmailAddressSelection &selection, selections ) {
162 mUI.mNameLineEdit->setEnabled(
true );
163 mUI.mEmailLineEdit->setEnabled(
true );
164 QListWidgetItem *item =
new QListWidgetItem(
mUI.mListWidget );
165 mUI.mListWidget->setItemSelected( item,
true );
166 mUI.mNameLineEdit->setText( selection.name() );
167 mUI.mEmailLineEdit->setText( selection.email() );
168 mUI.mListWidget->addItem( item );
171 mUI.mRemove->setEnabled(
true );
177 if ( !
mUI.mListWidget->selectedItems().count() ) {
181 KCalCore::Person person(
mUI.mNameLineEdit->text(),
mUI.mEmailLineEdit->text() );
182 QListWidgetItem *item =
mUI.mListWidget->selectedItems().first();
183 item->setText( person.fullName() );
188 if ( !
mUI.mListWidget->selectedItems().count() ) {
192 mUI.mNameLineEdit->setEnabled(
true );
193 mUI.mEmailLineEdit->setEnabled(
true );
195 QListWidgetItem *item =
mUI.mListWidget->selectedItems().first();
197 KPIMUtils::extractEmailAddressAndName( item->text(), mail, name );
198 mUI.mNameLineEdit->setText( name );
199 mUI.mEmailLineEdit->setText( mail );
202 #include "publishdialog.moc"
Ui::PublishDialog_base mUI
void addAttendee(const KCalCore::Attendee::Ptr &attendee)
PublishDialog(QWidget *parent=0)