26 #include <boost/regex.hpp>
33 this->basename = basename;
34 this->nodeType = nodeType;
35 this->parentNode = parentNode;
36 this->parentGroup = parentGroup;
37 this->stateIsPublic = stateIsPublic;
38 this->cppExists =
false;
49 children.append(
child);
52 int StateTreeNode::NodeTypeToSortIndex(NodeType nodeType)
72 int aTypeIndex = NodeTypeToSortIndex(
a->nodeType);
73 int bTypeIndex = NodeTypeToSortIndex(b->nodeType);
75 if (aTypeIndex != bTypeIndex)
77 return aTypeIndex < bTypeIndex;
80 return a->display.toLower().localeAwareCompare(b->display.toLower()) < 0;
85 qStableSort(children.begin(), children.end(), CompareChildren);
90 children.removeOne(
child);
95 return children.value(
row);
100 return children.count();
123 for (
int i = 0; i < parent->children.count(); i++)
125 if (parent->children.at(i).get() ==
this)
139 return parentNode.lock();
144 return parentGroup.lock();
165 return std::filesystem::path();
175 return std::filesystem::path();
178 std::string
filename = std::string(state->getStateName().toUtf8().data()) +
".cpp";
180 return (path.remove_filename() /
filename);
187 return std::filesystem::path();
190 std::string
filename = std::string(state->getStateName().toUtf8().data()) +
".h";
192 return (path.remove_filename() /
filename);
199 return std::filesystem::path();
202 std::string
filename = std::string(state->getStateName().toUtf8().data()) +
".generated.h";
204 return (path.remove_filename() /
filename);
230 return parentPath / basename.toUtf8().data();
235 std::filesystem::path result = basename.toUtf8().data();
238 while (p && !p->isGroup())
240 result = std::filesystem::path(p->getBasename().toUtf8().data()) / result;
254 return nodeType ==
State;
264 return nodeType ==
Group;
269 return nodeType ==
Folder;
278 node = node->getParent();
287 if (state && state->getStateName() == name)
289 return shared_from_this();
292 for (
int i = 0; i < children.count(); i++)
307 QVector<StateTreeNodePtr> result;
311 result.push_back(node);
313 for (
const auto& n : node->getAllSubNodesRecursively())
324 QVector<statechartmodel::StatePtr> result;
328 result.push_back(state);
329 GetAllSubstatesRecursively(state, result, localOnly);
333 for (
const auto&
child : children)
335 for (
const auto& state :
child->getAllStatesRecursively(localOnly))
337 result.push_back(state);
345 void StateTreeNode::GetAllSubstatesRecursively(
const statechartmodel::StatePtr& state, QVector<statechartmodel::StatePtr>& result,
bool localOnly)
const
347 for (
const auto& substate : state->getSubstates())
349 const auto& stateClass = substate->getStateClass();
351 if (stateClass && (!localOnly || substate->getType() != eRemoteState))
353 result.push_back(stateClass);
354 GetAllSubstatesRecursively(stateClass, result, localOnly);
363 return parentNode.lock()->getNestingLevelRelativeToGroup() + 1;
371 std::string
str = name.toUtf8().data();
372 boost::regex nameRegex(
"[a-zA-Z][a-zA-Z0-9]*");
374 return boost::regex_match(
str, what, nameRegex);
386 return stateIsPublic;