[sword-devel] Understanding the structure of generic books and their relationship with TreeKey.
junk_and_mail at yahoo.com
Mon Nov 2 21:09:09 MST 2009
--- On Sun, 11/1/09, Greg Hellings <greg.hellings at gmail.com> wrote:
> From: Greg Hellings <greg.hellings at gmail.com>
> Subject: Re: [sword-devel] Understanding the structure of generic books and their relationship with TreeKey.
> To: "SWORD Developers' Collaboration Forum" <sword-devel at crosswire.org>
> Date: Sunday, November 1, 2009, 5:33 PM
> On Sun, Nov 1, 2009 at 4:01 PM, Rendezvous <junk_and_mail at yahoo.com>
> > Through browsing through some source code i've managed
> to figure out that you need to convert a SWKey
> (SWModule::getKey()) to a TreeKey to be able to iterate
> through the sections/chapters of a GenBook. However, i have
> yet to figure out how to obtain the children for each
> section/chapter. Rather than taking a guess with trial and
> error and searching through more Sword frontends' source
> code, i would prefer to have a _full_ understanding on how
> Sword handles GenBooks and how frontends can make use of
> those methods.
> > My questions: Is TreeKey the only way to obtain the
> sections/chapters of a Genbook? And how do i get a list of
> the children for each section/chapter? Am i right to assume
> that i have to use SWModule::setKey() to set the current key
> to one of the root sections and then re-cast
> SWModule::getKey() to a TreeKey and iterate through that? Or
> is another method required?
> You might want to look into the documentation on
> http://www.crosswire.org/~ghellings/1_6_0classdocs/ for
> version 1.6.0
> of the engine. Particularly look under
> TreeKey::firstChild() and
The code i was using already made use of those methods. However, i could go down no further than the root level. I am wondering how to obtain the children for the keys i've only been able to get. Here's is the current, relevant part of the code i am using:
sword::TreeKey *tk = dynamic_cast<sword::TreeKey*>(swModule->getKey());
node.name = tk->getText();
node.parent = NULL;
sectionsList << node;
Let's say i load the English GenBook, "Immitation." I only get the following:
though the last four have children. Trying to figure out how to obtain the children through trial and error have so far led me no where.
More information about the sword-devel