Messagelib

filtersavedmenu.cpp
1 /*
2  SPDX-FileCopyrightText: 2021 Laurent Montel <[email protected]>
3 
4  SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 
7 #include "filtersavedmenu.h"
8 #include "core/filtersavedmanager.h"
9 #include <KLocalizedString>
10 #include <QAction>
11 #include <QIcon>
12 using namespace MessageList::Core;
13 
14 FilterSavedMenu::FilterSavedMenu(QWidget *parent)
15  : QMenu(parent)
16  , mSaveAction(new QAction(QIcon::fromTheme(QStringLiteral("document-save-as")), i18n("Save Filter..."), this))
17  , mConfigureAction(new QAction(QIcon::fromTheme(QStringLiteral("settings-configure")), i18n("Configure..."), this))
18 {
19  connect(this, &FilterSavedMenu::aboutToShow, this, &FilterSavedMenu::slotShowMenu);
20 }
21 
22 FilterSavedMenu::~FilterSavedMenu() = default;
23 
24 void FilterSavedMenu::slotShowMenu()
25 {
26  for (auto act : std::as_const(mListAction)) {
27  removeAction(act);
28  }
29  qDeleteAll(mListAction);
30  mListAction.clear();
31  removeAction(mSaveAction);
32  removeAction(mConfigureAction);
33  clear();
34  FilterSavedManager::self()->loadMenu(this);
35  if (!isEmpty()) {
36  addSeparator();
37  }
38  addAction(mSaveAction);
39  addSeparator();
40  addAction(mConfigureAction);
41  connect(mSaveAction, &QAction::triggered, this, &FilterSavedMenu::saveFilter);
42  connect(mConfigureAction, &QAction::triggered, this, &FilterSavedMenu::configureFilters);
43 }
void triggered(bool checked)
The implementation independent part of the MessageList library.
Definition: aggregation.h:21
bool isEmpty() const
Returns true if this filter is empty (0 status mask, empty search string and empty tag) and it&#39;s usel...
Definition: filter.cpp:117
void clear()
Clears this filter (sets status to 0, search string and tag id to empty strings)
Definition: filter.cpp:134
QString i18n(const char *text, const TYPE &arg...)
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sun Dec 5 2021 23:04:53 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.