summaryrefslogtreecommitdiff
path: root/src/backend/drivers/cswordbiblemoduleinfo.h
blob: 27805589522abfac1deeee16797e9351215e8f9f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/*********
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
* Copyright 1999-2008 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/

#ifndef CSWORDBIBLEMODULEINFO_H
#define CSWORDBIBLEMODULEINFO_H

#include "backend/drivers/cswordmoduleinfo.h"

#include <QStringList>
#include "backend/keys/cswordversekey.h"


/**
 * This is the CModuleInfo imlementation for Bible modules managed by Sword.
 *
 * @short Implementation for Sword Bibles
  * @author The BibleTime team
  * @version $Id: cswordbiblemoduleinfo.h,v 1.18 2006/02/25 11:38:15 joachim Exp $
  */

class CSwordBibleModuleInfo : public CSwordModuleInfo {

    public:
        enum Testament {
            OldTestament = 1,
            NewTestament = 2
        };

        /**
        * The constructor of this class
        */
        CSwordBibleModuleInfo( sword::SWModule* module, CSwordBackend* const );
        /** The copy constructor for this Bible module.
        */
        CSwordBibleModuleInfo( const CSwordBibleModuleInfo& m );
        /**
        * The destructor of this class
        */
        ~CSwordBibleModuleInfo();
        /**
        * Returns the number of avalable verses for the given chapter and book.
        *
        * @param book The number book we should use
        * @param chapter The chapter we should use
        * @return The number of verses for the given book and chapter
        */
        virtual unsigned int verseCount( const unsigned int book, const unsigned int chapter );
        /**
        * Returns the number of avalable verses for the given chapter and book.
        *
        * @param book The name of the book we use
        * @param chapter The number of the chapter we use
        * @return The number of verses for the given book and chapter
        */
        virtual unsigned int verseCount( const QString& book, const unsigned int chapter );
        /** Information about the chapters in a book.
        * @return The number of available chapters of the given book.
        * @return The number of chapters for the given book
        */
        virtual unsigned int chapterCount( const unsigned int book );
        /** Information about the chapters in a book.
        * @return The number of available chapters of the given book.
        */
        virtual unsigned int chapterCount( const QString& book );
        /** Return all book of this module.
        * @return A QStringList containing the books which are available in this module.
        */
        virtual QStringList* books();
        /**
        * Reimplementation, Returns the type
        */
        virtual CSwordModuleInfo::ModuleType type() const;
        /**
        * @return the book number, values starting with 1; 0 if not found
        */
        unsigned int bookNumber(const QString &book);
        /**
        * Returns true if his module has the text of desired type of testament
        */
        bool hasTestament( CSwordBibleModuleInfo::Testament );
        /** Reimplementation to clone this object. */
        virtual CSwordModuleInfo* clone();
        /**
        * Returns the key which represents the lower bound of this module.
        */
        inline const CSwordVerseKey& lowerBound();
        /**
        * Returns the key which represents the upper bound of this module.
        */
        inline const CSwordVerseKey& upperBound();

    private:
        void initBounds();

        CSwordVerseKey m_lowerBound;
        CSwordVerseKey m_upperBound;

        QStringList* m_bookList; //This booklist is cached
        QString m_cachedLocale;
        short int m_hasOT;
        short int m_hasNT;
};

inline CSwordModuleInfo::ModuleType CSwordBibleModuleInfo::type() const {
    return CSwordModuleInfo::Bible;
}

/** Returns the key which represents the lower bound of this module. */
inline const CSwordVerseKey& CSwordBibleModuleInfo::lowerBound() {
    initBounds();
    return m_lowerBound;
}

/** Returns the key which represents the lower bound of this module. */
inline const CSwordVerseKey& CSwordBibleModuleInfo::upperBound() {
    initBounds();
    return m_upperBound;
}

#endif