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 _KwBiblePassage_h_
21 #define _KwBiblePassage_h_
24 * @file KwBiblePassage.h
25 * @brief A passage of rendered bible text.
26 * @author James Hogan <james@albanarts.com>
29 #include "KwBibleModule.h"
36 /** A passage of rendered bible text.
37 * Stores enough information to adjust settings.
38 * Can be used as a cache.
45 * Constructors + destructor
48 /// Default constructor.
52 virtual ~KwBiblePassage();
58 /// Import the passage in a DOM.
59 void importFromDom(const QDomElement
& element
);
61 /// Export the passage using DOM.
62 void exportToDom(QDomDocument
& document
, QDomElement
& element
) const;
68 /** Clear the passage.
73 /** Clear the chapters in a book.
74 * Deletes all chapters.
76 void clearChapters(int bookNumber
);
78 /** Clear the verses in a chapter.
81 void clearVerses(int bookNumber
, int chapterNumber
);
83 /** Set the source module.
84 * @param managerId ID of the bible manager.
85 * @param moduleId ID of the bible module.
86 * @param rightToLeft Whether the text is right-to-left.
88 void setSource(const QString
& managerId
, const QString
& moduleId
, bool rightToLeft
);
90 /** Initialise the books in the passage.
91 * If books are already initialised they will be cleared first.
92 * @param firstBook Number of first book in passage.
93 * @param numBooks Number of books covered in this passage.
96 void initBooks(int firstBook
, int numBooks
);
98 /** Initialise a book in the passage.
99 * If the book is already initialised it will be cleared first.
100 * @param bookNumber Number of the book to initialise.
101 * @param name Name of the book.
102 * @param firstChapter Number of first chapter in book.
103 * @param numChapters Number of chapters covered in this book.
104 * @pre firstBookNumber() <= bookNumber <= lastBookNumber()
105 * @pre numChapters > 0
107 void initBook(int bookNumber
,
108 const QString
& name
, int firstChapter
, int numChapters
);
110 /** Initialise a chapter in the passage.
111 * If the chapter is already initialised it will be cleared first.
112 * @param bookNumber Number of the book with the chapter to initialise.
113 * @param chapterNumber Number of the chapter to initialise.
114 * @param firstVerse Number of first verse in chapter.
115 * @param numVerses Number of verses covered in this chapter.
116 * @pre firstBookNumber() <= bookNumber <= lastBookNumber()
117 * @pre firstChapterNumber(bookNumber) <= chapterNumber <= lastChapterNumber(bookNumber)
120 void initChapter(int bookNumber
, int chapterNumber
,
121 int firstVerse
, int numVerses
);
123 /** Initialise a verse in the passage.
124 * If the verse is already initialised it will be cleared first.
125 * @param bookNumber Number of the book with the chapter to initialise.
126 * @param chapterNumber Number of the chapter with the verse to initialise.
127 * @param verseNumber Number of the verse to initialise.
128 * @param headings Headings HTML preceeding this verse.
129 * @param content Main HTML in this verse.
130 * @pre firstBookNumber() <= bookNumber <= lastBookNumber()
131 * @pre firstChapterNumber(bookNumber) <= chapterNumber <= lastChapterNumber(bookNumber)
132 * @pre firstVerseNumber(bookNumber) <= verseNumber <= lastVerseNumber(bookNumber)
134 void initVerse(int bookNumber
, int chapterNumber
, int verseNumber
,
135 const QString
& headings
, const QString
& content
);
141 /// Find whether the passage is empty.
142 bool isEmpty() const;
144 /// Get textual key of this passage.
145 QString
textualKey() const;
147 /// Get the first book number in the passage.
148 int firstBookNumber() const;
149 /// Get the last book number in the passage.
150 int lastBookNumber() const;
152 /** Get the first chapter number in a book of the passage.
153 * @param bookNumber The number of the book.
154 * @pre firstBookNumber() <= bookNumber <= lastBookNumber()
156 int firstChapterNumber(int bookNumber
) const;
157 /** Get the last chapter number in a book of the passage.
158 * @param bookNumber The number of the book.
159 * @pre firstBookNumber() <= bookNumber <= lastBookNumber()
161 int lastChapterNumber(int bookNumber
) const;
163 /** Get the first verse number in a chapter of the passage.
164 * @param bookNumber The number of the book.
165 * @param chapterNumber The number of the chapter within the book.
166 * @pre firstBookNumber() <= bookNumber <= lastBookNumber()
167 * @pre firstChapterNumber(bookNumber) <= chapterNumber <= lastChapterNumber(bookNumber)
169 int firstVerseNumber(int bookNumber
, int chapterNumber
) const;
170 /** Get the last verse number in a chapter of the passage.
171 * @param bookNumber The number of the book.
172 * @param chapterNumber The number of the chapter within the book.
173 * @pre firstBookNumber() <= bookNumber <= lastBookNumber()
174 * @pre firstChapterNumber(bookNumber) <= chapterNumber <= lastChapterNumber(bookNumber)
176 int lastVerseNumber(int bookNumber
, int chapterNumber
) const;
182 /// Get the entire passaage rendered as HTML.
183 /// @todo Needs some rendering options, headings, footnotes etc.
184 QString
renderedText() const;
192 /// A verse in a chapter in a book.
195 /// The headings preceeding this verse.
197 /// The main HTML content of this verse.
202 /// A chapter in a book containing verses.
205 /// The number of the first verse in this chapter.
207 /// The number of verses in this chapter.
209 /// The array of verses.
213 /// A book containing chapters.
216 /// The name of this book.
218 /// The number of the first chapter in this book.
220 /// The number of chapters in this book.
222 /// The array of chapters.
230 /// Bible manager id.
235 /// Whether the text is right-to-left.
238 /// The number of the first book.
240 /// The number of books.
242 /// The array of books.
246 #endif // _KwBiblePassage_h_