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.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'smtreemodel.cpp') 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 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); -- cgit v1.2.3-70-g09d2