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