--- /dev/null
+/*\r
+ * This file is part of family-shop-mgr.\r
+ *\r
+ * family-shop-mgr is free software: you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation, either version 3 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * family-shop-mgr is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with family-shop-mgr. If not, see <http://www.gnu.org/licenses/>.\r
+ *\r
+ * Author: Unai IRIGOYEN\r
+ * Date: 12/07/2009\r
+ *\r
+ */\r
+\r
+#ifndef SHOPPINGTREEMODEL_H\r
+#define SHOPPINGTREEMODEL_H\r
+\r
+#include <QAbstractItemModel>\r
+#include <QDomDocument>\r
+#include <QModelIndex>\r
+#include <QVariant>\r
+\r
+class ShoppingTreeItem;\r
+\r
+enum ItemType{\r
+ item,\r
+ category\r
+};\r
+\r
+class ShoppingTreeModel : public QAbstractItemModel\r
+{\r
+ Q_OBJECT\r
+\r
+public:\r
+ ShoppingTreeModel(QString fileName, QObject *parent = 0);\r
+ ~ShoppingTreeModel();\r
+\r
+ QVariant data(const QModelIndex &index, int role) const;\r
+ Qt::ItemFlags flags(const QModelIndex &index) const;\r
+ QVariant headerData(int section, Qt::Orientation orientation,\r
+ int role = Qt::DisplayRole) const;\r
+ QModelIndex index(int row, int column,\r
+ const QModelIndex &parent = QModelIndex()) const;\r
+ QModelIndex parent(const QModelIndex &child) const;\r
+ int rowCount(const QModelIndex &parent = QModelIndex()) const;\r
+ int columnCount(const QModelIndex &parent = QModelIndex()) const;\r
+ bool insertRows(int row, int count,\r
+ const QModelIndex & parent = QModelIndex(),\r
+ ItemType type = item);\r
+ bool removeRows(int row, int count, const QModelIndex & parent = QModelIndex());\r
+\r
+public slots:\r
+ void addCategory(QModelIndex & index);\r
+ void addItem(QModelIndex & index);\r
+ void removeElement(QModelIndex & index);\r
+ void save();\r
+\r
+signals:\r
+ void documentChanged();\r
+\r
+private:\r
+ QString m_fileName;\r
+ QDomDocument domDocument;\r
+ QDomNode rootItemNode;\r
+ ShoppingTreeItem *rootItem;\r
+};\r
+\r
+#endif // SHOPPINGTREEMODEL_H\r