From a5e77bdac14a79d6c8a09a6db8f1a2307b1537f3 Mon Sep 17 00:00:00 2001 From: Sebastian Geerken Date: Fri, 16 Aug 2013 18:17:47 +0200 Subject: Fixed a bug in DeepIterator (level calculation should regard generators). --- dw/widget.cc | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'dw/widget.cc') diff --git a/dw/widget.cc b/dw/widget.cc index 42566a17..f5bca367 100644 --- a/dw/widget.cc +++ b/dw/widget.cc @@ -477,6 +477,25 @@ int Widget::getLevel () return level; } +/** + * \brief Get the level of the widget within the tree, regarting the + * generators, not the parents. + * + * The root widget has the level 0. + */ +int Widget::getGeneratorLevel () +{ + Widget *widget = this; + int level = 0; + + while (widget->getGenerator ()) { + level++; + widget = widget->getGenerator (); + } + + return level; +} + /** * \brief Get the widget with the highest level, which is a direct ancestor of * widget1 and widget2. -- cgit v1.2.3