File indexing completed on 2024-04-28 09:40:19

0001 /***************************************************************************
0002  *   Copyright (C) 2012 by Daniel Nicoletti                                *
0003  *   dantti12@gmail.com                                                    *
0004  *                                                                         *
0005  *   This program is free software; you can redistribute it and/or modify  *
0006  *   it under the terms of the GNU General Public License as published by  *
0007  *   the Free Software Foundation; either version 2 of the License, or     *
0008  *   (at your option) any later version.                                   *
0009  *                                                                         *
0010  *   This program is distributed in the hope that it will be useful,       *
0011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
0012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
0013  *   GNU General Public License for more details.                          *
0014  *                                                                         *
0015  *   You should have received a copy of the GNU General Public License     *
0016  *   along with this program; see the file COPYING. If not, write to       *
0017  *   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,  *
0018  *   Boston, MA 02110-1301, USA.                                           *
0019  ***************************************************************************/
0020 
0021 #ifndef CATEGORYMATCHER_H
0022 #define CATEGORYMATCHER_H
0023 
0024 #include <QMetaType>
0025 #include <QString>
0026 #include <QStringList>
0027 #include <QList>
0028 
0029 //#include <kdemacros.h>
0030 
0031 class Q_DECL_EXPORT CategoryMatcher
0032 {
0033 public:
0034     typedef enum {
0035         And,
0036         Or,
0037         Not,
0038         Term
0039     } Kind;
0040     explicit CategoryMatcher(Kind kind = And, const QString &term = QString());
0041     CategoryMatcher(const CategoryMatcher &other);
0042     ~CategoryMatcher();
0043     CategoryMatcher& operator=(const CategoryMatcher &other);
0044 
0045     bool match(const QStringList &categories) const;
0046 
0047     void setChild(const QList<CategoryMatcher> &child);
0048     QList<CategoryMatcher> child() const;
0049     QString term() const;
0050     Kind kind() const;
0051 
0052 private:
0053     Kind m_kind;
0054     QString m_term;
0055     QList<CategoryMatcher> m_child;
0056 };
0057 
0058 Q_DECLARE_METATYPE(CategoryMatcher)
0059 
0060 #endif // CATEGORYMATCHER_H