Commit 8b5782cd authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Generate identifier + save filter

parent 7ab1f813
Pipeline #63951 passed with stage
in 40 minutes and 30 seconds
......@@ -11,12 +11,13 @@
#include <AkonadiSearch/PIM/emailquery.h>
#include <AkonadiSearch/PIM/resultiterator.h>
#include <KRandom>
using namespace MessageList::Core;
Filter::Filter(QObject *parent)
: QObject(parent)
{
generateRandomIdentifier();
}
bool Filter::containString(const QString &searchInString) const
......@@ -33,6 +34,21 @@ bool Filter::containString(const QString &searchInString) const
return found;
}
const QString &Filter::filterName() const
{
return mFilterName;
}
void Filter::setFilterName(const QString &newFilterName)
{
mFilterName = newFilterName;
}
void Filter::setIdentifier(const QString &newIdentifier)
{
mIdentifier = newIdentifier;
}
bool Filter::match(const MessageItem *item) const
{
if (!mStatus.isEmpty()) {
......@@ -134,6 +150,7 @@ void Filter::save(const KSharedConfig::Ptr &config, const QString &filtername)
newGroup.writeEntry("searchOptions", static_cast<int>(mOptions));
newGroup.writeEntry("tagId", mTagId);
newGroup.writeEntry("currentFolder", mCurrentFolder.id());
newGroup.writeEntry("identifier", mIdentifier);
// TODO mStatus.toQInt32()
newGroup.sync();
grp.writeEntry("NumberFilter", numberFilter);
......@@ -150,6 +167,8 @@ Filter *Filter::load(const KSharedConfig::Ptr &config, int filternumber)
filter->setSearchString(newGroup.readEntry("searchString"), static_cast<QuickSearchLine::SearchOptions>(newGroup.readEntry("searchOptions").toInt()));
filter->setCurrentFolder(Akonadi::Collection(newGroup.readEntry("currentFolder").toInt()));
filter->setTagId(newGroup.readEntry("tagId"));
filter->setIdentifier(newGroup.readEntry("identifier"));
filter->setFilterName(newGroup.readEntry("name"));
return filter;
}
return nullptr;
......@@ -228,3 +247,13 @@ void Filter::setTagId(const QString &tagId)
{
mTagId = tagId;
}
void Filter::generateRandomIdentifier()
{
mIdentifier = KRandom::randomString(16);
}
QString Filter::identifier() const
{
return mIdentifier;
}
......@@ -91,6 +91,13 @@ public:
void save(const KSharedConfig::Ptr &config, const QString &filtername);
static Q_REQUIRED_RESULT Filter *load(const KSharedConfig::Ptr &config, int filternumber);
void generateRandomIdentifier();
Q_REQUIRED_RESULT QString identifier() const;
void setIdentifier(const QString &newIdentifier);
Q_REQUIRED_RESULT const QString &filterName() const;
void setFilterName(const QString &newFilterName);
Q_SIGNALS:
void finished();
......@@ -103,6 +110,8 @@ private:
QSet<qint64> mMatchingItemIds;
QuickSearchLine::SearchOptions mOptions;
QStringList mSearchList;
QString mIdentifier;
QString mFilterName;
};
} // namespace Core
} // namespace MessageList
......
......@@ -74,12 +74,10 @@ void FilterSavedManager::removeFilter(const QString &identifier)
int numberOfFilter = 0;
for (Filter *f : qAsConst(lst)) {
#if 0
if (f->identifier != identifier) {
f->save(KSharedConfig::openConfig(), f->name());
if (f->identifier() != identifier) {
f->save(KSharedConfig::openConfig(), f->filterName());
numberOfFilter++;
}
#endif
}
// TODO save number of filter
qDeleteAll(lst);
......
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