From df8f1d512c60a96f9041f9663b3fdc2db51cba33 Mon Sep 17 00:00:00 2001 From: "Roberto C. Sanchez" Date: Tue, 21 Oct 2014 22:48:35 -0400 Subject: Imported Upstream version 2.8.1 --- src/backend/rendering/cbookdisplay.cpp | 32 +++++--- src/backend/rendering/cbookdisplay.h | 39 +++++----- src/backend/rendering/cchapterdisplay.cpp | 21 +++-- src/backend/rendering/cchapterdisplay.h | 29 +++---- src/backend/rendering/cdisplayrendering.cpp | 24 +++--- src/backend/rendering/cdisplayrendering.h | 10 ++- src/backend/rendering/centrydisplay.cpp | 16 ++-- src/backend/rendering/centrydisplay.h | 27 +++---- src/backend/rendering/chtmlexportrendering.cpp | 85 +++++++++++--------- src/backend/rendering/chtmlexportrendering.h | 18 +++-- .../rendering/cplaintextexportrendering.cpp | 32 +++++--- src/backend/rendering/cplaintextexportrendering.h | 10 +-- src/backend/rendering/ctextrendering.cpp | 90 +++++++++++++--------- src/backend/rendering/ctextrendering.h | 49 ++++++++---- 14 files changed, 279 insertions(+), 203 deletions(-) (limited to 'src/backend/rendering') diff --git a/src/backend/rendering/cbookdisplay.cpp b/src/backend/rendering/cbookdisplay.cpp index 9da57f2..259e904 100644 --- a/src/backend/rendering/cbookdisplay.cpp +++ b/src/backend/rendering/cbookdisplay.cpp @@ -2,14 +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/cbookdisplay.h" -#include +#include #include #include "backend/drivers/cswordbookmoduleinfo.h" @@ -17,12 +17,18 @@ #include "backend/rendering/cdisplayrendering.h" -/** Returns the rendered text using the modules in the list and using the key parameter. The displayoptions and filter options are used, too. */ -const QString Rendering::CBookDisplay::text( const QList& modules, const QString& keyName, const CSwordBackend::DisplayOptions displayOptions, const CSwordBackend::FilterOptions filterOptions ) { - CSwordBookModuleInfo* book = dynamic_cast(modules.first()); +const QString Rendering::CBookDisplay::text( + const QList &modules, + const QString &keyName, + const DisplayOptions &displayOptions, + const FilterOptions &filterOptions) +{ + typedef CSwordBookModuleInfo CSBMI; + + const CSBMI* book = dynamic_cast(modules.first()); Q_ASSERT(book); - CSwordBackend::DisplayOptions dOpts = displayOptions; + DisplayOptions dOpts = displayOptions; dOpts.lineBreaks = true; //books should render with blocks, not with inlined sections CDisplayRendering render(dOpts, filterOptions); @@ -32,10 +38,10 @@ const QString Rendering::CBookDisplay::text( const QList& mod // the number of levels which should be display together, 1 means display no entries together int displayLevel = book->config( CSwordModuleInfo::DisplayLevel ).toInt(); - boost::scoped_ptr key ( + QSharedPointer key ( dynamic_cast( CSwordKey::createInstance(book) ) ); - key->key(keyName); //set the key to position we'd like to get + key->setKey(keyName); //set the key to position we'd like to get const unsigned long offset = key->getOffset(); @@ -60,7 +66,7 @@ const QString Rendering::CBookDisplay::text( const QList& mod int possibleLevels = 1; //we start with the default value of displayLevel, which means no entries together - while ( key->parent() && (key->key() != "/") && !key->key().isEmpty() ) {//add parents + while ( key->sword::TreeKeyIdx::parent() && (key->key() != "/") && !key->key().isEmpty() ) {//add parents ++possibleLevels; }; @@ -90,7 +96,7 @@ const QString Rendering::CBookDisplay::text( const QList& mod // at the moment we're at the lowest level, so we only have to go up! for (int currentLevel = 1; currentLevel < displayLevel; ++currentLevel) { //we start again with 1 == standard of displayLevel - if ( !key->parent() ) { //something went wrong although we checked before! Be safe and return entry's text + if ( !key->sword::TreeKeyIdx::parent() ) { //something went wrong although we checked before! Be safe and return entry's text tree.append( new CDisplayRendering::KeyTreeItem( key->key(), modules, itemSettings ) ); const QString renderedText = render.renderKeyTree(tree); @@ -108,7 +114,7 @@ const QString Rendering::CBookDisplay::text( const QList& mod //const bool hasToplevelText = !key->strippedText().isEmpty(); key->firstChild(); //go to the first sibling on the same level - setupRenderTree(key.get(), &tree, keyName); + setupRenderTree(key.data(), &tree, keyName); const QString renderedText = render.renderKeyTree(tree); @@ -126,7 +132,9 @@ void Rendering::CBookDisplay::setupRenderTree(CSwordTreeKey * swordTree, CTextRe CTextRendering::KeyTreeItem::Settings settings; settings.highlight = (key == highlightKey); - CTextRendering::KeyTreeItem* item = new CTextRendering::KeyTreeItem(key, swordTree->module(0), settings ); + /// \todo Check whether this is correct: + CTextRendering::KeyTreeItem *item = new CTextRendering::KeyTreeItem( + key, swordTree->module(), settings); renderTree->append( item ); if (swordTree->hasChildren()) { //print tree for the child items diff --git a/src/backend/rendering/cbookdisplay.h b/src/backend/rendering/cbookdisplay.h index 832249f..be5ec9b 100644 --- a/src/backend/rendering/cbookdisplay.h +++ b/src/backend/rendering/cbookdisplay.h @@ -2,7 +2,7 @@ * * 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. * **********/ @@ -20,26 +20,27 @@ class CSwordTreeKey; namespace Rendering { /** -* A CEntryDisplay implementation which works on tree-based GenBook modules -* of Sword. -* @short CEntryDisplay implementation for GenBook modules, -* @author The BibleTime team -*/ - -class CBookDisplay : public CEntryDisplay { - public: // Public methods - virtual ~CBookDisplay() {} +* \brief CEntryDisplay implementation for GenBook modules, - /** - * Returns the rendered text using the modules in the list and using the key parameter. - * The displayoptions and filter options are used, too. - */ - virtual const QString text( const QList& modules, const QString& key, const CSwordBackend::DisplayOptions displayOptions, const CSwordBackend::FilterOptions filterOptions); - - protected: - void setupRenderTree(CSwordTreeKey* swordTree, CTextRendering::KeyTree* renderTree, const QString& highlightKey); + A CEntryDisplay implementation which works on tree-based GenBook modules of + Sword. +*/ +class CBookDisplay: public CEntryDisplay { + public: /* Methods: */ + virtual inline ~CBookDisplay() {} + + /** Reimplemented from CEntryDisplay. */ + virtual const QString text(const QList &modules, + const QString &key, + const DisplayOptions &displayOptions, + const FilterOptions &filterOptions); + + protected: /* Methods: */ + void setupRenderTree(CSwordTreeKey *swordTree, + CTextRendering::KeyTree *renderTree, + const QString &highlightKey); }; -} +} // namespace Rendering #endif diff --git a/src/backend/rendering/cchapterdisplay.cpp b/src/backend/rendering/cchapterdisplay.cpp index 74063cf..31b56b8 100644 --- a/src/backend/rendering/cchapterdisplay.cpp +++ b/src/backend/rendering/cchapterdisplay.cpp @@ -2,7 +2,7 @@ * * 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. * **********/ @@ -14,11 +14,18 @@ #include "backend/rendering/cdisplayrendering.h" -const QString Rendering::CChapterDisplay::text( const QList& modules, const QString& keyName, const CSwordBackend::DisplayOptions displayOptions, const CSwordBackend::FilterOptions filterOptions ) { +const QString Rendering::CChapterDisplay::text( + const QList &modules, + const QString &keyName, + const DisplayOptions &displayOptions, + const FilterOptions &filterOptions) +{ + typedef CSwordBibleModuleInfo CSBMI; + Q_ASSERT( modules.count() >= 1 ); Q_ASSERT( !keyName.isEmpty() ); - CSwordModuleInfo* module = modules.first(); + const CSwordModuleInfo *module = modules.first(); if (modules.count() == 1) module->module()->setSkipConsecutiveLinks( true ); //skip empty, linked verses @@ -37,14 +44,14 @@ const QString Rendering::CChapterDisplay::text( const QList& if (module->type() == CSwordModuleInfo::Bible) { ((sword::VerseKey*)(module->module()->getKey()))->Headings(1); //HACK: enable headings for VerseKeys - CSwordBibleModuleInfo* bible = dynamic_cast(module); - Q_ASSERT(bible); + Q_ASSERT(dynamic_cast(module) != 0); + const CSBMI *bible = static_cast(module); CSwordVerseKey k1(module); k1.Headings(1); - k1.key(keyName); + k1.setKey(keyName); - if (k1.Chapter() == 1) k1.Chapter(0); //Chapter 1, start with 0:0, otherwise X:0 + if (k1.Chapter() == 1) k1.Chapter(0); //Chapter 1, start with 0:0, otherwise X:0 k1.Verse(0); diff --git a/src/backend/rendering/cchapterdisplay.h b/src/backend/rendering/cchapterdisplay.h index 3b3d363..a13ebc3 100644 --- a/src/backend/rendering/cchapterdisplay.h +++ b/src/backend/rendering/cchapterdisplay.h @@ -2,7 +2,7 @@ * * 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. * **********/ @@ -15,24 +15,25 @@ namespace Rendering { -/** Chapter rendering. -* A CEntryDisplay implementation mde for Bibles to display whole chapters -* at once. -* @author The BibleTime team -*/ - -class CChapterDisplay : public CEntryDisplay { +/** + \brief CEntryDisplay implementation for whole chapters. - public: // Public methods - virtual ~CChapterDisplay() {} + A CEntryDisplay implementation made for Bibles to display whole chapters at + once. +*/ +class CChapterDisplay: public CEntryDisplay { + public: /* Methods: */ + virtual inline ~CChapterDisplay() {} /** - * Returns the rendered text using the modules in the list and using the key parameter. - * The displayoptions and filter options are used, too. + Reimplemented from CEntryDisplay. */ - virtual const QString text( const QList& modules, const QString& key, const CSwordBackend::DisplayOptions displayOptions, const CSwordBackend::FilterOptions filterOptions); + virtual const QString text(const QList &modules, + const QString &key, + const DisplayOptions &displayOptions, + const FilterOptions &filterOptions); }; -} +} // namespace Rendering #endif diff --git a/src/backend/rendering/cdisplayrendering.cpp b/src/backend/rendering/cdisplayrendering.cpp index cc3f7c9..c79cfdf 100644 --- a/src/backend/rendering/cdisplayrendering.cpp +++ b/src/backend/rendering/cdisplayrendering.cpp @@ -2,7 +2,7 @@ * * 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. * **********/ @@ -16,15 +16,21 @@ #include "backend/keys/cswordversekey.h" #include "backend/managers/cdisplaytemplatemgr.h" #include "backend/managers/referencemanager.h" -#include "util/cpointers.h" namespace Rendering { -CDisplayRendering::CDisplayRendering(CSwordBackend::DisplayOptions displayOptions, CSwordBackend::FilterOptions filterOptions) - : CHTMLExportRendering(CHTMLExportRendering::Settings(true), displayOptions, filterOptions) {} +CDisplayRendering::CDisplayRendering(const DisplayOptions &displayOptions, + const FilterOptions &filterOptions) + : CHTMLExportRendering(CHTMLExportRendering::Settings(true), + displayOptions, filterOptions) +{ + // Intentionally empty +} -const QString CDisplayRendering::entryLink( const KeyTreeItem& item, CSwordModuleInfo* module ) { +const QString CDisplayRendering::entryLink(const KeyTreeItem &item, + const CSwordModuleInfo *module) +{ QString linkText; const bool isBible = module && (module->type() == CSwordModuleInfo::Bible); @@ -32,7 +38,7 @@ const QString CDisplayRendering::entryLink( const KeyTreeItem& item, CSwordModul vk.Headings(true); if (isBible) { - vk.key(item.key()); + vk.setKey(item.key()); } if (isBible && (vk.Verse() == 0)) { @@ -105,7 +111,7 @@ const QString CDisplayRendering::keyToHTMLAnchor(const QString& key) { } const QString CDisplayRendering::finishText( const QString& oldText, KeyTree& tree ) { - QList modules = collectModules(&tree); + QList modules = collectModules(&tree); qDebug() << "CDisplayRendering::finishText"; //marking words is very slow, we have to find a better solution @@ -139,9 +145,9 @@ const QString CDisplayRendering::finishText( const QString& oldText, KeyTree& tr const CLanguageMgr::Language* const lang = (modules.count() >= 1) ? modules.first()->language() - : CPointers::languageMgr()->defaultLanguage(); + : CLanguageMgr::instance()->defaultLanguage(); - CDisplayTemplateMgr* tMgr = CPointers::displayTemplateManager(); + CDisplayTemplateMgr *tMgr = CDisplayTemplateMgr::instance(); //Q_ASSERT(modules.count() >= 1); diff --git a/src/backend/rendering/cdisplayrendering.h b/src/backend/rendering/cdisplayrendering.h index f66e556..8b222ac 100644 --- a/src/backend/rendering/cdisplayrendering.h +++ b/src/backend/rendering/cdisplayrendering.h @@ -2,7 +2,7 @@ * * 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. * **********/ @@ -25,12 +25,14 @@ class CDisplayRendering : public CHTMLExportRendering { static const QString keyToHTMLAnchor(const QString& key); CDisplayRendering( - CSwordBackend::DisplayOptions displayOptions = CBTConfig::getDisplayOptionDefaults(), - CSwordBackend::FilterOptions filterOptions = CBTConfig::getFilterOptionDefaults() + const DisplayOptions &displayOptions = CBTConfig::getDisplayOptionDefaults(), + const FilterOptions &filterOptions = CBTConfig::getFilterOptionDefaults() ); protected: - virtual const QString entryLink( const KeyTreeItem& item, CSwordModuleInfo* const module ); + virtual const QString entryLink(const KeyTreeItem &item, + const CSwordModuleInfo *module); + virtual const QString finishText( const QString&, KeyTree& tree ); }; diff --git a/src/backend/rendering/centrydisplay.cpp b/src/backend/rendering/centrydisplay.cpp index b6c7a27..d1b2a34 100644 --- a/src/backend/rendering/centrydisplay.cpp +++ b/src/backend/rendering/centrydisplay.cpp @@ -2,7 +2,7 @@ * * 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. * **********/ @@ -24,15 +24,17 @@ using namespace Rendering; -/** Returns the rendered text using the modules in the list and using the key parameter. - * The displayoptions and filter options are used, too. - */ -const QString CEntryDisplay::text( const QList& modules, const QString& keyName, const CSwordBackend::DisplayOptions displayOptions, const CSwordBackend::FilterOptions filterOptions ) { +const QString CEntryDisplay::text( + const QList &modules, + const QString &keyName, + const DisplayOptions &displayOptions, + const FilterOptions &filterOptions) +{ CDisplayRendering render(displayOptions, filterOptions); //no highlighted key and no extra key link in the text CTextRendering::KeyTreeItem::Settings normal_settings(false, CTextRendering::KeyTreeItem::Settings::CompleteShort); - CSwordModuleInfo* module = modules.first(); + const CSwordModuleInfo *module = modules.first(); Rendering::CTextRendering::KeyTree tree; @@ -42,7 +44,7 @@ const QString CEntryDisplay::text( const QList& modules, cons CSwordVerseKey k1(module); k1.Headings(1); - k1.key(keyName); + k1.setKey(keyName); // don't print the key CTextRendering::KeyTreeItem::Settings preverse_settings(false, CTextRendering::KeyTreeItem::Settings::NoKey); diff --git a/src/backend/rendering/centrydisplay.h b/src/backend/rendering/centrydisplay.h index 5f410a5..08a55c4 100644 --- a/src/backend/rendering/centrydisplay.h +++ b/src/backend/rendering/centrydisplay.h @@ -2,7 +2,7 @@ * * 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. * **********/ @@ -10,35 +10,28 @@ #ifndef CENTRYDISPLAY_H #define CENTRYDISPLAY_H -#include "util/cpointers.h" - #include -#include "backend/managers/cswordbackend.h" // Sword includes: #include class CSwordModuleInfo; +struct DisplayOptions; +struct FilterOptions; namespace Rendering { -/** -* The reimplementation of SWDisplay to fit our needs. -* @short Display implementation -* @author The BibleTime team -*/ - -class CEntryDisplay : public sword::SWDisplay, public CPointers { - +class CEntryDisplay: public sword::SWDisplay { public: - virtual ~CEntryDisplay() {} - /** - * Returns the rendered text using the modules in the list and using the key parameter. - * The displayoptions and filter options are used, too. + \returns the rendered text using the modules in the list and using the + key parameter. */ - virtual const QString text( const QList& modules, const QString& key, const CSwordBackend::DisplayOptions displayOptions, const CSwordBackend::FilterOptions filterOptions); + virtual const QString text(const QList &modules, + const QString &key, + const DisplayOptions &displayOptions, + const FilterOptions &filterOptions); }; 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 -#include +#include #include #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 modules = collectModules(tree); + const QList 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& modules( i.modules() ); + const QList &modules(i.modules()); if (modules.count() == 0) { return QString(""); //no module present for rendering } - boost::scoped_ptr scoped_key( !k ? CSwordKey::createInstance(modules.first()) : 0 ); - CSwordKey* key = k ? k : scoped_key.get(); + QSharedPointer scoped_key( !k ? CSwordKey::createInstance(modules.first()) : 0 ); + CSwordKey* key = k ? k : scoped_key.data(); Q_ASSERT(key); CSwordVerseKey* myVK = dynamic_cast(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::const_iterator end_modItr = modules.end(); + QList::const_iterator end_modItr = modules.end(); - for (QList::const_iterator mod_Itr(modules.begin()); mod_Itr != end_modItr; ++mod_Itr) { - key->module(*mod_Itr); - key->key( i.key() ); + for (QList::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("(.*)"); + if (unfiltered.indexOf(filter) >= 0) { + preverseHeading = filter.cap(1); + } else { + preverseHeading = unfiltered; + } + /// \todo Take care of the heading type! if (!preverseHeading.isEmpty()) { entry.append("
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 modules = collectModules(&tree); + const QList 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(); } diff --git a/src/backend/rendering/chtmlexportrendering.h b/src/backend/rendering/chtmlexportrendering.h index 065bb85..97e632d 100644 --- a/src/backend/rendering/chtmlexportrendering.h +++ b/src/backend/rendering/chtmlexportrendering.h @@ -2,7 +2,7 @@ * * 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. * **********/ @@ -14,6 +14,7 @@ #include "backend/config/cbtconfig.h" #include "backend/managers/cswordbackend.h" +#include "btglobal.h" namespace Rendering { @@ -37,20 +38,21 @@ class CHTMLExportRendering : public CTextRendering { }; CHTMLExportRendering( - const Settings& settings, - CSwordBackend::DisplayOptions displayOptions = CBTConfig::getDisplayOptionDefaults(), - CSwordBackend::FilterOptions filterOptions = CBTConfig::getFilterOptionDefaults() + const Settings &settings, + const DisplayOptions &displayOptions = CBTConfig::getDisplayOptionDefaults(), + const FilterOptions &filterOptions = CBTConfig::getFilterOptionDefaults() ); - virtual ~CHTMLExportRendering(); + virtual inline ~CHTMLExportRendering() {}; protected: virtual const QString renderEntry( const KeyTreeItem&, CSwordKey* = 0 ); virtual const QString finishText( const QString&, KeyTree& tree ); - virtual const QString entryLink( const KeyTreeItem& item, CSwordModuleInfo* module ); + virtual const QString entryLink(const KeyTreeItem &item, + const CSwordModuleInfo *module); virtual void initRendering(); - CSwordBackend::DisplayOptions m_displayOptions; - CSwordBackend::FilterOptions m_filterOptions; + DisplayOptions m_displayOptions; + FilterOptions m_filterOptions; Settings m_settings; }; diff --git a/src/backend/rendering/cplaintextexportrendering.cpp b/src/backend/rendering/cplaintextexportrendering.cpp index fdbf78d..cad5eb9 100644 --- a/src/backend/rendering/cplaintextexportrendering.cpp +++ b/src/backend/rendering/cplaintextexportrendering.cpp @@ -2,40 +2,48 @@ * * 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/cplaintextexportrendering.h" -#include +#include #include "backend/keys/cswordkey.h" namespace Rendering { -CPlainTextExportRendering::CPlainTextExportRendering(const CPlainTextExportRendering::Settings& settings, CSwordBackend::DisplayOptions displayOptions, CSwordBackend::FilterOptions filterOptions) - : CHTMLExportRendering(settings, displayOptions, filterOptions) {} +CPlainTextExportRendering::CPlainTextExportRendering( + const CPlainTextExportRendering::Settings &settings, + const DisplayOptions &displayOptions, + const FilterOptions &filterOptions) + : CHTMLExportRendering(settings, displayOptions, filterOptions) +{ + // Intentionally empty +} -CPlainTextExportRendering::~CPlainTextExportRendering() {} +const QString CPlainTextExportRendering::renderEntry(const KeyTreeItem &i, + CSwordKey *k) +{ + Q_UNUSED(k); -const QString CPlainTextExportRendering::renderEntry( const KeyTreeItem& i, CSwordKey* ) { if (!m_settings.addText) { return QString(i.key()).append("\n"); } - QList modules = i.modules(); - boost::scoped_ptr key( CSwordKey::createInstance(modules.first()) ); + QList modules = i.modules(); + QSharedPointer key( CSwordKey::createInstance(modules.first()) ); QString renderedText = QString(i.key()).append(":\n"); QString entry; // for (CSwordModuleInfo* m = modules.first(); m; m = modules.next()) { - QList::iterator end_it = modules.end(); + QList::iterator end_it = modules.end(); - for (QList::iterator it(modules.begin()); it != end_it; ++it) { - key->module(*it); - key->key( i.key() ); + for (QList::iterator it(modules.begin()); it != end_it; ++it) { + key->setModule(*it); + key->setKey(i.key()); /// \todo Check this code entry.append(key->strippedText()).append("\n"); diff --git a/src/backend/rendering/cplaintextexportrendering.h b/src/backend/rendering/cplaintextexportrendering.h index 5ebbb24..d14192e 100644 --- a/src/backend/rendering/cplaintextexportrendering.h +++ b/src/backend/rendering/cplaintextexportrendering.h @@ -2,7 +2,7 @@ * * 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. * **********/ @@ -25,11 +25,11 @@ class CPlainTextExportRendering : public CHTMLExportRendering { public: CPlainTextExportRendering( - const Settings& settings, - CSwordBackend::DisplayOptions displayOptions = CBTConfig::getDisplayOptionDefaults(), - CSwordBackend::FilterOptions filterOptions = CBTConfig::getFilterOptionDefaults() + const Settings &settings, + const DisplayOptions &displayOptions = CBTConfig::getDisplayOptionDefaults(), + const FilterOptions &filterOptions = CBTConfig::getFilterOptionDefaults() ); - virtual ~CPlainTextExportRendering(); + virtual inline ~CPlainTextExportRendering() {}; protected: virtual const QString renderEntry( const KeyTreeItem&, CSwordKey* = 0 ); diff --git a/src/backend/rendering/ctextrendering.cpp b/src/backend/rendering/ctextrendering.cpp index 645b5d6..586d11e 100644 --- a/src/backend/rendering/ctextrendering.cpp +++ b/src/backend/rendering/ctextrendering.cpp @@ -2,14 +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/ctextrendering.h" -#include +#include #include #include @@ -26,17 +26,20 @@ using namespace Rendering; -CTextRendering::KeyTreeItem::KeyTreeItem(const QString& key, CSwordModuleInfo const * mod, const Settings settings ) - : m_settings( settings ), +CTextRendering::KeyTreeItem::KeyTreeItem(const QString &key, + const CSwordModuleInfo *module, + const Settings &settings) + : m_settings(settings), m_moduleList(), m_key( key ), m_childList(), m_stopKey( QString::null ), m_alternativeContent( QString::null ) { - m_moduleList.append( const_cast(mod) ); //BAD CODE + m_moduleList.append( const_cast(module) ); //BAD CODE } -CTextRendering::KeyTreeItem::KeyTreeItem(const QString& content, const Settings settings ) +CTextRendering::KeyTreeItem::KeyTreeItem(const QString &content, + const Settings &settings) : m_settings( settings ), m_moduleList(), m_key( QString::null ), @@ -45,7 +48,9 @@ CTextRendering::KeyTreeItem::KeyTreeItem(const QString& content, const Settings m_alternativeContent( content ) { } -CTextRendering::KeyTreeItem::KeyTreeItem(const QString& key, const QList& mods, const Settings settings ) +CTextRendering::KeyTreeItem::KeyTreeItem(const QString &key, + const QList &mods, + const Settings &settings) : m_settings( settings ), m_moduleList( mods ), m_key( key ), @@ -76,11 +81,10 @@ CTextRendering::KeyTreeItem::KeyTreeItem(const KeyTreeItem& i) } -CTextRendering::KeyTreeItem::~KeyTreeItem() { - qDeleteAll(m_childList); -} - -CTextRendering::KeyTreeItem::KeyTreeItem(const QString& startKey, const QString& stopKey, CSwordModuleInfo* module, const Settings settings) +CTextRendering::KeyTreeItem::KeyTreeItem(const QString &startKey, + const QString &stopKey, + const CSwordModuleInfo *module, + const Settings &settings) : m_settings( settings ), m_moduleList(), m_key( startKey ), @@ -94,10 +98,10 @@ CTextRendering::KeyTreeItem::KeyTreeItem(const QString& startKey, const QString& if (module->type() == CSwordModuleInfo::Bible) { CSwordVerseKey start(module); - start.key(startKey); + start.setKey(startKey); CSwordVerseKey stop(module); - stop.key(stopKey); + stop.setKey(stopKey); if (!m_key.isEmpty() && !m_stopKey.isEmpty()) { //we have a range of keys bool ok = true; @@ -154,13 +158,13 @@ const QString& CTextRendering::KeyTreeItem::getAlternativeContent() const { return m_alternativeContent; } -const QList CTextRendering::collectModules(KeyTree* const tree) const { +const QList CTextRendering::collectModules(KeyTree* const tree) const { //collect all modules which are available and used by child items - QList modules; + QList modules; foreach (KeyTreeItem* c, (*tree)) { Q_ASSERT(c); - foreach (CSwordModuleInfo* mod, c->modules()) { + foreach (const CSwordModuleInfo* mod, c->modules()) { if (!modules.contains(mod)) { modules.append(mod); } @@ -172,20 +176,22 @@ const QList CTextRendering::collectModules(KeyTree* const tre const QString CTextRendering::renderKeyTree( KeyTree& tree ) { initRendering(); - QList modules = collectModules(&tree); + QList modules = collectModules(&tree); QString t; //optimization for entries with the same key - boost::scoped_ptr key( + QSharedPointer key( (modules.count() == 1) ? CSwordKey::createInstance(modules.first()) : 0 ); - foreach (KeyTreeItem* c, tree) { - if (modules.count() == 1) { //this optimizes the rendering, only one key created for all items - key->key( c->key() ); - t.append( renderEntry( *c, key.get()) ); + if (modules.count() == 1) { //this optimizes the rendering, only one key created for all items + foreach (KeyTreeItem* c, tree) { + key->setKey(c->key()); + t.append( renderEntry( *c, key.data()) ); } - else { + } + else { + foreach (KeyTreeItem* c, tree) { t.append( renderEntry( *c ) ); } } @@ -193,19 +199,25 @@ const QString CTextRendering::renderKeyTree( KeyTree& tree ) { return finishText(t, tree); } -const QString CTextRendering::renderKeyRange( const QString& start, const QString& stop, const QList& modules, const QString& highlightKey, const KeyTreeItem::Settings& keySettings ) { +const QString CTextRendering::renderKeyRange( + const QString &start, + const QString &stop, + const QList &modules, + const QString &highlightKey, + const KeyTreeItem::Settings &keySettings) +{ - CSwordModuleInfo* module = modules.first(); + const CSwordModuleInfo *module = modules.first(); //qWarning( "renderKeyRange start %s stop %s \n", start.latin1(), stop.latin1() ); - boost::scoped_ptr lowerBound( CSwordKey::createInstance(module) ); - lowerBound->key(start); + QSharedPointer lowerBound( CSwordKey::createInstance(module) ); + lowerBound->setKey(start); - boost::scoped_ptr upperBound( CSwordKey::createInstance(module) ); - upperBound->key(stop); + QSharedPointer upperBound( CSwordKey::createInstance(module) ); + upperBound->setKey(stop); - sword::SWKey* sw_start = dynamic_cast(lowerBound.get()); - sword::SWKey* sw_stop = dynamic_cast(upperBound.get()); + sword::SWKey* sw_start = dynamic_cast(lowerBound.data()); + sword::SWKey* sw_stop = dynamic_cast(upperBound.data()); Q_ASSERT((*sw_start == *sw_stop) || (*sw_start < *sw_stop)); @@ -216,10 +228,10 @@ const QString CTextRendering::renderKeyRange( const QString& start, const QStrin KeyTree tree; KeyTreeItem::Settings settings = keySettings; - CSwordVerseKey* vk_start = dynamic_cast(lowerBound.get()); + CSwordVerseKey* vk_start = dynamic_cast(lowerBound.data()); Q_ASSERT(vk_start); - CSwordVerseKey* vk_stop = dynamic_cast(upperBound.get()); + CSwordVerseKey* vk_stop = dynamic_cast(upperBound.data()); Q_ASSERT(vk_stop); bool ok = true; @@ -250,13 +262,15 @@ const QString CTextRendering::renderKeyRange( const QString& start, const QStrin return QString::null; } -const QString CTextRendering::renderSingleKey( const QString& key, const QList& moduleList, const KeyTreeItem::Settings& settings ) { +const QString CTextRendering::renderSingleKey( + const QString &key, + const QList &modules, + const KeyTreeItem::Settings &settings) +{ KeyTree tree; - tree.append( new KeyTreeItem(key, moduleList, settings) ); + tree.append( new KeyTreeItem(key, modules, settings) ); const QString renderedText = renderKeyTree(tree); qDeleteAll(tree); return renderedText; } - - diff --git a/src/backend/rendering/ctextrendering.h b/src/backend/rendering/ctextrendering.h index b6dd5e1..c6b187a 100644 --- a/src/backend/rendering/ctextrendering.h +++ b/src/backend/rendering/ctextrendering.h @@ -2,7 +2,7 @@ * * 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. * **********/ @@ -53,13 +53,26 @@ class CTextRendering { KeyRenderingFace keyRenderingFace; }; - KeyTreeItem(const QString& key, CSwordModuleInfo const * module, const Settings settings); - KeyTreeItem(const QString& key, const QList& modules, const Settings settings); - KeyTreeItem(const QString& startKey, const QString& stopKey, CSwordModuleInfo* module, const Settings settings); - KeyTreeItem(const QString& content, const Settings settings); - KeyTreeItem(const KeyTreeItem& i); + KeyTreeItem(const QString &key, + const CSwordModuleInfo *module, + const Settings &settings); - virtual ~KeyTreeItem(); + KeyTreeItem(const QString &key, + const QList &modules, + const Settings &settings); + + KeyTreeItem(const QString &startKey, + const QString &stopKey, + const CSwordModuleInfo *module, + const Settings &settings); + + KeyTreeItem(const QString &content, const Settings &settings); + + KeyTreeItem(const KeyTreeItem &i); + + virtual inline ~KeyTreeItem() { + qDeleteAll(m_childList); + } const QString& getAlternativeContent() const; inline void setAlternativeContent(const QString& newContent) { @@ -70,7 +83,7 @@ class CTextRendering { return !m_alternativeContent.isNull(); }; - inline const QList& modules() const { + inline const QList& modules() const { return m_moduleList; }; @@ -83,13 +96,13 @@ class CTextRendering { }; inline KeyTree* childList() const; -// inline const bool hasChildItems() const; +// inline const bool hasChildItems() const; protected: KeyTreeItem(); Settings m_settings; - QList m_moduleList; + QList m_moduleList; QString m_key; mutable KeyTree m_childList; @@ -101,12 +114,20 @@ class CTextRendering { const QString renderKeyTree( KeyTree& ); - const QString renderKeyRange( const QString& start, const QString& stop, const QList& modules, const QString& hightlightKey = QString::null, const KeyTreeItem::Settings& settings = KeyTreeItem::Settings() ); + const QString renderKeyRange( + const QString &start, + const QString &stop, + const QList &modules, + const QString &hightlightKey = QString::null, + const KeyTreeItem::Settings &settings = KeyTreeItem::Settings()); - const QString renderSingleKey( const QString& key, const QList&, const KeyTreeItem::Settings& settings = KeyTreeItem::Settings() ); + const QString renderSingleKey( + const QString &key, + const QList &modules, + const KeyTreeItem::Settings &settings = KeyTreeItem::Settings()); protected: - const QList collectModules(KeyTree* const tree) const; + const QList collectModules(KeyTree* const tree) const; virtual const QString renderEntry( const KeyTreeItem&, CSwordKey* = 0 ) = 0; virtual const QString finishText( const QString&, KeyTree& tree ) = 0; virtual void initRendering() = 0; @@ -117,7 +138,7 @@ inline CTextRendering::KeyTree* CTextRendering::KeyTreeItem::childList() const { } // //inline const bool CTextRendering::KeyTreeItem::hasChildItems() const { -// return !m_childList.isEmpty(); +// return !m_childList.isEmpty(); //} } -- cgit v1.2.3