MailCommon::KMFilterDialog Class

class MailCommon::KMFilterDialog

The filter dialog. More...

Header: #include <MailCommon/KMFilterDialog>
CMake: find_package(KPim6MailCommon REQUIRED)
target_link_libraries(mytarget PRIVATE KPim6::MailCommon)
Inherits: QDialog

Public Functions

KMFilterDialog(const QList<KActionCollection *> &actionCollection, QWidget *parent = nullptr, bool createDummyFilter = true)
void createFilter(const QByteArray &field, const QString &value)

Public Slots

virtual void accept() override
void slotFilterSelected(MailCommon::MailFilter *aFilter)

Protected Slots

void slotApplicabilityChanged()
void slotApplicableAccountsChanged()
void slotApply()
void slotConfigureToolbarButtonToggled(bool aChecked)
void slotDialogUpdated()
void slotDisableAccept()
void slotExportFilters()
void slotFetchItemsForFolderDone(KJob *job)
void slotFilterActionIconChanged(const QString &icon)
void slotFinished()
void slotFolderChanged(const Akonadi::Collection &)
void slotImportFilter(QAction *)
void slotReset()
void slotRunFilters()
void slotSaveSize()
void slotShortcutChanged(const QKeySequence &newSeq)
void slotStopProcessingButtonToggled(bool aChecked)
void slotUpdateAccountList()
void slotUpdateFilter()

Protected Variables

MailCommon::KMFilterAccountList *mAccountList
MailCommon::FilterActionWidgetLister *mActionLister
QRadioButton *mApplyOnForAll
QCheckBox *mApplyOnIn
MailCommon::KMFilterListBox *mFilterList
MailCommon::SearchPatternEdit *mPatternEdit

Detailed Description

The filter dialog. This is a non-modal dialog used to manage the filters. It should only be called through the filter manager. The dialog consists of three main parts:

  • The KMFilterListBox in the left half allows the user to select a filter to be displayed using the widgets on the right half. It also has buttons to delete filters, add new ones, to rename them and to change their order (maybe you will be able to move the filters around by dragging later, and to optimize the filters by trying to apply them to all locally available KMMessage in turn and thus profiling which filters (and which rules of the search patterns) matches most often and sorting the filter/rules list according to the results, but I first want the basic functionality in place).
  • The SearchPatternEdit in the upper-right quarter allows the user to modify the filter criteria.
  • The FilterActionWidgetLister in the lower-right quarter allows the user to select the actions that will be executed for any message that matches the search pattern.
  • (tbi) There will be another widget that will allow the user to select to which folders the filter may be applied and whether it should be applied on outbound or inbound message transfers or both or none (meaning the filter is only applied when the user explicitly hits CTRL-J). I'm not sure whether there should be a per-folder filter list or a single list where you can select the names of folders this rule will be applied to.

Upon creating the dialog, a (deep) copy of the current filter list is made by KMFilterListBox. The changed filters are local to KMFilterListBox until the user clicks the 'Apply' button.

Note: Though this dialog is non-modal, it completely ignores all the stuff that goes on behind the scenes with folders esp. folder creation, move and create. The widgets that depend on the filter list and the filters that use folders as parameters are not updated as you expect. I hope this will change sometime soon.

KMFilterDialog supports the creation of new filters through context menus, dubbed "rapid filters". Call IFilter::createFilter() to use this. That call will be delivered to this dialog, which in turn delivers it to the KMFilterListBox.

If you change the (DocBook) anchor for the filter dialog help, make sure to change KMFilterDialogHelpAnchor in kmfilterdlg.cpp accordingly.

Author: Marc Mutz <mutz@kde.org>, based upon work by Stefan Taferner <taferner@kde.org>.

See also MailCommon::MailFilter and MailCommon::SearchPatternEdit.

Member Function Documentation

[explicit] KMFilterDialog::KMFilterDialog(const QList<KActionCollection *> &actionCollection, QWidget *parent = nullptr, bool createDummyFilter = true)

