From b85e4d5f20317609d8a4277482e8bb3dac3e2dae Mon Sep 17 00:00:00 2001 From: Arno Date: Wed, 8 Apr 2015 05:46:59 +0200 Subject: NewPicsDialog: Select current item in MappingTree on change in ResultView Usability fix: When selecting a mapping in the result view, select it in the source tree, too. --- mappingtreewidget.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'mappingtreewidget.cpp') diff --git a/mappingtreewidget.cpp b/mappingtreewidget.cpp index 6497cbd..917da68 100644 --- a/mappingtreewidget.cpp +++ b/mappingtreewidget.cpp @@ -208,8 +208,8 @@ void MappingTreeWidget::deleteType(){ } } -void MappingTreeWidget::selectPath(const QList &data){ - QModelIndex pathIdx = mModel->indexFromParentPath(data, true); +void MappingTreeWidget::selectPath(const QList &data, bool reverse){ + QModelIndex pathIdx = mModel->indexFromParentPath(data, reverse); if(!pathIdx.isValid()){ return; } @@ -298,6 +298,7 @@ MappingEditWidget::MappingEditWidget(QWidget *parent) : QWidget(parent){ mMappingResult->setColumnHidden(1, true); mMappingResult->setColumnHidden(2, true); mMappingResult->setColumnHidden(3, true); + connect(mMappingResult->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), this, SLOT(resultMappingChanged(QModelIndex,QModelIndex))); //buttons mAddMapping = new QPushButton(tr(">>")); @@ -347,6 +348,20 @@ void MappingEditWidget::setMappings(const QList &mappings){ mMappingResult->expandAll(); } +void MappingEditWidget::resultMappingChanged(const QModelIndex &cur, const QModelIndex &prev){ + Q_UNUSED(prev); + if(!cur.isValid()){ + return; + } + QModelIndex idx = cur; + QList path; + while(idx.isValid()){ + path << idx.data(MappingTreeResultModel::MappingIdRole).toInt(); + idx = idx.parent(); + } + mMappingTree->selectPath(path, false); +} + MappingInputDialog::MappingInputDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f){ mOk = new QPushButton(tr("Ok")); connect(mOk, SIGNAL(clicked()), this, SLOT(accept())); -- cgit v1.2.3-70-g09d2