1
/***************************************************************************
2
* Copyright (C) 2012 by Daniel Nicoletti *
5
* This program is free software; you can redistribute it and/or modify *
6
* it under the terms of the GNU General Public License as published by *
7
* the Free Software Foundation; either version 2 of the License, or *
8
* (at your option) any later version. *
10
* This program is distributed in the hope that it will be useful, *
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13
* GNU General Public License for more details. *
15
* You should have received a copy of the GNU General Public License *
16
* along with this program; see the file COPYING. If not, write to *
17
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, *
18
* Boston, MA 02110-1301, USA. *
19
***************************************************************************/
21
#include "CategoryMatcher.h"
23
CategoryMatcher::CategoryMatcher(Kind kind, const QString &term) :
29
CategoryMatcher::CategoryMatcher(const CategoryMatcher &other) :
32
m_child(other.m_child)
36
CategoryMatcher::~CategoryMatcher()
40
CategoryMatcher &CategoryMatcher::operator =(const CategoryMatcher &other)
42
m_kind = other.m_kind;
43
m_term = other.m_term;
44
m_child = other.m_child;
48
bool CategoryMatcher::match(const QStringList &categories) const
50
if (categories.isEmpty()) {
57
ret = categories.contains(m_term);
60
foreach (const CategoryMatcher &parser, m_child) {
61
if (!(ret = parser.match(categories))) {
67
foreach (const CategoryMatcher &parser, m_child) {
68
if ((ret = parser.match(categories))) {
74
// We match like And but negating
75
foreach (const CategoryMatcher &parser, m_child) {
76
if (!(ret = !parser.match(categories))) {
85
void CategoryMatcher::setChild(const QList<CategoryMatcher> &child)
90
QList<CategoryMatcher> CategoryMatcher::child() const
95
QString CategoryMatcher::term() const
100
CategoryMatcher::Kind CategoryMatcher::kind() const