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 ***************************************************************************/
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"
32 #include <markupfiltmgr.h>
34 KW_REGISTER_BIBLE_MANAGER(KwBibleManagerSword
)
37 * Constructors + destructor
40 /// Default constructor.
41 KwBibleManagerSword::KwBibleManagerSword()
43 , m_manager(new sword::SWMgr(new sword::MarkupFilterMgr(sword::FMT_HTMLHREF
)))
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
);
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
))
66 m_modulesByLanguage
[lang
] << name
;
72 KwBibleManagerSword::~KwBibleManagerSword()
74 foreach (KwBibleModule
* module
, m_modules
)
85 QString
KwBibleManagerSword::name() const
90 bool KwBibleManagerSword::isRemote() const
95 KwBibleModule
* KwBibleManagerSword::module(const QString
& name
)
97 QHash
<QString
, KwBibleModule
*>::const_iterator it
= m_modules
.constFind(name
);
98 if (it
!= m_modules
.constEnd())
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())
122 return QStringList();
126 QStringList
KwBibleManagerSword::languages()