2
* Copyright (C) 2007 Ivan Cukic <ivan.cukic(at)kde.org>
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU Lesser/Library General Public License version 2,
6
* or (at your option) any later version, as published by the Free
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU Lesser/Library General Public License for more details
14
* You should have received a copy of the GNU Lesser/Library General Public
15
* License along with this program; if not, write to the
16
* Free Software Foundation, Inc.,
17
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20
#ifndef LANCELOT_STANDARD_ACTION_TREE_MODEL_H
21
#define LANCELOT_STANDARD_ACTION_TREE_MODEL_H
23
#include "ActionTreeModel.h"
25
#include <lancelot/lancelot_export.h>
30
class LANCELOT_EXPORT StandardActionTreeModel: public ActionTreeModel {
33
* This class represents an item in the list model.
35
class LANCELOT_EXPORT Item {
37
explicit Item(QString itemTitle = QString(),
38
QString itemDescription = QString(),
39
QIcon itemIcon = QIcon(),
40
QVariant itemData = QVariant());
49
QList < Item * > children;
52
StandardActionTreeModel(Item * root);
55
virtual StandardActionTreeModel * createChild(int index) = 0;
59
StandardActionTreeModel();
61
virtual ~StandardActionTreeModel();
64
L_Override ActionTreeModel * child(int index);
65
L_Override QString selfTitle() const;
66
L_Override QIcon selfIcon() const;
69
L_Override QString title(int index) const;
70
L_Override QString description(int index) const;
71
L_Override QIcon icon(int index) const;
72
L_Override bool isCategory(int index) const;
74
L_Override int size() const;
76
QVariant data(int index) const;
79
* Adds a new item into the model
80
* @param item new item
82
void add(Item * item, Item * parent = NULL);
85
* Adds a new item into the model
86
* @param title the title for the new item
87
* @param description the description of the new item
88
* @param icon the icon for the new item
89
* @param data data for the new item. Not shown to user
91
void add(const QString & title, const QString & description,
92
QIcon icon, const QVariant & data, Item * parent = NULL);
95
* Replaces existing item at specified index with a new one
96
* @param index index of the item to be replaced
97
* @param item new item
99
void set(int index, Item * item, Item * parent = NULL);
102
* Replaces existing item at specified index with a new one
103
* @param index index of the item to be replaced
104
* @param title the title for the new item
105
* @param description the description of the new item
106
* @param icon the icon for the new item
107
* @param data data for the new item. Not shown to user
109
void set(int index, const QString & title, const QString & description,
110
QIcon icon, const QVariant & data, Item * parent = NULL);
114
* @param index index of the item to remove
116
void removeAt(int index, Item * parent = NULL);
119
* @returns the specified item
120
* @param index index of the item to return
122
Item * itemAt(int index, Item * parent = NULL);
127
void clear(Item * parent = NULL);
135
} // namespace Lancelot
137
#endif /* LANCELOT_STANDARD_ACTION_TREE_MODEL_H */