Compare commits

..

No commits in common. "ca8d68fe9307056f2444da8be1db286817a69caf" and "6508f54333497ef665dfc4262017f9cd4248552e" have entirely different histories.

3 changed files with 14 additions and 15 deletions

View File

@ -33,7 +33,6 @@ PixelPath LayerWrapper::getCache()
LayerWrapper::LayerWrapper(QJsonObject json, FolderLayerWrapper*parent) LayerWrapper::LayerWrapper(QJsonObject json, FolderLayerWrapper*parent)
{ {
this->parent = parent; this->parent = parent;
this->qTreeWidgetItem = new QTreeWidgetItem();
auto transformJson = json.value("transform").toObject(); auto transformJson = json.value("transform").toObject();
property.name = json.value("name").toString(); property.name = json.value("name").toString();
property.offset = {transformJson.value("offset").toObject().value("x").toDouble(), property.offset = {transformJson.value("offset").toObject().value("x").toDouble(),
@ -120,22 +119,22 @@ void LayerWrapper::setParent(FolderLayerWrapper* newParent)
void FolderLayerWrapper::removeAllChild() void FolderLayerWrapper::removeAllChild()
{ {
children.clear(); children.clear();
qTreeWidgetItem->takeChildren(); qTreeWidgetItem.takeChildren();
} }
void LayerWrapper::del() { void LayerWrapper::del() {
qDebug() << "LayerWrapper::del()"; qDebug() << "LayerWrapper::del()";
if (parent != nullptr){ if (parent != nullptr){
qTreeWidgetItem->takeChildren(); qTreeWidgetItem.takeChildren();
parent->qTreeWidgetItem->removeChild(qTreeWidgetItem); parent->qTreeWidgetItem.removeChild(&qTreeWidgetItem);
} }
} }
void LayerWrapper::delSelf() { void LayerWrapper::delSelf() {
qDebug() << "LayerWrapper::delSelf()"; qDebug() << "LayerWrapper::delSelf()";
if (parent != nullptr) { if (parent != nullptr) {
qTreeWidgetItem->takeChildren(); qTreeWidgetItem.takeChildren();
parent->qTreeWidgetItem->removeChild(qTreeWidgetItem); parent->qTreeWidgetItem.removeChild(&qTreeWidgetItem);
} }
} }
@ -155,7 +154,7 @@ void FolderLayerWrapper::delSelf() {
qDebug() << this; qDebug() << this;
for (auto& child : this->children) { for (auto& child : this->children) {
this->parent->addChild(child); this->parent->addChild(child);
this->parent->qTreeWidgetItem->addChild(child.get()->qTreeWidgetItem); this->parent->qTreeWidgetItem.addChild(&child.get()->qTreeWidgetItem);
child->setParent(this->parent); child->setParent(this->parent);
} }
while (!this->children.empty()) { while (!this->children.empty()) {
@ -167,18 +166,18 @@ void FolderLayerWrapper::delSelf() {
QTreeWidgetItem* LayerWrapper::getQTreeItem() QTreeWidgetItem* LayerWrapper::getQTreeItem()
{ {
this->qTreeWidgetItem->setText(0, this->property.name); this->qTreeWidgetItem.setText(0, this->property.name);
this->qTreeWidgetItem->setData(0, Qt::UserRole, QVariant::fromValue(this)); this->qTreeWidgetItem.setData(0, Qt::UserRole, QVariant::fromValue(this));
return this->qTreeWidgetItem; return &this->qTreeWidgetItem;
} }
QTreeWidgetItem* FolderLayerWrapper::getQTreeItem() QTreeWidgetItem* FolderLayerWrapper::getQTreeItem()
{ {
while (this->qTreeWidgetItem->childCount() > 0) { while (this->qTreeWidgetItem.childCount() > 0) {
this->qTreeWidgetItem->removeChild(this->qTreeWidgetItem->child(0)); this->qTreeWidgetItem.removeChild(this->qTreeWidgetItem.child(0));
} }
for (auto& child : this->children) { for (auto& child : this->children) {
this->qTreeWidgetItem->addChild(child->getQTreeItem()); this->qTreeWidgetItem.addChild(child->getQTreeItem());
} }
return LayerWrapper::getQTreeItem(); return LayerWrapper::getQTreeItem();
} }

View File

@ -33,7 +33,7 @@ class LayerWrapper
PixelPath cache; PixelPath cache;
public: public:
QTreeWidgetItem* qTreeWidgetItem; QTreeWidgetItem qTreeWidgetItem;
struct SimpleProperty struct SimpleProperty
{ {
QString name = ""; QString name = "";

View File

@ -51,7 +51,7 @@ void LayerTreeWidget::popMenu(const QPoint &pos)
else else
newLayer = new LeafLayerWrapper(jsonObj, this->elementManager, folderLayer); newLayer = new LeafLayerWrapper(jsonObj, this->elementManager, folderLayer);
folderLayer->addChild(std::shared_ptr<LayerWrapper>(newLayer)); folderLayer->addChild(std::shared_ptr<LayerWrapper>(newLayer));
folderLayer->qTreeWidgetItem->addChild(newLayer->getQTreeItem()); folderLayer->qTreeWidgetItem.addChild(newLayer->getQTreeItem());
qDebug() << jsonObj<<"----------------------"; qDebug() << jsonObj<<"----------------------";
this->refresh(); this->refresh();
emit requireRefreshPreview(); emit requireRefreshPreview();