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... --- shemov.cpp | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) (limited to 'shemov.cpp') diff --git a/shemov.cpp b/shemov.cpp index eed20df..a2fd195 100644 --- a/shemov.cpp +++ b/shemov.cpp @@ -59,6 +59,7 @@ #include "pictureviewer2.h" #include "helper.h" #include "smdirmodel.h" +#include "smtreeview.h" SheMov::SheMov(QWidget *parent, Qt::WindowFlags flags) : QMainWindow(parent, flags), mOpenWithGroupFS(0), mOpenWithGroupAV(0) { //application icon @@ -104,7 +105,7 @@ SheMov::SheMov(QWidget *parent, Qt::WindowFlags flags) : QMainWindow(parent, fla connect(mPicWidget->picView(), SIGNAL(selectedSize(qint64)), this, SLOT(setSize(qint64))); PictureViewer2 *picViewer = SmGlobals::instance()->pictureViewer(); - //newmoviewizard + dbanalyzer + //newmoviewizard + dbanalyzer + newpicsdialog splash.showMessage(tr("Creating misc. Dialogs..."), Qt::AlignHCenter, Qt::yellow); qApp->processEvents(); mNewMovieWizard = new NewMovieWizard(this); @@ -112,6 +113,7 @@ SheMov::SheMov(QWidget *parent, Qt::WindowFlags flags) : QMainWindow(parent, fla mDbAnalyzerDialog = new DbAnalyzerDialog(this); connect(mDbAnalyzerDialog, SIGNAL(partClicked(int, int)), mATree, SLOT(selectMoviePart(int, int))); connect(mDbAnalyzerDialog, SIGNAL(delItems(int,QList&)), this, SLOT(analyzeDelete(int,QList&))); + mNewPicsDialog = new NewPicsDialog(this); QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->addWidget(mTab); @@ -144,6 +146,7 @@ SheMov::SheMov(QWidget *parent, Qt::WindowFlags flags) : QMainWindow(parent, fla QWidget *centralWidget = new QWidget; centralWidget->setLayout(mainLayout); setCentralWidget(centralWidget); + show(); splash.finish(this); mATree->readSettings(); @@ -398,8 +401,6 @@ void SheMov::createActions(){ connect(mConsistencyA, SIGNAL(triggered()), this, SLOT(checkConsistency())); mAnalyzerA = new QAction(QIcon(":/higheels.png"), tr("Analyze Db..."), this); connect(mAnalyzerA, SIGNAL(triggered()), this, SLOT(analyzeDb())); - mMappingEditorA = new QAction(tr("Mapping editor..."), this); - connect(mMappingEditorA, SIGNAL(triggered()), this, SLOT(mappingEditor())); mNewPicsA = new QAction(tr("Archive pics...."), this); connect(mNewPicsA, SIGNAL(triggered()), this, SLOT(newPicsDialog())); @@ -765,7 +766,7 @@ void SheMov::createMenus(){ fileMenu->addSeparator(); fileMenu->addAction(mConsistencyA); fileMenu->addAction(mAnalyzerA); - fileMenu->addAction(mMappingEditorA); + //fileMenu->addAction(mMappingEditorA); fileMenu->addSeparator(); fileMenu->addAction(mQuitA); menuBar()->addMenu(fileMenu); @@ -1110,9 +1111,11 @@ void SheMov::createPalette(){ pal.setColor(QPalette::Base, Qt::white); pal.setColor(QPalette::AlternateBase, Qt::white); } - qApp->setPalette(pal); foreach(QWidget *w, SmGlobals::instance()->treeWidgets()){ - w->setPalette(pal); + SmTreeView *aiv = qobject_cast(w); + if(aiv){ + aiv->setPalette(pal); + } } } @@ -1171,18 +1174,8 @@ void SheMov::editMappings(QString table){ ed.exec(); } -void SheMov::mappingEditor(){ - QDialog dlg(this); - QHBoxLayout *dlgLayout = new QHBoxLayout; - MappingTreeWidget *mtw = new MappingTreeWidget; - dlgLayout->addWidget(mtw); - dlg.setLayout(dlgLayout); - dlg.exec(); -} - void SheMov::newPicsDialog(){ - NewPicsDialog npd(this); - npd.exec(); + mNewPicsDialog->exec(); } void SheMov::newPicsDialogWithFiles(){ @@ -1194,6 +1187,7 @@ void SheMov::newPicsDialogWithFiles(){ foreach(QModelIndex idx, selected){ files << idx.data(SmDirModel::FullPathRole).toString(); } - NewPicsDialog npd(files, this); - npd.exec(); + mNewPicsDialog->clearFiles(); + mNewPicsDialog->addFiles(files); + mNewPicsDialog->exec(); } -- cgit v1.2.3-70-g09d2