1 /***************************************************************************
2 * This file is part of KWorship. *
3 * Copyright 2008 James Hogan <james@albanarts.com> *
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. *
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. *
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 _KwBibleModule_h_
21 #define _KwBibleModule_h_
24 * @file KwBibleModule.h
25 * @brief An abstract bible module (analagous to a SWORD module).
26 * @author James Hogan <james@albanarts.com>
30 #include <QStringList>
34 /// A bible module (analagous to a SWORD module).
46 /// Book of the bible.
48 /// Chapter of the book (-1 for entire book).
50 /// Verse of the chapter (-1 for entire chapter).
54 /// Range of verse keys.
57 /// Start key of range.
64 * Constructors + destructor
67 /// Default constructor.
71 virtual ~KwBibleModule();
77 /// Create a key from a string.
78 Key
createKey(const QString
& text
, bool* valid
= 0);
80 /// Create a key from a string relative to another key.
81 Key
createKey(const Key
& other
, const QString
& text
, bool* valid
= 0);
83 /// Create a key from individual values.
84 Key
createKey(int book
, int chapter
, int verse
= -1);
86 /// Create a key from individual values.
87 Key
createKey(const QString
& book
, int chapter
, int verse
= -1);
89 /// Create a range key between two verses in the same chapter.
90 Key
createKey(const QString
& book
, int chapter
, int verseStart
,
93 /// Create a range key between two verses in different chapters.
94 Key
createKey(const QString
& book
, int chapterStart
, int verseStart
,
95 int chapterEnd
, int verseEnd
);
97 /// Create a range key between two verses in different books.
98 Key
createKey(const QString
& bookStart
, int chapterStart
, int verseStart
,
99 const QString
& bookEnd
, int chapterEnd
, int verseEnd
);
101 /// Get the name of the module.
102 virtual QString
name() = 0;
104 /// Get the description of the module.
105 virtual QString
description() = 0;
107 /// Get the id of the manager for this module.
108 virtual QString
managerId() = 0;
110 /// Is the text right to left?
111 bool isRightToLeft() const;
113 /// List the books in this module.
114 const QStringList
& books();
116 /** Get the index of a book from it's name.
117 * @param name Name of the book to look for.
118 * @return Index of the book in this module or -1 if it does not exist.
120 int bookIndex(const QString
& name
);
122 /// Get the name of a book from it's index.
123 QString
bookName(int book
);
125 /// Get the number of chapters in this book.
126 virtual int numChapters(int book
) = 0;
128 /// Get the number of verses in a chapter of a book.
129 virtual int numVerses(int book
, int chapter
) = 0;
131 /// Fill a passage object.
132 bool fillPassage(const Key
& key
, KwBiblePassage
* outPassage
);
134 /// Fill a single verse with data.
135 virtual bool fillPassageVerse(int bookIndex
, int chapterIndex
, int verseIndex
, KwBiblePassage
* outPassage
) = 0;
140 * Protected virtual interface
143 /// Ensure that the book list is up to date.
144 virtual void obtainBooks();
147 * Protected interface
150 /// Update the list of books.
151 void setBooks(const QStringList
& books
);
153 /// Set whether the module has text right-to-left.
154 void setRightToLeft(bool rightToLeft
);
162 /// List of book names.
165 /// Whether the module has text right to left.
170 #endif // _KwBibleModule_h_