1 /***************************************************************************
2  *   Copyright (C) 2013~2013 by CSSlayer                                   *
3  *   wengxt@gmail.com                                                      *
4  *                                                                         *
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 3 of the License, or      *
8  *  (at your option) any later version.                                    *
9  *                                                                         *
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.                           *
14  *                                                                         *
15  *  You should have received a copy of the GNU General Public License      *
16  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.  *
17  *                                                                         *
18  ***************************************************************************/
19 
20 #ifndef RULEMODEL_H
21 #define RULEMODEL_H
22 #include <QAbstractListModel>
23 
24 #include <libskk/libskk.h>
25 
26 class Rule {
27 public:
Rule(const QString & name,const QString & label)28     Rule(const QString& name, const QString& label) :
29         m_name(name),
30         m_label(label)
31     {
32     }
33 
name()34     const QString& name() const {
35         return m_name;
36     }
37 
label()38     const QString& label() const {
39         return m_label;
40     }
41 
42 private:
43     QString m_name;
44     QString m_label;
45 };
46 
47 class RuleModel : public QAbstractListModel
48 {
49     Q_OBJECT
50 public:
51     explicit RuleModel(QObject* parent = 0);
52 
53     virtual ~RuleModel();
54 
55     virtual int rowCount(const QModelIndex& parent = QModelIndex()) const;
56     virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
57     void load();
58     int findRule(const QString& name);
59 
60 private:
61     QList<Rule> m_rules;
62 };
63 
64 #endif // RULEMODEL_H
65