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. --- filestreemodel.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'filestreemodel.cpp') diff --git a/filestreemodel.cpp b/filestreemodel.cpp index 35ae8bc..f47f8c3 100644 --- a/filestreemodel.cpp +++ b/filestreemodel.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include "filestreemodel.h" #include "smtreeitem.h" @@ -74,7 +75,7 @@ FilesTreeModel::~FilesTreeModel(){ const QString FilesTreeModel::modeName(int mode) const{ if(mode == -1){ - return mModeNames.value(mMode); + return QString(); } return mModeNames.value(mode); } @@ -139,6 +140,14 @@ QVariant FilesTreeModel::data(const QModelIndex &index, int role) const{ } return item->data(Quality); } + if(index.column() == FileType){ + return mFileTypes.value(item->data(FileType).toInt()); + } + if(index.column() == FullPath){ + if(item->data(DvdNo).toInt() > 0){ + return QString("(not available)"); + } + } return item->data(index.column()); } if(role == Qt::ToolTipRole){ @@ -185,6 +194,11 @@ QVariant FilesTreeModel::data(const QModelIndex &index, int role) const{ return QColor(Qt::green); } } + if(role == Qt::FontRole){ + if(index.column() == Md5Sum){ + return QFont("courier"); + } + } if(role == FileNameRole){ return item->data(FileName); } -- cgit v1.2.3-70-g09d2