1 #ifndef FILTERTREEMODEL_H 2 #define FILTERTREEMODEL_H 3 4 #include <QAbstractItemModel> 5 6 class FilterTree; 7 class CardFilter; 8 class FilterTreeNode; 9 10 class FilterTreeModel : public QAbstractItemModel 11 { 12 Q_OBJECT 13 private: 14 FilterTree *fTree; 15 16 public slots: 17 void addFilter(const CardFilter *f); 18 19 private slots: 20 void proxyBeginInsertRow(const FilterTreeNode *, int); 21 void proxyEndInsertRow(const FilterTreeNode *, int); 22 void proxyBeginRemoveRow(const FilterTreeNode *, int); 23 void proxyEndRemoveRow(const FilterTreeNode *, int); 24 25 private: 26 FilterTreeNode *indexToNode(const QModelIndex &idx) const; 27 QModelIndex nodeIndex(const FilterTreeNode *node, int row, int column) const; 28 29 public: 30 FilterTreeModel(QObject *parent = nullptr); 31 ~FilterTreeModel(); filterTree()32 FilterTree *filterTree() const 33 { 34 return fTree; 35 } 36 int rowCount(const QModelIndex &parent = QModelIndex()) const; 37 int columnCount(const QModelIndex & /*parent*/ = QModelIndex()) const; 38 QVariant data(const QModelIndex &index, int role) const; 39 bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole); 40 Qt::ItemFlags flags(const QModelIndex &index) const; 41 QModelIndex parent(const QModelIndex &ind) const; 42 QModelIndex index(int row, int column, const QModelIndex &parent) const; 43 bool removeRows(int row, int count, const QModelIndex &parent); 44 }; 45 46 #endif 47