Commit 5876c145 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Allow to remove item

parent 6b27866d
Pipeline #63148 canceled with stage
......@@ -6,7 +6,9 @@
#include "configurefilterswidget.h"
#include "core/filtersavedmanager.h"
#include <KLocalizedString>
#include <QListWidget>
#include <QMenu>
#include <QVBoxLayout>
using namespace MessageList::Core;
ConfigureFiltersWidget::ConfigureFiltersWidget(QWidget *parent)
......@@ -18,6 +20,8 @@ ConfigureFiltersWidget::ConfigureFiltersWidget(QWidget *parent)
mainLayout->setContentsMargins({});
mListFiltersWidget->setObjectName(QStringLiteral("mListFiltersWidget"));
mainLayout->addWidget(mListFiltersWidget);
mListFiltersWidget->setContextMenuPolicy(Qt::CustomContextMenu);
connect(mListFiltersWidget, &QListWidget::customContextMenuRequested, this, &ConfigureFiltersWidget::slotCustomContextMenuRequested);
init();
}
......@@ -27,5 +31,27 @@ ConfigureFiltersWidget::~ConfigureFiltersWidget()
void ConfigureFiltersWidget::init()
{
const QVector<FilterSavedManager::FilterInfo> lstFilters = FilterSavedManager::self()->filterInfos();
for (const auto &filter : lstFilters) {
mListFiltersWidget->addItem(filter.filterName);
}
// TODO load filter
}
void ConfigureFiltersWidget::slotCustomContextMenuRequested(const QPoint &pos)
{
auto item = mListFiltersWidget->itemAt(pos);
if (item) {
QMenu menu(this);
QString identifier;
menu.addAction(i18n("Remove"), this, [this, identifier]() {
removeFilterInfo(identifier);
});
menu.exec(QCursor::pos());
}
}
void ConfigureFiltersWidget::removeFilterInfo(const QString &identifier)
{
// TODO
}
......@@ -21,6 +21,8 @@ public:
~ConfigureFiltersWidget() override;
private:
void slotCustomContextMenuRequested(const QPoint &pos);
void removeFilterInfo(const QString &identifier);
void init();
QListWidget *const mListFiltersWidget;
};
......
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