Commit 44771d24 authored by hjk's avatar hjk

Utils: Remove now unused type-unsafe TreeItem child iteration

Change-Id: I128b2230e58c5a84ff9c018978ff31fc02171771
Reviewed-by: Christian Stenger's avatarChristian Stenger <christian.stenger@qt.io>
parent 6cd4d682
......@@ -778,25 +778,6 @@ QModelIndex TreeItem::index() const
return m_model->indexForItem(this);
}
void TreeItem::walkTree(TreeItemVisitor *visitor)
{
if (visitor->preVisit(this)) {
++visitor->m_level;
visitor->visit(this);
foreach (TreeItem *item, m_children)
item->walkTree(visitor);
--visitor->m_level;
}
visitor->postVisit(this);
}
void TreeItem::walkTree(std::function<void (TreeItem *)> f)
{
f(this);
foreach (TreeItem *item, m_children)
item->walkTree(f);
}
void TreeItem::clear()
{
while (m_children.size()) {
......
......@@ -33,26 +33,8 @@
namespace Utils {
class TreeItem;
class TreeModel;
class QTCREATOR_UTILS_EXPORT TreeItemVisitor
{
public:
TreeItemVisitor() : m_level(0) {}
virtual ~TreeItemVisitor() {}
virtual bool preVisit(TreeItem *) { return true; }
virtual void visit(TreeItem *) {}
virtual void postVisit(TreeItem *) {}
int level() const { return m_level; }
private:
friend class TreeItem;
int m_level;
};
class QTCREATOR_UTILS_EXPORT TreeItem
{
public:
......@@ -92,8 +74,6 @@ public:
TreeModel *model() const { return m_model; }
void walkTree(TreeItemVisitor *visitor);
void walkTree(std::function<void(TreeItem *)> f);
template <class T, class Predicate>
void forSelectedChildren(const Predicate &pred) const {
foreach (TreeItem *item, m_children) {
......@@ -141,33 +121,6 @@ public:
return 0;
}
// FIXME: Remove. Should only be present in LevelModels
template <class T, typename Predicate>
T findChildAtLevel(int n, Predicate func) const {
if (n == 1) {
foreach (TreeItem *item, m_children)
if (func(static_cast<T>(item)))
return static_cast<T>(item);
} else {
foreach (TreeItem *item, m_children)
if (T found = item->findChildAtLevel<T>(n - 1, func))
return found;
}
return 0;
}
// Levels are 1-based: Child at Level 1 is an immediate child.
// FIXME: Remove. Should only be present in LevelModels
template <class T, typename Function>
void forEachChildAtLevel(int n, Function func) {
foreach (TreeItem *item, m_children) {
if (n == 1)
func(static_cast<T>(item));
else
item->forEachChildAtLevel<T>(n - 1, func);
}
}
template <class T, typename Predicate>
T findAnyChild(Predicate pred) const {
foreach (TreeItem *item, m_children) {
......@@ -256,18 +209,6 @@ public:
TreeItem *takeItem(TreeItem *item); // item is not destroyed.
// FIXME: Remove. Should only be uses in LeveledTreeModel
template <class T, typename Predicate>
T findItemAtLevel(int n, Predicate func) const {
return m_root->findChildAtLevel<T>(n, func);
}
// FIXME: Remove. Should only be uses in LeveledTreeModel
template <class T, typename Function>
void forEachItemAtLevel(int n, Function func) const {
m_root->forEachChildAtLevel<T>(n, func);
}
signals:
void requestExpansion(QModelIndex);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment