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