X-Git-Url: http://git.maemo.org/git/?p=family-shop-mgr;a=blobdiff_plain;f=code%2Ffamily-shop-mgr%2Fmodel%2FShoppingTreeModel.h;fp=code%2Ffamily-shop-mgr%2Fmodel%2FShoppingTreeModel.h;h=cb283b023257fe18d80842bbd8b35b209fe0ad1b;hp=0000000000000000000000000000000000000000;hb=6d19d55e61c6fe26d16f246c06bec58b955010ca;hpb=c8fe8c6762998fd5238ed8816b8b862b6edaa30d
diff --git a/code/family-shop-mgr/model/ShoppingTreeModel.h b/code/family-shop-mgr/model/ShoppingTreeModel.h
new file mode 100644
index 0000000..cb283b0
--- /dev/null
+++ b/code/family-shop-mgr/model/ShoppingTreeModel.h
@@ -0,0 +1,75 @@
+/*
+ * This file is part of family-shop-mgr.
+ *
+ * family-shop-mgr is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * family-shop-mgr is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with family-shop-mgr. If not, see .
+ *
+ * Author: Unai IRIGOYEN
+ * Date: 12/07/2009
+ *
+ */
+
+#ifndef SHOPPINGTREEMODEL_H
+#define SHOPPINGTREEMODEL_H
+
+#include
+#include
+#include
+#include
+
+class ShoppingTreeItem;
+
+enum ItemType{
+ item,
+ category
+};
+
+class ShoppingTreeModel : public QAbstractItemModel
+{
+ Q_OBJECT
+
+public:
+ ShoppingTreeModel(QString fileName, QObject *parent = 0);
+ ~ShoppingTreeModel();
+
+ QVariant data(const QModelIndex &index, int role) const;
+ Qt::ItemFlags flags(const QModelIndex &index) const;
+ QVariant headerData(int section, Qt::Orientation orientation,
+ int role = Qt::DisplayRole) const;
+ QModelIndex index(int row, int column,
+ const QModelIndex &parent = QModelIndex()) const;
+ QModelIndex parent(const QModelIndex &child) const;
+ int rowCount(const QModelIndex &parent = QModelIndex()) const;
+ int columnCount(const QModelIndex &parent = QModelIndex()) const;
+ bool insertRows(int row, int count,
+ const QModelIndex & parent = QModelIndex(),
+ ItemType type = item);
+ bool removeRows(int row, int count, const QModelIndex & parent = QModelIndex());
+
+public slots:
+ void addCategory(QModelIndex & index);
+ void addItem(QModelIndex & index);
+ void removeElement(QModelIndex & index);
+ void save();
+
+signals:
+ void documentChanged();
+
+private:
+ QString m_fileName;
+ QDomDocument domDocument;
+ QDomNode rootItemNode;
+ ShoppingTreeItem *rootItem;
+};
+
+#endif // SHOPPINGTREEMODEL_H