summaryrefslogtreecommitdiffstats
path: root/smtreemodel.cpp
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.cpp
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.cpp')
-rw-r--r--smtreemodel.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/smtreemodel.cpp b/smtreemodel.cpp
index a39f718..2712cef 100644
--- a/smtreemodel.cpp
+++ b/smtreemodel.cpp
@@ -12,6 +12,9 @@
SmTreeModel::SmTreeModel(const QStringList &headers, QObject *parent) : QAbstractItemModel(parent), mRootItem(0){
mHeaders = headers;
+ for(int i = 0; i < mHeaders.size(); ++i){
+ mHeaderData.insert(mHeaders.at(i), i);
+ }
mRootItem = new SmTreeItem(headers.count());
}
@@ -69,6 +72,10 @@ QVariant SmTreeModel::headerData(int section, Qt::Orientation orientation, int r
return QVariant();
}
+const QHash<QString, int> SmTreeModel::headerData() const{
+ return mHeaderData;
+}
+
bool SmTreeModel::setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role){
if((orientation == Qt::Horizontal) && (role == Qt::DisplayRole)){
mRootItem->setData(section, value);