gui: restore menu for new tree model
This commit is contained in:
parent
1038b7ef23
commit
c728cdcae0
@ -630,53 +630,56 @@ void DesignWidget::updateHighlightGroup(QList<LazyTreeItem *> items, int group)
|
|||||||
|
|
||||||
void DesignWidget::prepareMenuProperty(const QPoint &pos)
|
void DesignWidget::prepareMenuProperty(const QPoint &pos)
|
||||||
{
|
{
|
||||||
//QTreeWidget *tree = propertyEditor->treeWidget();
|
QTreeWidget *tree = propertyEditor->treeWidget();
|
||||||
//QList<LazyTreeItem *> items;
|
QList<LazyTreeItem *> items;
|
||||||
//for (auto itemContextMenu : tree->selectedItems()) {
|
for (auto itemContextMenu : tree->selectedItems()) {
|
||||||
// QtBrowserItem *browserItem = propertyEditor->itemToBrowserItem(itemContextMenu);
|
QtBrowserItem *browserItem = propertyEditor->itemToBrowserItem(itemContextMenu);
|
||||||
// if (!browserItem)
|
if (!browserItem)
|
||||||
// continue;
|
continue;
|
||||||
// QtProperty *selectedProperty = browserItem->property();
|
QtProperty *selectedProperty = browserItem->property();
|
||||||
// ElementType type = getElementTypeByName(selectedProperty->propertyId());
|
ElementType type = getElementTypeByName(selectedProperty->propertyId());
|
||||||
// if (type == ElementType::NONE)
|
if (type == ElementType::NONE)
|
||||||
// continue;
|
continue;
|
||||||
// IdString value = ctx->id(selectedProperty->valueText().toStdString());
|
IdString value = ctx->id(selectedProperty->valueText().toStdString());
|
||||||
// items.append(treeModel->nodeForIdType(type, value.c_str(ctx)));
|
auto node = treeModel->nodeForIdType(type, value);
|
||||||
//}
|
if (!node)
|
||||||
//int selectedIndex = -1;
|
continue;
|
||||||
//if (items.size() == 1) {
|
items.append(*node);
|
||||||
// LazyTreeItem *item = items.at(0);
|
}
|
||||||
// if (highlightSelected.contains(item))
|
int selectedIndex = -1;
|
||||||
// selectedIndex = highlightSelected[item];
|
if (items.size() == 1) {
|
||||||
//}
|
LazyTreeItem *item = items.at(0);
|
||||||
|
if (highlightSelected.contains(item))
|
||||||
|
selectedIndex = highlightSelected[item];
|
||||||
|
}
|
||||||
|
|
||||||
//QMenu menu(this);
|
QMenu menu(this);
|
||||||
//QAction *selectAction = new QAction("&Select", this);
|
QAction *selectAction = new QAction("&Select", this);
|
||||||
//connect(selectAction, &QAction::triggered, this, [this, items] {
|
connect(selectAction, &QAction::triggered, this, [this, items] {
|
||||||
// std::vector<DecalXY> decals;
|
std::vector<DecalXY> decals;
|
||||||
// for (auto clickItem : items) {
|
for (auto clickItem : items) {
|
||||||
// std::vector<DecalXY> d = getDecals(clickItem->type(), clickItem->id());
|
std::vector<DecalXY> d = getDecals(clickItem->type(), clickItem->id());
|
||||||
// std::move(d.begin(), d.end(), std::back_inserter(decals));
|
std::move(d.begin(), d.end(), std::back_inserter(decals));
|
||||||
// }
|
}
|
||||||
// Q_EMIT selected(decals, false);
|
Q_EMIT selected(decals, false);
|
||||||
//});
|
});
|
||||||
//menu.addAction(selectAction);
|
menu.addAction(selectAction);
|
||||||
|
|
||||||
//QMenu *subMenu = menu.addMenu("Highlight");
|
QMenu *subMenu = menu.addMenu("Highlight");
|
||||||
//QActionGroup *group = new QActionGroup(this);
|
QActionGroup *group = new QActionGroup(this);
|
||||||
//group->setExclusive(true);
|
group->setExclusive(true);
|
||||||
//for (int i = 0; i < 8; i++) {
|
for (int i = 0; i < 8; i++) {
|
||||||
// QPixmap pixmap(32, 32);
|
QPixmap pixmap(32, 32);
|
||||||
// pixmap.fill(QColor(highlightColors[i]));
|
pixmap.fill(QColor(highlightColors[i]));
|
||||||
// QAction *action = new QAction(QIcon(pixmap), ("Group " + std::to_string(i)).c_str(), this);
|
QAction *action = new QAction(QIcon(pixmap), ("Group " + std::to_string(i)).c_str(), this);
|
||||||
// action->setCheckable(true);
|
action->setCheckable(true);
|
||||||
// subMenu->addAction(action);
|
subMenu->addAction(action);
|
||||||
// group->addAction(action);
|
group->addAction(action);
|
||||||
// if (selectedIndex == i)
|
if (selectedIndex == i)
|
||||||
// action->setChecked(true);
|
action->setChecked(true);
|
||||||
// connect(action, &QAction::triggered, this, [this, i, items] { updateHighlightGroup(items, i); });
|
connect(action, &QAction::triggered, this, [this, i, items] { updateHighlightGroup(items, i); });
|
||||||
//}
|
}
|
||||||
//menu.exec(tree->mapToGlobal(pos));
|
menu.exec(tree->mapToGlobal(pos));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DesignWidget::prepareMenuTree(const QPoint &pos)
|
void DesignWidget::prepareMenuTree(const QPoint &pos)
|
||||||
|
Loading…
Reference in New Issue
Block a user