summaryrefslogtreecommitdiffstats
path: root/mappingeditwidget.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'mappingeditwidget.cpp')
-rw-r--r--mappingeditwidget.cpp16
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 &current, 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 &current, 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);
}