#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
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