3
* This file is part of BibleTime's source code, http://www.bibletime.info/.
5
* Copyright 1999-2006 by the BibleTime developers.
6
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
12
#ifndef CSWORDBACKEND_H
13
#define CSWORDBACKEND_H
16
#include "cswordmoduleinfo.h"
17
//#include "centrydisplay.h"
23
#include <qstringlist.h>
29
#include <swversion.h>
30
#include <localemgr.h>
33
using namespace sword;
39
class CChapterDisplay;
44
/** The backend layer main class.
45
* This is the implementation of CBackend for Sword. It's additionally derived from SWMgr
46
* to provide functions of Sword.
48
* @short The backend implementation of Sword
49
* @author The BibleTime team
50
* @version $Id: cswordbackend.h,v 1.58 2007/03/14 21:32:47 joachim Exp $
53
class CSwordBackend : public sword::SWMgr {
56
/** Filter options. Filter options to
57
* control the text display of modules. Uses int and not bool because not all
58
* options have just two toggle values.
61
struct FilterOptions {
62
int footnotes; /**< 0 for disabled, 1 for enabled */
63
int strongNumbers; /**< 0 for disabled, 1 for enabled */
64
int headings; /**< 0 for disabled, 1 for enabled */
65
int morphTags; /**< 0 for disabled, 1 for enabled */
66
int lemmas; /**< 0 for disabled, 1 for enabled */
67
int hebrewPoints; /**< 0 for disabled, 1 for enabled */
68
int hebrewCantillation; /**< 0 for disabled, 1 for enabled */
69
int greekAccents; /**< 0 for disabled, 1 for enabled */
70
int textualVariants; /**< Number n to enabled the n-th variant */
71
int redLetterWords; /**< 0 for disabled, 1 for enabled */
72
int scriptureReferences; /**< 0 for disabled, 1 for enabled */
73
int morphSegmentation; /**< 0 for disabled, 1 for enabled */
76
/** Control the display of a text.
79
struct DisplayOptions {
84
/** The error codes which may be returned by the @ref Load() call.
86
enum LoadError { // the values exist to cast from the char return of SWMgr::Load
92
* The constructor of the Sword backend.
93
* It creates the SWModule objects using SWMgr's methods, it adds the necessary
94
* filters for the module format.
98
* The constructor of the Sword backend.
99
* @param path The path which is used to load modules
100
* @param augmentHome True if the $HOME/.sword/ modules should be augmented with the other modules
102
CSwordBackend( const QString& path, const bool augmentHome = true );
105
* The destrctor of this backend. This function shuts the modules down using @ref shutdownModules.
107
virtual ~CSwordBackend();
110
* This function returns the list of available modules managed by this backend.
111
* You have to call initModules() first;
113
* @return The list of modules managed by this backend
115
inline virtual ListCSwordModuleInfo& moduleList();
117
* Initializes the Sword modules.
119
* @return True if the initializiation was succesful, otherwise return false.
121
virtual const CSwordBackend::LoadError initModules();
123
* This function deinitializes the modules and deletes them.
125
* @return True if it was succesful, otherwise return false
127
virtual const bool shutdownModules();
129
* Sets the given options enabled or disabled depending on the second parameter.
131
* @param type This is the type this function should set enabled or disabled
132
* @param enable If this is true the option will be enabled, otherwise it will be disabled.
134
void setOption( const CSwordModuleInfo::FilterTypes type, const int state );
135
void setFilterOptions( const CSwordBackend::FilterOptions options );
136
void setDisplayOptions( const CSwordBackend::DisplayOptions options );
138
* Returns true if the given option is enabled.
140
* @return Returns true if the options given as aparameter is switched on at this time, otherwise return false.
142
virtual const bool isOptionEnabled( const CSwordModuleInfo::FilterTypes type);
144
* Sets the language for the international booknames of Sword.
145
* @param langName The abbreviation string which should be used for the Sword backend
147
const QString booknameLanguage( const QString& langName = QString::null );
149
* This function searches for a module with the specified description
150
* @param description The description of the desired module
151
* @return pointer to the desired module; null if no module has the specified description
153
virtual CSwordModuleInfo* const findModuleByDescription(const QString& description);
155
* This function searches for a module with the specified description
156
* @param description The description of the desired module
157
* @return pointer to the desired module; null if no module has the specified description
159
const QString findModuleNameByDescription(const QString& description);
161
* This function searches for a module with the specified name
162
* @param name The name of the desired module
163
* @return Pointer to the desired module; null if no module has the specified name
165
CSwordModuleInfo* const findModuleByName(const QString& name);
167
* This function searches for a module with the specified sword module as module() object!
168
* @param swmodule to a Sword module
169
* @return pointer to the desired module; null if no module has the specified name
171
CSwordModuleInfo* const findSwordModuleByPointer(const sword::SWModule* const swmodule);
173
* This function searches for a module which is the same as the passed module.
174
* @param module The module which should be used for searching the new one. May be child of a different backend.
175
* @return Pointer to the desired module; null if no module has the specified name
177
CSwordModuleInfo* const findModuleByPointer(const CSwordModuleInfo* const module);
179
* @return Our global config object which contains the configs of all modules merged together.
181
inline sword::SWConfig* const getConfig() const;
183
* Tries to find the config object for the module. The second paramter will be the found config.
184
* @return True if the config was found, false if not. If false is returned the moduleConfig object is in undefined/unknwon state.
186
const bool moduleConfig(const QString& module, sword::SWConfig& moduleConfig );
188
* Returns the text used for the option given as parameter.
189
* @param The paramter enum
190
* @return The name of the option given by the parameter
192
static const QString optionName( const CSwordModuleInfo::FilterTypes option );
194
* Returns the text used for the option given as parameter.
196
static const QString configOptionName( const CSwordModuleInfo::FilterTypes option );
198
* Returns the translated name of the option given as parameter.
199
* @param The translated option name
201
static const QString translatedOptionName(const CSwordModuleInfo::FilterTypes option );
203
* Returns the version of the Sword library.
204
* @return The version used by this backend
206
inline virtual const sword::SWVersion Version();
208
* Reload all Sword modules.
210
void reloadModules();
211
/** Sword prefix list.
212
* @return A list of all known Sword prefix dirs
214
const QStringList swordDirList();
218
* Adds a render filter to the module.
219
* @param module Add a render filter to this module!
221
virtual void AddRenderFilters(sword::SWModule *module, sword::ConfigEntMap §ion);
223
* Initializes the filters provided by BibleTime.
225
virtual void filterInit();
231
sword::SWFilter *gbf;
232
sword::SWFilter *plain;
233
sword::SWFilter *thml;
234
sword::SWFilter *osis;
240
Rendering::CChapterDisplay* chapter;
241
Rendering::CEntryDisplay* entry;
242
Rendering::CBookDisplay* book;
247
ListCSwordModuleInfo m_moduleList;
248
QMap<QString, QString> m_moduleDescriptionMap;
251
/**Returns The list of modules managed by this backend*/
252
inline ListCSwordModuleInfo& CSwordBackend::moduleList() {
256
/** Returns our local config object to store the cipher keys etc. locally for each user. The values of the config are merged with the global config. */
257
inline sword::SWConfig* const CSwordBackend::getConfig() const {
261
/** Returns the version of the Sword library. */
262
inline const sword::SWVersion CSwordBackend::Version() {
263
return sword::SWVersion::currentVersion;