From a39a1118320c2c2e291f9e771ab75d32549431a7 Mon Sep 17 00:00:00 2001 From: Arno Date: Wed, 10 Apr 2013 21:36:26 +0200 Subject: Fix setAlternatignRowColors Well, what started as a try to simplify QTreeView ended in a mass header murder... What happened: * I searched for a way to let every QTreeView honor the setAlternatingRowcolors() setting. Unfortunately it isn't enough to just set the global palette and set it to true. So every QTreeView is now derived from SmTreeView * SmTreeView registers itself with SmGlobals, so the property is set _after_ it's constructed. It's definitely not enough to call it in the constructor. I guess that's a bug. But it's enough to append the SmTreeView to a QList in SmGlobals and call it _after_ the painting is done. * As an added Bonus we can add virt. funcs to every SmTreeView at will While at it I realized that most of the included headers were void, so remove them. No idea what impact it has on the bin size... --- filesystemwidget.cpp | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) (limited to 'filesystemwidget.cpp') diff --git a/filesystemwidget.cpp b/filesystemwidget.cpp index dce3b19..7ded048 100644 --- a/filesystemwidget.cpp +++ b/filesystemwidget.cpp @@ -5,11 +5,8 @@ 2 of the License, or (at your option) any later version. */ -#include -#include #include #include -#include #include #include #include @@ -17,9 +14,7 @@ #include #include #include -#include #include -#include #include #include #include @@ -30,7 +25,6 @@ #include "fileview.h" #include "shemoviconprovider.h" #include "filesystemfileproxy.h" -#include "helper.h" #include "pictureviewer2.h" #include "smglobals.h" #include "smdirmodel.h" @@ -41,7 +35,7 @@ FilesystemWidget::FilesystemWidget(QWidget *parent) : QWidget(parent), mClipboar mModel->setFilter(QDir::AllEntries | QDir::NoDot); mModel->setReadOnly(false); mIconProvider = new SheMovIconProvider; - mModel->setIconProvider(mIconProvider); + mModel->setIconProvider(mIconProvider); QStringList fHeaders = QStringList() << tr("Name") << tr("Size") << tr("Type") << tr("Created") << tr("Md5Sum") << tr("Dur./Size") << tr("Bitrate") << tr("Full Path") << tr("Present"); mFileModel = new SmDirModel(fHeaders, this); @@ -49,7 +43,7 @@ FilesystemWidget::FilesystemWidget(QWidget *parent) : QWidget(parent), mClipboar mDirProxy = new FilesystemDirProxy; mDirProxy->setSourceModel(mModel); - mDirView = new QTreeView; + mDirView = new SmTreeView; mDirView->setModel(mDirProxy); mDirView->setColumnHidden(1, true); mDirView->setColumnHidden(2, true); @@ -59,8 +53,6 @@ FilesystemWidget::FilesystemWidget(QWidget *parent) : QWidget(parent), mClipboar mDirView->setEditTriggers(QAbstractItemView::NoEditTriggers); mDirView->setSortingEnabled(true); mDirView->sortByColumn(0, Qt::AscendingOrder); - mDirView->setAlternatingRowColors(true); - SmGlobals::instance()->treeWidgets().append(mDirView); mFileView = new FileView; mFileProxy = new FilesystemFileProxy; @@ -74,7 +66,6 @@ FilesystemWidget::FilesystemWidget(QWidget *parent) : QWidget(parent), mClipboar mFileView->setSelectionMode(QAbstractItemView::ExtendedSelection); mFileView->setSelectionBehavior(QAbstractItemView::SelectRows); - mFileView->setAlternatingRowColors(true); mFileProxy->setDynamicSortFilter(true); connect(mFileView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), mFileView, SLOT(selectedFilesChanged())); connect(mFileModel, SIGNAL(modelAboutToBeReset()), mFileView, SLOT(saveSelection())); -- cgit v1.2.3-70-g09d2