Commit 0989858e authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Don't save not defined filter

parent bc4b6b18
Pipeline #66081 canceled with stage
......@@ -28,12 +28,14 @@
#include <QActionGroup>
#include <QHeaderView>
#include <QPointer>
#include <QTimer>
#include <QVBoxLayout>
#include <QVariant>
#include "messagelist_debug.h"
#include <KLocalizedString>
#include <KMessageBox>
#include <QAction>
#include <QComboBox>
#include <QMenu>
......@@ -42,6 +44,7 @@
#include <Akonadi/KMime/MessageStatus>
#include <collection.h>
#include <core/widgets/filternamedialog.h>
using namespace MessageList::Core;
......@@ -171,10 +174,17 @@ void Widget::slotActivateFilter(Filter *f)
d->quickSearchLine->setFilterMessageStatus(f->status());
}
void Widget::slotSaveFilter(const QString &filterName)
void Widget::slotSaveFilter()
{
if (d->mFilter) {
FilterSavedManager::self()->saveFilter(d->mFilter, filterName);
QPointer<FilterNameDialog> dlg = new FilterNameDialog(this);
dlg->setExistingFilterNames(FilterSavedManager::self()->existingFilterNames());
if (dlg->exec()) {
FilterSavedManager::self()->saveFilter(d->mFilter, dlg->filterName());
}
delete dlg;
} else {
KMessageBox::information(this, i18n("Any filter defined."), i18n("Create Filter"));
}
}
......
......@@ -252,7 +252,7 @@ protected Q_SLOTS:
*/
void slotViewHeaderSectionClicked(int logicalIndex);
void slotStatusButtonsClicked();
void slotSaveFilter(const QString &filterName);
void slotSaveFilter();
private:
void slotActivateFilter(Filter *f);
......
......@@ -68,7 +68,7 @@ Q_SIGNALS:
void searchOptionChanged();
void statusButtonsClicked();
void forceLostFocus();
void saveFilter(const QString &filterName);
void saveFilter();
void activateFilter(Filter *f);
protected:
......
......@@ -119,7 +119,7 @@ void SearchLineStatus::initializeActions()
mFilterSavedMenu = new FilterSavedMenu(this);
mSaveFilterAction->setMenu(mFilterSavedMenu);
connect(mSaveFilterAction, &QAction::triggered, this, &SearchLineStatus::showSavedFiltersMenu);
connect(mFilterSavedMenu, &FilterSavedMenu::saveFilter, this, &SearchLineStatus::slotSaveFilter);
connect(mFilterSavedMenu, &FilterSavedMenu::saveFilter, this, &SearchLineStatus::saveFilter);
connect(mFilterSavedMenu, &FilterSavedMenu::configureFilters, this, &SearchLineStatus::slotConfigureFilters);
}
......@@ -139,17 +139,6 @@ void SearchLineStatus::slotConfigureFilters()
dlg.exec();
}
void SearchLineStatus::slotSaveFilter()
{
// TODO verify that current filter is valid
QPointer<FilterNameDialog> dlg = new FilterNameDialog(this);
dlg->setExistingFilterNames(FilterSavedManager::self()->existingFilterNames());
if (dlg->exec()) {
Q_EMIT saveFilter(dlg->filterName());
}
delete dlg;
}
void SearchLineStatus::slotToggledLockAction()
{
mLocked = !mLocked;
......
......@@ -42,7 +42,7 @@ Q_SIGNALS:
void searchOptionChanged();
void clearButtonClicked();
void forceLostFocus();
void saveFilter(const QString &filterName);
void saveFilter();
void activateFilter(MessageList::Core::Filter *f);
protected:
......@@ -67,7 +67,6 @@ private:
void changeSearchAgainstFromOrToText();
void slotClear();
void showSavedFiltersMenu();
void slotSaveFilter();
void slotConfigureFilters();
void slotActivateFilter(const QString &identifier);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment