aboutsummaryrefslogtreecommitdiffstats
path: root/gui/designwidget.cc
diff options
context:
space:
mode:
Diffstat (limited to 'gui/designwidget.cc')
-rw-r--r--gui/designwidget.cc119
1 files changed, 62 insertions, 57 deletions
diff --git a/gui/designwidget.cc b/gui/designwidget.cc
index c17990a5..43964edf 100644
--- a/gui/designwidget.cc
+++ b/gui/designwidget.cc
@@ -567,6 +567,7 @@ void DesignWidget::onItemSelectionChanged()
QtProperty *topItem = addTopLevelProperty("Wire");
addProperty(topItem, QVariant::String, "Name", c.c_str(ctx));
+ addProperty(topItem, QVariant::String, "Type", ctx->getWireType(wire).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),
@@ -618,6 +619,7 @@ void DesignWidget::onItemSelectionChanged()
QtProperty *topItem = addTopLevelProperty("Pip");
addProperty(topItem, QVariant::String, "Name", c.c_str(ctx));
+ addProperty(topItem, QVariant::String, "Type", ctx->getPipType(pip).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),
@@ -775,52 +777,64 @@ std::vector<DecalXY> DesignWidget::getDecals(ElementType type, IdString value)
return decals;
}
-void DesignWidget::updateHighlightGroup(QTreeWidgetItem *item, int group)
+void DesignWidget::updateHighlightGroup(QList<QTreeWidgetItem *> items, int group)
{
- if (highlightSelected.contains(item)) {
- if (highlightSelected[item] == group) {
- highlightSelected.remove(item);
+ const bool shouldClear = items.size() == 1;
+ for (auto item : items) {
+ if (highlightSelected.contains(item)) {
+ if (shouldClear && highlightSelected[item] == group) {
+ highlightSelected.remove(item);
+ } else
+ highlightSelected[item] = group;
} else
- highlightSelected[item] = group;
- } else
- highlightSelected.insert(item, group);
-
- std::vector<DecalXY> decals;
+ highlightSelected.insert(item, group);
+ }
+ std::vector<DecalXY> decals[8];
for (auto it : highlightSelected.toStdMap()) {
- if (it.second == group) {
- ElementType type = static_cast<ElementTreeItem *>(it.first)->getType();
- IdString value = static_cast<IdStringTreeItem *>(it.first)->getData();
- std::vector<DecalXY> d = getDecals(type, value);
- std::move(d.begin(), d.end(), std::back_inserter(decals));
- }
+ ElementType type = static_cast<ElementTreeItem *>(it.first)->getType();
+ IdString value = static_cast<IdStringTreeItem *>(it.first)->getData();
+ std::vector<DecalXY> d = getDecals(type, value);
+ std::move(d.begin(), d.end(), std::back_inserter(decals[it.second]));
}
-
- Q_EMIT highlight(decals, group);
+ for (int i = 0; i < 8; i++)
+ Q_EMIT highlight(decals[i], i);
}
void DesignWidget::prepareMenuProperty(const QPoint &pos)
{
QTreeWidget *tree = propertyEditor->treeWidget();
-
- itemContextMenu = tree->itemAt(pos);
- if (itemContextMenu->parent() == nullptr)
- 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));
+ QList<QTreeWidgetItem *> items;
+ for (auto itemContextMenu : tree->selectedItems()) {
+ QtBrowserItem *browserItem = propertyEditor->itemToBrowserItem(itemContextMenu);
+ if (!browserItem)
+ continue;
+ QtProperty *selectedProperty = browserItem->property();
+ ElementType type = getElementTypeByName(selectedProperty->propertyId());
+ if (type == ElementType::NONE)
+ continue;
+ IdString value = ctx->id(selectedProperty->valueText().toStdString());
+ items.append(nameToItem[getElementIndex(type)].value(value.c_str(ctx)));
+ }
+ int selectedIndex = -1;
+ if (items.size() == 1) {
+ QTreeWidgetItem *item = items.at(0);
+ if (highlightSelected.contains(item))
+ selectedIndex = highlightSelected[item];
+ }
QMenu menu(this);
QAction *selectAction = new QAction("&Select", this);
- connect(selectAction, &QAction::triggered, this, [this, type, value] { Q_EMIT selected(getDecals(type, value)); });
+ connect(selectAction, &QAction::triggered, this, [this, items] {
+ std::vector<DecalXY> decals;
+ for (auto clickItem : items) {
+ IdString value = static_cast<IdStringTreeItem *>(clickItem)->getData();
+ ElementType type = static_cast<ElementTreeItem *>(clickItem)->getType();
+ std::vector<DecalXY> d = getDecals(type, value);
+ std::move(d.begin(), d.end(), std::back_inserter(decals));
+ }
+ Q_EMIT selected(decals);
+ });
menu.addAction(selectAction);
QMenu *subMenu = menu.addMenu("Highlight");
@@ -833,27 +847,24 @@ void DesignWidget::prepareMenuProperty(const QPoint &pos)
action->setCheckable(true);
subMenu->addAction(action);
group->addAction(action);
- if (highlightSelected.contains(item) && highlightSelected[item] == i)
+ if (selectedIndex == i)
action->setChecked(true);
- connect(action, &QAction::triggered, this, [this, i, item] { updateHighlightGroup(item, i); });
+ connect(action, &QAction::triggered, this, [this, i, items] { updateHighlightGroup(items, i); });
}
menu.exec(tree->mapToGlobal(pos));
}
void DesignWidget::prepareMenuTree(const QPoint &pos)
{
- QTreeWidget *tree = treeWidget;
-
- itemContextMenu = tree->itemAt(pos);
-
- ElementType type = static_cast<ElementTreeItem *>(itemContextMenu)->getType();
- IdString value = static_cast<IdStringTreeItem *>(itemContextMenu)->getData();
-
- if (type == ElementType::NONE)
+ if (treeWidget->selectedItems().size() == 0)
return;
-
- QTreeWidgetItem *item = nameToItem[getElementIndex(type)].value(value.c_str(ctx));
-
+ int selectedIndex = -1;
+ QList<QTreeWidgetItem *> items = treeWidget->selectedItems();
+ if (treeWidget->selectedItems().size() == 1) {
+ QTreeWidgetItem *item = treeWidget->selectedItems().at(0);
+ if (highlightSelected.contains(item))
+ selectedIndex = highlightSelected[item];
+ }
QMenu menu(this);
QMenu *subMenu = menu.addMenu("Highlight");
QActionGroup *group = new QActionGroup(this);
@@ -865,11 +876,11 @@ void DesignWidget::prepareMenuTree(const QPoint &pos)
action->setCheckable(true);
subMenu->addAction(action);
group->addAction(action);
- if (highlightSelected.contains(item) && highlightSelected[item] == i)
+ if (selectedIndex == i)
action->setChecked(true);
- connect(action, &QAction::triggered, this, [this, i, item] { updateHighlightGroup(item, i); });
+ connect(action, &QAction::triggered, this, [this, i, items] { updateHighlightGroup(items, i); });
}
- menu.exec(tree->mapToGlobal(pos));
+ menu.exec(treeWidget->mapToGlobal(pos));
}
void DesignWidget::onItemDoubleClicked(QTreeWidgetItem *item, int column)
@@ -878,14 +889,8 @@ void DesignWidget::onItemDoubleClicked(QTreeWidgetItem *item, int column)
ElementType type = getElementTypeByName(selectedProperty->propertyId());
QString value = selectedProperty->valueText();
int index = getElementIndex(type);
- switch (type) {
- case ElementType::NONE:
- return;
- default: {
- if (nameToItem[index].contains(value))
- treeWidget->setCurrentItem(nameToItem[index].value(value));
- } break;
- }
+ if (type != ElementType::NONE && nameToItem[index].contains(value))
+ treeWidget->setCurrentItem(nameToItem[index].value(value));
}
NEXTPNR_NAMESPACE_END