Commit c13f5caa authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Continue to implement filtersavedmanager

parent a3c708e6
......@@ -6,7 +6,9 @@
#include "filtersavedmanager.h"
#include "filter.h"
#include <KConfigGroup>
#include <KSharedConfig>
#include <QMenu>
using namespace MessageList::Core;
FilterSavedManager::FilterSavedManager(QObject *parent)
: QObject(parent)
......@@ -24,5 +26,14 @@ void FilterSavedManager::saveFilter(MessageList::Core::Filter *filter, const QSt
void FilterSavedManager::loadMenu(QMenu *menu)
{
// TODO
KConfigGroup grp(KSharedConfig::openConfig(), "General");
const int numberFilter = grp.readEntry("NumberFilter").toInt();
for (int i = 0; i < numberFilter; ++i) {
KConfigGroup newGroup(KSharedConfig::openConfig(), QStringLiteral("Filter_%1").arg(i));
auto act = menu->addAction(newGroup.readEntry(QStringLiteral("name")));
const QString identifier = newGroup.readEntry(QStringLiteral("identifier"));
connect(act, &QAction::triggered, this, [this, identifier]() {
Q_EMIT activateFilter(identifier);
});
}
}
......@@ -21,6 +21,8 @@ public:
void saveFilter(MessageList::Core::Filter *filter, const QString &filtername);
void loadMenu(QMenu *menu);
Q_SIGNALS:
void activateFilter(const QString &identifier);
};
}
}
......@@ -5,6 +5,7 @@
*/
#include "filtersavedmenu.h"
#include "core/filtersavedmanager.h"
#include <KLocalizedString>
#include <QAction>
#include <QIcon>
......@@ -14,6 +15,7 @@ FilterSavedMenu::FilterSavedMenu(QWidget *parent)
: QMenu(parent)
, mSaveAction(new QAction(QIcon::fromTheme(QStringLiteral("document-save-as")), i18n("Save Filter..."), this))
, mConfigureAction(new QAction(i18n("Configure..."), this))
, mFilterSaveManager(new FilterSavedManager(this))
{
connect(this, &FilterSavedMenu::aboutToShow, this, &FilterSavedMenu::slotShowMenu);
connect(mSaveAction, &QAction::triggered, this, &FilterSavedMenu::saveFilter);
......
......@@ -14,6 +14,7 @@ namespace MessageList
{
namespace Core
{
class FilterSavedManager;
class MESSAGELIST_TESTS_EXPORT FilterSavedMenu : public QMenu
{
Q_OBJECT
......@@ -31,6 +32,7 @@ private:
QAction *const mSaveAction;
QAction *const mConfigureAction;
QList<QAction *> mListAction;
FilterSavedManager *const mFilterSaveManager;
};
}
}
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