aboutsummaryrefslogtreecommitdiffstats
path: root/gui/designwidget.cc
diff options
context:
space:
mode:
authorMiodrag Milanovic <mmicko@gmail.com>2018-07-28 18:48:32 +0200
committerMiodrag Milanovic <mmicko@gmail.com>2018-07-28 18:48:32 +0200
commitba2531edc04a9e57b69fe6a289444db2f69c44d2 (patch)
tree9f20f1218338e3033c3579f577650a7bf73b97d2 /gui/designwidget.cc
parent9a30b6330b1997d07a8f18b87e2b413faf95094a (diff)
downloadnextpnr-ba2531edc04a9e57b69fe6a289444db2f69c44d2.tar.gz
nextpnr-ba2531edc04a9e57b69fe6a289444db2f69c44d2.tar.bz2
nextpnr-ba2531edc04a9e57b69fe6a289444db2f69c44d2.zip
add proper info on model changes
Diffstat (limited to 'gui/designwidget.cc')
-rw-r--r--gui/designwidget.cc18
1 files changed, 10 insertions, 8 deletions
diff --git a/gui/designwidget.cc b/gui/designwidget.cc
index 106c3146..0f01b3c5 100644
--- a/gui/designwidget.cc
+++ b/gui/designwidget.cc
@@ -160,6 +160,10 @@ DesignWidget::DesignWidget(QWidget *parent) : QWidget(parent), ctx(nullptr), sel
connect(treeView, &QTreeWidget::customContextMenuRequested, this, &DesignWidget::prepareMenuTree);
+ selectionModel = treeView->selectionModel();
+ connect(selectionModel, SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)),
+ SLOT(onSelectionChanged(const QItemSelection &, const QItemSelection &)));
+
history_index = -1;
history_ignore = false;
@@ -210,7 +214,6 @@ void DesignWidget::newContext(Context *ctx)
highlightSelected.clear();
this->ctx = ctx;
- treeView->setModel(nullptr);
treeModel->loadData(ctx);
updateTree();
}
@@ -232,10 +235,6 @@ void DesignWidget::updateTree()
}
treeModel->updateData(ctx);
- treeView->setModel(treeModel);
- selectionModel = treeView->selectionModel();
- connect(selectionModel, SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)),
- SLOT(onSelectionChanged(const QItemSelection &, const QItemSelection &)));
}
QtProperty *DesignWidget::addTopLevelProperty(const QString &id)
{
@@ -310,21 +309,24 @@ QtProperty *DesignWidget::addSubGroup(QtProperty *topItem, const QString &name)
void DesignWidget::onClickedBel(BelId bel, bool keep)
{
ContextTreeItem *item = treeModel->nodeForIdType(ElementType::BEL, ctx->getBelName(bel).c_str(ctx));
- selectionModel->setCurrentIndex(treeModel->indexFromNode(item), keep ? QItemSelectionModel::Select : QItemSelectionModel::ClearAndSelect);
+ selectionModel->setCurrentIndex(treeModel->indexFromNode(item),
+ keep ? QItemSelectionModel::Select : QItemSelectionModel::ClearAndSelect);
Q_EMIT selected(getDecals(ElementType::BEL, ctx->getBelName(bel)), keep);
}
void DesignWidget::onClickedWire(WireId wire, bool keep)
{
ContextTreeItem *item = treeModel->nodeForIdType(ElementType::WIRE, ctx->getWireName(wire).c_str(ctx));
- selectionModel->setCurrentIndex(treeModel->indexFromNode(item), keep ? QItemSelectionModel::Select : QItemSelectionModel::ClearAndSelect);
+ selectionModel->setCurrentIndex(treeModel->indexFromNode(item),
+ keep ? QItemSelectionModel::Select : QItemSelectionModel::ClearAndSelect);
Q_EMIT selected(getDecals(ElementType::WIRE, ctx->getWireName(wire)), keep);
}
void DesignWidget::onClickedPip(PipId pip, bool keep)
{
ContextTreeItem *item = treeModel->nodeForIdType(ElementType::PIP, ctx->getPipName(pip).c_str(ctx));
- selectionModel->setCurrentIndex(treeModel->indexFromNode(item), keep ? QItemSelectionModel::Select : QItemSelectionModel::ClearAndSelect);
+ selectionModel->setCurrentIndex(treeModel->indexFromNode(item),
+ keep ? QItemSelectionModel::Select : QItemSelectionModel::ClearAndSelect);
Q_EMIT selected(getDecals(ElementType::PIP, ctx->getPipName(pip)), keep);
}