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... --- mappingtablewidget.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'mappingtablewidget.cpp') diff --git a/mappingtablewidget.cpp b/mappingtablewidget.cpp index 991b09d..593fd75 100644 --- a/mappingtablewidget.cpp +++ b/mappingtablewidget.cpp @@ -5,11 +5,8 @@ 2 of the License, or (at your option) any later version. */ -#include -#include #include #include -#include #include #include #include @@ -22,13 +19,12 @@ MappingTableWidget::MappingTableWidget(const QString &table, QWidget *parent) : QWidget(parent), mTable(table), mCurrentId(-1){ //the view - mView = new QTreeView; + mView = new SmTreeView; mView->setHeaderHidden(true); mModel = new MappingTableItemModel(this); mModel->setHeaderData(0, Qt::Horizontal, mTable); mView->setModel(mModel); mView->setAlternatingRowColors(true); - SmGlobals::instance()->treeWidgets().append(mView); //mapping model mMappingModel = static_cast(SmGlobals::instance()->model(mTable)); @@ -169,7 +165,7 @@ QModelIndex MappingTableItemModel::find(const QString &value) const{ MappingTableResultDialog::MappingTableResultDialog(const QStringList &results, QWidget *parent, Qt::WindowFlags f) : SmDialog(parent, f){ mModel = new QStringListModel(results, this); - mView = new QTreeView(this); + mView = new SmTreeView(this); mView->setModel(mModel); mView->setRootIsDecorated(false); mView->setSelectionMode(QAbstractItemView::SingleSelection); -- cgit v1.2.3-70-g09d2