aboutsummaryrefslogtreecommitdiffstats
path: root/gui
diff options
context:
space:
mode:
authorSergiusz Bazanski <q3k@q3k.org>2018-08-01 02:11:23 +0100
committerSergiusz Bazanski <q3k@q3k.org>2018-08-01 02:11:23 +0100
commitc728cdcae0e73c3046628838dc318f1d92c65b79 (patch)
treee16eb9b9695ad51f976d97a276bb94f4803e2a99 /gui
parent1038b7ef23dbc1336212962be12994f98a68226a (diff)
downloadnextpnr-c728cdcae0e73c3046628838dc318f1d92c65b79.tar.gz
nextpnr-c728cdcae0e73c3046628838dc318f1d92c65b79.tar.bz2
nextpnr-c728cdcae0e73c3046628838dc318f1d92c65b79.zip
gui: restore menu for new tree model
Diffstat (limited to 'gui')
-rw-r--r--gui/designwidget.cc97
1 files changed, 50 insertions, 47 deletions
diff --git a/gui/designwidget.cc b/gui/designwidget.cc
index fe99a3c2..d5c0c963 100644
--- a/gui/designwidget.cc
+++ b/gui/designwidget.cc
@@ -630,53 +630,56 @@ void DesignWidget::updateHighlightGroup(QList<LazyTreeItem *> items, int group)
void DesignWidget::prepareMenuProperty(const QPoint &pos)
{
- //QTreeWidget *tree = propertyEditor->treeWidget();
- //QList<LazyTreeItem *> 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(treeModel->nodeForIdType(type, value.c_str(ctx)));
- //}
- //int selectedIndex = -1;
- //if (items.size() == 1) {
- // LazyTreeItem *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, items] {
- // std::vector<DecalXY> decals;
- // for (auto clickItem : items) {
- // std::vector<DecalXY> d = getDecals(clickItem->type(), clickItem->id());
- // std::move(d.begin(), d.end(), std::back_inserter(decals));
- // }
- // Q_EMIT selected(decals, false);
- //});
- //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 (selectedIndex == i)
- // action->setChecked(true);
- // connect(action, &QAction::triggered, this, [this, i, items] { updateHighlightGroup(items, i); });
- //}
- //menu.exec(tree->mapToGlobal(pos));
+ QTreeWidget *tree = propertyEditor->treeWidget();
+ QList<LazyTreeItem *> 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());
+ auto node = treeModel->nodeForIdType(type, value);
+ if (!node)
+ continue;
+ items.append(*node);
+ }
+ int selectedIndex = -1;
+ if (items.size() == 1) {
+ LazyTreeItem *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, items] {
+ std::vector<DecalXY> decals;
+ for (auto clickItem : items) {
+ std::vector<DecalXY> d = getDecals(clickItem->type(), clickItem->id());
+ std::move(d.begin(), d.end(), std::back_inserter(decals));
+ }
+ Q_EMIT selected(decals, false);
+ });
+ 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 (selectedIndex == i)
+ action->setChecked(true);
+ connect(action, &QAction::triggered, this, [this, i, items] { updateHighlightGroup(items, i); });
+ }
+ menu.exec(tree->mapToGlobal(pos));
}
void DesignWidget::prepareMenuTree(const QPoint &pos)