Finished (for now) filling of bible passage and now renders html from it
[kworship.git] / kworship / bible / KwBibleModule.h
blob38cc65a89553af6a75e7d7f69701cf72603e1f89
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 _KwBibleModule_h_
21 #define _KwBibleModule_h_
23 /**
24 * @file KwBibleModule.h
25 * @brief An abstract bible module (analagous to a SWORD module).
26 * @author James Hogan <james@albanarts.com>
29 #include <QString>
30 #include <QStringList>
32 class KwBiblePassage;
34 /// A bible module (analagous to a SWORD module).
35 class KwBibleModule
37 public:
40 * Types
43 /// Verse key.
44 struct VerseKey
46 /// Book of the bible.
47 int book;
48 /// Chapter of the book (-1 for entire book).
49 int chapter;
50 /// Verse of the chapter (-1 for entire chapter).
51 int verse;
54 /// Range of verse keys.
55 struct Key
57 /// Start key of range.
58 VerseKey start;
59 /// End key of range.
60 VerseKey end;
64 * Constructors + destructor
67 /// Default constructor.
68 KwBibleModule();
70 /// Destructor.
71 virtual ~KwBibleModule();
74 * Main interface
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,
91 int verseEnd);
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 /// List the books in this module.
108 const QStringList& books();
110 /** Get the index of a book from it's name.
111 * @param name Name of the book to look for.
112 * @return Index of the book in this module or -1 if it does not exist.
114 int bookIndex(const QString& name);
116 /// Get the name of a book from it's index.
117 QString bookName(int book);
119 /// Get the number of chapters in this book.
120 virtual int numChapters(int book) = 0;
122 /// Get the number of verses in a chapter of a book.
123 virtual int numVerses(int book, int chapter) = 0;
125 /// Fill a passage object.
126 bool fillPassage(const Key& key, KwBiblePassage* outPassage);
128 /// Fill a single verse with data.
129 virtual bool fillPassageVerse(int bookIndex, int chapterIndex, int verseIndex, KwBiblePassage* outPassage) = 0;
131 /// Get rendered text for a given passage.
132 virtual QString renderText(const Key& key) = 0;
134 protected:
137 * Protected virtual interface
140 /// Ensure that the book list is up to date.
141 virtual void obtainBooks();
144 * Protected interface
147 /// Update the list of books.
148 void setBooks(const QStringList& books);
150 private:
153 * Variables
156 /// List of book names.
157 QStringList m_books;
161 #endif // _KwBibleModule_h_