summaryrefslogtreecommitdiff
path: root/src/backend/rendering/chtmlexportrendering.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/rendering/chtmlexportrendering.cpp')
-rw-r--r--src/backend/rendering/chtmlexportrendering.cpp85
1 files changed, 48 insertions, 37 deletions
diff --git a/src/backend/rendering/chtmlexportrendering.cpp b/src/backend/rendering/chtmlexportrendering.cpp
index 6a571c6..3d82602 100644
--- a/src/backend/rendering/chtmlexportrendering.cpp
+++ b/src/backend/rendering/chtmlexportrendering.cpp
@@ -2,15 +2,14 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
#include "backend/rendering/chtmlexportrendering.h"
-#include <boost/scoped_ptr.hpp>
-#include <iostream>
+#include <QSharedPointer>
#include <QDebug>
#include "backend/drivers/cswordmoduleinfo.h"
@@ -18,42 +17,43 @@
#include "backend/keys/cswordversekey.h"
#include "backend/managers/cdisplaytemplatemgr.h"
#include "backend/managers/clanguagemgr.h"
-#include "util/cpointers.h"
+#ifdef BT_DEBUG
namespace {
-/*
- * Helper function to dump a verse with all its enty attributes
- */
-
+/** Helper function to dump a verse with all its enty attributes. */
void dumpEntryAttributes(sword::SWModule *module) {
- std::cout << "Attributes for key: " << module->getKeyText() << std::endl;
+ qDebug() << "Attributes for key: " << module->getKeyText();
sword::AttributeTypeList::iterator i1;
sword::AttributeList::iterator i2;
sword::AttributeValue::iterator i3;
for (i1 = module->getEntryAttributes().begin(); i1 != module->getEntryAttributes().end(); i1++) {
- std::cout << "[ " << i1->first << " ]\n";
+ qDebug() << "[ " << i1->first << " ]";
for (i2 = i1->second.begin(); i2 != i1->second.end(); i2++) {
- std::cout << "\t[ " << i2->first << " ]\n";
+ qDebug() << "\t[ " << i2->first << " ]";
for (i3 = i2->second.begin(); i3 != i2->second.end(); i3++) {
- std::cout << "\t\t" << i3->first << " = " << i3->second << "\n";
+ qDebug() << "\t\t" << i3->first << " = " << i3->second;
}
}
}
- std::cout << std::endl;
}
-}
+} // anonymous namespace
+#endif
namespace Rendering {
-CHTMLExportRendering::CHTMLExportRendering(const CHTMLExportRendering::Settings& settings, CSwordBackend::DisplayOptions displayOptions, CSwordBackend::FilterOptions filterOptions)
+CHTMLExportRendering::CHTMLExportRendering(
+ const CHTMLExportRendering::Settings &settings,
+ const DisplayOptions &displayOptions,
+ const FilterOptions &filterOptions)
: m_displayOptions(displayOptions),
- m_filterOptions(filterOptions),
- m_settings(settings) {}
-
-CHTMLExportRendering::~CHTMLExportRendering() {}
+ m_filterOptions(filterOptions),
+ m_settings(settings)
+{
+ // Intentionally empty
+}
const QString CHTMLExportRendering::renderEntry( const KeyTreeItem& i, CSwordKey* k) {
@@ -62,13 +62,13 @@ const QString CHTMLExportRendering::renderEntry( const KeyTreeItem& i, CSwordKey
ret.append(i.getAlternativeContent());
// Q_ASSERT(i.hasChildItems());
-
+
if (!i.childList()->isEmpty()) {
KeyTree * const tree = i.childList();
- const QList<CSwordModuleInfo*> modules = collectModules(tree);
+ const QList<const CSwordModuleInfo*> modules = collectModules(tree);
- if (modules.count() == 1) { //insert the direction into the sorrounding div
+ if (modules.count() == 1) { //insert the direction into the surrounding div
ret.insert( 5, QString("dir=\"%1\" ").arg((modules.first()->textDirection() == CSwordModuleInfo::LeftToRight) ? "ltr" : "rtl" ));
}
@@ -82,13 +82,13 @@ const QString CHTMLExportRendering::renderEntry( const KeyTreeItem& i, CSwordKey
}
- const QList<CSwordModuleInfo*>& modules( i.modules() );
+ const QList<const CSwordModuleInfo*> &modules(i.modules());
if (modules.count() == 0) {
return QString(""); //no module present for rendering
}
- boost::scoped_ptr<CSwordKey> scoped_key( !k ? CSwordKey::createInstance(modules.first()) : 0 );
- CSwordKey* key = k ? k : scoped_key.get();
+ QSharedPointer<CSwordKey> scoped_key( !k ? CSwordKey::createInstance(modules.first()) : 0 );
+ CSwordKey* key = k ? k : scoped_key.data();
Q_ASSERT(key);
CSwordVerseKey* myVK = dynamic_cast<CSwordVerseKey*>(key);
@@ -100,19 +100,17 @@ const QString CHTMLExportRendering::renderEntry( const KeyTreeItem& i, CSwordKey
//declarations out of the loop for optimization
QString entry;
- QString keyText;
bool isRTL;
QString preverseHeading;
QString langAttr;
QString key_renderedText;
- QList<CSwordModuleInfo*>::const_iterator end_modItr = modules.end();
+ QList<const CSwordModuleInfo*>::const_iterator end_modItr = modules.end();
- for (QList<CSwordModuleInfo*>::const_iterator mod_Itr(modules.begin()); mod_Itr != end_modItr; ++mod_Itr) {
- key->module(*mod_Itr);
- key->key( i.key() );
+ for (QList<const CSwordModuleInfo*>::const_iterator mod_Itr(modules.begin()); mod_Itr != end_modItr; ++mod_Itr) {
+ key->setModule(*mod_Itr);
+ key->setKey(i.key());
- keyText = key->key();
isRTL = ((*mod_Itr)->textDirection() == CSwordModuleInfo::RightToLeft);
entry = QString::null;
@@ -144,7 +142,16 @@ const QString CHTMLExportRendering::renderEntry( const KeyTreeItem& i, CSwordKey
(*mod_Itr)->module()->getEntryAttributes()["Heading"]["Preverse"].end();
for (; it != end; ++it) {
- preverseHeading = QString::fromUtf8(it->second.c_str());
+ QString unfiltered = it->second.c_str();
+
+ /// \todo This is only a preliminary workaround to strip the tags:
+ QRegExp filter("<title>(.*)</title>");
+ if (unfiltered.indexOf(filter) >= 0) {
+ preverseHeading = filter.cap(1);
+ } else {
+ preverseHeading = unfiltered;
+ }
+
/// \todo Take care of the heading type!
if (!preverseHeading.isEmpty()) {
entry.append("<div ")
@@ -207,16 +214,16 @@ const QString CHTMLExportRendering::renderEntry( const KeyTreeItem& i, CSwordKey
}
void CHTMLExportRendering::initRendering() {
- //CPointers::backend()->setDisplayOptions( m_displayOptions );
- CPointers::backend()->setFilterOptions( m_filterOptions );
+ //CSwordBackend::instance()()->setDisplayOptions( m_displayOptions );
+ CSwordBackend::instance()->setFilterOptions( m_filterOptions );
}
const QString CHTMLExportRendering::finishText( const QString& text, KeyTree& tree ) {
- const QList<CSwordModuleInfo*> modules = collectModules(&tree);
+ const QList<const CSwordModuleInfo*> modules = collectModules(&tree);
const CLanguageMgr::Language* const lang = modules.first()->language();
- CDisplayTemplateMgr* tMgr = CPointers::displayTemplateManager();
+ CDisplayTemplateMgr *tMgr = CDisplayTemplateMgr::instance();
CDisplayTemplateMgr::Settings settings;
settings.modules = modules;
settings.langAbbrev = ((modules.count() == 1) && lang->isValid()) ? lang->abbrev() : "unknown";
@@ -231,7 +238,11 @@ const QString CHTMLExportRendering::finishText( const QString& text, KeyTree& tr
/*!
\fn CHTMLExportRendering::entryLink( KeyTreeItem& item )
*/
-const QString CHTMLExportRendering::entryLink( const KeyTreeItem& item, CSwordModuleInfo* ) {
+const QString CHTMLExportRendering::entryLink(const KeyTreeItem& item,
+ const CSwordModuleInfo *module)
+{
+ Q_UNUSED(module);
+
return item.key();
}