diff options
author | Arno <am@disconnect.de> | 2013-04-10 21:36:26 +0200 |
---|---|---|
committer | Arno <am@disconnect.de> | 2013-04-10 21:36:26 +0200 |
commit | a39a1118320c2c2e291f9e771ab75d32549431a7 (patch) | |
tree | a82ae27aa4e0e398e99b1127b51d65da36f1c5b9 /dbanalyzer.cpp | |
parent | 69791ade746638180a959c190fa5db6519c83a38 (diff) | |
download | SheMov-a39a1118320c2c2e291f9e771ab75d32549431a7.tar.gz SheMov-a39a1118320c2c2e291f9e771ab75d32549431a7.tar.bz2 SheMov-a39a1118320c2c2e291f9e771ab75d32549431a7.zip |
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<QWidget*> 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...
Diffstat (limited to 'dbanalyzer.cpp')
-rw-r--r-- | dbanalyzer.cpp | 28 |
1 files changed, 8 insertions, 20 deletions
diff --git a/dbanalyzer.cpp b/dbanalyzer.cpp index 90debeb..f9e3830 100644 --- a/dbanalyzer.cpp +++ b/dbanalyzer.cpp @@ -6,24 +6,16 @@ */ #include <QSqlQuery> -#include <QtWidgets/QTableWidget> -#include <QtWidgets/QTreeView> #include <QtWidgets/QPushButton> -#include <QtWidgets/QHBoxLayout> -#include <QtWidgets/QVBoxLayout> -#include <QMutexLocker> -#include <QtWidgets/QTableWidget> -#include <QModelIndex> #include <QtWidgets/QLabel> -#include <QColor> #include <QtWidgets/QMenu> -#include <QtWidgets/QAction> #include <QtWidgets/QStackedLayout> #include "dbanalyzer.h" #include "smtreemodel.h" #include "smtreeitem.h" #include "smglobals.h" +#include "smtreeview.h" DbAnalyzerDialog::DbAnalyzerDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f), mMarkMode(DbAnalyzer::NOMARKS), mCurrentView(0){ //create tab widget @@ -35,7 +27,7 @@ DbAnalyzerDialog::DbAnalyzerDialog(QWidget *parent, Qt::WindowFlags f) : QDialog //no actors QWidget *noActorsT = new QWidget; QStringList noActorsHeaders = QStringList() << tr("Series") << tr("Part/Subtitle") << tr("Series Part") << tr("Seriespart Id") << tr("Series Id") << tr("Seriespart"); - mNoActorsV = new QTreeView; + mNoActorsV = new SmTreeView; mNoActorsM = new SmTreeModel(noActorsHeaders, this); mNoActorsV->setModel(mNoActorsM); QVBoxLayout *noActorsL = new QVBoxLayout; @@ -52,12 +44,11 @@ DbAnalyzerDialog::DbAnalyzerDialog(QWidget *parent, Qt::WindowFlags f) : QDialog noActorsT->setLayout(noActorsL); mCurrentView = mNoActorsV; mMarkMode = DbAnalyzer::MARKS_ACTORS; - SmGlobals::instance()->treeWidgets().append(mNoActorsV); //no covers QWidget *noCoversT = new QWidget; QStringList noCoversHeaders = QStringList() << tr("Series") << tr("Part/Subtitle") << tr("Series Part") << tr("Seriespart Id") << tr("Series Id") << tr("Seriespart"); - mNoCoversV = new QTreeView; + mNoCoversV = new SmTreeView; mNoCoversM = new SmTreeModel(noCoversHeaders, this); mNoCoversV->setModel(mNoCoversM); QVBoxLayout *noCoversL = new QVBoxLayout; @@ -72,12 +63,11 @@ DbAnalyzerDialog::DbAnalyzerDialog(QWidget *parent, Qt::WindowFlags f) : QDialog mNoCoversV->setAlternatingRowColors(true); connect(mNoCoversV, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(noDataDoubleClicked(QModelIndex))); noCoversT->setLayout(noCoversL); - SmGlobals::instance()->treeWidgets().append(mNoCoversV); //stray actors QWidget *strayActorsT = new QWidget; QStringList strayActorsHeaders = QStringList() << tr("Actor") << tr("Actor Id") << tr("Count"); - mStrayActorsV = new QTreeView; + mStrayActorsV = new SmTreeView; mStrayActorsM = new SmTreeModel(strayActorsHeaders, this); mStrayActorsV->setModel(mStrayActorsM); QVBoxLayout *strayActorsL = new QVBoxLayout; @@ -88,12 +78,11 @@ DbAnalyzerDialog::DbAnalyzerDialog(QWidget *parent, Qt::WindowFlags f) : QDialog mStrayActorsV->setSelectionMode(QAbstractItemView::ExtendedSelection); mStrayActorsV->setAlternatingRowColors(true); strayActorsT->setLayout(strayActorsL); - SmGlobals::instance()->treeWidgets().append(mStrayActorsV); //stray genres QWidget *strayGenresT = new QWidget; QStringList strayGenresHeaders = QStringList() << tr("Genre") << tr("Genre Id") << tr("Count"); - mStrayGenresV = new QTreeView; + mStrayGenresV = new SmTreeView; mStrayGenresM = new SmTreeModel(strayGenresHeaders, this); mStrayGenresV->setModel(mStrayGenresM); QVBoxLayout *strayGenresL = new QVBoxLayout; @@ -104,7 +93,6 @@ DbAnalyzerDialog::DbAnalyzerDialog(QWidget *parent, Qt::WindowFlags f) : QDialog mStrayGenresV->setSelectionMode(QAbstractItemView::ExtendedSelection); mStrayGenresV->setAlternatingRowColors(true); strayGenresT->setLayout(strayGenresL); - SmGlobals::instance()->treeWidgets().append(mStrayGenresV); //buttons mCancel = new QPushButton(tr("Cancel")); @@ -214,7 +202,7 @@ void DbAnalyzerDialog::noDataDoubleClicked(const QModelIndex &idx){ } void DbAnalyzerDialog::deleteItems(){ - QTreeView *view = 0; + SmTreeView *view = 0; int deleteMode; switch(mTab->currentIndex()){ case 0: @@ -288,7 +276,7 @@ void DbAnalyzerDialog::deleteMarks(){ } } -void DbAnalyzerDialog::populate(QTreeView *view, SmTreeModel *model, const QList<QList<QVariant> > &data, const QHash<int, QVariant> &marks){ +void DbAnalyzerDialog::populate(SmTreeView *view, SmTreeModel *model, const QList<QList<QVariant> > &data, const QHash<int, QVariant> &marks){ if(data.isEmpty()){ return; } @@ -314,7 +302,7 @@ void DbAnalyzerDialog::populate(QTreeView *view, SmTreeModel *model, const QList } const QList<int> DbAnalyzerDialog::currentIds() const { - QTreeView *curView = qobject_cast<QTreeView*>(mCurrentView); + SmTreeView *curView = qobject_cast<SmTreeView*>(mCurrentView); Q_ASSERT(curView); QModelIndexList curIdxs = curView->selectionModel()->selectedRows(4); QList<int> retval; |