diff options
author | Arno <arno@disconnect.de> | 2018-07-20 04:58:38 +0200 |
---|---|---|
committer | Arno <arno@disconnect.de> | 2018-07-20 04:58:38 +0200 |
commit | 83873855d4f4d3042b50e521029c902bc5e05893 (patch) | |
tree | ba4af6c4cf964fac3cd671cfb7a871d4f3d4b903 | |
parent | d54f8bc5effe3c008ff39f0e55bf1b71e08c19af (diff) | |
download | SheMov-83873855d4f4d3042b50e521029c902bc5e05893.tar.gz SheMov-83873855d4f4d3042b50e521029c902bc5e05893.tar.bz2 SheMov-83873855d4f4d3042b50e521029c902bc5e05893.zip |
Fix headere view for PictureListView
Make the headers great again!
-rw-r--r-- | picturelistview.cpp | 8 | ||||
-rw-r--r-- | pictureswidget.cpp | 28 | ||||
-rw-r--r-- | shemov.cpp | 7 | ||||
-rw-r--r-- | shemov.h | 1 | ||||
-rw-r--r-- | smtreeview.cpp | 14 |
5 files changed, 27 insertions, 31 deletions
diff --git a/picturelistview.cpp b/picturelistview.cpp index 22e27af..3037eb2 100644 --- a/picturelistview.cpp +++ b/picturelistview.cpp @@ -23,14 +23,6 @@ PictureListView::PictureListView(QWidget *parent) : SmTreeView("ui/picheaderpos" connect(selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(selectedFilesChanged())); mMappingTreeModel = static_cast<MappingTreeModel*>(SmGlobals::instance()->model("MappingTree")); - //read settings - QSettings s; - QByteArray pvHeader = s.value("ui/pvheader").toByteArray(); - mCursorOffset = s.value("ui/cursoroffset").toInt(); - if(!pvHeader.isEmpty()){ - header()->restoreState(pvHeader); - } - //hover window mHoverWin = new HoverWindow(this); diff --git a/pictureswidget.cpp b/pictureswidget.cpp index 157dd81..5a90a71 100644 --- a/pictureswidget.cpp +++ b/pictureswidget.cpp @@ -12,6 +12,8 @@ #include <QMessageBox> #include <QSettings> #include <QAction> +#include <QMenu> +#include <QHeaderView> #include <QToolBar> #include "pictureswidget.h" @@ -27,6 +29,7 @@ PicturesWidget::PicturesWidget(QWidget *parent) : QWidget(parent), mWindowTitleB mMappingTree = new MappingTreeWidget; mPictureListView = new PictureListView; mPictureListView->setItemDelegateForColumn(PicFilesModel::Size, new SizeDelegate(this)); + mPictureListView->readHeaderConfig(); connect(mMappingTree, &MappingTreeWidget::mappingChanged, mPictureListView, &PictureListView::mappingChanged); connect(mMappingTree, &MappingTreeWidget::mappingChanged, this, &PicturesWidget::constructWindowTitle); connect(mPictureListView, &PictureListView::doubleClicked, this, &PicturesWidget::showInPicViewer); @@ -76,6 +79,29 @@ void PicturesWidget::setupWidget(){ toolBar->addAction(refreshA); mPictureListView->addAction(refreshA); toolBar->addSeparator(); + QHash<QString, int> hData = mPictureListView->filesModel()->headerData(); + QStringList hDataSorted = hData.keys(); + std::sort(hDataSorted.begin(), hDataSorted.end()); + QActionGroup *hDataAG = new QActionGroup(this); + hDataAG->setExclusive(false); + for(const QString &h : hDataSorted){ + QAction *a = new QAction(h, this); + a->setCheckable(true); + a->setData(hData.value(h)); + hDataAG->addAction(a); + if(!mPictureListView->header()->isSectionHidden(hData.value(h))){ + a->setChecked(true); + } + connect(a, &QAction::triggered, [=] { mPictureListView->toggleHeader(a); }); + } + QIcon headerIcon = Helper::icon(QColor(255,85,255), Qt::white, 'H', true, true); + QAction *headerA = new QAction(headerIcon, tr("Show headers"), this); + QMenu *headerMenu = new QMenu; + headerMenu->addActions(hDataAG->actions()); + headerA->setMenu(headerMenu); + toolBar->addAction(headerA); + mPictureListView->addAction(headerA); + toolBar->addSeparator(); toolBar->addAction(SmGlobals::instance()->globalAction()); QWidget *spacer2 = new QWidget; spacer2->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum); @@ -123,7 +149,7 @@ void PicturesWidget::readSettings(){ for(int i = 0; i < ps.count(); ++i){ path << ps.at(i).toInt(); } - mPictureListView->readHeaderConfig(); + } void PicturesWidget::editMappings(){ @@ -359,10 +359,6 @@ void SheMov::createStatusbar(){ void SheMov::createActions(){ //headers - mPicsTreeHeaderGroup = new QActionGroup(this); - SmTreeModel *picFilesModel = static_cast<SmTreeModel*>(SmGlobals::instance()->model("PicFiles")); - createHeaderMapper(picFilesModel, mPicWidget->picView(), mPicsTreeHeaderGroup); - mPicWidget->picView()->setHeaderGroup(mPicsTreeHeaderGroup); SmTreeModel *abrowsermodel = static_cast<SmTreeModel*>(SmGlobals::instance()->model("BrowserModel")); mArchiveBrowserAG = new QActionGroup(this); createHeaderMapper(abrowsermodel, mArchiveBrowser->archiveTree(), mArchiveBrowserAG); @@ -395,9 +391,6 @@ void SheMov::createMenus(){ analyzeMenu->addAction(mAnalyzeSeriesA); analyzeMenu->addAction(mAnalyzePartsA); - QMenu *headerMenu = new QMenu(tr("Show headers"), this); - headerMenu->addActions(mPicsTreeHeaderGroup->actions()); - //Archive Browser view menu mArchiveBrowserViewMenu = new QMenu(tr("&View"), this); QMenu *abHeaderMenu = new QMenu(tr("Show headers"), this); @@ -82,7 +82,6 @@ class SheMov : public QMainWindow { QAction *mStatisticsA; QAction *mConsistencyA; QAction *mSearchDialogA; - QActionGroup *mPicsTreeHeaderGroup; QActionGroup *mPicActionGroup; //ArchiveBrowser diff --git a/smtreeview.cpp b/smtreeview.cpp index 7fd7b48..024093a 100644 --- a/smtreeview.cpp +++ b/smtreeview.cpp @@ -34,20 +34,6 @@ void SmTreeView::readHeaderConfig(){ if(!headerPos.isEmpty()){ header()->restoreState(headerPos); } - QHeaderView *hv = header(); - QHash<int, QAction*> headerActions; - foreach(QAction *a, mHeaderGroup->actions()){ - headerActions.insert(a->data().toInt(), a); - } - for(int i = 0; i < hv->count(); ++i){ - // don't crash if header count is smaller than saved... - if(i >= mHeaderGroup->actions().count()){ - continue; - } - if(!hv->isSectionHidden(i)){ - headerActions.value(i)->setChecked(true); - } - } } void SmTreeView::writeHeaderConfig(){ |