From 609e8d6f4ae179243d6f258205701561d94500f5 Mon Sep 17 00:00:00 2001 From: Arno Date: Sun, 5 Dec 2010 08:29:05 +0100 Subject: Selectable columns in FilesTreeView Made columns shown in FilesTreeView selectable. Also, the order of columns is saved and restored. This was a difficult one. I even had to make a debug build of qt. But I fixed a serious bug in FilesTreeModel::modeName: don't access the Hash if modeName == -1. --- smtreemodel.h | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'smtreemodel.h') diff --git a/smtreemodel.h b/smtreemodel.h index 3eae432..73abe64 100644 --- a/smtreemodel.h +++ b/smtreemodel.h @@ -10,6 +10,7 @@ #include #include +#include class SmTreeItem; @@ -20,17 +21,18 @@ class SmTreeModel : public QAbstractItemModel { virtual ~SmTreeModel(); // counts - int rowCount(const QModelIndex &parent) const; - int columnCount(const QModelIndex &parent) const; + virtual int rowCount(const QModelIndex &parent) const; + virtual 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; + virtual QModelIndex index(int row, int column, const QModelIndex &parent) const; + virtual QModelIndex parent(const QModelIndex &child) const; virtual 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); + virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const; + virtual const QHash headerData() const; + virtual bool setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role); virtual QVariant data(const QModelIndex &index, int role) const; virtual bool setData(const QModelIndex &index, const QVariant &value, int role); virtual QModelIndex find(const QVariant &value, int column = 0, const QModelIndex &parent = QModelIndex()) const; @@ -42,8 +44,8 @@ class SmTreeModel : public QAbstractItemModel { void reparent(const QModelIndex &idx, const QModelIndex &newParent); // row manipulation - bool insertRows(int row, int count, const QModelIndex &parent); - bool removeRows(int row, int count, const QModelIndex &parent); + virtual bool insertRows(int row, int count, const QModelIndex &parent); + virtual bool removeRows(int row, int count, const QModelIndex &parent); bool addRow(const QList &data, const QModelIndex &parent); protected: @@ -52,6 +54,7 @@ class SmTreeModel : public QAbstractItemModel { private: QStringList mHeaders; SmTreeItem *mRootItem; + QHash mHeaderData; }; #endif -- cgit v1.2.3-70-g09d2