完善函数
parent
39602e091d
commit
5b5465103a
|
@ -4,6 +4,7 @@ EditorWidget::EditorWidget(QWidget *parent) : QWidget(parent)
|
|||
{
|
||||
ui.setupUi(this);
|
||||
previewWindow = ui.Preview;
|
||||
qDebug() << "123";
|
||||
// test
|
||||
QFile settingFile;
|
||||
settingFile.setFileName("../data.json");
|
||||
|
|
|
@ -18,8 +18,9 @@ void FolderLayerWrapper::removeChild(LayerWrapper *child)
|
|||
}
|
||||
}
|
||||
|
||||
QPainterPath LayerWrapper::getCache() const
|
||||
QPainterPath LayerWrapper::getCache()
|
||||
{
|
||||
this->refresh();
|
||||
return cache;
|
||||
}
|
||||
// TODO: undone
|
||||
|
@ -49,11 +50,28 @@ FolderLayerWrapper::FolderLayerWrapper(QJsonObject json, ElementManager *element
|
|||
shared_ptr<LayerWrapper>(new LeafLayerWrapper(childJson.toObject(), elementManager, this)));
|
||||
}
|
||||
}
|
||||
#include <iostream>
|
||||
|
||||
LeafLayerWrapper::LeafLayerWrapper(QJsonObject json, ElementManager *elementManager, LayerWrapper *parent)
|
||||
: LayerWrapper(json, parent)
|
||||
{
|
||||
qDebug() << json.value("name").toString();
|
||||
int elementIndex = json.value("element").toInt();
|
||||
wrappedElement = elementManager->getElementById(elementIndex);
|
||||
}
|
||||
|
||||
void LayerWrapper::refresh()
|
||||
{
|
||||
}
|
||||
|
||||
void FolderLayerWrapper::refresh()
|
||||
{
|
||||
cache.clear();
|
||||
for (auto &child : children)
|
||||
cache += child.get()->getCache();
|
||||
}
|
||||
|
||||
void LeafLayerWrapper::refresh()
|
||||
{
|
||||
cache.clear();
|
||||
if (wrappedElement != nullptr)
|
||||
cache += wrappedElement->getPaintObject();
|
||||
}
|
||||
|
|
|
@ -26,7 +26,8 @@ class LayerWrapper
|
|||
QPainterPath cache;
|
||||
|
||||
public:
|
||||
QPainterPath getCache() const; // invoke by manager, then invoke parent's applyStyles
|
||||
virtual void refresh();
|
||||
QPainterPath getCache(); // invoke by manager, then invoke parent's applyStyles
|
||||
LayerWrapper(QJsonObject json, LayerWrapper *parent);
|
||||
LayerWrapper() = default;
|
||||
};
|
||||
|
@ -37,6 +38,7 @@ class FolderLayerWrapper : public LayerWrapper
|
|||
vector<shared_ptr<LayerWrapper>> children;
|
||||
|
||||
public:
|
||||
void refresh() override;
|
||||
FolderLayerWrapper() = default;
|
||||
FolderLayerWrapper(QJsonObject json, ElementManager *elementManager, LayerWrapper *parent);
|
||||
void addChild(LayerWrapper *child);
|
||||
|
@ -49,6 +51,7 @@ class LeafLayerWrapper : public LayerWrapper
|
|||
GraphicElement *wrappedElement;
|
||||
|
||||
public:
|
||||
void refresh() override;
|
||||
LeafLayerWrapper() = default;
|
||||
LeafLayerWrapper(QJsonObject json, ElementManager *elementManager, LayerWrapper *parent);
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue