重置了LayerTree的右键菜单
parent
08e54cfc30
commit
ef990cd4b4
|
@ -35,32 +35,31 @@ void LayerTreeWidget::popMenu(const QPoint &pos)
|
|||
QMenu menu;
|
||||
QTreeWidgetItem *item = itemAt(pos);
|
||||
this->selectedItem = item;
|
||||
// TODO
|
||||
if (item != nullptr) {
|
||||
auto layer = this->selectedItem->data(0, Qt::UserRole).value<LayerWrapper*>();
|
||||
if (layer != nullptr) {
|
||||
if (typeid(*layer) == typeid(FolderLayerWrapper)) {
|
||||
menu.addAction(QString::fromLocal8Bit("创建子节点"), this, &LayerTreeWidget::onRenameEvent);
|
||||
//if (item != root->getQTreeItem())
|
||||
//{
|
||||
menu.addAction(QString::fromLocal8Bit("ÖØÃüÃû"), this, &LayerTreeWidget::onRenameEvent);
|
||||
// menu.addAction("Copy", this, &LayerTreeWidget::onRenameEvent);
|
||||
if (item != nullptr && item->childCount() > 0)
|
||||
menu.addAction(QString::fromLocal8Bit("删除(保留子节点)"), this, [this]() {
|
||||
if (this->selectedItem == nullptr)
|
||||
return;
|
||||
auto layer = this->selectedItem->data(0, Qt::UserRole).value<LayerWrapper*>();
|
||||
layer->delSelf();
|
||||
layer->getParent()->removeChild(layer);
|
||||
this->refresh();
|
||||
emit requireRefreshPreview();
|
||||
});
|
||||
}
|
||||
if (layer != root) {
|
||||
menu.addAction(QString::fromLocal8Bit("删除"), this, [this]() {
|
||||
if (this->selectedItem == nullptr)
|
||||
return;
|
||||
auto layer = this->selectedItem->data(0, Qt::UserRole).value<LayerWrapper*>();
|
||||
layer->del();
|
||||
layer->getParent()->removeChild(layer);
|
||||
this->refresh();
|
||||
emit requireRefreshPreview();
|
||||
});
|
||||
//}
|
||||
menu.addAction(QString::fromLocal8Bit("ÖØÃüÃû"), this, &LayerTreeWidget::onRenameEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
menu.exec(mapToGlobal(pos));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue