KNewStuff

tagsfilterchecker.h
1/*
2 SPDX-FileCopyrightText: 2018 Dan Leinir Turthra Jensen <admin@leinir.dk>
3
4 SPDX-License-Identifier: LGPL-2.1-or-later
5*/
6
7#ifndef KNSCORE_TAGSFILTERCHECKER_H
8#define KNSCORE_TAGSFILTERCHECKER_H
9
10#include "knewstuffcore_export.h"
11#include <QStringList>
12
13#include <memory>
14
15namespace KNSCore
16{
17class TagsFilterCheckerPrivate;
18/**
19 * @brief Apply simple filtering logic to a list of tags
20 *
21 * == Examples of specifying tag filters ==
22 * Value for tag "tagname" must be exactly "tagdata":
23 * tagname==tagdata
24 *
25 * Value for tag "tagname" must be different from "tagdata":
26 * tagname!=tagdata
27 *
28 * == Tag filter list ==
29 * A tag filter list is a string list of filters as shown above, and a combination
30 * of which might look like:
31 *
32 * - ghns_excluded!=1
33 * - data##mimetype==application/cbr+zip
34 * - data##mimetype==application/cbr+rar
35 *
36 * which would filter out anything which has ghns_excluded set to 1, and
37 * anything where the value of data##mimetype does not equal either
38 * "application/cbr+zip" or "application/cbr+rar".
39 * Notice in particular the two data##mimetype entries. Use this
40 * for when a tag may have multiple values.
41 *
42 * The value does not current support wildcards. The list should be considered
43 * a binary AND operation (that is, all filter entries must match for the data
44 * entry to be included in the return data)
45 * @since 5.51
46 */
47// TODO KF7: privatize this class. it's not used by the outside
48class KNEWSTUFFCORE_EXPORT TagsFilterChecker
49{
50public:
51 /**
52 * Constructs an instance of the tags filter checker, prepopulated
53 * with the list of tag filters in the tagFilter parameter.
54 *
55 * @param tagFilter The list of tag filters
56 * @since 5.51
57 */
58 explicit TagsFilterChecker(const QStringList &tagFilter);
60
61 TagsFilterChecker(const TagsFilterChecker &) = delete;
62 TagsFilterChecker &operator=(const TagsFilterChecker &) = delete;
63
64 /**
65 * Check whether the filter list accepts the passed list of tags
66 *
67 * @param tags A list of tags in the form of key=value strings
68 * @return True if the filter accepts the list, false if not
69 * @since 5.51
70 */
71 bool filterAccepts(const QStringList &tags);
72
73private:
74 const std::unique_ptr<TagsFilterCheckerPrivate> d;
75};
76
77}
78
79#endif // KNSCORE_TAGSFILTERCHECKER_H
Apply simple filtering logic to a list of tags.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 29 2024 11:53:59 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.