X-Git-Url: https://vcs.maemo.org/git/?a=blobdiff_plain;f=code%2Ffamily-shop-mgr%2FShoppingTreeModel.h;h=cb283b023257fe18d80842bbd8b35b209fe0ad1b;hb=c8fe8c6762998fd5238ed8816b8b862b6edaa30d;hp=92ef5c7ebb2a387a6f426f5c021ea1d945717c03;hpb=949383586d4a19d7f5d8f537e10cdfa01d36b6fc;p=family-shop-mgr diff --git a/code/family-shop-mgr/ShoppingTreeModel.h b/code/family-shop-mgr/ShoppingTreeModel.h index 92ef5c7..cb283b0 100644 --- a/code/family-shop-mgr/ShoppingTreeModel.h +++ b/code/family-shop-mgr/ShoppingTreeModel.h @@ -27,15 +27,20 @@ #include #include -class DomItem; +class ShoppingTreeItem; -class DomModel : public QAbstractItemModel +enum ItemType{ + item, + category +}; + +class ShoppingTreeModel : public QAbstractItemModel { Q_OBJECT public: - DomModel(QDomDocument document, QObject *parent = 0); - ~DomModel(); + ShoppingTreeModel(QString fileName, QObject *parent = 0); + ~ShoppingTreeModel(); QVariant data(const QModelIndex &index, int role) const; Qt::ItemFlags flags(const QModelIndex &index) const; @@ -46,11 +51,25 @@ public: 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; - DomItem *rootItem; + ShoppingTreeItem *rootItem; }; #endif // SHOPPINGTREEMODEL_H