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 /newpicsdialog.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 'newpicsdialog.cpp')
-rw-r--r-- | newpicsdialog.cpp | 25 |
1 files changed, 9 insertions, 16 deletions
diff --git a/newpicsdialog.cpp b/newpicsdialog.cpp index 37a9cba..36fdfe1 100644 --- a/newpicsdialog.cpp +++ b/newpicsdialog.cpp @@ -5,36 +5,24 @@ 2 of the License, or (at your option) any later version. */ -#include <QFileInfo> -#include <QSqlDatabase> #include <QSqlQuery> -#include <QtWidgets/QLabel> -#include <QtWidgets/QTreeView> #include <QSortFilterProxyModel> #include <QtWidgets/QPushButton> #include <QSettings> -#include <QDir> #include <QtWidgets/QFileDialog> -#include <QPersistentModelIndex> -#include <QtWidgets/QHBoxLayout> #include <QtWidgets/QVBoxLayout> -#include <QApplication> #include "newpicsdialog.h" #include "smtreeitem.h" #include "helper.h" #include "mappingtreewidget.h" #include "mappingtreemodel.h" +#include "smglobals.h" NewPicsDialog::NewPicsDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f) { setupDlg(); } -NewPicsDialog::NewPicsDialog(const QStringList &files, QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f){ - setupDlg(); - addFiles(files); -} - void NewPicsDialog::setupDlg(){ //setup database mDb = QSqlDatabase::database("treedb"); @@ -45,16 +33,14 @@ void NewPicsDialog::setupDlg(){ //files widget mFilesWidget = new QWidget; - mFilesV = new QTreeView; + mFilesV = new SmTreeView; mFilesProxy = new QSortFilterProxyModel(this); mFilesModel = new NewPicFilesModel(QStringList() << tr("Filename") << tr("Size") << tr("Val.") << tr("Md5") << tr("Mime type") << tr("Full path"), this); mFilesProxy->setSourceModel(mFilesModel); mFilesV->setModel(mFilesProxy); mFilesV->setSortingEnabled(true); - mFilesV->setAlternatingRowColors(true); mFilesV->setColumnHidden(2, true); mFilesV->setAlternatingRowColors(true); - mFilesV->setPalette(qApp->palette()); mAddFiles = new QPushButton(tr("Select...")); connect(mAddFiles, SIGNAL(clicked()), this, SLOT(selectFiles())); mRemoveFiles = new QPushButton(tr("Remove")); @@ -118,6 +104,13 @@ void NewPicsDialog::addFiles(const QStringList &files){ } } +void NewPicsDialog::clearFiles(){ + mFilesV->setSortingEnabled(false); + SmTreeItem *rootItem = new SmTreeItem(NewPicFilesModel::NumFields); + mFilesModel->setRoot(rootItem); + mFilesV->setSortingEnabled(true); +} + void NewPicsDialog::removeFiles(){ QModelIndexList selected = mFilesV->selectionModel()->selectedRows(); if(selected.isEmpty()){ |