21 #include <Akonadi/Contact/EmailAddressSelectionWidget>
22 #include <Akonadi/Session>
23 #include <Akonadi/ItemFetchScope>
24 #include <Akonadi/EntityDisplayAttribute>
25 #include <Akonadi/Contact/ContactsTreeModel>
26 #include <Akonadi/ChangeRecorder>
28 #include <KABC/Addressee>
30 #include <KLocalizedString>
38 setCaption( i18n(
"Select Contact" ) );
39 setButtons( Ok|Cancel );
40 setDefaultButton( Ok );
41 setButtonText(KDialog::Ok, i18n(
"Select"));
44 Akonadi::Session *session =
new Akonadi::Session(
"AddEmailToExistingContactDialog",
this );
46 Akonadi::ItemFetchScope scope;
47 scope.fetchFullPayload(
true );
48 scope.fetchAttribute<Akonadi::EntityDisplayAttribute>();
50 Akonadi::ChangeRecorder *changeRecorder =
new Akonadi::ChangeRecorder(
this );
51 changeRecorder->setSession( session );
52 changeRecorder->fetchCollection(
true );
53 changeRecorder->setItemFetchScope( scope );
54 changeRecorder->setCollectionMonitored( Akonadi::Collection::root() );
56 changeRecorder->setMimeTypeMonitored( KABC::Addressee::mimeType(),
true );
58 Akonadi::ContactsTreeModel *model =
new Akonadi::ContactsTreeModel( changeRecorder,
this );
60 mEmailSelectionWidget =
new Akonadi::EmailAddressSelectionWidget(
false, model,
this);
61 setMainWidget(mEmailSelectionWidget);
62 mEmailSelectionWidget->view()->setSelectionMode(QAbstractItemView::SingleSelection);
64 connect(mEmailSelectionWidget->view()->selectionModel(), SIGNAL(selectionChanged(
QItemSelection,
QItemSelection)),
this, SLOT(slotSelectionChanged()));
65 enableButtonOk(
false);
73 void AddEmailToExistingContactDialog::slotSelectionChanged()
75 enableButtonOk(!mEmailSelectionWidget->selectedAddresses().isEmpty());
78 void AddEmailToExistingContactDialog::readConfig()
80 KConfigGroup group(
KMKernel::self()->config(),
"AddEmailToExistingContactDialog" );
81 const QSize size = group.readEntry(
"Size",
QSize(600, 400) );
87 void AddEmailToExistingContactDialog::writeConfig()
89 KConfigGroup group(
KMKernel::self()->config(),
"AddEmailToExistingContactDialog" );
90 group.writeEntry(
"Size", size() );
97 Akonadi::EmailAddressSelection::List lst = mEmailSelectionWidget->selectedAddresses();
99 item = lst.first().item();
104 #include "moc_addemailtoexistingcontactdialog.cpp"
static KMKernel * self()
normal control stuff