Improve sword modules interface
[kworship.git] / kworship / bible / KwBibleModuleSword.h
blobd60d642cb9264d53c196c85c93f24333d7e83fb0
1 /***************************************************************************
2 * This file is part of KWorship. *
3 * Copyright 2008 James Hogan <james@albanarts.com> *
4 * *
5 * KWorship is free software: you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation, either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * KWorship is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with KWorship. If not, write to the Free Software Foundation, *
17 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
18 ***************************************************************************/
20 #ifndef _KwBibleModuleSword_h_
21 #define _KwBibleModuleSword_h_
23 /**
24 * @file KwBibleModuleSword.h
25 * @brief A SWORD bible module.
26 * @author James Hogan <james@albanarts.com>
29 #include "KwBibleModule.h"
31 namespace sword
33 class SWText;
36 /// A SWORD bible module.
37 class KwBibleModuleSword : public KwBibleModule
39 public:
42 * Constructors + destructor
45 /// Default constructor.
46 KwBibleModuleSword(sword::SWText* module);
48 /// Destructor.
49 virtual ~KwBibleModuleSword();
52 * Main interface
55 // Reimplemented
56 virtual QString name();
58 // Reimplemented
59 virtual QString description();
61 // Reimplemented
62 virtual int numChapters(int book);
64 // Reimplemented
65 virtual int numVerses(int book, int chapter);
67 // Reimplemented
68 virtual QString renderText(const KwBibleModule::Key& key);
70 protected:
73 * Protected virtual interface
76 // Reimplemented
77 virtual void obtainBooks();
80 * Internal functions
83 /** Convert a local book index to a bible book index.
84 * @param localIndex Local index of book in module.
85 * @returns Index of the book in the bible.
87 int localToBible(int localIndex) const;
89 /** Convert a bible book index to a local book index.
90 * @param bibleIndex Index of book in bible.
91 * @returns Local index of book in module.
93 int bibleToLocal(int bibleIndex) const;
95 /** Convert a testament & book number to a bible book index.
96 * @param testament Testament number [0,1].
97 * @param book Book number [0,..].
98 * @returns Bible book index.
100 int testamentBookToBible(int testament, int book) const;
102 /** Convert a bible book index into a testament and book number.
103 * @param bibleIndex Bible book index.
104 * @param book[out] Points to int in which to write book number.
105 * @returns Which testament [0,1].
107 int bibleToTestamentBook(int bibleIndex, int* book) const;
109 /** Convert a testament & book number to a local book index.
110 * @param testament Testament number [0,1].
111 * @param book Book number [0,..].
112 * @returns Local book index.
114 int testamentBookToLocal(int testament, int book) const;
116 /** Convert a local book index into a testament and book number.
117 * @param localIndex Local book index.
118 * @param book[out] Points to int in which to write book number.
119 * @returns Which testament [0,1].
121 int localToTestamentBook(int localIndex, int* book) const;
123 private:
126 * Variables
129 /// SWORD module object.
130 sword::SWText* m_module;
132 /// First book of the bible in this module.
133 int m_firstBibleBookIndex;
135 /// Last book of the bible in this module.
136 int m_lastBibleBookIndex;
139 #endif // _KwBibleModuleSword_h_