git-svn-id: file:///svnroot/family-shop-mgr@27 26eb2498-383b-47a6-be48-5d6f36779e85
[family-shop-mgr] / code / family-shop-mgr / ShoppingTreeItem.h
1 /*\r
2  * This file is part of family-shop-mgr.\r
3  *\r
4  * family-shop-mgr is free software: you can redistribute it and/or modify\r
5  * it under the terms of the GNU General Public License as published by\r
6  * the Free Software Foundation, either version 3 of the License, or\r
7  * (at your option) any later version.\r
8  *\r
9  * family-shop-mgr is distributed in the hope that it will be useful,\r
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
12  * GNU General Public License for more details.\r
13  *\r
14  * You should have received a copy of the GNU General Public License\r
15  * along with family-shop-mgr.  If not, see <http://www.gnu.org/licenses/>.\r
16  *\r
17  * Author: Unai IRIGOYEN\r
18  * Date: 12/07/2009\r
19  *\r
20  */\r
21 \r
22 #ifndef SHOPPINGTREEITEM_H\r
23 #define SHOPPINGTREEITEM_H\r
24 \r
25 #include <QList>\r
26 #include <QVariant>\r
27 #include <QVector>\r
28 \r
29 #include "ShoppingTreeModel.h"\r
30 \r
31 class ShoppingTreeItem : public QObject\r
32 {\r
33 Q_OBJECT\r
34 \r
35 public:\r
36 \r
37     enum ItemType\r
38     {\r
39         Category = 0,\r
40         Item = 1,\r
41 \r
42         NotDefined = -1\r
43     };\r
44 \r
45     ShoppingTreeItem(const QVector<QVariant> &data, ShoppingTreeItem *parent = 0);\r
46     ~ShoppingTreeItem();\r
47 \r
48     ShoppingTreeItem *child(int number);\r
49     int childCount() const;\r
50     int columnCount() const;\r
51     QVariant data(int column) const;\r
52     bool insertChildren(int position, int count, int columns,\r
53                         ShoppingTreeModel* model = 0);\r
54     bool insertColumns(int position, int columns);\r
55     ShoppingTreeItem *parent();\r
56     bool removeChildren(int position, int count);\r
57     bool removeColumns(int position, int columns);\r
58     int childNumber() const;\r
59     bool setData(int column, const QVariant &value);\r
60     bool setItemType(const ItemType type);\r
61     ItemType getItemType() const;\r
62 \r
63 signals:\r
64     void childItemSet(ShoppingTreeItem *item);\r
65     void dataChanged(int column);\r
66     void childRemoved(ShoppingTreeItem *item);\r
67 \r
68 private:\r
69     QList<ShoppingTreeItem*> childItems;\r
70     QVector<QVariant> itemData;\r
71     ShoppingTreeItem *parentItem;\r
72 \r
73     ItemType m_itemType;\r
74 };\r
75 \r
76 #endif // SHOPPINGTREEITEM_H\r