LeechCraft
0.6.70-19424-g027e980fd1
Modular cross-platform feature rich live environment.
Toggle main menu visibility
Loading...
Searching...
No Matches
tagschange.cpp
Go to the documentation of this file.
1
/**********************************************************************
2
* LeechCraft - modular cross-platform feature rich internet client.
3
* Copyright (C) 2006-2014 Georg Rudoy
4
*
5
* Distributed under the Boost Software License, Version 1.0.
6
* (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
7
**********************************************************************/
8
9
#include "
tagschange.h
"
10
#include <algorithm>
11
12
namespace
LC::Util
13
{
14
namespace
15
{
16
QStringList Difference (
const
QStringList& from,
const
QStringList& subtracted)
17
{
18
QStringList result;
19
for
(
const
auto
& tag : from)
20
if
(!subtracted.contains (tag) && !result.contains (tag))
21
result << tag;
22
return
result;
23
}
24
25
bool
IsSubset (
const
QStringList& sub,
const
QStringList& of)
26
{
27
return
std::ranges::all_of (sub, [&of] (
const
QString& tag) {
return
of.contains (tag); });
28
}
29
}
30
31
QStringList
TagsChange::Added
()
const
32
{
33
return
Difference (
After_
,
Before_
);
34
}
35
36
QStringList
TagsChange::Removed
()
const
37
{
38
return
Difference (
Before_
,
After_
);
39
}
40
41
bool
TagsChange::IsEmpty
()
const
42
{
43
return
IsSubset (
After_
,
Before_
) && IsSubset (
Before_
,
After_
);
44
}
45
46
QStringList
TagsChange::ApplyTo
(QStringList tags)
const
47
{
48
for
(
const
auto
& tag :
Removed
())
49
tags.removeAll (tag);
50
51
for
(
const
auto
& tag :
Added
())
52
if
(!tags.contains (tag))
53
tags << tag;
54
55
return
tags;
56
}
57
}
LC::Util
Definition
icoreproxy.h:34
LC::Util::TagsChange::IsEmpty
bool IsEmpty() const
Returns whether this change neither adds nor removes tags.
Definition
tagschange.cpp:41
LC::Util::TagsChange::Removed
QStringList Removed() const
Returns the tags of Before_ missing from After_.
Definition
tagschange.cpp:36
LC::Util::TagsChange::Before_
QStringList Before_
Definition
tagschange.h:23
LC::Util::TagsChange::After_
QStringList After_
Definition
tagschange.h:24
LC::Util::TagsChange::ApplyTo
QStringList ApplyTo(QStringList tags) const
Applies this change to another tags list.
Definition
tagschange.cpp:46
LC::Util::TagsChange::Added
QStringList Added() const
Returns the tags of After_ missing from Before_.
Definition
tagschange.cpp:31
tagschange.h
src
util
tags
tagschange.cpp
Generated by
1.18.0