25 #include "publishdialog_p.h"
27 #include <kcalcore/attendee.h>
28 #include <kcalcore/person.h>
31 #include <KLocalizedString>
33 using namespace KCalCore;
34 using namespace Akonadi;
36 PublishDialog::PublishDialog(QWidget *parent)
37 : KDialog(parent), d(new Private(this))
39 setCaption(i18n(
"Select Addresses"));
40 setButtons(Ok|Cancel|Help);
41 setHelp(
"group-scheduling",
"korganizer");
42 QWidget *widget =
new QWidget(
this);
43 widget->setObjectName(
"PublishFreeBusy");
44 d->mUI.setupUi(widget);
45 setMainWidget(widget);
46 d->mUI.mListWidget->setSelectionMode(QAbstractItemView::SingleSelection);
47 d->mUI.mNameLineEdit->setEnabled(
false);
48 d->mUI.mEmailLineEdit->setEnabled(
false);
50 setButtonToolTip(Ok, i18n(
"Send email to these recipients"));
51 setButtonWhatsThis(Ok, i18n(
"Clicking the <b>Ok</b> button will cause "
52 "an email to be sent to the recipients you "
54 setButtonToolTip(Cancel, i18n(
"Cancel recipient selection and the email"));
55 setButtonWhatsThis(Cancel, i18n(
"Clicking the <b>Cancel</b> button will "
56 "cause the email operation to be terminated."));
58 setButtonWhatsThis(Help, i18n(
"Click the <b>Help</b> button to read "
59 "more information about Group Scheduling."));
61 d->mUI.mNew->setIcon(KIcon(
"list-add"));
62 d->mUI.mRemove->setIcon(KIcon(
"list-remove"));
63 d->mUI.mRemove->setEnabled(
false);
64 d->mUI.mSelectAddressee->setIcon(KIcon(
"view-pim-contacts"));
66 connect(d->mUI.mListWidget, SIGNAL(itemSelectionChanged()),
67 d, SLOT(updateInput()));
68 connect(d->mUI.mNew, SIGNAL(clicked()),
70 connect(d->mUI.mRemove, SIGNAL(clicked()),
71 d, SLOT(removeItem()));
72 connect(d->mUI.mSelectAddressee, SIGNAL(clicked()),
73 d, SLOT(openAddressbook()));
74 connect(d->mUI.mNameLineEdit, SIGNAL(textChanged(QString)),
75 d, SLOT(updateItem()));
76 connect(d->mUI.mEmailLineEdit, SIGNAL(textChanged(QString)),
77 d, SLOT(updateItem()));
80 PublishDialog::~PublishDialog()
85 void PublishDialog::addAttendee(
const Attendee::Ptr &attendee)
87 d->mUI.mNameLineEdit->setEnabled(
true);
88 d->mUI.mEmailLineEdit->setEnabled(
true);
89 QListWidgetItem *item =
new QListWidgetItem(d->mUI.mListWidget);
90 Person person(attendee->name(), attendee->email());
91 item->setText(person.fullName());
92 d->mUI.mListWidget->addItem(item);
93 d->mUI.mRemove->setEnabled(!d->mUI.mListWidget->selectedItems().isEmpty());
96 QString PublishDialog::addresses()
const
99 QListWidgetItem *item;
100 const int count = d->mUI.mListWidget->count();
101 for (
int i=0; i<count; ++i) {
102 item = d->mUI.mListWidget->item(i);
103 if (!item->text().isEmpty()) {