Skip to content

Commit

Permalink
Add a new method to MythGenericTree to calculate the present depth in…
Browse files Browse the repository at this point in the history
… the tree for a given node.
  • Loading branch information
stuartm committed Jan 25, 2011
1 parent 46d0061 commit 31b500f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 29 deletions.
2 changes: 1 addition & 1 deletion mythtv/libs/libmythdb/mythversion.h
Expand Up @@ -11,7 +11,7 @@
/// Update this whenever the plug-in API changes.
/// Including changes in the libmythdb, libmyth, libmythtv, libmythav* and
/// libmythui class methods used by plug-ins.
#define MYTH_BINARY_VERSION "0.25.20110125-1"
#define MYTH_BINARY_VERSION "0.25.20110125-2"

/** \brief Increment this whenever the MythTV network protocol changes.
*
Expand Down
36 changes: 10 additions & 26 deletions mythtv/libs/libmythui/mythgenerictree.cpp
Expand Up @@ -186,32 +186,6 @@ void MythGenericTree::deleteNode(MythGenericTree *child)
child = NULL;
}

int MythGenericTree::calculateDepth(int start)
{
int current_depth;
current_depth = start + 1;

QList<MythGenericTree*> *children = getAllChildren();
if (children && children->count() > 0)
{
int found_depth;
SortableMythGenericTreeList::Iterator it;
MythGenericTree *child = NULL;

for (it = children->begin(); it != children->end(); ++it)
{
child = *it;
if (!child)
continue;
found_depth = child->calculateDepth(start + 1);
if (found_depth > current_depth)
current_depth = found_depth;
}
}

return current_depth;
}

MythGenericTree* MythGenericTree::findLeaf()
{
if (m_subnodes->count() > 0)
Expand Down Expand Up @@ -341,6 +315,16 @@ int MythGenericTree::siblingCount(void) const
return 1;
}

/**
* \brief Establish how deep in the current tree this node lies
*/
int MythGenericTree::currentDepth(void)
{
QList<MythGenericTree *> route = getRoute();

return (route.size() - 1);
}

QList<MythGenericTree*> *MythGenericTree::getAllChildren() const
{
if (m_currentOrderingIndex == -1)
Expand Down
4 changes: 2 additions & 2 deletions mythtv/libs/libmythui/mythgenerictree.h
Expand Up @@ -81,12 +81,12 @@ class MPUBLIC MythGenericTree
void SetData(QVariant data) { m_data = data; }
const QVariant GetData(void) const { return m_data; }

int calculateDepth(int start=0);

int childCount(void) const;
uint visibleChildCount() const { return m_visibleCount; }
int siblingCount(void) const;

int currentDepth(void);

void setSelectable(bool flag) { m_selectable = flag; }
bool isSelectable() const { return m_selectable; }

Expand Down

0 comments on commit 31b500f

Please sign in to comment.