From 77818f53bd7cb866d7d8404bb176b21c142f0fa2 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Wed, 11 Jul 2018 16:20:33 +0200 Subject: GUI preparation for search and browse history --- gui/designwidget.cc | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'gui/designwidget.cc') diff --git a/gui/designwidget.cc b/gui/designwidget.cc index 4922074b..b38d5a4c 100644 --- a/gui/designwidget.cc +++ b/gui/designwidget.cc @@ -20,8 +20,10 @@ #include "designwidget.h" #include #include +#include #include #include +#include #include #include "fpgaviewwidget.h" @@ -88,8 +90,38 @@ DesignWidget::DesignWidget(QWidget *parent) : QWidget(parent), ctx(nullptr), net propertyEditor->show(); + const QIcon searchIcon(":/icons/resources/zoom.png"); + QLineEdit* lineEdit = new QLineEdit(); + lineEdit->setClearButtonEnabled(true); + lineEdit->addAction(searchIcon, QLineEdit::LeadingPosition); + lineEdit->setPlaceholderText("Search..."); + + QAction *actionFirst = new QAction("", this); + QIcon iconFirst(QStringLiteral(":/icons/resources/resultset_first.png")); + actionFirst->setIcon(iconFirst); + + QAction *actionPrev = new QAction("", this); + QIcon iconPrev(QStringLiteral(":/icons/resources/resultset_previous.png")); + actionPrev->setIcon(iconPrev); + + QAction *actionNext = new QAction("", this); + QIcon iconNext(QStringLiteral(":/icons/resources/resultset_next.png")); + actionNext->setIcon(iconNext); + + QAction *actionLast = new QAction("", this); + QIcon iconLast(QStringLiteral(":/icons/resources/resultset_last.png")); + actionLast->setIcon(iconLast); + + QToolBar *toolbar = new QToolBar(); + toolbar->addAction(actionFirst); + toolbar->addAction(actionPrev); + toolbar->addAction(actionNext); + toolbar->addAction(actionLast); + QSplitter *splitter = new QSplitter(Qt::Vertical); + splitter->addWidget(lineEdit); splitter->addWidget(treeWidget); + splitter->addWidget(toolbar); splitter->addWidget(propertyEditor); QGridLayout *mainLayout = new QGridLayout(); -- cgit v1.2.3 From 0d979b964e1db576fc5c702a80c418ba6a1ffe09 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Wed, 11 Jul 2018 18:15:25 +0200 Subject: Fix layout --- gui/designwidget.cc | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) (limited to 'gui/designwidget.cc') diff --git a/gui/designwidget.cc b/gui/designwidget.cc index b38d5a4c..98fd3f30 100644 --- a/gui/designwidget.cc +++ b/gui/designwidget.cc @@ -118,11 +118,32 @@ DesignWidget::DesignWidget(QWidget *parent) : QWidget(parent), ctx(nullptr), net toolbar->addAction(actionNext); toolbar->addAction(actionLast); + QWidget *topWidget = new QWidget(); + QVBoxLayout *vbox1 = new QVBoxLayout(); + topWidget->setLayout(vbox1); + vbox1->setSpacing(5); + vbox1->setContentsMargins(0, 0, 0, 0); + vbox1->addWidget(lineEdit); + vbox1->addWidget(treeWidget); + + QWidget *toolbarWidget = new QWidget(); + QHBoxLayout *hbox = new QHBoxLayout; + hbox->setAlignment(Qt::AlignCenter); + toolbarWidget->setLayout(hbox); + hbox->addWidget(toolbar); + + QWidget *btmWidget = new QWidget(); + + QVBoxLayout *vbox2 = new QVBoxLayout(); + btmWidget->setLayout(vbox2); + vbox2->setSpacing(5); + vbox2->setContentsMargins(0, 0, 0, 0); + vbox2->addWidget(toolbarWidget); + vbox2->addWidget(propertyEditor); + QSplitter *splitter = new QSplitter(Qt::Vertical); - splitter->addWidget(lineEdit); - splitter->addWidget(treeWidget); - splitter->addWidget(toolbar); - splitter->addWidget(propertyEditor); + splitter->addWidget(topWidget); + splitter->addWidget(btmWidget); QGridLayout *mainLayout = new QGridLayout(); mainLayout->setSpacing(0); -- cgit v1.2.3 From ab5798e09efe525d51827773f895c6fd2e9a2d0c Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Wed, 11 Jul 2018 18:25:48 +0200 Subject: margins fix --- gui/designwidget.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'gui/designwidget.cc') diff --git a/gui/designwidget.cc b/gui/designwidget.cc index 98fd3f30..027512af 100644 --- a/gui/designwidget.cc +++ b/gui/designwidget.cc @@ -130,13 +130,15 @@ DesignWidget::DesignWidget(QWidget *parent) : QWidget(parent), ctx(nullptr), net QHBoxLayout *hbox = new QHBoxLayout; hbox->setAlignment(Qt::AlignCenter); toolbarWidget->setLayout(hbox); + hbox->setSpacing(0); + hbox->setContentsMargins(0, 0, 0, 0); hbox->addWidget(toolbar); QWidget *btmWidget = new QWidget(); QVBoxLayout *vbox2 = new QVBoxLayout(); btmWidget->setLayout(vbox2); - vbox2->setSpacing(5); + vbox2->setSpacing(0); vbox2->setContentsMargins(0, 0, 0, 0); vbox2->addWidget(toolbarWidget); vbox2->addWidget(propertyEditor); -- cgit v1.2.3 From 93214a2fb041769e2c9f783ec3d187b3d74d3f7c Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Wed, 11 Jul 2018 18:30:56 +0200 Subject: disable actions and make them accesible --- gui/designwidget.cc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'gui/designwidget.cc') diff --git a/gui/designwidget.cc b/gui/designwidget.cc index 027512af..14de974e 100644 --- a/gui/designwidget.cc +++ b/gui/designwidget.cc @@ -96,21 +96,25 @@ DesignWidget::DesignWidget(QWidget *parent) : QWidget(parent), ctx(nullptr), net lineEdit->addAction(searchIcon, QLineEdit::LeadingPosition); lineEdit->setPlaceholderText("Search..."); - QAction *actionFirst = new QAction("", this); + actionFirst = new QAction("", this); QIcon iconFirst(QStringLiteral(":/icons/resources/resultset_first.png")); actionFirst->setIcon(iconFirst); + actionFirst->setEnabled(false); - QAction *actionPrev = new QAction("", this); + actionPrev = new QAction("", this); QIcon iconPrev(QStringLiteral(":/icons/resources/resultset_previous.png")); actionPrev->setIcon(iconPrev); + actionPrev->setEnabled(false); - QAction *actionNext = new QAction("", this); + actionNext = new QAction("", this); QIcon iconNext(QStringLiteral(":/icons/resources/resultset_next.png")); actionNext->setIcon(iconNext); + actionNext->setEnabled(false); - QAction *actionLast = new QAction("", this); + actionLast = new QAction("", this); QIcon iconLast(QStringLiteral(":/icons/resources/resultset_last.png")); actionLast->setIcon(iconLast); + actionLast->setEnabled(false); QToolBar *toolbar = new QToolBar(); toolbar->addAction(actionFirst); -- cgit v1.2.3 From b8a42ff53b1fbb6e03d169d14e58180a750f4cad Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Thu, 12 Jul 2018 22:04:13 +0200 Subject: Updates from clang-format Signed-off-by: Clifford Wolf --- gui/designwidget.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'gui/designwidget.cc') diff --git a/gui/designwidget.cc b/gui/designwidget.cc index 14de974e..110cf1b7 100644 --- a/gui/designwidget.cc +++ b/gui/designwidget.cc @@ -91,7 +91,7 @@ DesignWidget::DesignWidget(QWidget *parent) : QWidget(parent), ctx(nullptr), net propertyEditor->show(); const QIcon searchIcon(":/icons/resources/zoom.png"); - QLineEdit* lineEdit = new QLineEdit(); + QLineEdit *lineEdit = new QLineEdit(); lineEdit->setClearButtonEnabled(true); lineEdit->addAction(searchIcon, QLineEdit::LeadingPosition); lineEdit->setPlaceholderText("Search..."); @@ -139,17 +139,17 @@ DesignWidget::DesignWidget(QWidget *parent) : QWidget(parent), ctx(nullptr), net hbox->addWidget(toolbar); QWidget *btmWidget = new QWidget(); - + QVBoxLayout *vbox2 = new QVBoxLayout(); - btmWidget->setLayout(vbox2); + btmWidget->setLayout(vbox2); vbox2->setSpacing(0); vbox2->setContentsMargins(0, 0, 0, 0); vbox2->addWidget(toolbarWidget); vbox2->addWidget(propertyEditor); QSplitter *splitter = new QSplitter(Qt::Vertical); - splitter->addWidget(topWidget); - splitter->addWidget(btmWidget); + splitter->addWidget(topWidget); + splitter->addWidget(btmWidget); QGridLayout *mainLayout = new QGridLayout(); mainLayout->setSpacing(0); -- cgit v1.2.3 From 3352ff4abbcac563e08d78ed8aa77728d00284a8 Mon Sep 17 00:00:00 2001 From: Sergiusz Bazanski Date: Sat, 14 Jul 2018 11:46:32 +0100 Subject: Move read methods to ReadMethods, remove some legacy access to Arch --- gui/designwidget.cc | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'gui/designwidget.cc') diff --git a/gui/designwidget.cc b/gui/designwidget.cc index 110cf1b7..e839f006 100644 --- a/gui/designwidget.cc +++ b/gui/designwidget.cc @@ -335,10 +335,12 @@ void DesignWidget::onItemClicked(QTreeWidgetItem *clickItem, int pos) return; } + auto &&proxy = ctx->rproxy(); + clearProperties(); if (type == ElementType::BEL) { IdString c = static_cast(clickItem)->getData(); - BelId bel = ctx->getBelByName(c); + BelId bel = proxy.getBelByName(c); QtProperty *topItem = groupManager->addProperty("Bel"); addProperty(topItem, "Bel"); @@ -352,20 +354,20 @@ void DesignWidget::onItemClicked(QTreeWidgetItem *clickItem, int pos) topItem->addSubProperty(typeItem); QtVariantProperty *availItem = readOnlyManager->addProperty(QVariant::Bool, "Available"); - availItem->setValue(ctx->checkBelAvail(bel)); + availItem->setValue(proxy.checkBelAvail(bel)); topItem->addSubProperty(availItem); QtVariantProperty *cellItem = readOnlyManager->addProperty(QVariant::String, "Bound Cell"); - cellItem->setValue(ctx->getBoundBelCell(bel).c_str(ctx)); + cellItem->setValue(proxy.getBoundBelCell(bel).c_str(ctx)); topItem->addSubProperty(cellItem); QtVariantProperty *conflictItem = readOnlyManager->addProperty(QVariant::String, "Conflicting Cell"); - conflictItem->setValue(ctx->getConflictingBelCell(bel).c_str(ctx)); + conflictItem->setValue(proxy.getConflictingBelCell(bel).c_str(ctx)); topItem->addSubProperty(conflictItem); } else if (type == ElementType::WIRE) { IdString c = static_cast(clickItem)->getData(); - WireId wire = ctx->getWireByName(c); + WireId wire = proxy.getWireByName(c); QtProperty *topItem = groupManager->addProperty("Wire"); addProperty(topItem, "Wire"); @@ -375,15 +377,15 @@ void DesignWidget::onItemClicked(QTreeWidgetItem *clickItem, int pos) topItem->addSubProperty(nameItem); QtVariantProperty *availItem = readOnlyManager->addProperty(QVariant::Bool, "Available"); - availItem->setValue(ctx->checkWireAvail(wire)); + availItem->setValue(proxy.checkWireAvail(wire)); topItem->addSubProperty(availItem); QtVariantProperty *cellItem = readOnlyManager->addProperty(QVariant::String, "Bound Net"); - cellItem->setValue(ctx->getBoundWireNet(wire).c_str(ctx)); + cellItem->setValue(proxy.getBoundWireNet(wire).c_str(ctx)); topItem->addSubProperty(cellItem); QtVariantProperty *conflictItem = readOnlyManager->addProperty(QVariant::String, "Conflicting Net"); - conflictItem->setValue(ctx->getConflictingWireNet(wire).c_str(ctx)); + conflictItem->setValue(proxy.getConflictingWireNet(wire).c_str(ctx)); topItem->addSubProperty(conflictItem); BelPin uphill = ctx->getBelPinUphill(wire); @@ -439,7 +441,7 @@ void DesignWidget::onItemClicked(QTreeWidgetItem *clickItem, int pos) } else if (type == ElementType::PIP) { IdString c = static_cast(clickItem)->getData(); - PipId pip = ctx->getPipByName(c); + PipId pip = proxy.getPipByName(c); QtProperty *topItem = groupManager->addProperty("Pip"); addProperty(topItem, "Pip"); @@ -449,15 +451,15 @@ void DesignWidget::onItemClicked(QTreeWidgetItem *clickItem, int pos) topItem->addSubProperty(nameItem); QtVariantProperty *availItem = readOnlyManager->addProperty(QVariant::Bool, "Available"); - availItem->setValue(ctx->checkPipAvail(pip)); + availItem->setValue(proxy.checkPipAvail(pip)); topItem->addSubProperty(availItem); QtVariantProperty *cellItem = readOnlyManager->addProperty(QVariant::String, "Bound Net"); - cellItem->setValue(ctx->getBoundPipNet(pip).c_str(ctx)); + cellItem->setValue(proxy.getBoundPipNet(pip).c_str(ctx)); topItem->addSubProperty(cellItem); QtVariantProperty *conflictItem = readOnlyManager->addProperty(QVariant::String, "Conflicting Net"); - conflictItem->setValue(ctx->getConflictingPipNet(pip).c_str(ctx)); + conflictItem->setValue(proxy.getConflictingPipNet(pip).c_str(ctx)); topItem->addSubProperty(conflictItem); QtVariantProperty *srcWireItem = readOnlyManager->addProperty(QVariant::String, "Src Wire"); -- cgit v1.2.3 From 0b1ae3ce8da9fb3a3b4eaf337d6bf0b7f6aaab1e Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Sat, 14 Jul 2018 17:50:06 +0200 Subject: use itemSelectionChanged, keyboard selection works --- gui/designwidget.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'gui/designwidget.cc') diff --git a/gui/designwidget.cc b/gui/designwidget.cc index e839f006..9602a4d3 100644 --- a/gui/designwidget.cc +++ b/gui/designwidget.cc @@ -160,7 +160,7 @@ DesignWidget::DesignWidget(QWidget *parent) : QWidget(parent), ctx(nullptr), net // Connection connect(treeWidget, &QTreeWidget::customContextMenuRequested, this, &DesignWidget::prepareMenu); - connect(treeWidget, SIGNAL(itemClicked(QTreeWidgetItem *, int)), SLOT(onItemClicked(QTreeWidgetItem *, int))); + connect(treeWidget, SIGNAL(itemSelectionChanged()), SLOT(onItemSelectionChanged())); } DesignWidget::~DesignWidget() {} @@ -325,8 +325,12 @@ void DesignWidget::clearProperties() idToProperty.clear(); } -void DesignWidget::onItemClicked(QTreeWidgetItem *clickItem, int pos) +void DesignWidget::onItemSelectionChanged() { + if (treeWidget->selectedItems().size()== 0) return; + + QTreeWidgetItem *clickItem = treeWidget->selectedItems().at(0); + if (!clickItem->parent()) return; -- cgit v1.2.3 From f339f796a1bd7e98be184085e831e9d44ea85dd1 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Sat, 14 Jul 2018 17:58:58 +0200 Subject: simplified Icon allocation --- gui/designwidget.cc | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) (limited to 'gui/designwidget.cc') diff --git a/gui/designwidget.cc b/gui/designwidget.cc index 9602a4d3..ba2c76f5 100644 --- a/gui/designwidget.cc +++ b/gui/designwidget.cc @@ -89,31 +89,26 @@ DesignWidget::DesignWidget(QWidget *parent) : QWidget(parent), ctx(nullptr), net propertyEditor->setPropertiesWithoutValueMarked(true); propertyEditor->show(); - - const QIcon searchIcon(":/icons/resources/zoom.png"); + QLineEdit *lineEdit = new QLineEdit(); lineEdit->setClearButtonEnabled(true); - lineEdit->addAction(searchIcon, QLineEdit::LeadingPosition); + lineEdit->addAction(QIcon(":/icons/resources/zoom.png"), QLineEdit::LeadingPosition); lineEdit->setPlaceholderText("Search..."); - actionFirst = new QAction("", this); - QIcon iconFirst(QStringLiteral(":/icons/resources/resultset_first.png")); - actionFirst->setIcon(iconFirst); + actionFirst = new QAction("", this); + actionFirst->setIcon(QIcon(":/icons/resources/resultset_first.png")); actionFirst->setEnabled(false); - actionPrev = new QAction("", this); - QIcon iconPrev(QStringLiteral(":/icons/resources/resultset_previous.png")); - actionPrev->setIcon(iconPrev); + actionPrev = new QAction("", this); + actionPrev->setIcon(QIcon(":/icons/resources/resultset_previous.png")); actionPrev->setEnabled(false); - actionNext = new QAction("", this); - QIcon iconNext(QStringLiteral(":/icons/resources/resultset_next.png")); - actionNext->setIcon(iconNext); + actionNext = new QAction("", this); + actionNext->setIcon(QIcon(":/icons/resources/resultset_next.png")); actionNext->setEnabled(false); - actionLast = new QAction("", this); - QIcon iconLast(QStringLiteral(":/icons/resources/resultset_last.png")); - actionLast->setIcon(iconLast); + actionLast = new QAction("", this); + actionLast->setIcon(QIcon(":/icons/resources/resultset_last.png")); actionLast->setEnabled(false); QToolBar *toolbar = new QToolBar(); -- cgit v1.2.3 From 8d1996cae99ff80a2d9390b94db54217ed1d8726 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Sat, 14 Jul 2018 19:44:37 +0200 Subject: display selected object from tree --- gui/designwidget.cc | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'gui/designwidget.cc') diff --git a/gui/designwidget.cc b/gui/designwidget.cc index ba2c76f5..a6ebba5e 100644 --- a/gui/designwidget.cc +++ b/gui/designwidget.cc @@ -336,10 +336,15 @@ void DesignWidget::onItemSelectionChanged() auto &&proxy = ctx->rproxy(); + std::vector decals; + clearProperties(); if (type == ElementType::BEL) { IdString c = static_cast(clickItem)->getData(); BelId bel = proxy.getBelByName(c); + + decals.push_back(ctx->getBelDecal(bel)); + Q_EMIT selected(decals); QtProperty *topItem = groupManager->addProperty("Bel"); addProperty(topItem, "Bel"); @@ -368,6 +373,9 @@ void DesignWidget::onItemSelectionChanged() IdString c = static_cast(clickItem)->getData(); WireId wire = proxy.getWireByName(c); + decals.push_back(ctx->getWireDecal(wire)); + Q_EMIT selected(decals); + QtProperty *topItem = groupManager->addProperty("Wire"); addProperty(topItem, "Wire"); @@ -421,7 +429,7 @@ void DesignWidget::onItemSelectionChanged() portItem->setValue(pinname); dhItem->addSubProperty(portItem); } - +/* QtProperty *pipsDownItem = groupManager->addProperty("Pips Downhill"); topItem->addSubProperty(pipsDownItem); for (const auto &item : ctx->getPipsDownhill(wire)) { @@ -437,11 +445,14 @@ void DesignWidget::onItemSelectionChanged() pipItem->setValue(ctx->getPipName(item).c_str(ctx)); pipsUpItem->addSubProperty(pipItem); } - +*/ } else if (type == ElementType::PIP) { IdString c = static_cast(clickItem)->getData(); PipId pip = proxy.getPipByName(c); + decals.push_back(ctx->getPipDecal(pip)); + Q_EMIT selected(decals); + QtProperty *topItem = groupManager->addProperty("Pip"); addProperty(topItem, "Pip"); -- cgit v1.2.3 From ade67ecf21c274c73c99543e51eda99ac847686c Mon Sep 17 00:00:00 2001 From: Sergiusz Bazanski Date: Sat, 14 Jul 2018 18:50:23 +0100 Subject: Revert "Move read methods to ReadMethods, remove some legacy access to Arch" This reverts commit 3352ff4abbcac563e08d78ed8aa77728d00284a8. --- gui/designwidget.cc | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) (limited to 'gui/designwidget.cc') diff --git a/gui/designwidget.cc b/gui/designwidget.cc index e839f006..110cf1b7 100644 --- a/gui/designwidget.cc +++ b/gui/designwidget.cc @@ -335,12 +335,10 @@ void DesignWidget::onItemClicked(QTreeWidgetItem *clickItem, int pos) return; } - auto &&proxy = ctx->rproxy(); - clearProperties(); if (type == ElementType::BEL) { IdString c = static_cast(clickItem)->getData(); - BelId bel = proxy.getBelByName(c); + BelId bel = ctx->getBelByName(c); QtProperty *topItem = groupManager->addProperty("Bel"); addProperty(topItem, "Bel"); @@ -354,20 +352,20 @@ void DesignWidget::onItemClicked(QTreeWidgetItem *clickItem, int pos) topItem->addSubProperty(typeItem); QtVariantProperty *availItem = readOnlyManager->addProperty(QVariant::Bool, "Available"); - availItem->setValue(proxy.checkBelAvail(bel)); + availItem->setValue(ctx->checkBelAvail(bel)); topItem->addSubProperty(availItem); QtVariantProperty *cellItem = readOnlyManager->addProperty(QVariant::String, "Bound Cell"); - cellItem->setValue(proxy.getBoundBelCell(bel).c_str(ctx)); + cellItem->setValue(ctx->getBoundBelCell(bel).c_str(ctx)); topItem->addSubProperty(cellItem); QtVariantProperty *conflictItem = readOnlyManager->addProperty(QVariant::String, "Conflicting Cell"); - conflictItem->setValue(proxy.getConflictingBelCell(bel).c_str(ctx)); + conflictItem->setValue(ctx->getConflictingBelCell(bel).c_str(ctx)); topItem->addSubProperty(conflictItem); } else if (type == ElementType::WIRE) { IdString c = static_cast(clickItem)->getData(); - WireId wire = proxy.getWireByName(c); + WireId wire = ctx->getWireByName(c); QtProperty *topItem = groupManager->addProperty("Wire"); addProperty(topItem, "Wire"); @@ -377,15 +375,15 @@ void DesignWidget::onItemClicked(QTreeWidgetItem *clickItem, int pos) topItem->addSubProperty(nameItem); QtVariantProperty *availItem = readOnlyManager->addProperty(QVariant::Bool, "Available"); - availItem->setValue(proxy.checkWireAvail(wire)); + availItem->setValue(ctx->checkWireAvail(wire)); topItem->addSubProperty(availItem); QtVariantProperty *cellItem = readOnlyManager->addProperty(QVariant::String, "Bound Net"); - cellItem->setValue(proxy.getBoundWireNet(wire).c_str(ctx)); + cellItem->setValue(ctx->getBoundWireNet(wire).c_str(ctx)); topItem->addSubProperty(cellItem); QtVariantProperty *conflictItem = readOnlyManager->addProperty(QVariant::String, "Conflicting Net"); - conflictItem->setValue(proxy.getConflictingWireNet(wire).c_str(ctx)); + conflictItem->setValue(ctx->getConflictingWireNet(wire).c_str(ctx)); topItem->addSubProperty(conflictItem); BelPin uphill = ctx->getBelPinUphill(wire); @@ -441,7 +439,7 @@ void DesignWidget::onItemClicked(QTreeWidgetItem *clickItem, int pos) } else if (type == ElementType::PIP) { IdString c = static_cast(clickItem)->getData(); - PipId pip = proxy.getPipByName(c); + PipId pip = ctx->getPipByName(c); QtProperty *topItem = groupManager->addProperty("Pip"); addProperty(topItem, "Pip"); @@ -451,15 +449,15 @@ void DesignWidget::onItemClicked(QTreeWidgetItem *clickItem, int pos) topItem->addSubProperty(nameItem); QtVariantProperty *availItem = readOnlyManager->addProperty(QVariant::Bool, "Available"); - availItem->setValue(proxy.checkPipAvail(pip)); + availItem->setValue(ctx->checkPipAvail(pip)); topItem->addSubProperty(availItem); QtVariantProperty *cellItem = readOnlyManager->addProperty(QVariant::String, "Bound Net"); - cellItem->setValue(proxy.getBoundPipNet(pip).c_str(ctx)); + cellItem->setValue(ctx->getBoundPipNet(pip).c_str(ctx)); topItem->addSubProperty(cellItem); QtVariantProperty *conflictItem = readOnlyManager->addProperty(QVariant::String, "Conflicting Net"); - conflictItem->setValue(proxy.getConflictingPipNet(pip).c_str(ctx)); + conflictItem->setValue(ctx->getConflictingPipNet(pip).c_str(ctx)); topItem->addSubProperty(conflictItem); QtVariantProperty *srcWireItem = readOnlyManager->addProperty(QVariant::String, "Src Wire"); -- cgit v1.2.3 From bce235fad582dbb727354a7917e4d25a6529c650 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Sun, 15 Jul 2018 09:49:19 +0200 Subject: show selected item from property window as well, cleanup --- gui/designwidget.cc | 437 ++++++++++++++++++++++------------------------------ 1 file changed, 183 insertions(+), 254 deletions(-) (limited to 'gui/designwidget.cc') diff --git a/gui/designwidget.cc b/gui/designwidget.cc index edf9f1ec..553171ab 100644 --- a/gui/designwidget.cc +++ b/gui/designwidget.cc @@ -29,16 +29,6 @@ NEXTPNR_NAMESPACE_BEGIN -enum class ElementType -{ - NONE, - BEL, - WIRE, - PIP, - NET, - CELL -}; - class ElementTreeItem : public QTreeWidgetItem { public: @@ -87,27 +77,28 @@ DesignWidget::DesignWidget(QWidget *parent) : QWidget(parent), ctx(nullptr), net propertyEditor = new QtTreePropertyBrowser(this); propertyEditor->setFactoryForManager(variantManager, variantFactory); propertyEditor->setPropertiesWithoutValueMarked(true); - + connect(propertyEditor, SIGNAL(currentItemChanged(QtBrowserItem *)), this, + SLOT(onCurrentPropertyChanged(QtBrowserItem *))); propertyEditor->show(); - + QLineEdit *lineEdit = new QLineEdit(); lineEdit->setClearButtonEnabled(true); lineEdit->addAction(QIcon(":/icons/resources/zoom.png"), QLineEdit::LeadingPosition); lineEdit->setPlaceholderText("Search..."); - actionFirst = new QAction("", this); + actionFirst = new QAction("", this); actionFirst->setIcon(QIcon(":/icons/resources/resultset_first.png")); actionFirst->setEnabled(false); - actionPrev = new QAction("", this); + actionPrev = new QAction("", this); actionPrev->setIcon(QIcon(":/icons/resources/resultset_previous.png")); actionPrev->setEnabled(false); - actionNext = new QAction("", this); + actionNext = new QAction("", this); actionNext->setIcon(QIcon(":/icons/resources/resultset_next.png")); actionNext->setEnabled(false); - actionLast = new QAction("", this); + actionLast = new QAction("", this); actionLast->setIcon(QIcon(":/icons/resources/resultset_last.png")); actionLast->setEnabled(false); @@ -301,12 +292,13 @@ void DesignWidget::updateTree() cells_root->addChild(item.second); } } - -void DesignWidget::addProperty(QtProperty *property, const QString &id) +QtProperty *DesignWidget::addTopLevelProperty(const QString &id) { - propertyToId[property] = id; - idToProperty[id] = property; - propertyEditor->addProperty(property); + QtProperty *topItem = groupManager->addProperty(id); + propertyToId[topItem] = id; + idToProperty[id] = topItem; + propertyEditor->addProperty(topItem); + return topItem; } void DesignWidget::clearProperties() @@ -320,10 +312,90 @@ void DesignWidget::clearProperties() idToProperty.clear(); } +void DesignWidget::onCurrentPropertyChanged(QtBrowserItem *_item) +{ + if (_item) { + QtProperty *selectedProperty = _item->property(); + QString type = selectedProperty->propertyId(); + IdString value = ctx->id(selectedProperty->valueText().toStdString()); + std::vector decals; + if (type == "BEL") { + BelId bel = ctx->getBelByName(value); + if (bel != BelId()) { + decals.push_back(ctx->getBelDecal(bel)); + Q_EMIT selected(decals); + } + } else if (type == "WIRE") { + WireId wire = ctx->getWireByName(value); + if (wire != WireId()) { + decals.push_back(ctx->getWireDecal(wire)); + Q_EMIT selected(decals); + } + } else if (type == "PIP") { + PipId pip = ctx->getPipByName(value); + if (pip != PipId()) { + decals.push_back(ctx->getPipDecal(pip)); + Q_EMIT selected(decals); + } + } else if (type == "NET") { + } else if (type == "CELL") { + } + } +} + +QString DesignWidget::getElementTypeName(ElementType type) +{ + if (type == ElementType::NONE) + return ""; + if (type == ElementType::BEL) + return "BEL"; + if (type == ElementType::WIRE) + return "WIRE"; + if (type == ElementType::PIP) + return "PIP"; + if (type == ElementType::NET) + return "NET"; + if (type == ElementType::CELL) + return "CELL"; + return ""; +} + +ElementType DesignWidget::getElementTypeByName(QString type) +{ + if (type == "BEL") + return ElementType::BEL; + if (type == "WIRE") + return ElementType::WIRE; + if (type == "PIP") + return ElementType::PIP; + if (type == "NET") + return ElementType::NET; + if (type == "CELL") + return ElementType::CELL; + return ElementType::NONE; +} + +void DesignWidget::addProperty(QtProperty *topItem, int propertyType, const QString &name, QVariant value, + const ElementType &type) +{ + QtVariantProperty *item = readOnlyManager->addProperty(propertyType, name); + item->setValue(value); + item->setPropertyId(getElementTypeName(type)); + topItem->addSubProperty(item); +} + +QtProperty *DesignWidget::addSubGroup(QtProperty *topItem, const QString &name) +{ + QtProperty *item = groupManager->addProperty(name); + topItem->addSubProperty(item); + return item; +} + void DesignWidget::onItemSelectionChanged() { - if (treeWidget->selectedItems().size()== 0) return; - + if (treeWidget->selectedItems().size() == 0) + return; + QTreeWidgetItem *clickItem = treeWidget->selectedItems().at(0); if (!clickItem->parent()) @@ -340,32 +412,18 @@ void DesignWidget::onItemSelectionChanged() if (type == ElementType::BEL) { IdString c = static_cast(clickItem)->getData(); BelId bel = ctx->getBelByName(c); - - decals.push_back(ctx->getBelDecal(bel)); - Q_EMIT selected(decals); - - QtProperty *topItem = groupManager->addProperty("Bel"); - addProperty(topItem, "Bel"); - - QtVariantProperty *nameItem = readOnlyManager->addProperty(QVariant::String, "Name"); - nameItem->setValue(c.c_str(ctx)); - topItem->addSubProperty(nameItem); - QtVariantProperty *typeItem = readOnlyManager->addProperty(QVariant::String, "Type"); - typeItem->setValue(ctx->belTypeToId(ctx->getBelType(bel)).c_str(ctx)); - topItem->addSubProperty(typeItem); - - QtVariantProperty *availItem = readOnlyManager->addProperty(QVariant::Bool, "Available"); - availItem->setValue(ctx->checkBelAvail(bel)); - topItem->addSubProperty(availItem); + decals.push_back(ctx->getBelDecal(bel)); + Q_EMIT selected(decals); - QtVariantProperty *cellItem = readOnlyManager->addProperty(QVariant::String, "Bound Cell"); - cellItem->setValue(ctx->getBoundBelCell(bel).c_str(ctx)); - topItem->addSubProperty(cellItem); + QtProperty *topItem = addTopLevelProperty("Bel"); - QtVariantProperty *conflictItem = readOnlyManager->addProperty(QVariant::String, "Conflicting Cell"); - conflictItem->setValue(ctx->getConflictingBelCell(bel).c_str(ctx)); - topItem->addSubProperty(conflictItem); + addProperty(topItem, QVariant::String, "Name", c.c_str(ctx)); + addProperty(topItem, QVariant::String, "Type", ctx->belTypeToId(ctx->getBelType(bel)).c_str(ctx)); + addProperty(topItem, QVariant::Bool, "Available", ctx->checkBelAvail(bel)); + addProperty(topItem, QVariant::String, "Bound Cell", ctx->getBoundBelCell(bel).c_str(ctx), ElementType::CELL); + addProperty(topItem, QVariant::String, "Conflicting Cell", ctx->getConflictingBelCell(bel).c_str(ctx), + ElementType::CELL); } else if (type == ElementType::WIRE) { IdString c = static_cast(clickItem)->getData(); @@ -374,76 +432,45 @@ void DesignWidget::onItemSelectionChanged() decals.push_back(ctx->getWireDecal(wire)); Q_EMIT selected(decals); - QtProperty *topItem = groupManager->addProperty("Wire"); - addProperty(topItem, "Wire"); - - QtVariantProperty *nameItem = readOnlyManager->addProperty(QVariant::String, "Name"); - nameItem->setValue(c.c_str(ctx)); - topItem->addSubProperty(nameItem); - - QtVariantProperty *availItem = readOnlyManager->addProperty(QVariant::Bool, "Available"); - availItem->setValue(ctx->checkWireAvail(wire)); - topItem->addSubProperty(availItem); + QtProperty *topItem = addTopLevelProperty("Wire"); - QtVariantProperty *cellItem = readOnlyManager->addProperty(QVariant::String, "Bound Net"); - cellItem->setValue(ctx->getBoundWireNet(wire).c_str(ctx)); - topItem->addSubProperty(cellItem); - - QtVariantProperty *conflictItem = readOnlyManager->addProperty(QVariant::String, "Conflicting Net"); - conflictItem->setValue(ctx->getConflictingWireNet(wire).c_str(ctx)); - topItem->addSubProperty(conflictItem); + addProperty(topItem, QVariant::String, "Name", c.c_str(ctx)); + addProperty(topItem, QVariant::Bool, "Available", ctx->checkWireAvail(wire)); + addProperty(topItem, QVariant::String, "Bound Net", ctx->getBoundWireNet(wire).c_str(ctx), ElementType::NET); + addProperty(topItem, QVariant::String, "Conflicting Net", ctx->getConflictingWireNet(wire).c_str(ctx), + ElementType::NET); + QtProperty *belpinItem = addSubGroup(topItem, "BelPin Uphill"); BelPin uphill = ctx->getBelPinUphill(wire); - QtProperty *belpinItem = groupManager->addProperty("BelPin Uphill"); - topItem->addSubProperty(belpinItem); - - QtVariantProperty *belUphillItem = readOnlyManager->addProperty(QVariant::String, "Bel"); if (uphill.bel != BelId()) - belUphillItem->setValue(ctx->getBelName(uphill.bel).c_str(ctx)); + addProperty(belpinItem, QVariant::String, "Bel", ctx->getBelName(uphill.bel).c_str(ctx), ElementType::BEL); else - belUphillItem->setValue(""); - belpinItem->addSubProperty(belUphillItem); + addProperty(belpinItem, QVariant::String, "Bel", "", ElementType::BEL); - QtVariantProperty *portUphillItem = readOnlyManager->addProperty(QVariant::String, "PortPin"); - portUphillItem->setValue(ctx->portPinToId(uphill.pin).c_str(ctx)); - belpinItem->addSubProperty(portUphillItem); + addProperty(belpinItem, QVariant::String, "PortPin", ctx->portPinToId(uphill.pin).c_str(ctx), ElementType::BEL); - QtProperty *downhillItem = groupManager->addProperty("BelPins Downhill"); - topItem->addSubProperty(downhillItem); + QtProperty *downhillItem = addSubGroup(topItem, "BelPin Downhill"); for (const auto &item : ctx->getBelPinsDownhill(wire)) { QString belname = ""; if (item.bel != BelId()) belname = ctx->getBelName(item.bel).c_str(ctx); QString pinname = ctx->portPinToId(item.pin).c_str(ctx); - QtProperty *dhItem = groupManager->addProperty(belname + "-" + pinname); - downhillItem->addSubProperty(dhItem); - - QtVariantProperty *belItem = readOnlyManager->addProperty(QVariant::String, "Bel"); - belItem->setValue(belname); - dhItem->addSubProperty(belItem); - - QtVariantProperty *portItem = readOnlyManager->addProperty(QVariant::String, "PortPin"); - portItem->setValue(pinname); - dhItem->addSubProperty(portItem); - } -/* - QtProperty *pipsDownItem = groupManager->addProperty("Pips Downhill"); - topItem->addSubProperty(pipsDownItem); - for (const auto &item : ctx->getPipsDownhill(wire)) { - QtVariantProperty *pipItem = readOnlyManager->addProperty(QVariant::String, ""); - pipItem->setValue(ctx->getPipName(item).c_str(ctx)); - pipsDownItem->addSubProperty(pipItem); + QtProperty *dhItem = addSubGroup(downhillItem, belname + "-" + pinname); + addProperty(dhItem, QVariant::String, "Bel", belname, ElementType::BEL); + addProperty(dhItem, QVariant::String, "PortPin", pinname); } + /* + QtProperty *pipsDownItem = addSubGroup(downhillItem, "Pips Downhill"); + for (const auto &item : ctx->getPipsDownhill(wire)) { + addProperty(pipsDownItem, QVariant::String, "", ctx->getPipName(item).c_str(ctx), ElementType::PIP); + } - QtProperty *pipsUpItem = groupManager->addProperty("Pips Uphill"); - topItem->addSubProperty(pipsUpItem); - for (const auto &item : ctx->getPipsUphill(wire)) { - QtVariantProperty *pipItem = readOnlyManager->addProperty(QVariant::String, ""); - pipItem->setValue(ctx->getPipName(item).c_str(ctx)); - pipsUpItem->addSubProperty(pipItem); - } -*/ + QtProperty *pipsUpItem = addSubGroup(downhillItem, "Pips Uphill"); + for (const auto &item : ctx->getPipsUphill(wire)) { + addProperty(pipsUpItem, QVariant::String, "", ctx->getPipName(item).c_str(ctx), ElementType::PIP); + } + */ } else if (type == ElementType::PIP) { IdString c = static_cast(clickItem)->getData(); PipId pip = ctx->getPipByName(c); @@ -451,199 +478,108 @@ void DesignWidget::onItemSelectionChanged() decals.push_back(ctx->getPipDecal(pip)); Q_EMIT selected(decals); - QtProperty *topItem = groupManager->addProperty("Pip"); - addProperty(topItem, "Pip"); + QtProperty *topItem = addTopLevelProperty("Pip"); - QtVariantProperty *nameItem = readOnlyManager->addProperty(QVariant::String, "Name"); - nameItem->setValue(c.c_str(ctx)); - topItem->addSubProperty(nameItem); - - QtVariantProperty *availItem = readOnlyManager->addProperty(QVariant::Bool, "Available"); - availItem->setValue(ctx->checkPipAvail(pip)); - topItem->addSubProperty(availItem); - - QtVariantProperty *cellItem = readOnlyManager->addProperty(QVariant::String, "Bound Net"); - cellItem->setValue(ctx->getBoundPipNet(pip).c_str(ctx)); - topItem->addSubProperty(cellItem); - - QtVariantProperty *conflictItem = readOnlyManager->addProperty(QVariant::String, "Conflicting Net"); - conflictItem->setValue(ctx->getConflictingPipNet(pip).c_str(ctx)); - topItem->addSubProperty(conflictItem); - - QtVariantProperty *srcWireItem = readOnlyManager->addProperty(QVariant::String, "Src Wire"); - srcWireItem->setValue(ctx->getWireName(ctx->getPipSrcWire(pip)).c_str(ctx)); - topItem->addSubProperty(srcWireItem); - - QtVariantProperty *destWireItem = readOnlyManager->addProperty(QVariant::String, "Dest Wire"); - destWireItem->setValue(ctx->getWireName(ctx->getPipDstWire(pip)).c_str(ctx)); - topItem->addSubProperty(destWireItem); + addProperty(topItem, QVariant::String, "Name", c.c_str(ctx)); + addProperty(topItem, QVariant::Bool, "Available", ctx->checkPipAvail(pip)); + addProperty(topItem, QVariant::String, "Bound Net", ctx->getBoundPipNet(pip).c_str(ctx), ElementType::NET); + addProperty(topItem, QVariant::String, "Conflicting Net", ctx->getConflictingPipNet(pip).c_str(ctx), + ElementType::NET); + addProperty(topItem, QVariant::String, "Src Wire", ctx->getWireName(ctx->getPipSrcWire(pip)).c_str(ctx), + ElementType::WIRE); + addProperty(topItem, QVariant::String, "Dest Wire", ctx->getWireName(ctx->getPipDstWire(pip)).c_str(ctx), + ElementType::WIRE); DelayInfo delay = ctx->getPipDelay(pip); - QtProperty *delayItem = groupManager->addProperty("Delay"); - topItem->addSubProperty(delayItem); - - QtVariantProperty *raiseDelayItem = readOnlyManager->addProperty(QVariant::Double, "Raise"); - raiseDelayItem->setValue(delay.raiseDelay()); - delayItem->addSubProperty(raiseDelayItem); - - QtVariantProperty *fallDelayItem = readOnlyManager->addProperty(QVariant::Double, "Fall"); - fallDelayItem->setValue(delay.fallDelay()); - delayItem->addSubProperty(fallDelayItem); - - QtVariantProperty *avgDelayItem = readOnlyManager->addProperty(QVariant::Double, "Average"); - avgDelayItem->setValue(delay.avgDelay()); - delayItem->addSubProperty(avgDelayItem); + QtProperty *delayItem = addSubGroup(topItem, "Delay"); + addProperty(delayItem, QVariant::Double, "Raise", delay.raiseDelay()); + addProperty(delayItem, QVariant::Double, "Fall", delay.fallDelay()); + addProperty(delayItem, QVariant::Double, "Average", delay.avgDelay()); } else if (type == ElementType::NET) { IdString c = static_cast(clickItem)->getData(); NetInfo *net = ctx->nets.at(c).get(); - QtProperty *topItem = groupManager->addProperty("Net"); - addProperty(topItem, "Net"); + QtProperty *topItem = addTopLevelProperty("Net"); - QtVariantProperty *nameItem = readOnlyManager->addProperty(QVariant::String, "Name"); - nameItem->setValue(net->name.c_str(ctx)); - topItem->addSubProperty(nameItem); + addProperty(topItem, QVariant::String, "Name", net->name.c_str(ctx)); - QtProperty *driverItem = groupManager->addProperty("Driver"); - topItem->addSubProperty(driverItem); - - QtVariantProperty *portItem = readOnlyManager->addProperty(QVariant::String, "Port"); - portItem->setValue(net->driver.port.c_str(ctx)); - driverItem->addSubProperty(portItem); - - QtVariantProperty *budgetItem = readOnlyManager->addProperty(QVariant::Double, "Budget"); - budgetItem->setValue(net->driver.budget); - driverItem->addSubProperty(budgetItem); - - QtVariantProperty *cellNameItem = readOnlyManager->addProperty(QVariant::String, "Cell"); + QtProperty *driverItem = addSubGroup(topItem, "Driver"); + addProperty(driverItem, QVariant::String, "Port", net->driver.port.c_str(ctx)); + addProperty(driverItem, QVariant::Double, "Budget", net->driver.budget); if (net->driver.cell) - cellNameItem->setValue(net->driver.cell->name.c_str(ctx)); + addProperty(driverItem, QVariant::String, "Cell", net->driver.cell->name.c_str(ctx), ElementType::CELL); else - cellNameItem->setValue(""); - driverItem->addSubProperty(cellNameItem); + addProperty(driverItem, QVariant::String, "Cell", "", ElementType::CELL); - QtProperty *usersItem = groupManager->addProperty("Users"); - topItem->addSubProperty(usersItem); + QtProperty *usersItem = addSubGroup(topItem, "Users"); for (auto &item : net->users) { - QtProperty *portItem = groupManager->addProperty(item.port.c_str(ctx)); - usersItem->addSubProperty(portItem); - - QtVariantProperty *nameItem = readOnlyManager->addProperty(QVariant::String, "Port"); - nameItem->setValue(item.port.c_str(ctx)); - portItem->addSubProperty(nameItem); - - QtVariantProperty *budgetItem = readOnlyManager->addProperty(QVariant::Double, "Budget"); - budgetItem->setValue(item.budget); - portItem->addSubProperty(budgetItem); + QtProperty *portItem = addSubGroup(usersItem, item.port.c_str(ctx)); - QtVariantProperty *userItem = readOnlyManager->addProperty(QVariant::String, "Cell"); + addProperty(portItem, QVariant::String, "Port", item.port.c_str(ctx)); + addProperty(portItem, QVariant::Double, "Budget", item.budget); if (item.cell) - userItem->setValue(item.cell->name.c_str(ctx)); + addProperty(portItem, QVariant::String, "Cell", item.cell->name.c_str(ctx), ElementType::CELL); else - userItem->setValue(""); - portItem->addSubProperty(userItem); + addProperty(portItem, QVariant::String, "Cell", "", ElementType::CELL); } - QtProperty *attrsItem = groupManager->addProperty("Attributes"); - topItem->addSubProperty(attrsItem); + QtProperty *attrsItem = addSubGroup(topItem, "Attributes"); for (auto &item : net->attrs) { - QtVariantProperty *attrItem = readOnlyManager->addProperty(QVariant::String, item.first.c_str(ctx)); - attrItem->setValue(item.second.c_str()); - attrsItem->addSubProperty(attrItem); + addProperty(attrsItem, QVariant::String, item.first.c_str(ctx), item.second.c_str()); } - QtProperty *wiresItem = groupManager->addProperty("Wires"); - topItem->addSubProperty(wiresItem); + QtProperty *wiresItem = addSubGroup(topItem, "Wires"); for (auto &item : net->wires) { auto name = ctx->getWireName(item.first).c_str(ctx); - QtProperty *wireItem = groupManager->addProperty(name); - - QtVariantProperty *nameItem = readOnlyManager->addProperty(QVariant::String, "Name"); - nameItem->setValue(name); - wireItem->addSubProperty(nameItem); - - QtVariantProperty *pipItem = readOnlyManager->addProperty(QVariant::String, "Pip"); + QtProperty *wireItem = addSubGroup(wiresItem, name); + addProperty(wireItem, QVariant::String, "Name", name); if (item.second.pip != PipId()) - pipItem->setValue(ctx->getPipName(item.second.pip).c_str(ctx)); + addProperty(wireItem, QVariant::String, "Pip", ctx->getPipName(item.second.pip).c_str(ctx), + ElementType::PIP); else - pipItem->setValue(""); - wireItem->addSubProperty(pipItem); + addProperty(wireItem, QVariant::String, "Pip", "", ElementType::PIP); - QtVariantProperty *strengthItem = readOnlyManager->addProperty(QVariant::Int, "Strength"); - strengthItem->setValue((int)item.second.strength); - wireItem->addSubProperty(strengthItem); - - wiresItem->addSubProperty(wireItem); + addProperty(wireItem, QVariant::Int, "Strength", (int)item.second.strength); } } else if (type == ElementType::CELL) { IdString c = static_cast(clickItem)->getData(); CellInfo *cell = ctx->cells.at(c).get(); - QtProperty *topItem = groupManager->addProperty("Cell"); - addProperty(topItem, "Cell"); - - QtVariantProperty *cellNameItem = readOnlyManager->addProperty(QVariant::String, "Name"); - cellNameItem->setValue(cell->name.c_str(ctx)); - topItem->addSubProperty(cellNameItem); + QtProperty *topItem = addTopLevelProperty("Cell"); - QtVariantProperty *cellTypeItem = readOnlyManager->addProperty(QVariant::String, "Type"); - cellTypeItem->setValue(cell->type.c_str(ctx)); - topItem->addSubProperty(cellTypeItem); - - QtVariantProperty *cellBelItem = readOnlyManager->addProperty(QVariant::String, "Bel"); + addProperty(topItem, QVariant::String, "Name", cell->name.c_str(ctx)); + addProperty(topItem, QVariant::String, "Type", cell->type.c_str(ctx)); if (cell->bel != BelId()) - cellBelItem->setValue(ctx->getBelName(cell->bel).c_str(ctx)); + addProperty(topItem, QVariant::String, "Bel", ctx->getBelName(cell->bel).c_str(ctx), ElementType::BEL); else - cellBelItem->setValue(""); - topItem->addSubProperty(cellBelItem); - - QtVariantProperty *cellBelStrItem = readOnlyManager->addProperty(QVariant::Int, "Bel strength"); - cellBelStrItem->setValue(int(cell->belStrength)); - topItem->addSubProperty(cellBelStrItem); + addProperty(topItem, QVariant::String, "Bel", "", ElementType::BEL); + addProperty(topItem, QVariant::Int, "Bel strength", int(cell->belStrength)); - QtProperty *cellPortsItem = groupManager->addProperty("Ports"); - topItem->addSubProperty(cellPortsItem); + QtProperty *cellPortsItem = addSubGroup(topItem, "Ports"); for (auto &item : cell->ports) { PortInfo p = item.second; - QtProperty *portInfoItem = groupManager->addProperty(p.name.c_str(ctx)); - - QtVariantProperty *portInfoNameItem = readOnlyManager->addProperty(QVariant::String, "Name"); - portInfoNameItem->setValue(p.name.c_str(ctx)); - portInfoItem->addSubProperty(portInfoNameItem); - - QtVariantProperty *portInfoTypeItem = readOnlyManager->addProperty(QVariant::Int, "Type"); - portInfoTypeItem->setValue(int(p.type)); - portInfoItem->addSubProperty(portInfoTypeItem); - - QtVariantProperty *portInfoNetItem = readOnlyManager->addProperty(QVariant::String, "Net"); + QtProperty *portInfoItem = addSubGroup(cellPortsItem, p.name.c_str(ctx)); + addProperty(portInfoItem, QVariant::String, "Name", p.name.c_str(ctx)); + addProperty(portInfoItem, QVariant::Int, "Type", int(p.type)); if (p.net) - portInfoNetItem->setValue(p.net->name.c_str(ctx)); + addProperty(portInfoItem, QVariant::String, "Net", p.net->name.c_str(ctx), ElementType::NET); else - portInfoNetItem->setValue(""); - portInfoItem->addSubProperty(portInfoNetItem); - - cellPortsItem->addSubProperty(portInfoItem); + addProperty(portInfoItem, QVariant::String, "Net", "", ElementType::NET); } - QtProperty *cellAttrItem = groupManager->addProperty("Attributes"); - topItem->addSubProperty(cellAttrItem); + QtProperty *cellAttrItem = addSubGroup(topItem, "Attributes"); for (auto &item : cell->attrs) { - QtVariantProperty *attrItem = readOnlyManager->addProperty(QVariant::String, item.first.c_str(ctx)); - attrItem->setValue(item.second.c_str()); - cellAttrItem->addSubProperty(attrItem); + addProperty(cellAttrItem, QVariant::String, item.first.c_str(ctx), item.second.c_str()); } - QtProperty *cellParamsItem = groupManager->addProperty("Parameters"); - topItem->addSubProperty(cellParamsItem); + QtProperty *cellParamsItem = addSubGroup(topItem, "Parameters"); for (auto &item : cell->params) { - QtVariantProperty *paramItem = readOnlyManager->addProperty(QVariant::String, item.first.c_str(ctx)); - paramItem->setValue(item.second.c_str()); - cellParamsItem->addSubProperty(paramItem); + addProperty(cellParamsItem, QVariant::String, item.first.c_str(ctx), item.second.c_str()); } QtProperty *cellPinsItem = groupManager->addProperty("Pins"); @@ -652,17 +588,10 @@ void DesignWidget::onItemSelectionChanged() std::string cell_port = item.first.c_str(ctx); std::string bel_pin = item.second.c_str(ctx); - QtProperty *pinGroupItem = groupManager->addProperty((cell_port + " -> " + bel_pin).c_str()); - - QtVariantProperty *cellItem = readOnlyManager->addProperty(QVariant::String, "Cell"); - cellItem->setValue(cell_port.c_str()); - pinGroupItem->addSubProperty(cellItem); - - QtVariantProperty *belItem = readOnlyManager->addProperty(QVariant::String, "Bel"); - belItem->setValue(bel_pin.c_str()); - pinGroupItem->addSubProperty(belItem); + QtProperty *pinGroupItem = addSubGroup(cellPortsItem, (cell_port + " -> " + bel_pin).c_str()); - cellPinsItem->addSubProperty(pinGroupItem); + addProperty(pinGroupItem, QVariant::String, "Cell", cell_port.c_str(), ElementType::CELL); + addProperty(pinGroupItem, QVariant::String, "Bel", bel_pin.c_str(), ElementType::BEL); } } } -- cgit v1.2.3 From bf0b1d2db3e071f5606e117d5fc5f2213b948997 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Sun, 15 Jul 2018 12:39:19 +0200 Subject: add select on property pane, and action to double click --- gui/designwidget.cc | 58 +++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 41 insertions(+), 17 deletions(-) (limited to 'gui/designwidget.cc') diff --git a/gui/designwidget.cc b/gui/designwidget.cc index 553171ab..cfcdc9fc 100644 --- a/gui/designwidget.cc +++ b/gui/designwidget.cc @@ -77,9 +77,8 @@ DesignWidget::DesignWidget(QWidget *parent) : QWidget(parent), ctx(nullptr), net propertyEditor = new QtTreePropertyBrowser(this); propertyEditor->setFactoryForManager(variantManager, variantFactory); propertyEditor->setPropertiesWithoutValueMarked(true); - connect(propertyEditor, SIGNAL(currentItemChanged(QtBrowserItem *)), this, - SLOT(onCurrentPropertyChanged(QtBrowserItem *))); propertyEditor->show(); + propertyEditor->treeWidget()->setContextMenuPolicy(Qt::CustomContextMenu); QLineEdit *lineEdit = new QLineEdit(); lineEdit->setClearButtonEnabled(true); @@ -144,7 +143,9 @@ DesignWidget::DesignWidget(QWidget *parent) : QWidget(parent), ctx(nullptr), net setLayout(mainLayout); // Connection - connect(treeWidget, &QTreeWidget::customContextMenuRequested, this, &DesignWidget::prepareMenu); + connect(propertyEditor->treeWidget(), &QTreeWidget::customContextMenuRequested, this, + &DesignWidget::prepareMenuProperty); + connect(propertyEditor->treeWidget(), &QTreeWidget::itemDoubleClicked, this, &DesignWidget::onItemDoubleClicked); connect(treeWidget, SIGNAL(itemSelectionChanged()), SLOT(onItemSelectionChanged())); } @@ -312,33 +313,41 @@ void DesignWidget::clearProperties() idToProperty.clear(); } -void DesignWidget::onCurrentPropertyChanged(QtBrowserItem *_item) +void DesignWidget::onCurrentPropertySelected(QtBrowserItem *_item) { if (_item) { QtProperty *selectedProperty = _item->property(); - QString type = selectedProperty->propertyId(); + ElementType type = getElementTypeByName(selectedProperty->propertyId()); IdString value = ctx->id(selectedProperty->valueText().toStdString()); std::vector decals; - if (type == "BEL") { + switch (type) { + case ElementType::BEL: { BelId bel = ctx->getBelByName(value); if (bel != BelId()) { decals.push_back(ctx->getBelDecal(bel)); Q_EMIT selected(decals); } - } else if (type == "WIRE") { + } break; + case ElementType::WIRE: { WireId wire = ctx->getWireByName(value); if (wire != WireId()) { decals.push_back(ctx->getWireDecal(wire)); Q_EMIT selected(decals); } - } else if (type == "PIP") { + } break; + case ElementType::PIP: { PipId pip = ctx->getPipByName(value); if (pip != PipId()) { decals.push_back(ctx->getPipDecal(pip)); Q_EMIT selected(decals); } - } else if (type == "NET") { - } else if (type == "CELL") { + } break; + case ElementType::NET: { + } break; + case ElementType::CELL: { + } break; + default: + break; } } } @@ -596,23 +605,38 @@ void DesignWidget::onItemSelectionChanged() } } -void DesignWidget::prepareMenu(const QPoint &pos) +void DesignWidget::prepareMenuProperty(const QPoint &pos) { - QTreeWidget *tree = treeWidget; + QTreeWidget *tree = propertyEditor->treeWidget(); itemContextMenu = tree->itemAt(pos); + if (itemContextMenu->parent() == nullptr) + return; - QAction *selectAction = new QAction("&Select", this); - selectAction->setStatusTip("Select item on view"); - - connect(selectAction, SIGNAL(triggered()), this, SLOT(selectObject())); + QtBrowserItem *browserItem = propertyEditor->itemToBrowserItem(itemContextMenu); + // if (((ElementTreeItem*)itemContextMenu)->getType() == ElementType::NONE) return; QMenu menu(this); + QAction *selectAction = new QAction("&Select", this); + connect(selectAction, &QAction::triggered, this, [this, browserItem] { onCurrentPropertySelected(browserItem); }); + menu.addAction(selectAction); menu.exec(tree->mapToGlobal(pos)); } -void DesignWidget::selectObject() { Q_EMIT info("selected " + itemContextMenu->text(0).toStdString() + "\n"); } +void DesignWidget::onItemDoubleClicked(QTreeWidgetItem *item, int column) +{ + QtProperty *selectedProperty = propertyEditor->itemToBrowserItem(item)->property(); + ElementType type = getElementTypeByName(selectedProperty->propertyId()); + IdString value = ctx->id(selectedProperty->valueText().toStdString()); + switch (type) { + case ElementType::NONE: + return; + default: + Q_EMIT info("double clicked " + std::string(value.c_str(ctx)) + "\n"); + break; + } +} NEXTPNR_NAMESPACE_END -- cgit v1.2.3 From 3eb34bf38b8e2da66b3852bf35927a0b540a3cff Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Sun, 15 Jul 2018 15:12:31 +0200 Subject: make linked items clickable --- gui/designwidget.cc | 58 +++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 43 insertions(+), 15 deletions(-) (limited to 'gui/designwidget.cc') diff --git a/gui/designwidget.cc b/gui/designwidget.cc index cfcdc9fc..2b0c43c0 100644 --- a/gui/designwidget.cc +++ b/gui/designwidget.cc @@ -155,6 +155,9 @@ DesignWidget::~DesignWidget() {} void DesignWidget::newContext(Context *ctx) { treeWidget->clear(); + for (int i = 0; i < 6; i++) + nameToItem[i].clear(); + this->ctx = ctx; // Add bels to tree @@ -174,7 +177,7 @@ void DesignWidget::newContext(Context *ctx) name += items.at(i); if (!bel_items.contains(name)) { if (i == items.size() - 1) - bel_items.insert(name, new IdStringTreeItem(id, ElementType::BEL, items.at(i), parent)); + nameToItem[0].insert(name, new IdStringTreeItem(id, ElementType::BEL, items.at(i), parent)); else bel_items.insert(name, new ElementTreeItem(ElementType::NONE, items.at(i), parent)); } @@ -185,6 +188,9 @@ void DesignWidget::newContext(Context *ctx) for (auto bel : bel_items.toStdMap()) { bel_root->addChild(bel.second); } + for (auto bel : nameToItem[0].toStdMap()) { + bel_root->addChild(bel.second); + } // Add wires to tree QTreeWidgetItem *wire_root = new QTreeWidgetItem(treeWidget); @@ -203,7 +209,7 @@ void DesignWidget::newContext(Context *ctx) name += items.at(i); if (!wire_items.contains(name)) { if (i == items.size() - 1) - wire_items.insert(name, new IdStringTreeItem(id, ElementType::WIRE, items.at(i), parent)); + nameToItem[1].insert(name, new IdStringTreeItem(id, ElementType::WIRE, items.at(i), parent)); else wire_items.insert(name, new ElementTreeItem(ElementType::NONE, items.at(i), parent)); } @@ -214,7 +220,9 @@ void DesignWidget::newContext(Context *ctx) for (auto wire : wire_items.toStdMap()) { wire_root->addChild(wire.second); } - + for (auto wire : nameToItem[1].toStdMap()) { + wire_root->addChild(wire.second); + } // Add pips to tree QTreeWidgetItem *pip_root = new QTreeWidgetItem(treeWidget); QMap pip_items; @@ -232,7 +240,7 @@ void DesignWidget::newContext(Context *ctx) name += items.at(i); if (!pip_items.contains(name)) { if (i == items.size() - 1) - pip_items.insert(name, new IdStringTreeItem(id, ElementType::PIP, items.at(i), parent)); + nameToItem[2].insert(name, new IdStringTreeItem(id, ElementType::PIP, items.at(i), parent)); else pip_items.insert(name, new ElementTreeItem(ElementType::NONE, items.at(i), parent)); } @@ -243,6 +251,9 @@ void DesignWidget::newContext(Context *ctx) for (auto pip : pip_items.toStdMap()) { pip_root->addChild(pip.second); } + for (auto pip : nameToItem[2].toStdMap()) { + pip_root->addChild(pip.second); + } // Add nets to tree nets_root = new QTreeWidgetItem(treeWidget); @@ -260,36 +271,38 @@ void DesignWidget::updateTree() clearProperties(); delete nets_root; delete cells_root; + nameToItem[3].clear(); + nameToItem[4].clear(); // Add nets to tree nets_root = new QTreeWidgetItem(treeWidget); - QMap nets_items; nets_root->setText(0, "Nets"); treeWidget->insertTopLevelItem(0, nets_root); if (ctx) { for (auto &item : ctx->nets) { auto id = item.first; QString name = QString(id.c_str(ctx)); - nets_items.insert(name, new IdStringTreeItem(id, ElementType::NET, name, nullptr)); + IdStringTreeItem *newItem = new IdStringTreeItem(id, ElementType::NET, name, nullptr); + nameToItem[3].insert(name, newItem); } } - for (auto item : nets_items.toStdMap()) { + for (auto item : nameToItem[3].toStdMap()) { nets_root->addChild(item.second); } // Add cells to tree cells_root = new QTreeWidgetItem(treeWidget); - QMap cells_items; cells_root->setText(0, "Cells"); treeWidget->insertTopLevelItem(0, cells_root); if (ctx) { for (auto &item : ctx->cells) { auto id = item.first; QString name = QString(id.c_str(ctx)); - cells_items.insert(name, new IdStringTreeItem(id, ElementType::CELL, name, nullptr)); + IdStringTreeItem *newItem = new IdStringTreeItem(id, ElementType::CELL, name, nullptr); + nameToItem[4].insert(name, newItem); } } - for (auto item : cells_items.toStdMap()) { + for (auto item : nameToItem[4].toStdMap()) { cells_root->addChild(item.second); } } @@ -368,6 +381,20 @@ QString DesignWidget::getElementTypeName(ElementType type) return "CELL"; return ""; } +int DesignWidget::getElementIndex(ElementType type) +{ + if (type == ElementType::BEL) + return 0; + if (type == ElementType::WIRE) + return 1; + if (type == ElementType::PIP) + return 2; + if (type == ElementType::NET) + return 3; + if (type == ElementType::CELL) + return 4; + return -1; +} ElementType DesignWidget::getElementTypeByName(QString type) { @@ -615,7 +642,6 @@ void DesignWidget::prepareMenuProperty(const QPoint &pos) QtBrowserItem *browserItem = propertyEditor->itemToBrowserItem(itemContextMenu); - // if (((ElementTreeItem*)itemContextMenu)->getType() == ElementType::NONE) return; QMenu menu(this); QAction *selectAction = new QAction("&Select", this); connect(selectAction, &QAction::triggered, this, [this, browserItem] { onCurrentPropertySelected(browserItem); }); @@ -629,13 +655,15 @@ void DesignWidget::onItemDoubleClicked(QTreeWidgetItem *item, int column) { QtProperty *selectedProperty = propertyEditor->itemToBrowserItem(item)->property(); ElementType type = getElementTypeByName(selectedProperty->propertyId()); - IdString value = ctx->id(selectedProperty->valueText().toStdString()); + QString value = selectedProperty->valueText(); + int index = getElementIndex(type); switch (type) { case ElementType::NONE: return; - default: - Q_EMIT info("double clicked " + std::string(value.c_str(ctx)) + "\n"); - break; + default: { + if (nameToItem[index].contains(value)) + treeWidget->setCurrentItem(nameToItem[index].value(value)); + } break; } } -- cgit v1.2.3 From 82c9fef3de1017d39a15b5c23be84a8f3c8bebc0 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Sun, 15 Jul 2018 16:20:35 +0200 Subject: added browsing history --- gui/designwidget.cc | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) (limited to 'gui/designwidget.cc') diff --git a/gui/designwidget.cc b/gui/designwidget.cc index 2b0c43c0..698e4ca8 100644 --- a/gui/designwidget.cc +++ b/gui/designwidget.cc @@ -88,18 +88,42 @@ DesignWidget::DesignWidget(QWidget *parent) : QWidget(parent), ctx(nullptr), net actionFirst = new QAction("", this); actionFirst->setIcon(QIcon(":/icons/resources/resultset_first.png")); actionFirst->setEnabled(false); + connect(actionFirst, &QAction::triggered, this, [this] { + history_ignore = true; + history_index = 0; + treeWidget->setCurrentItem(history.at(history_index)); + updateButtons(); + }); actionPrev = new QAction("", this); actionPrev->setIcon(QIcon(":/icons/resources/resultset_previous.png")); actionPrev->setEnabled(false); + connect(actionPrev, &QAction::triggered, this, [this] { + history_ignore = true; + history_index--; + treeWidget->setCurrentItem(history.at(history_index)); + updateButtons(); + }); actionNext = new QAction("", this); actionNext->setIcon(QIcon(":/icons/resources/resultset_next.png")); actionNext->setEnabled(false); + connect(actionNext, &QAction::triggered, this, [this] { + history_ignore = true; + history_index++; + treeWidget->setCurrentItem(history.at(history_index)); + updateButtons(); + }); actionLast = new QAction("", this); actionLast->setIcon(QIcon(":/icons/resources/resultset_last.png")); actionLast->setEnabled(false); + connect(actionLast, &QAction::triggered, this, [this] { + history_ignore = true; + history_index = int(history.size() - 1); + treeWidget->setCurrentItem(history.at(history_index)); + updateButtons(); + }); QToolBar *toolbar = new QToolBar(); toolbar->addAction(actionFirst); @@ -148,13 +172,43 @@ DesignWidget::DesignWidget(QWidget *parent) : QWidget(parent), ctx(nullptr), net connect(propertyEditor->treeWidget(), &QTreeWidget::itemDoubleClicked, this, &DesignWidget::onItemDoubleClicked); connect(treeWidget, SIGNAL(itemSelectionChanged()), SLOT(onItemSelectionChanged())); + + history_index = -1; + history_ignore = false; } DesignWidget::~DesignWidget() {} +void DesignWidget::updateButtons() +{ + int count = int(history.size()); + actionFirst->setEnabled(history_index > 0); + actionPrev->setEnabled(history_index > 0); + actionNext->setEnabled(history_index < (count - 1)); + actionLast->setEnabled(history_index < (count - 1)); +} + +void DesignWidget::addToHistory(QTreeWidgetItem *item) +{ + if (!history_ignore) { + int count = int(history.size()); + for (int i = count - 1; i > history_index; i--) + history.pop_back(); + history.push_back(item); + history_index++; + } + history_ignore = false; + updateButtons(); +} + void DesignWidget::newContext(Context *ctx) { treeWidget->clear(); + history_ignore = false; + history_index = -1; + history.clear(); + updateButtons(); + for (int i = 0; i < 6; i++) nameToItem[i].clear(); @@ -444,6 +498,8 @@ void DesignWidget::onItemSelectionChanged() std::vector decals; + addToHistory(clickItem); + clearProperties(); if (type == ElementType::BEL) { IdString c = static_cast(clickItem)->getData(); -- cgit v1.2.3 From ecc4c3fa7bdf1726377cd5cf2199b3cabd233427 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Sun, 15 Jul 2018 17:50:58 +0200 Subject: added highlight groups --- gui/designwidget.cc | 165 +++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 124 insertions(+), 41 deletions(-) (limited to 'gui/designwidget.cc') diff --git a/gui/designwidget.cc b/gui/designwidget.cc index 698e4ca8..1f039c60 100644 --- a/gui/designwidget.cc +++ b/gui/designwidget.cc @@ -172,9 +172,19 @@ DesignWidget::DesignWidget(QWidget *parent) : QWidget(parent), ctx(nullptr), net connect(propertyEditor->treeWidget(), &QTreeWidget::itemDoubleClicked, this, &DesignWidget::onItemDoubleClicked); connect(treeWidget, SIGNAL(itemSelectionChanged()), SLOT(onItemSelectionChanged())); + connect(treeWidget, &QTreeWidget::customContextMenuRequested, this, &DesignWidget::prepareMenuTree); history_index = -1; history_ignore = false; + + highlightColors[0] = QColor("#6495ed"); + highlightColors[1] = QColor("#7fffd4"); + highlightColors[2] = QColor("#98fb98"); + highlightColors[3] = QColor("#ffd700"); + highlightColors[4] = QColor("#cd5c5c"); + highlightColors[5] = QColor("#fa8072"); + highlightColors[6] = QColor("#ff69b4"); + highlightColors[7] = QColor("#da70d6"); } DesignWidget::~DesignWidget() {} @@ -380,45 +390,6 @@ void DesignWidget::clearProperties() idToProperty.clear(); } -void DesignWidget::onCurrentPropertySelected(QtBrowserItem *_item) -{ - if (_item) { - QtProperty *selectedProperty = _item->property(); - ElementType type = getElementTypeByName(selectedProperty->propertyId()); - IdString value = ctx->id(selectedProperty->valueText().toStdString()); - std::vector decals; - switch (type) { - case ElementType::BEL: { - BelId bel = ctx->getBelByName(value); - if (bel != BelId()) { - decals.push_back(ctx->getBelDecal(bel)); - Q_EMIT selected(decals); - } - } break; - case ElementType::WIRE: { - WireId wire = ctx->getWireByName(value); - if (wire != WireId()) { - decals.push_back(ctx->getWireDecal(wire)); - Q_EMIT selected(decals); - } - } break; - case ElementType::PIP: { - PipId pip = ctx->getPipByName(value); - if (pip != PipId()) { - decals.push_back(ctx->getPipDecal(pip)); - Q_EMIT selected(decals); - } - } break; - case ElementType::NET: { - } break; - case ElementType::CELL: { - } break; - default: - break; - } - } -} - QString DesignWidget::getElementTypeName(ElementType type) { if (type == ElementType::NONE) @@ -688,6 +659,64 @@ void DesignWidget::onItemSelectionChanged() } } +std::vector DesignWidget::getDecals(ElementType type, IdString value) +{ + std::vector decals; + switch (type) { + case ElementType::BEL: { + BelId bel = ctx->getBelByName(value); + if (bel != BelId()) { + decals.push_back(ctx->getBelDecal(bel)); + } + } break; + case ElementType::WIRE: { + WireId wire = ctx->getWireByName(value); + if (wire != WireId()) { + decals.push_back(ctx->getWireDecal(wire)); + Q_EMIT selected(decals); + } + } break; + case ElementType::PIP: { + PipId pip = ctx->getPipByName(value); + if (pip != PipId()) { + decals.push_back(ctx->getPipDecal(pip)); + Q_EMIT selected(decals); + } + } break; + case ElementType::NET: { + } break; + case ElementType::CELL: { + } break; + default: + break; + } + return decals; +} + +void DesignWidget::updateHighlightGroup(QTreeWidgetItem *item, int group) +{ + if (highlightSelected.contains(item)) { + if (highlightSelected[item] == group) { + highlightSelected.remove(item); + } else + highlightSelected[item] = group; + } else + highlightSelected.insert(item, group); + + std::vector decals; + + for (auto it : highlightSelected.toStdMap()) { + if (it.second == group) { + ElementType type = static_cast(it.first)->getType(); + IdString value = static_cast(it.first)->getData(); + std::vector d = getDecals(type, value); + std::move(d.begin(), d.end(), std::back_inserter(decals)); + } + } + + Q_EMIT highlight(decals, group); +} + void DesignWidget::prepareMenuProperty(const QPoint &pos) { QTreeWidget *tree = propertyEditor->treeWidget(); @@ -697,13 +726,67 @@ void DesignWidget::prepareMenuProperty(const QPoint &pos) return; QtBrowserItem *browserItem = propertyEditor->itemToBrowserItem(itemContextMenu); + if (!browserItem) + return; + QtProperty *selectedProperty = browserItem->property(); + ElementType type = getElementTypeByName(selectedProperty->propertyId()); + if (type == ElementType::NONE) + return; + IdString value = ctx->id(selectedProperty->valueText().toStdString()); + + QTreeWidgetItem *item = nameToItem[getElementIndex(type)].value(value.c_str(ctx)); QMenu menu(this); QAction *selectAction = new QAction("&Select", this); - connect(selectAction, &QAction::triggered, this, [this, browserItem] { onCurrentPropertySelected(browserItem); }); - + connect(selectAction, &QAction::triggered, this, [this, type, value] { Q_EMIT selected(getDecals(type, value)); }); menu.addAction(selectAction); + QMenu *subMenu = menu.addMenu("Highlight"); + QActionGroup *group = new QActionGroup(this); + group->setExclusive(true); + for (int i = 0; i < 8; i++) { + QPixmap pixmap(32, 32); + pixmap.fill(QColor(highlightColors[i])); + QAction *action = new QAction(QIcon(pixmap), ("Group " + std::to_string(i)).c_str(), this); + action->setCheckable(true); + subMenu->addAction(action); + group->addAction(action); + if (highlightSelected.contains(item) && highlightSelected[item] == i) + action->setChecked(true); + connect(action, &QAction::triggered, this, [this, i, item] { updateHighlightGroup(item, i); }); + } + menu.exec(tree->mapToGlobal(pos)); +} + +void DesignWidget::prepareMenuTree(const QPoint &pos) +{ + QTreeWidget *tree = treeWidget; + + itemContextMenu = tree->itemAt(pos); + + ElementType type = static_cast(itemContextMenu)->getType(); + IdString value = static_cast(itemContextMenu)->getData(); + + if (type == ElementType::NONE) + return; + + QTreeWidgetItem *item = nameToItem[getElementIndex(type)].value(value.c_str(ctx)); + + QMenu menu(this); + QMenu *subMenu = menu.addMenu("Highlight"); + QActionGroup *group = new QActionGroup(this); + group->setExclusive(true); + for (int i = 0; i < 8; i++) { + QPixmap pixmap(32, 32); + pixmap.fill(QColor(highlightColors[i])); + QAction *action = new QAction(QIcon(pixmap), ("Group " + std::to_string(i)).c_str(), this); + action->setCheckable(true); + subMenu->addAction(action); + group->addAction(action); + if (highlightSelected.contains(item) && highlightSelected[item] == i) + action->setChecked(true); + connect(action, &QAction::triggered, this, [this, i, item] { updateHighlightGroup(item, i); }); + } menu.exec(tree->mapToGlobal(pos)); } -- cgit v1.2.3 From 8e12ae2cfed728ee1ecab4e5f60f0435bf2d58b8 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Sun, 15 Jul 2018 20:31:42 +0200 Subject: Added splash screen info while loading --- gui/designwidget.cc | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'gui/designwidget.cc') diff --git a/gui/designwidget.cc b/gui/designwidget.cc index 1f039c60..8b9e9d22 100644 --- a/gui/designwidget.cc +++ b/gui/designwidget.cc @@ -230,6 +230,7 @@ void DesignWidget::newContext(Context *ctx) bel_root->setText(0, "Bels"); treeWidget->insertTopLevelItem(0, bel_root); if (ctx) { + Q_EMIT contextLoadStatus("Configuring bels..."); for (auto bel : ctx->getBels()) { auto id = ctx->getBelName(bel); QStringList items = QString(id.c_str(ctx)).split("/"); @@ -262,6 +263,7 @@ void DesignWidget::newContext(Context *ctx) wire_root->setText(0, "Wires"); treeWidget->insertTopLevelItem(0, wire_root); if (ctx) { + Q_EMIT contextLoadStatus("Configuring wires..."); for (auto wire : ctx->getWires()) { auto id = ctx->getWireName(wire); QStringList items = QString(id.c_str(ctx)).split("/"); @@ -293,6 +295,7 @@ void DesignWidget::newContext(Context *ctx) pip_root->setText(0, "Pips"); treeWidget->insertTopLevelItem(0, pip_root); if (ctx) { + Q_EMIT contextLoadStatus("Configuring pips..."); for (auto pip : ctx->getPips()) { auto id = ctx->getPipName(pip); QStringList items = QString(id.c_str(ctx)).split("/"); @@ -328,6 +331,8 @@ void DesignWidget::newContext(Context *ctx) cells_root = new QTreeWidgetItem(treeWidget); cells_root->setText(0, "Cells"); treeWidget->insertTopLevelItem(0, cells_root); + + Q_EMIT finishContextLoad(); } void DesignWidget::updateTree() -- cgit v1.2.3 From 21bf78dae9ef95e65b549c60061bce9790b1b611 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Sun, 15 Jul 2018 21:06:04 +0200 Subject: Make at least 50 of pips available in uphill/downhill --- gui/designwidget.cc | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) (limited to 'gui/designwidget.cc') diff --git a/gui/designwidget.cc b/gui/designwidget.cc index 8b9e9d22..335ed929 100644 --- a/gui/designwidget.cc +++ b/gui/designwidget.cc @@ -528,17 +528,28 @@ void DesignWidget::onItemSelectionChanged() addProperty(dhItem, QVariant::String, "Bel", belname, ElementType::BEL); addProperty(dhItem, QVariant::String, "PortPin", pinname); } - /* - QtProperty *pipsDownItem = addSubGroup(downhillItem, "Pips Downhill"); - for (const auto &item : ctx->getPipsDownhill(wire)) { - addProperty(pipsDownItem, QVariant::String, "", ctx->getPipName(item).c_str(ctx), ElementType::PIP); - } - QtProperty *pipsUpItem = addSubGroup(downhillItem, "Pips Uphill"); - for (const auto &item : ctx->getPipsUphill(wire)) { - addProperty(pipsUpItem, QVariant::String, "", ctx->getPipName(item).c_str(ctx), ElementType::PIP); - } - */ + int counter = 0; + QtProperty *pipsDownItem = addSubGroup(downhillItem, "Pips Downhill"); + for (const auto &item : ctx->getPipsDownhill(wire)) { + addProperty(pipsDownItem, QVariant::String, "", ctx->getPipName(item).c_str(ctx), ElementType::PIP); + counter++; + if (counter == 50) { + addProperty(pipsDownItem, QVariant::String, "Warning", "Too many items...", ElementType::NONE); + break; + } + } + + counter = 0; + QtProperty *pipsUpItem = addSubGroup(downhillItem, "Pips Uphill"); + for (const auto &item : ctx->getPipsUphill(wire)) { + addProperty(pipsUpItem, QVariant::String, "", ctx->getPipName(item).c_str(ctx), ElementType::PIP); + counter++; + if (counter == 50) { + addProperty(pipsUpItem, QVariant::String, "Warning", "Too many items...", ElementType::NONE); + break; + } + } } else if (type == ElementType::PIP) { IdString c = static_cast(clickItem)->getData(); PipId pip = ctx->getPipByName(c); -- cgit v1.2.3