26 #include <Akonadi/EntityMimeTypeFilterModel>
28 #include <Mailtransport/TransportComboBox>
29 #include <Mailtransport/Transport>
30 #include <Mailtransport/TransportManager>
32 #include <KPIMIdentities/IdentityCombo>
35 #include <KUrlRequester>
37 #include <QVBoxLayout>
39 #include <QListWidget>
42 const Akonadi::Collection::List &list,
const QString &filtername,
43 const QString &argStr,
QWidget *parent )
48 setCaption( i18n(
"Select Folder" ) );
49 setButtons( Ok | Cancel );
50 setDefaultButton( Ok );
51 showButtonSeparator(
true );
52 QVBoxLayout *lay =
new QVBoxLayout( mainWidget() );
53 QLabel *lab =
new QLabel( i18n(
"Folder path was \"%1\".", argStr ) );
54 lab->setWordWrap(
true);
55 lay->addWidget( lab );
56 if ( !list.isEmpty() ) {
57 lab =
new QLabel( i18n(
"The following folders can be used for this filter:" ) );
58 lab->setWordWrap(
true);
59 lay->addWidget( lab );
60 mListwidget =
new QListWidget(
this );
61 lay->addWidget( mListwidget );
62 const int numberOfItems( list.count() );
63 for (
int i = 0; i< numberOfItems; ++i ) {
64 Akonadi::Collection col = list.at( i );
66 item->setData( FilterActionMissingCollectionDialog::IdentifyCollection, col.id() );
67 mListwidget->addItem( item );
70 SLOT(slotCurrentItemChanged()));
76 QLabel *label =
new QLabel(
this );
77 label->setWordWrap(
true);
78 if (filtername.isEmpty())
79 label->setText( i18n(
"Please select a folder" ));
81 label->setText( i18n(
"Filter folder is missing. "
82 "Please select a folder to use with filter \"%1\"",
84 lay->addWidget( label );
86 connect( mFolderRequester, SIGNAL(folderChanged(Akonadi::Collection)),
87 this, SLOT(slotFolderChanged(Akonadi::Collection)) );
88 lay->addWidget( mFolderRequester );
89 enableButtonOk(
false );
98 void FilterActionMissingCollectionDialog::readConfig()
100 KConfigGroup group(
KernelIf->config(),
"FilterActionMissingCollectionDialog" );
102 const QSize size = group.readEntry(
"Size", QSize(500, 300) );
103 if ( size.isValid() ) {
108 void FilterActionMissingCollectionDialog::writeConfig()
110 KConfigGroup group(
KernelIf->config(),
"FilterActionMissingCollectionDialog" );
111 group.writeEntry(
"Size", size() );
115 void FilterActionMissingCollectionDialog::slotFolderChanged(
const Akonadi::Collection &col )
117 enableButtonOk( col.isValid() );
120 void FilterActionMissingCollectionDialog::slotDoubleItemClicked(
QListWidgetItem *item )
126 const Akonadi::Collection::Id
id =
127 item->data( FilterActionMissingCollectionDialog::IdentifyCollection ).toLongLong();
129 mFolderRequester->
setCollection( Akonadi::Collection(
id ) );
133 void FilterActionMissingCollectionDialog::slotCurrentItemChanged()
137 const Akonadi::Collection::Id
id =
138 currentItem->data( FilterActionMissingCollectionDialog::IdentifyCollection ).toLongLong();
139 mFolderRequester->
setCollection( Akonadi::Collection(
id ) );
148 void FilterActionMissingCollectionDialog::getPotentialFolders(
const QAbstractItemModel *model,
149 const QModelIndex &parentIndex,
150 const QString &lastElement,
151 Akonadi::Collection::List &list )
153 const int rowCount = model->rowCount( parentIndex );
154 for (
int row = 0; row < rowCount; ++row ) {
155 const QModelIndex index = model->index( row, 0, parentIndex );
156 if ( model->rowCount( index ) > 0 ) {
157 getPotentialFolders( model, index, lastElement, list );
159 if ( model->data( index ).toString() == lastElement ) {
161 index, Akonadi::EntityTreeModel::CollectionRole ).value<Akonadi::Collection>();
167 const QString &path,
bool &exactPath )
169 Akonadi::Collection::List lst;
171 if ( realPath.isEmpty() ) {
175 const int lastSlash = realPath.lastIndexOf( QLatin1Char(
'/' ) );
177 if ( lastSlash == -1 ) {
178 lastElement = realPath;
180 lastElement = realPath.right( realPath.length() - lastSlash - 1 );
183 if (
KernelIf->collectionModel() ) {
184 FilterActionMissingCollectionDialog::getPotentialFolders(
185 KernelIf->collectionModel(), QModelIndex(), lastElement, lst );
187 const int numberOfItems( lst.count() );
188 for (
int i = 0; i < numberOfItems; ++i ) {
191 return Akonadi::Collection::List() << lst.at( i );
203 setCaption( i18n(
"Select Identity" ) );
204 setButtons( Ok | Cancel );
205 setDefaultButton( Ok );
206 showButtonSeparator(
true );
207 QVBoxLayout *lay =
new QVBoxLayout( mainWidget() );
208 QLabel *label =
new QLabel(
this );
209 label->setText( i18n(
"Filter identity is missing. "
210 "Please select an identity to use with filter \"%1\"",
212 label->setWordWrap(
true);
213 lay->addWidget( label );
214 mComboBoxIdentity =
new KPIMIdentities::IdentityCombo(
KernelIf->identityManager(), this );
215 lay->addWidget( mComboBoxIdentity );
224 void FilterActionMissingIdentityDialog::readConfig()
226 KConfigGroup group(
KernelIf->config(),
"FilterActionMissingMissingIdentity" );
228 const QSize size = group.readEntry(
"Size", QSize(500, 300) );
229 if ( size.isValid() ) {
234 void FilterActionMissingIdentityDialog::writeConfig()
236 KConfigGroup group(
KernelIf->config(),
"FilterActionMissingMissingIdentity" );
237 group.writeEntry(
"Size", size() );
243 return mComboBoxIdentity->currentIdentity();
251 setCaption( i18n(
"Select Transport" ) );
252 setButtons( Ok | Cancel );
253 setDefaultButton( Ok );
254 showButtonSeparator(
true );
255 QVBoxLayout *lay =
new QVBoxLayout( mainWidget() );
256 QLabel *label =
new QLabel(
this );
257 label->setText( i18n(
"Filter transport is missing. "
258 "Please select a transport to use with filter \"%1\"",
260 label->setWordWrap(
true);
261 lay->addWidget( label );
262 mComboBoxTransport =
new MailTransport::TransportComboBox(
this );
263 lay->addWidget( mComboBoxTransport );
272 void FilterActionMissingTransportDialog::readConfig()
274 KConfigGroup group(
KernelIf->config(),
"FilterActionMissingTransportDialog" );
276 const QSize size = group.readEntry(
"Size", QSize(500, 300) );
277 if ( size.isValid() ) {
282 void FilterActionMissingTransportDialog::writeConfig()
284 KConfigGroup group(
KernelIf->config(),
"FilterActionMissingTransportDialog" );
285 group.writeEntry(
"Size", size() );
291 return mComboBoxTransport->currentTransportId();
295 const QStringList &templateList,
const QString &filtername,
QWidget *parent )
299 setCaption( i18n(
"Select Template" ) );
300 setButtons( Ok | Cancel );
301 setDefaultButton( Ok );
302 showButtonSeparator(
true );
303 QVBoxLayout *lay =
new QVBoxLayout( mainWidget() );
304 QLabel *label =
new QLabel(
this );
305 label->setText( i18n(
"Filter template is missing. "
306 "Please select a template to use with filter \"%1\"",
308 label->setWordWrap(
true);
309 lay->addWidget( label );
310 mComboBoxTemplate =
new KComboBox(
this );
311 mComboBoxTemplate->addItems( templateList );
312 lay->addWidget( mComboBoxTemplate );
322 void FilterActionMissingTemplateDialog::readConfig()
324 KConfigGroup group(
KernelIf->config(),
"FilterActionMissingTemplateDialog" );
326 const QSize size = group.readEntry(
"Size", QSize(500, 300) );
327 if ( size.isValid() ) {
332 void FilterActionMissingTemplateDialog::writeConfig()
334 KConfigGroup group(
KernelIf->config(),
"FilterActionMissingTemplateDialog" );
335 group.writeEntry(
"Size", size() );
340 if ( mComboBoxTemplate->currentIndex() == 0 ) {
343 return mComboBoxTemplate->currentText();
348 const QString &filtername,
353 setCaption( i18n(
"Select Account" ) );
354 setButtons( Ok | Cancel );
355 setDefaultButton( Ok );
356 showButtonSeparator(
true );
357 QVBoxLayout *lay =
new QVBoxLayout( mainWidget() );
358 QLabel *label =
new QLabel(
this );
359 label->setText( i18n(
"Filter account is missing. "
360 "Please select account to use with filter \"%1\"",
362 label->setWordWrap(
true);
363 lay->addWidget( label );
366 lay->addWidget( mAccountList );
375 void FilterActionMissingAccountDialog::readConfig()
377 KConfigGroup group(
KernelIf->config(),
"FilterActionMissingAccountDialog" );
379 const QSize size = group.readEntry(
"Size", QSize(500, 300) );
380 if ( size.isValid() ) {
385 void FilterActionMissingAccountDialog::writeConfig()
387 KConfigGroup group(
KernelIf->config(),
"FilterActionMissingAccountDialog" );
388 group.writeEntry(
"Size", size() );
400 const int numberOfAccount( lst.count() );
401 const int numberOfAgent( lstAgent.count() );
403 for (
int i = 0; i <numberOfAccount; ++i ) {
405 const QString accountName( lst.at( i ) );
406 for (
int j=0; j < numberOfAgent;++j ) {
407 if ( lstAgent.at( j ).identifier() == accountName ) {
420 const QMap<QUrl, QString> &tagList,
const QString &filtername,
421 const QString &argsStr,
QWidget *parent )
425 setCaption( i18n(
"Select Tag" ) );
426 setButtons( Ok | User1 | Cancel );
427 setDefaultButton( Ok );
428 setButtonText(KDialog::User1, i18n(
"Add Tag..."));
429 showButtonSeparator(
true );
430 QVBoxLayout *lay =
new QVBoxLayout( mainWidget() );
431 QLabel *label =
new QLabel( i18n(
"Tag was \"%1\".", argsStr ) );
432 lay->addWidget( label );
434 label =
new QLabel(
this );
435 label->setText( i18n(
"Filter tag is missing. "
436 "Please select a tag to use with filter \"%1\"",
438 label->setWordWrap(
true);
439 lay->addWidget( label );
440 mTagList =
new QListWidget(
this );
442 QMapIterator<QUrl, QString> map(tagList);
443 while (map.hasNext()) {
446 item->setData(UrlData, map.key().toString());
447 mTagList->addItem(item);
450 connect(
this,SIGNAL(user1Clicked()),SLOT(slotAddTag()));
452 this, SLOT(accept()) );
453 lay->addWidget( mTagList );
462 void FilterActionMissingTagDialog::readConfig()
464 KConfigGroup group(
KernelIf->config(),
"FilterActionMissingTagDialog" );
466 const QSize size = group.readEntry(
"Size", QSize(500, 300) );
467 if ( size.isValid() ) {
472 void FilterActionMissingTagDialog::writeConfig()
474 KConfigGroup group(
KernelIf->config(),
"FilterActionMissingTagDialog" );
475 group.writeEntry(
"Size", size() );
480 if ( mTagList->currentItem() ) {
481 return mTagList->currentItem()->data(UrlData).toString();
486 void FilterActionMissingTagDialog::slotAddTag()
491 item->setData(UrlData, dlg->nepomukUrl());
492 mTagList->addItem(item);
498 const QString &argStr,
503 setButtons( Ok | Cancel );
504 setDefaultButton( Ok );
505 setCaption( i18n(
"Select sound" ) );
506 showButtonSeparator(
true );
507 QVBoxLayout *lay =
new QVBoxLayout( mainWidget() );
508 QLabel *label =
new QLabel( i18n(
"Sound file was \"%1\".", argStr ) );
509 lay->addWidget( label );
511 label =
new QLabel(
this );
512 label->setText( i18n(
"Sound file is missing. "
513 "Please select a sound to use with filter \"%1\"",
515 label->setWordWrap(
true);
516 lay->addWidget( label );
517 mUrlWidget =
new KUrlRequester(
this );
518 lay->addWidget( mUrlWidget );
529 return mUrlWidget->url().path();
532 void FilterActionMissingSoundUrlDialog::readConfig()
534 KConfigGroup group(
KernelIf->config(),
"FilterActionMissingSoundUrlDialog" );
536 const QSize size = group.readEntry(
"Size", QSize(500, 300) );
537 if ( size.isValid() ) {
542 void FilterActionMissingSoundUrlDialog::writeConfig()
544 KConfigGroup group(
KernelIf->config(),
"FilterActionMissingSoundUrlDialog" );
545 group.writeEntry(
"Size", size() );
549 #include "filteractionmissingargumentdialog.moc"
MAILCOMMON_EXPORT Akonadi::AgentInstance::List agentInstances(bool excludeMailTransport=true)
QString selectedTemplate() const
FilterActionMissingIdentityDialog(const QString &filtername, QWidget *parent=0)
~FilterActionMissingSoundUrlDialog()
static bool allAccountExist(const QStringList &lst)
FilterActionMissingCollectionDialog(const Akonadi::Collection::List &list, const QString &filtername=QString(), const QString &argStr=QString(), QWidget *parent=0)
Akonadi::Collection selectedCollection() const
FilterActionMissingTransportDialog(const QString &filtername, QWidget *parent=0)
~FilterActionMissingAccountDialog()
~FilterActionMissingTemplateDialog()
QString selectedTag() const
int selectedTransport() const
FilterActionMissingAccountDialog(const QStringList &lstAccount, const QString &filtername, QWidget *parent=0)
Akonadi::Collection collection() const
Returns the selected collection.
QStringList selectedAccount()
A widget that contains a KLineEdit which shows the current folder and a button that fires a FolderSel...
~FilterActionMissingCollectionDialog()
~FilterActionMissingIdentityDialog()
FilterActionMissingTagDialog(const QMap< QUrl, QString > &templateList, const QString &filtername, const QString &argsStr, QWidget *parent=0)
QStringList selectedAccount() const
~FilterActionMissingTransportDialog()
FilterActionMissingSoundUrlDialog(const QString &filtername, const QString &argStr, QWidget *parent=0)
FilterActionMissingTemplateDialog(const QStringList &templateList, const QString &filtername, QWidget *parent=0)
MAILCOMMON_EXPORT QString fullCollectionPath(const Akonadi::Collection &collection)
~FilterActionMissingTagDialog()
void setCollection(const Akonadi::Collection &collection, bool fetchCollection=true)
Presets the folder to the collection collection.
void applyOnAccount(MailCommon::MailFilter *filter)
MAILCOMMON_EXPORT QString realFolderPath(const QString &path)
static Akonadi::Collection::List potentialCorrectFolders(const QString &path, bool &exactPath)
int selectedIdentity() const