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>
29 #include "KwBibleExport.h"
32 #include <QStringList>
36 /// A bible module (analagous to a SWORD module).
37 class KWBIBLE_EXPORT KwBibleModule
48 /// Book of the bible.
50 /// Chapter of the book (-1 for entire book).
52 /// Verse of the chapter (-1 for entire chapter).
56 /// Range of verse keys.
59 /// Start key of range.
66 * Constructors + destructor
69 /// Default constructor.
73 virtual ~KwBibleModule();
79 /// Create a key from a string.
80 Key
createKey(const QString
& text
, bool* valid
= 0);
82 /// Create a key from a string relative to another key.
83 Key
createKey(const Key
& other
, const QString
& text
, bool* valid
= 0);
85 /// Create a key from individual values.
86 Key
createKey(int book
, int chapter
, int verse
= -1);
88 /// Create a key from individual values.
89 Key
createKey(const QString
& book
, int chapter
, int verse
= -1);
91 /// Create a range key between two verses in the same chapter.
92 Key
createKey(const QString
& book
, int chapter
, int verseStart
,
95 /// Create a range key between two verses in different chapters.
96 Key
createKey(const QString
& book
, int chapterStart
, int verseStart
,
97 int chapterEnd
, int verseEnd
);
99 /// Create a range key between two verses in different books.
100 Key
createKey(const QString
& bookStart
, int chapterStart
, int verseStart
,
101 const QString
& bookEnd
, int chapterEnd
, int verseEnd
);
103 /// Get the name of the module.
104 virtual QString
name() = 0;
106 /// Get the description of the module.
107 virtual QString
description() = 0;
109 /// Get the id of the manager for this module.
110 virtual QString
managerId() = 0;
112 /// Is the text right to left?
113 bool isRightToLeft() const;
115 /// List the books in this module.
116 const QStringList
& books();
118 /** Get the index of a book from it's name.
119 * @param name Name of the book to look for.
120 * @return Index of the book in this module or -1 if it does not exist.
122 int bookIndex(const QString
& name
);
124 /// Get the name of a book from it's index.
125 QString
bookName(int book
);
127 /// Get the number of chapters in this book.
128 virtual int numChapters(int book
) = 0;
130 /// Get the number of verses in a chapter of a book.
131 virtual int numVerses(int book
, int chapter
) = 0;
133 /// Fill a passage object.
134 bool fillPassage(const Key
& key
, KwBiblePassage
* outPassage
);
136 /// Fill a single verse with data.
137 virtual bool fillPassageVerse(int bookIndex
, int chapterIndex
, int verseIndex
, KwBiblePassage
* outPassage
) = 0;
142 * Protected virtual interface
145 /// Ensure that the book list is up to date.
146 virtual void obtainBooks();
149 * Protected interface
152 /// Update the list of books.
153 void setBooks(const QStringList
& books
);
155 /// Set whether the module has text right-to-left.
156 void setRightToLeft(bool rightToLeft
);
164 /// List of book names.
167 /// Whether the module has text right to left.
172 #endif // _KwBibleModule_h_