Add some const

Change-Id: I81173280ad3e76ef62e4aefaf6914c54cfa1eac3
Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
Tobias Hunger
2012-01-12 14:47:44 +01:00
committed by hjk
parent 9128fc2ab0
commit 80a6230144

View File

@@ -62,29 +62,29 @@ public:
qDeleteAll(children); qDeleteAll(children);
} }
BranchNode *rootNode() BranchNode *rootNode() const
{ {
return parent ? parent->rootNode() : this; return parent ? parent->rootNode() : const_cast<BranchNode *>(this);
} }
int count() int count() const
{ {
return children.count(); return children.count();
} }
bool isLeaf() bool isLeaf() const
{ {
return children.isEmpty(); return children.isEmpty();
} }
bool childOf(BranchNode *node) bool childOf(BranchNode *node) const
{ {
if (this == node) if (this == node)
return true; return true;
return parent ? parent->childOf(node) : false; return parent ? parent->childOf(node) : false;
} }
bool isLocal() bool isLocal() const
{ {
BranchNode *rn = rootNode(); BranchNode *rn = rootNode();
if (rn->isLeaf()) if (rn->isLeaf())
@@ -92,7 +92,7 @@ public:
return childOf(rn->children.at(0)); return childOf(rn->children.at(0));
} }
BranchNode *childOfName(const QString &name) BranchNode *childOfName(const QString &name) const
{ {
for (int i = 0; i < children.count(); ++i) { for (int i = 0; i < children.count(); ++i) {
if (children.at(i)->name == name) if (children.at(i)->name == name)
@@ -101,13 +101,13 @@ public:
return 0; return 0;
} }
QStringList fullName() QStringList fullName() const
{ {
Q_ASSERT(isLeaf()); Q_ASSERT(isLeaf());
QStringList fn; QStringList fn;
QList<BranchNode *> nodes; QList<const BranchNode *> nodes;
BranchNode *current = this; const BranchNode *current = this;
while (current->parent) { while (current->parent) {
nodes.prepend(current); nodes.prepend(current);
current = current->parent; current = current->parent;
@@ -116,7 +116,7 @@ public:
if (current->children.at(0) == nodes.at(0)) if (current->children.at(0) == nodes.at(0))
nodes.removeFirst(); // remove local branch designation nodes.removeFirst(); // remove local branch designation
foreach (BranchNode *n, nodes) foreach (const BranchNode *n, nodes)
fn.append(n->name); fn.append(n->name);
return fn; return fn;
@@ -142,7 +142,7 @@ public:
return n; return n;
} }
QStringList childrenNames() QStringList childrenNames() const
{ {
if (children.count() > 0) { if (children.count() > 0) {
QStringList names; QStringList names;