removed types.rdb from openoffice.org, its generated at compile time, shouldn't be...
[kworship.git] / kworship / bible / KwBibleManagerSword.cpp
blobe8bed3c340e56f3e51ae2509b511fa2c5e3f4ad4
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 /**
21 * @file KwBibleManagerSword.cpp
22 * @brief A bible manager for SWORD.
23 * @author James Hogan <james@albanarts.com>
26 #include "KwBibleManagerSword.h"
27 #include "KwBibleModuleSword.h"
29 #include <swmgr.h>
30 #include <swmodule.h>
31 #include <swtext.h>
32 #include <markupfiltmgr.h>
34 KW_REGISTER_BIBLE_MANAGER(KwBibleManagerSword)
37 * Constructors + destructor
40 /// Default constructor.
41 KwBibleManagerSword::KwBibleManagerSword()
42 : KwBibleManager()
43 , m_manager(new sword::SWMgr(new sword::MarkupFilterMgr(sword::FMT_HTMLHREF)))
44 , m_modules()
45 , m_languages()
46 , m_modulesByLanguage()
48 m_manager->setGlobalOption("Headings", "On");
50 sword::ModMap::iterator modIterator;
52 for (modIterator = m_manager->Modules.begin(); modIterator != m_manager->Modules.end(); ++modIterator)
54 sword::SWBuf modName = (*modIterator).first;
55 sword::SWModule* module = (*modIterator).second;
56 sword::SWText* text = dynamic_cast<sword::SWText*>(module);
57 if (0 != text)
59 QString name = QString::fromUtf8(modName);
60 m_modules[name] = new KwBibleModuleSword(text);
61 QString lang = QString::fromUtf8(module->Lang());
62 if (-1 == m_languages.indexOf(lang))
64 m_languages << lang;
66 m_modulesByLanguage[lang] << name;
71 /// Destructor.
72 KwBibleManagerSword::~KwBibleManagerSword()
74 foreach (KwBibleModule* module, m_modules)
76 delete module;
78 delete m_manager;
82 * Main interface
85 QString KwBibleManagerSword::name() const
87 return "SWORD";
90 bool KwBibleManagerSword::isRemote() const
92 return false;
95 KwBibleModule* KwBibleManagerSword::module(const QString& name)
97 QHash<QString, KwBibleModule*>::const_iterator it = m_modules.constFind(name);
98 if (it != m_modules.constEnd())
100 return *it;
102 else
104 return 0;
108 QStringList KwBibleManagerSword::moduleNames()
110 return m_modules.keys();
113 QStringList KwBibleManagerSword::moduleNamesInLanguage(const QString& lang)
115 QHash<QString, QStringList>::const_iterator it = m_modulesByLanguage.constFind(lang);
116 if (it != m_modulesByLanguage.constEnd())
118 return *it;
120 else
122 return QStringList();
126 QStringList KwBibleManagerSword::languages()
128 return m_languages;