Creates the filter dialog with the given parent. The actions of actionCollection can be used as shortcuts for filters. If createDummyFilter is true, an empty filter is created when there is no filter. Only the filter manager should create this dialog. This ensures that there is only a single filter dialog.

[override virtual slot] void KMFilterDialog::accept()

Reimplements: QDialog::accept().

Override QDialog::accept to allow disabling close

void KMFilterDialog::createFilter(const QByteArray &field, const QString &value)

Called from the filter manager. Creates a new filter and presets the first rule with "field equals value", using field and value.

[protected slot] void KMFilterDialog::slotApplicabilityChanged()

Called when the applicability of the current filter changes.

[protected slot] void KMFilterDialog::slotApplicableAccountsChanged()

Called when the accounts the current filter applies to change.

[protected slot] void KMFilterDialog::slotApply()

Called wherenever the apply button is pressed.

[protected slot] void KMFilterDialog::slotConfigureToolbarButtonToggled(bool aChecked)

Called when the "add to toolbar" check box is toggled to aChecked.

[protected slot] void KMFilterDialog::slotDialogUpdated()

Called whenever a change in the filters configuration is detected, to enable the Apply button.

[protected slot] void KMFilterDialog::slotDisableAccept()

Called when a user decides to continue editing invalid filters

[protected slot] void KMFilterDialog::slotExportFilters()

Called when a user clicks the export filters button. Pops up a dialog asking the user which filters to export and which file to export to.

[protected slot] void KMFilterDialog::slotFetchItemsForFolderDone(KJob *job)

Called when the item fetch job for the selected folder is done.

[protected slot] void KMFilterDialog::slotFilterActionIconChanged(const QString &icon)

Called when the toolbar icon of the current filter changes.

[slot] void KMFilterDialog::slotFilterSelected(MailCommon::MailFilter *aFilter)

Internally connected to the filter list's filterSelected() signal. Loads the pattern and the actions of aFilter into the edit widgets.

[protected slot] void KMFilterDialog::slotFinished()

Called when the dialog is closed (finished).

[protected slot] void KMFilterDialog::slotFolderChanged(const Akonadi::Collection &)

Called when the selected folder changes.

[protected slot] void KMFilterDialog::slotImportFilter(QAction *)

Called when a user clicks the import filters button. Pops up a dialog asking the user which file to import from and which of the filters in that file to import.

[protected slot] void KMFilterDialog::slotReset()

Resets the edit widgets.

[protected slot] void KMFilterDialog::slotRunFilters()

Runs the selected filters on the selected folder.

[protected slot] void KMFilterDialog::slotSaveSize()

Saves the dialog size.

[protected slot] void KMFilterDialog::slotShortcutChanged(const QKeySequence &newSeq)

Called when the shortcut of the current filter changes to newSeq.

[protected slot] void KMFilterDialog::slotStopProcessingButtonToggled(bool aChecked)

Called when the "stop processing here" check box is toggled to aChecked.

[protected slot] void KMFilterDialog::slotUpdateAccountList()

Update the list of accounts shown in the advanced tab.

[protected slot] void KMFilterDialog::slotUpdateFilter()

Applies the content of the edit widgets to the current filter.

Member Variable Documentation

MailCommon::KMFilterAccountList *KMFilterDialog::mAccountList

ListView that shows the accounts in the advanced tab

MailCommon::FilterActionWidgetLister *KMFilterDialog::mActionLister

The widget that allows editing of the filter actions.

QRadioButton *KMFilterDialog::mApplyOnForAll

For a filter applied to inbound messages selects whether to apply this filter to all accounts or to selected accounts only.

QCheckBox *KMFilterDialog::mApplyOnIn

Lets the user select whether to apply this filter on inbound/outbound messages, both, or only on explicit CTRL-J.

MailCommon::KMFilterListBox *KMFilterDialog::mFilterList

The widget that contains the ListBox showing the filters, and the controls to remove filters, add new ones and to change their order.

MailCommon::SearchPatternEdit *KMFilterDialog::mPatternEdit

The widget that allows editing of the filter pattern.