git-svn-id: file:///svnroot/family-shop-mgr@33 26eb2498-383b-47a6-be48-5d6f36779e85
[family-shop-mgr] / code / family-shop-mgr / ShoppingTreeModel.h
index 92ef5c7..cb283b0 100644 (file)
 #include <QModelIndex>\r
 #include <QVariant>\r
 \r
-class DomItem;\r
+class ShoppingTreeItem;\r
 \r
-class DomModel : public QAbstractItemModel\r
+enum ItemType{\r
+    item,\r
+    category\r
+};\r
+\r
+class ShoppingTreeModel : public QAbstractItemModel\r
 {\r
     Q_OBJECT\r
 \r
 public:\r
-    DomModel(QDomDocument document, QObject *parent = 0);\r
-    ~DomModel();\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
@@ -46,11 +51,25 @@ public:
     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
-    DomItem *rootItem;\r
+    ShoppingTreeItem *rootItem;\r
 };\r
 \r
 #endif // SHOPPINGTREEMODEL_H\r