diff options
author | Arno <arno@disconnect.de> | 2019-01-12 17:51:29 +0100 |
---|---|---|
committer | Arno <arno@disconnect.de> | 2019-01-12 17:51:29 +0100 |
commit | 4e5e0e6ec5668a0f0397dd8acbee0bd2f4bd0f67 (patch) | |
tree | 9c2ae637ff28d4e22af3a39ab31447dee44622ea /mappingeditwidget.cpp | |
parent | 1836f0768e3e7f38d4957f9348995cb062f55a07 (diff) | |
download | SheMov-4e5e0e6ec5668a0f0397dd8acbee0bd2f4bd0f67.tar.gz SheMov-4e5e0e6ec5668a0f0397dd8acbee0bd2f4bd0f67.tar.bz2 SheMov-4e5e0e6ec5668a0f0397dd8acbee0bd2f4bd0f67.zip |
Make NewPicsDialog usable by keyboard
Fix focus policy: only change focus between MappingTreeWidget and
MappingTreeResultView.
Also, block updating the selection of MappingTreeWidget when removing an
item from the result view. That operation resets the result selection
and by signal changes the selection of the mapping tree. The easiest way
I could come up with was a member flag that is set in removeMapping and
checked and cleared in resultSelectionChanged. Clearing the flag right
after removing the item doesn't work, most likely because of thread
affinity (just a guess, didn't check it). If it has side effects remains to
be seen...
Diffstat (limited to 'mappingeditwidget.cpp')
-rw-r--r-- | mappingeditwidget.cpp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/mappingeditwidget.cpp b/mappingeditwidget.cpp index a08bb81..6e1a60f 100644 --- a/mappingeditwidget.cpp +++ b/mappingeditwidget.cpp @@ -37,14 +37,19 @@ MappingEditWidget::MappingEditWidget(QWidget *parent) : QWidget(parent){ //buttons QPushButton *addMappingB = new QPushButton(tr(">>")); + addMappingB->setFocusPolicy(Qt::ClickFocus); connect(addMappingB, &QPushButton::clicked, this, &MappingEditWidget::addMapping); QPushButton *removeMappingB = new QPushButton(tr("<<")); + removeMappingB->setFocusPolicy(Qt::ClickFocus); connect(removeMappingB, &QPushButton::clicked, this, &MappingEditWidget::removeMapping); QPushButton *clearMappingB = new QPushButton(tr("&Clear")); + clearMappingB->setFocusPolicy(Qt::ClickFocus); connect(clearMappingB, &QPushButton::clicked, this, &MappingEditWidget::clearMapping); QPushButton *addTreeB = new QPushButton(tr(">>>>")); + addTreeB->setFocusPolicy(Qt::ClickFocus); connect(addTreeB, &QPushButton::clicked, this, &MappingEditWidget::addTree); QPushButton *copyActorB = new QPushButton(tr("Copy")); + copyActorB->setFocusPolicy(Qt::ClickFocus); connect(copyActorB, &QPushButton::clicked, this, &MappingEditWidget::copyActor); //layout @@ -87,6 +92,9 @@ void MappingEditWidget::removeMapping(){ } QModelIndex firstIdx = sel.first(); if(firstIdx.isValid()){ + // removing an item from the model inevitably calls resultSelctionChanged + // check and clear the flag there! + blockResultChange(true); mResultModel->removeItem(firstIdx); } mMappingResult->expandAll(); @@ -146,6 +154,10 @@ void MappingEditWidget::loadMappings(QString from){ void MappingEditWidget::resultSelectionChanged(const QModelIndex ¤t, const QModelIndex &previous){ Q_UNUSED(previous) + if(mBlockResultChange){ + blockResultChange(false); + return; + } QStringList path; QModelIndex c = current; // gather elements from leaf to root @@ -167,7 +179,9 @@ void MappingEditWidget::resultSelectionChanged(const QModelIndex ¤t, const // yes, we have a valid index. Map it to the Proxy... QModelIndex real = mMappingTree->mappingTreeProxy()->mapFromSource(srcIdx); // select it and make sure it's visible! - mMappingTree->mappingTreeView()->selectionModel()->select(real, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows); + mMappingTree->mappingTreeView()->selectionModel()->clear(); + mMappingTree->mappingTreeView()->selectionModel()->select(real, QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows); + mMappingTree->mappingTreeView()->selectionModel()->setCurrentIndex(real, QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows); mMappingTree->mappingTreeView()->scrollTo(real, QAbstractItemView::PositionAtCenter); } |