features of DictManagerWidget restored in qml version.
[mdictionary] / src / mdictionary / gui / DictTypeModel.h
1 /*******************************************************************************
2
3     This file is part of mDictionary.
4
5     mDictionary 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     mDictionary 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 mDictionary.  If not, see <http://www.gnu.org/licenses/>.
17
18     Copyright 2010 Comarch S.A.
19
20 *******************************************************************************/
21
22 /*! \file DictTypeModel.h
23     \brief Contains plugins data for qml UI
24
25     \author Marcin Kaźmierczak <marcin.kazmierczak@comarch.pl>
26 */
27
28 #ifndef DICTTYPEMODEL_H
29 #define DICTTYPEMODEL_H
30
31 #include <QAbstractListModel>
32 #include <QHash>
33 #include "../../include/GUIInterface.h"
34
35 /*!
36   Contains a list of plugin types.
37   Data source for qml list view.
38 */
39 class DictTypeModel : public QAbstractListModel
40 {
41     Q_OBJECT
42 public:
43     enum DictTypeRoles
44     {
45         TypeRole = Qt::UserRole + 1,
46         NumberRole
47     };
48
49     //! Constructor
50     /*!
51       \param plugins list of plugin types
52       \param parent parent of this class.
53     */
54     explicit DictTypeModel(QList<CommonDictInterface*> plugins, QObject *parent = 0);
55
56     int rowCount(const QModelIndex & parent = QModelIndex()) const;
57
58     QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const;
59
60 private:
61     void setDictTypes(QList<CommonDictInterface*> plugins);
62     QList<CommonDictInterface*> _plugins;
63
64     void addType(CommonDictInterface* plugin);
65 };
66
67 #endif // DICTTYPEMODEL_H