summaryrefslogtreecommitdiffstats
path: root/smtreemodel.h
diff options
context:
space:
mode:
authorArno <am@disconnect.de>2010-12-05 08:29:05 +0100
committerArno <am@disconnect.de>2010-12-05 08:29:05 +0100
commit609e8d6f4ae179243d6f258205701561d94500f5 (patch)
tree057b5c21086d984c05b9d5e50cf5be59e167b5e6 /smtreemodel.h
parentd1837c9c92c9f38a464f0473001db4e9a57d44e7 (diff)
downloadSheMov-609e8d6f4ae179243d6f258205701561d94500f5.tar.gz
SheMov-609e8d6f4ae179243d6f258205701561d94500f5.tar.bz2
SheMov-609e8d6f4ae179243d6f258205701561d94500f5.zip
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.
Diffstat (limited to 'smtreemodel.h')
-rw-r--r--smtreemodel.h19
1 files changed, 11 insertions, 8 deletions
diff --git a/smtreemodel.h b/smtreemodel.h
index 3eae432..73abe64 100644
--- a/smtreemodel.h
+++ b/smtreemodel.h
@@ -10,6 +10,7 @@
#include <QAbstractItemModel>
#include <QStringList>
+#include <QHash>
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<QString, int> 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<QVariant> &data, const QModelIndex &parent);
protected:
@@ -52,6 +54,7 @@ class SmTreeModel : public QAbstractItemModel {
private:
QStringList mHeaders;
SmTreeItem *mRootItem;
+ QHash<QString, int> mHeaderData;
};
#endif