/* This program 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 2 of the License, or (at your option) any later version. */ #ifndef SMTREEMODEL_H #define SMTREEMODEL_H #include #include class SmTreeItem; class SmTreeModel : public QAbstractItemModel { Q_OBJECT public: explicit SmTreeModel(const QStringList &headers, QObject *parent = 0); ~SmTreeModel(); // counts int rowCount(const QModelIndex &parent) const; int columnCount(const QModelIndex &parent) const; // index, parent and flags QModelIndex index(int row, int column, const QModelIndex &parent) const; QModelIndex parent(const QModelIndex &child) const; Qt::ItemFlags flags(const QModelIndex &index) const; // headers + data QVariant headerData(int section, Qt::Orientation orientation, int role) const; bool setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role); QVariant data(const QModelIndex &index, int role) const; bool setData(const QModelIndex &index, const QVariant &value, int role); bool setRoot(SmTreeItem *rootItem); // row manipulation bool insertRows(int row, int count, const QModelIndex &parent); bool removeRows(int row, int count, const QModelIndex &parent); bool addRow(const QList &data, const QModelIndex &parent); private: SmTreeItem *itemAt(const QModelIndex &index) const; QStringList mHeaders; SmTreeItem *mRootItem; }; #endif