~ubuntu-branches/ubuntu/trusty/bibletime/trusty

« back to all changes in this revision

Viewing changes to src/backend/drivers/cswordbookmoduleinfo.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Marsden
  • Date: 2009-11-18 17:30:00 UTC
  • mfrom: (1.3.4 upstream) (5.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20091118173000-endkhjz5qai88tvr
Tags: 2.4-1
* New upstream version 2.4
* debian/control: 
  - Replace incorrect bibletime-data Depends on lib4qt-gui
    with bibletime Depends on libqtgui4 (>= 4.4.0). (Closes: #556209).
  - Add Build-depends: on zlib1g-dev and libcurl4-gnutls-dev 
    (Closes: #556805).

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
*
8
8
**********/
9
9
 
10
 
//BibleTime includes
11
 
#include "cswordbookmoduleinfo.h"
 
10
#include "backend/drivers/cswordbookmoduleinfo.h"
 
11
 
12
12
#include "backend/keys/cswordtreekey.h"
13
13
 
14
 
//Sword includes
 
14
// Sword includes:
 
15
#include <treekey.h>
15
16
#include <treekeyidx.h>
16
 
#include <treekey.h>
 
17
 
17
18
 
18
19
CSwordBookModuleInfo::CSwordBookModuleInfo( sword::SWModule* module, CSwordBackend* const usedBackend )
19
 
: CSwordModuleInfo(module, usedBackend),
20
 
m_depth(-1) {}
 
20
        : CSwordModuleInfo(module, usedBackend),
 
21
        m_depth(-1) {}
21
22
 
22
23
CSwordBookModuleInfo::CSwordBookModuleInfo( const CSwordBookModuleInfo& module )
23
 
: CSwordModuleInfo(module) {
24
 
        m_depth = module.m_depth;
 
24
        : CSwordModuleInfo(module) {
 
25
    m_depth = module.m_depth;
25
26
}
26
27
 
27
28
CSwordBookModuleInfo::~CSwordBookModuleInfo() {}
28
29
 
29
30
int CSwordBookModuleInfo::depth() {
30
 
        if (m_depth == -1) {
31
 
                sword::TreeKeyIdx* key = tree();
32
 
 
33
 
                if (key) {
34
 
                        key->root();
35
 
                        computeDepth(key, 0);
36
 
                }
37
 
        }
38
 
 
39
 
        return m_depth;
 
31
    if (m_depth == -1) {
 
32
        sword::TreeKeyIdx* key = tree();
 
33
 
 
34
        if (key) {
 
35
            key->root();
 
36
            computeDepth(key, 0);
 
37
        }
 
38
    }
 
39
 
 
40
    return m_depth;
40
41
}
41
42
 
42
43
void CSwordBookModuleInfo::computeDepth(sword::TreeKeyIdx* key, int level ) {
43
 
        std::string savedKey;
44
 
        //      savedKey = key->getFullName(); //sword 1.5.8
45
 
        savedKey = key->getText();
46
 
 
47
 
        if (level > m_depth) {
48
 
                m_depth = level;
49
 
        }
50
 
 
51
 
        if (key->hasChildren()) {
52
 
                key->firstChild();
53
 
                computeDepth(key, level+1);
54
 
 
55
 
                key->setText( savedKey.c_str() );//return to the initial value
56
 
        }
57
 
 
58
 
        if (key->nextSibling()) {
59
 
                computeDepth(key, level);
60
 
        }
 
44
    std::string savedKey;
 
45
    //  savedKey = key->getFullName(); //sword 1.5.8
 
46
    savedKey = key->getText();
 
47
 
 
48
    if (level > m_depth) {
 
49
        m_depth = level;
 
50
    }
 
51
 
 
52
    if (key->hasChildren()) {
 
53
        key->firstChild();
 
54
        computeDepth(key, level + 1);
 
55
 
 
56
        key->setText( savedKey.c_str() );//return to the initial value
 
57
    }
 
58
 
 
59
    if (key->nextSibling()) {
 
60
        computeDepth(key, level);
 
61
    }
61
62
}
62
63
 
63
64
/** Returns a treekey filled with the structure of this module */
64
65
sword::TreeKeyIdx* CSwordBookModuleInfo::tree() const {
65
 
        sword::TreeKeyIdx* treeKey = dynamic_cast<sword::TreeKeyIdx*>((sword::SWKey*)*(module()));
66
 
        Q_ASSERT(treeKey);
67
 
        return treeKey;
 
66
    sword::TreeKeyIdx* treeKey = dynamic_cast<sword::TreeKeyIdx*>((sword::SWKey*) * (module()));
 
67
    Q_ASSERT(treeKey);
 
68
    return treeKey;
68
69
}