made build working again
This commit is contained in:
parent
9971c86d09
commit
5753ce0497
|
@ -2,6 +2,7 @@
|
||||||
#define EDITORELEMENT_H
|
#define EDITORELEMENT_H
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <QMap>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#include "abstractguidededitormodel.h"
|
#include "editormodel.h"
|
||||||
|
|
||||||
EditorModel::EditorModel(QObject *parent) : QObject(parent)
|
EditorModel::EditorModel(QObject *parent) : QObject(parent)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,47 +1,52 @@
|
||||||
#include "editortreenode.h"
|
#include "editortreenode.h"
|
||||||
|
|
||||||
EditorTreeNode::EditorTreeNode() {}
|
template <typename T>
|
||||||
|
EditorTreeNode<T>::EditorTreeNode() {}
|
||||||
|
|
||||||
EditorTreeNode::EditorTreeNode(T v)
|
template <typename T>
|
||||||
: value(v)
|
EditorTreeNode<T>::EditorTreeNode(T v)
|
||||||
|
: val(v)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
EditorTreeNode::~EditorTreeNode()
|
template <typename T>
|
||||||
|
EditorTreeNode<T>::~EditorTreeNode()
|
||||||
{
|
{
|
||||||
if (parent != nullptr) {
|
if (parentNode != nullptr) {
|
||||||
remove();
|
this->remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const EditorTreeNode<T>* EditorTreeNode::nextSibling()
|
template <typename T>
|
||||||
|
const EditorTreeNode<T>* EditorTreeNode<T>::nextSibling()
|
||||||
{
|
{
|
||||||
if (parent() != nullptr) {
|
if (parent() != nullptr) {
|
||||||
uint i = parent()->children().indexOf(this);
|
uint i = parent()->children().indexOf(this);
|
||||||
if (i + 1 < parent->children().size())
|
if (i + 1 < parentNode->children().size())
|
||||||
return parent->children().at(i + 1); //next sibling...
|
return parentNode->children().at(i + 1); //next sibling...
|
||||||
else
|
else
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
const EditorTreeNode<T>* EditorTreeNode::next(TreeWalkStrategy walkStrategy)
|
template <typename T>
|
||||||
|
const EditorTreeNode<T>* EditorTreeNode<T>::next(TreeWalkStrategy walkStrategy)
|
||||||
{
|
{
|
||||||
if (walkStrategy == TreeWalkStrategy::mixture)
|
if (walkStrategy == TreeWalkStrategy::mixture)
|
||||||
// choose node, work through all siblings, choose next node, but don't change branches more than one parent away, except branch is at an end.
|
// choose node, work through all siblings, choose next node, but don't change branches more than one parent away, except branch is at an end.
|
||||||
if (parent() != nullptr) {
|
if (parent() != nullptr) {
|
||||||
if (nextSibling() != null) // next sibling
|
if (nextSibling() != nullptr) // next sibling
|
||||||
return nextSibling();
|
return nextSibling();
|
||||||
else // find next children
|
else // find next children
|
||||||
{
|
{
|
||||||
for (auto n : parent->children())
|
for (auto n : parentNode->children())
|
||||||
if (n->children().size() > 0)
|
if (n->children().size() > 0)
|
||||||
return n->children().first();
|
return n->children().first();
|
||||||
auto siblingOfParent = parent->nextSibling();
|
auto siblingOfParent = parentNode->nextSibling();
|
||||||
while (siblingOfParent != nullptr && siblingOfParent->children().size() == 0) {
|
while (siblingOfParent != nullptr && siblingOfParent->children().size() == 0) {
|
||||||
if (siblingOfParent->nextSibling() == nullptr)
|
if (siblingOfParent->nextSibling() == nullptr)
|
||||||
siblingOfParent = siblingOfParent->parent();
|
siblingOfParent = siblingOfParent->parentNode();
|
||||||
else
|
else
|
||||||
siblingOfParent = siblingOfParent->nextSibling();
|
siblingOfParent = siblingOfParent->nextSibling();
|
||||||
}
|
}
|
||||||
|
@ -51,25 +56,25 @@ const EditorTreeNode<T>* EditorTreeNode::next(TreeWalkStrategy walkStrategy)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (children.size() > 0)
|
if (childrenNodes.size() > 0)
|
||||||
return children.first();
|
return childrenNodes.first();
|
||||||
else
|
else
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
else if (walkStrategy == TreeWalkStrategy::depthFirst)
|
else if (walkStrategy == TreeWalkStrategy::depthFirst)
|
||||||
if (children().size() > 0)
|
if (children().size() > 0)
|
||||||
return children.first();
|
return childrenNodes.first();
|
||||||
else {
|
else {
|
||||||
auto node = this;
|
auto node = this;
|
||||||
while (node->nextSibling() == nullptr && node->parent() != nullptr)
|
while (node->nextSibling() == nullptr && node->parentNode() != nullptr)
|
||||||
node = node->parent();
|
node = node->parentNode();
|
||||||
return node->nextSibling();
|
return node->nextSibling();
|
||||||
}
|
}
|
||||||
else if (walkStrategy == TreeWalkStrategy::breadthFirst)
|
else if (walkStrategy == TreeWalkStrategy::breadthFirst)
|
||||||
if (parent != nullptr) {
|
if (parentNode != nullptr) {
|
||||||
auto nextOnLvl = nextOnSameLevel();
|
auto nextOnLvl = nextOnSameLevel();
|
||||||
if (nextOnLvl == nullptr){
|
if (nextOnLvl == nullptr){
|
||||||
for (auto n : this->children)
|
for (auto n : this->childrenNodes)
|
||||||
if (n->children().size() > 0)
|
if (n->children().size() > 0)
|
||||||
return n->children().first();
|
return n->children().first();
|
||||||
}
|
}
|
||||||
|
@ -78,7 +83,8 @@ const EditorTreeNode<T>* EditorTreeNode::next(TreeWalkStrategy walkStrategy)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
const EditorTreeNode<T>* EditorTreeNode::getRoot()
|
template <typename T>
|
||||||
|
const EditorTreeNode<T>* EditorTreeNode<T>::getRoot()
|
||||||
{
|
{
|
||||||
auto node = this;
|
auto node = this;
|
||||||
while (node->parent() != nullptr)
|
while (node->parent() != nullptr)
|
||||||
|
@ -86,51 +92,59 @@ const EditorTreeNode<T>* EditorTreeNode::getRoot()
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorTreeNode::move(EditorTreeNode<T>* to)
|
template <typename T>
|
||||||
|
void EditorTreeNode<T>::move(EditorTreeNode<T>* to)
|
||||||
{
|
{
|
||||||
this->parent()->children().removeOne(this);
|
this->parent()->children().removeOne(this);
|
||||||
to->children().append(this);
|
to->children().append(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorTreeNode::moveChildren(EditorTreeNode<T>* to)
|
template <typename T>
|
||||||
|
void EditorTreeNode<T>::moveChildren(EditorTreeNode<T>* to)
|
||||||
{
|
{
|
||||||
for (auto child : children)
|
for (auto child : childrenNodes)
|
||||||
child->move(to);
|
child->move(to);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorTreeNode::addChild(EditorTreeNode<T>* child)
|
template <typename T>
|
||||||
|
void EditorTreeNode<T>::addChild(EditorTreeNode<T>* child)
|
||||||
{
|
{
|
||||||
this->children().append(child);
|
this->children().append(child);
|
||||||
child->setParen(this);
|
child->setParen(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EditorTreeNode::removeChild(EditorTreeNode<T>* child)
|
template <typename T>
|
||||||
|
bool EditorTreeNode<T>::removeChild(EditorTreeNode<T>* child)
|
||||||
{
|
{
|
||||||
this->children().removeOne(child);
|
return this->children().removeOne(child);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EditorTreeNode::remove()
|
template <typename T>
|
||||||
|
bool EditorTreeNode<T>::remove()
|
||||||
{
|
{
|
||||||
if (parent != nullptr) {
|
bool worked = true;
|
||||||
parent->children().removeOne(this);
|
if (parentNode != nullptr) {
|
||||||
|
worked &= parentNode->children().removeOne(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (children.size() > 0) {
|
if (childrenNodes.size() > 0) {
|
||||||
for (auto node : children) {
|
for (auto node : childrenNodes) {
|
||||||
node->remove();
|
worked &= node->remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return worked;
|
||||||
}
|
}
|
||||||
|
|
||||||
EditorTreeNode<T>* EditorTreeNode::nextOnSameLevel()
|
template <typename T>
|
||||||
|
EditorTreeNode<T>* EditorTreeNode<T>::nextOnSameLevel()
|
||||||
{
|
{
|
||||||
if (nextSibling() != nullptr)
|
if (nextSibling() != nullptr)
|
||||||
return nextSibling();
|
return nextSibling();
|
||||||
uint lvl = 1;
|
uint lvl = 1;
|
||||||
auto node = this->parent();
|
auto node = this->parentNode();
|
||||||
auto pnode = this;
|
auto pnode = this;
|
||||||
while (lvl > 0 && node != nullptr) {
|
while (lvl > 0 && node != nullptr) {
|
||||||
if (node != pnode->parent() && node->children() > 0) {
|
if (node != pnode->parentNode() && node->children() > 0) {
|
||||||
node = node->children().first();
|
node = node->children().first();
|
||||||
--lvl;
|
--lvl;
|
||||||
} else {
|
} else {
|
||||||
|
@ -138,8 +152,8 @@ EditorTreeNode<T>* EditorTreeNode::nextOnSameLevel()
|
||||||
if (node->nextSibling() != nullptr)
|
if (node->nextSibling() != nullptr)
|
||||||
node = node->nextSibling();
|
node = node->nextSibling();
|
||||||
else {
|
else {
|
||||||
if (node->parent() != nullptr) {
|
if (node->parentNode() != nullptr) {
|
||||||
node = node->parent();
|
node = node->parentNode();
|
||||||
++lvl;
|
++lvl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,10 +9,10 @@ enum class TreeWalkStrategy {
|
||||||
mixture
|
mixture
|
||||||
};
|
};
|
||||||
|
|
||||||
template <T>
|
template <typename T>
|
||||||
class EditorTreeNode;
|
class EditorTreeNode;
|
||||||
|
|
||||||
template <T>
|
template <typename T>
|
||||||
class EditorTreeNode {
|
class EditorTreeNode {
|
||||||
public:
|
public:
|
||||||
explicit EditorTreeNode();
|
explicit EditorTreeNode();
|
||||||
|
@ -20,29 +20,30 @@ public:
|
||||||
~EditorTreeNode();
|
~EditorTreeNode();
|
||||||
|
|
||||||
const EditorTreeNode<T>* nextSibling();
|
const EditorTreeNode<T>* nextSibling();
|
||||||
const EditorTreeNode<T>* parent() { return parent; }
|
const EditorTreeNode<T>* parent() { return parentNode; }
|
||||||
QList<EditorTreeNode<T>*>& children() { return children; }
|
QList<EditorTreeNode<T>*>& children() { return childrenNodes; }
|
||||||
void setParen(EditorTreeNode<T>* parent) { this->parent = parent; }
|
void setParen(EditorTreeNode<T>* parent) { this->parentNode = parent; }
|
||||||
|
|
||||||
T value() { return value; }
|
T& value() { return val; }
|
||||||
|
|
||||||
const EditorTreeNode<T>* next(TreeWalkStrategy depth_first = TreeWalkStrategy::depthFirst);
|
const EditorTreeNode<T>* next(TreeWalkStrategy depth_first = TreeWalkStrategy::depthFirst);
|
||||||
const EditorTreeNode<T>* getRoot();
|
const EditorTreeNode<T>* getRoot();
|
||||||
void move(EditorTreeNode<T>* to); // as child!
|
void move(EditorTreeNode<T>* to); // as child!
|
||||||
void moveChildren(EditorTreeNode<T>* to); // move all children
|
void moveChildren(EditorTreeNode<T>* to); // move all children
|
||||||
signals:
|
|
||||||
|
//signals:
|
||||||
void nodeDataChanged(EditorTreeNode<T>* node);
|
void nodeDataChanged(EditorTreeNode<T>* node);
|
||||||
void treeChanged(EditorTreeNode<T>* node);
|
void treeChanged(EditorTreeNode<T>* node);
|
||||||
|
|
||||||
public slots:
|
//public slots:
|
||||||
void addChild(EditorTreeNode<T>* child);
|
void addChild(EditorTreeNode<T>* child);
|
||||||
bool removeChild(EditorTreeNode<T>* child);
|
bool removeChild(EditorTreeNode<T>* child);
|
||||||
bool remove();
|
bool remove();
|
||||||
|
//*/
|
||||||
private:
|
private:
|
||||||
T value;
|
T val;
|
||||||
EditorTreeNode<T>* parent = nullptr;
|
EditorTreeNode<T>* parentNode = nullptr;
|
||||||
QList<EditorTreeNode<T>*> children;
|
QList<EditorTreeNode<T>*> childrenNodes;
|
||||||
EditorTreeNode<T>* nextOnSameLevel();
|
EditorTreeNode<T>* nextOnSameLevel();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ GuidedEditorElementView::GuidedEditorElementView(QWidget* parent)
|
||||||
|
|
||||||
void GuidedEditorElementView::render()
|
void GuidedEditorElementView::render()
|
||||||
{
|
{
|
||||||
for (QWidget* w : this->propertyViews->values())
|
for (QWidget* w : this->propertyViews.values())
|
||||||
this->layout->removeWidget(w);
|
this->layout->removeWidget(w);
|
||||||
for (QString prop : this->propertyOrder) {
|
for (QString prop : this->propertyOrder) {
|
||||||
this->layout->addWidget(this->propertyViews[prop]);
|
this->layout->addWidget(this->propertyViews[prop]);
|
||||||
|
|
Reference in New Issue