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 KwBibleModule.cpp
22 * @brief A bible module (analagous to a SWORD module).
23 * @author James Hogan <james@albanarts.com>
26 #include "KwBibleModule.h"
28 #include <QStringList>
34 * Constructors + destructor
37 /// Default constructor.
38 KwBibleModule::KwBibleModule(sword::SWModule
* module
)
44 KwBibleModule::~KwBibleModule()
52 /// Get the name of the module.
53 QString
KwBibleModule::name() const
55 return m_module
->Name();
58 /// Get the description of the module.
59 QString
KwBibleModule::description() const
61 return m_module
->Description();
64 /// Get rendered text for a given passage.
65 QString
KwBibleModule::renderText(const QString
& key
) const
67 QStringList bits
= key
.split('-');
71 vkey
= sword::VerseKey(bits
[0].toAscii(), bits
[1].toAscii());
75 vkey
= sword::VerseKey(key
.toAscii(), key
.toAscii());
79 sword::VerseKey verse
= vkey
.LowerBound();
81 sword::VerseKey last
= vkey
.UpperBound();
82 Q_ASSERT(verse
.isTraversable());
85 for (; verse
.compare(last
) <= 0; verse
.increment(1))
87 m_module
->setKey(&verse
);
88 m_module
->RenderText();
89 const char* preverse
= m_module
->getEntryAttributes()["Heading"]["Preverse"]["0"];
91 if (preverse
[0] != '\0')
93 result
+= QString("<h1>%1</h1>").arg(QString::fromUtf8(preverse
));
95 result
+= QString("<sup>%1</sup>").arg(verse
.Verse()) + QString::fromUtf8(m_module
->RenderText());