diff options
author | Roberto C. Sanchez <roberto@connexer.com> | 2014-10-21 22:48:35 -0400 |
---|---|---|
committer | Roberto C. Sanchez <roberto@connexer.com> | 2014-10-21 22:48:35 -0400 |
commit | df8f1d512c60a96f9041f9663b3fdc2db51cba33 (patch) | |
tree | 3d2bdbd4732d417aca73be022ae9044eac96b7d3 /src/frontend/cexportmanager.cpp | |
parent | 4885bfcef4d89cf0cb391e00af617b9fd19c9cbb (diff) |
Imported Upstream version 2.8.1
Diffstat (limited to 'src/frontend/cexportmanager.cpp')
-rw-r--r-- | src/frontend/cexportmanager.cpp | 165 |
1 files changed, 102 insertions, 63 deletions
diff --git a/src/frontend/cexportmanager.cpp b/src/frontend/cexportmanager.cpp index 008963a..eaa0894 100644 --- a/src/frontend/cexportmanager.cpp +++ b/src/frontend/cexportmanager.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 "frontend/cexportmanager.h" -#include <boost/scoped_ptr.hpp> +#include <QSharedPointer> #include <QApplication> #include <QClipboard> #include <QFileDialog> @@ -35,7 +35,12 @@ using namespace Rendering; using namespace Printing; -CExportManager::CExportManager(const QString& caption, const bool showProgress, const QString& progressLabel, const CSwordBackend::FilterOptions filterOptions, const CSwordBackend::DisplayOptions displayOptions) { +CExportManager::CExportManager(const QString &caption, + const bool showProgress, + const QString &progressLabel, + const FilterOptions &filterOptions, + const DisplayOptions &displayOptions) +{ m_caption = !caption.isEmpty() ? caption : QString::fromLatin1("BibleTime"); m_progressLabel = progressLabel; m_filterOptions = filterOptions; @@ -56,7 +61,7 @@ bool CExportManager::saveKey(CSwordKey* key, const Format format, const bool add return false; } - CSwordBackend::FilterOptions filterOptions = m_filterOptions; + FilterOptions filterOptions = m_filterOptions; filterOptions.footnotes = false; filterOptions.strongNumbers = false; filterOptions.morphTags = false; @@ -65,7 +70,7 @@ bool CExportManager::saveKey(CSwordKey* key, const Format format, const bool add filterOptions.textualVariants = false; CHTMLExportRendering::Settings settings(addText); - boost::scoped_ptr<CTextRendering> render ( + QSharedPointer<CTextRendering> render ( (format == HTML) ? new CHTMLExportRendering(settings, m_displayOptions, filterOptions) : new CPlainTextExportRendering(settings, m_displayOptions, filterOptions) @@ -75,7 +80,7 @@ bool CExportManager::saveKey(CSwordKey* key, const Format format, const bool add QString startKey; QString stopKey; - QList<CSwordModuleInfo*> modules; + QList<const CSwordModuleInfo*> modules; modules.append(key->module()); CSwordVerseKey *vk = dynamic_cast<CSwordVerseKey*>(key); @@ -94,8 +99,14 @@ bool CExportManager::saveKey(CSwordKey* key, const Format format, const bool add return false; } -bool CExportManager::saveKeyList(sword::ListKey* list, CSwordModuleInfo* module, const Format format, const bool addText) { - if (!list->Count()) +bool CExportManager::saveKeyList(const sword::ListKey &l, + const CSwordModuleInfo *module, + Format format, + bool addText) +{ + /// \warning This is a workaround for Sword constness + sword::ListKey list = l; + if (!list.Count()) return false; const QString filename = getSaveFileName(format); @@ -103,7 +114,7 @@ bool CExportManager::saveKeyList(sword::ListKey* list, CSwordModuleInfo* module, return false; } - CSwordBackend::FilterOptions filterOptions = m_filterOptions; + FilterOptions filterOptions = m_filterOptions; filterOptions.footnotes = false; filterOptions.strongNumbers = false; filterOptions.morphTags = false; @@ -112,7 +123,7 @@ bool CExportManager::saveKeyList(sword::ListKey* list, CSwordModuleInfo* module, filterOptions.textualVariants = false; CHTMLExportRendering::Settings settings(addText); - boost::scoped_ptr<CTextRendering> render ( + QSharedPointer<CTextRendering> render ( (format == HTML) ? new CHTMLExportRendering(settings, m_displayOptions, filterOptions) : new CPlainTextExportRendering(settings, m_displayOptions, filterOptions) @@ -120,16 +131,16 @@ bool CExportManager::saveKeyList(sword::ListKey* list, CSwordModuleInfo* module, CTextRendering::KeyTree tree; - setProgressRange(list->Count()); + setProgressRange(list.Count()); CTextRendering::KeyTreeItem::Settings itemSettings; itemSettings.highlight = false; - *list = sword::TOP; - while (!list->Error() && !progressWasCancelled()) { - tree.append( new CTextRendering::KeyTreeItem(QString::fromLocal8Bit((const char*)(*list)) , module, itemSettings) ); + list.setPosition(sword::TOP); + while (!list.Error() && !progressWasCancelled()) { + tree.append( new CTextRendering::KeyTreeItem(QString::fromLocal8Bit((const char*)list) , module, itemSettings) ); incProgress(); - (*list)++; + list.increment(); } const QString text = render->renderKeyTree(tree); @@ -142,7 +153,10 @@ bool CExportManager::saveKeyList(sword::ListKey* list, CSwordModuleInfo* module, return false; } -bool CExportManager::saveKeyList(QList<CSwordKey*>& list, const Format format, const bool addText ) { +bool CExportManager::saveKeyList(const QList<CSwordKey*> &list, + Format format, + bool addText) +{ if (!list.count()) return false; @@ -151,7 +165,7 @@ bool CExportManager::saveKeyList(QList<CSwordKey*>& list, const Format format, c return false; } - CSwordBackend::FilterOptions filterOptions = m_filterOptions; + FilterOptions filterOptions = m_filterOptions; filterOptions.footnotes = false; filterOptions.strongNumbers = false; filterOptions.morphTags = false; @@ -160,7 +174,7 @@ bool CExportManager::saveKeyList(QList<CSwordKey*>& list, const Format format, c filterOptions.textualVariants = false; CHTMLExportRendering::Settings settings(addText); - boost::scoped_ptr<CTextRendering> render ( + QSharedPointer<CTextRendering> render ( (format == HTML) ? new CHTMLExportRendering(settings, m_displayOptions, filterOptions) : new CPlainTextExportRendering(settings, m_displayOptions, filterOptions) @@ -197,7 +211,7 @@ bool CExportManager::copyKey(CSwordKey* key, const Format format, const bool add return false; } - CSwordBackend::FilterOptions filterOptions = m_filterOptions; + FilterOptions filterOptions = m_filterOptions; filterOptions.footnotes = false; filterOptions.strongNumbers = false; filterOptions.morphTags = false; @@ -206,7 +220,7 @@ bool CExportManager::copyKey(CSwordKey* key, const Format format, const bool add filterOptions.textualVariants = false; CHTMLExportRendering::Settings settings(addText); - boost::scoped_ptr<CTextRendering> render ( + QSharedPointer<CTextRendering> render ( (format == HTML) ? new CHTMLExportRendering(settings, m_displayOptions, filterOptions) : new CPlainTextExportRendering(settings, m_displayOptions, filterOptions) @@ -216,7 +230,7 @@ bool CExportManager::copyKey(CSwordKey* key, const Format format, const bool add QString startKey; QString stopKey; - QList<CSwordModuleInfo*> modules; + QList<const CSwordModuleInfo*> modules; modules.append(key->module()); CSwordVerseKey *vk = dynamic_cast<CSwordVerseKey*>(key); @@ -235,11 +249,16 @@ bool CExportManager::copyKey(CSwordKey* key, const Format format, const bool add return true; } -bool CExportManager::copyKeyList(sword::ListKey* list, CSwordModuleInfo* module, const Format format, const bool addText) { - if (!list->Count()) +bool CExportManager::copyKeyList(const sword::ListKey &l, + const CSwordModuleInfo *module, + Format format, + bool addText) +{ + sword::ListKey list = l; + if (!list.Count()) return false; - CSwordBackend::FilterOptions filterOptions = m_filterOptions; + FilterOptions filterOptions = m_filterOptions; filterOptions.footnotes = false; filterOptions.strongNumbers = false; filterOptions.morphTags = false; @@ -248,7 +267,7 @@ bool CExportManager::copyKeyList(sword::ListKey* list, CSwordModuleInfo* module, filterOptions.textualVariants = false; CHTMLExportRendering::Settings settings(addText); - boost::scoped_ptr<CTextRendering> render ( + QSharedPointer<CTextRendering> render ( (format == HTML) ? new CHTMLExportRendering(settings, m_displayOptions, filterOptions) : new CPlainTextExportRendering(settings, m_displayOptions, filterOptions) @@ -258,11 +277,11 @@ bool CExportManager::copyKeyList(sword::ListKey* list, CSwordModuleInfo* module, CTextRendering::KeyTreeItem::Settings itemSettings; itemSettings.highlight = false; - *list = sword::TOP; - while (!list->Error() && !progressWasCancelled()) { - tree.append( new CTextRendering::KeyTreeItem(QString::fromLocal8Bit((const char*)(*list)) , module, itemSettings) ); + list.setPosition(sword::TOP); + while (!list.Error() && !progressWasCancelled()) { + tree.append( new CTextRendering::KeyTreeItem(QString::fromLocal8Bit((const char*)list) , module, itemSettings) ); - (*list)++; + list.increment(); } const QString text = render->renderKeyTree(tree); @@ -271,11 +290,14 @@ bool CExportManager::copyKeyList(sword::ListKey* list, CSwordModuleInfo* module, } -bool CExportManager::copyKeyList(QList<CSwordKey*>& list, const Format format, const bool addText ) { +bool CExportManager::copyKeyList(const QList<CSwordKey*> &list, + Format format, + bool addText) +{ if (!list.count()) return false; - CSwordBackend::FilterOptions filterOptions = m_filterOptions; + FilterOptions filterOptions = m_filterOptions; filterOptions.footnotes = false; filterOptions.strongNumbers = false; filterOptions.morphTags = false; @@ -284,7 +306,7 @@ bool CExportManager::copyKeyList(QList<CSwordKey*>& list, const Format format, c filterOptions.textualVariants = false; CHTMLExportRendering::Settings settings(addText); - boost::scoped_ptr<CTextRendering> render ( + QSharedPointer<CTextRendering> render ( (format == HTML) ? new CHTMLExportRendering(settings, m_displayOptions, filterOptions) : new CPlainTextExportRendering(settings, m_displayOptions, filterOptions) @@ -310,31 +332,42 @@ bool CExportManager::copyKeyList(QList<CSwordKey*>& list, const Format format, c return true; } -bool CExportManager::printKeyList(sword::ListKey* list, CSwordModuleInfo* module, CSwordBackend::DisplayOptions displayOptions, CSwordBackend::FilterOptions filterOptions) { +bool CExportManager::printKeyList(const sword::ListKey &l, + const CSwordModuleInfo *module, + const DisplayOptions &displayOptions, + const FilterOptions &filterOptions) +{ + /// \warning This is a workaround for Sword constness + sword::ListKey list = l; CPrinter::KeyTreeItem::Settings settings; CPrinter::KeyTree tree; QString startKey, stopKey; - setProgressRange(list->Count()); - - (*list) = sword::TOP; - while (!list->Error() && !progressWasCancelled()) { - sword::VerseKey* vk = dynamic_cast<sword::VerseKey*>(list); - if (vk) { - startKey = QString::fromUtf8((const char*)(vk->LowerBound()) ); - stopKey = QString::fromUtf8((const char*)(vk->UpperBound()) ); - tree.append( new CPrinter::KeyTreeItem(startKey, stopKey, module, settings) ); + setProgressRange(list.Count()); + + list.setPosition(sword::TOP); + while (!list.Error() && !progressWasCancelled()) { + if (dynamic_cast<const sword::VerseKey&>(l) != 0) { + const sword::VerseKey &vk = static_cast<const sword::VerseKey&>(l); + startKey = QString::fromUtf8((const char*) vk.LowerBound()); + stopKey = QString::fromUtf8((const char*) vk.UpperBound()); + tree.append(new CTextRendering::KeyTreeItem(startKey, + stopKey, + module, + settings)); } else { startKey = QString::fromUtf8((const char*) * list); - tree.append( new CPrinter::KeyTreeItem(startKey, module, settings) ); + tree.append(new CTextRendering::KeyTreeItem(startKey, + module, + settings)); } - (*list)++; + list.increment(); incProgress(); } - boost::scoped_ptr<CPrinter> printer(new CPrinter(0, displayOptions, filterOptions)); + QSharedPointer<CPrinter> printer(new CPrinter(0, displayOptions, filterOptions)); if (!progressWasCancelled()) { printer->printKeyTree(tree); @@ -345,7 +378,12 @@ bool CExportManager::printKeyList(sword::ListKey* list, CSwordModuleInfo* module return false; } -bool CExportManager::printKey( CSwordModuleInfo* module, const QString& startKey, const QString& stopKey, CSwordBackend::DisplayOptions displayOptions, CSwordBackend::FilterOptions filterOptions ) { +bool CExportManager::printKey(const CSwordModuleInfo *module, + const QString &startKey, + const QString &stopKey, + const DisplayOptions &displayOptions, + const FilterOptions &filterOptions) +{ CPrinter::KeyTreeItem::Settings settings; settings.keyRenderingFace = displayOptions.verseNumbers @@ -360,12 +398,15 @@ bool CExportManager::printKey( CSwordModuleInfo* module, const QString& startKey tree.append( new CPrinter::KeyTreeItem(startKey, module, settings) ); } - boost::scoped_ptr<CPrinter> printer(new CPrinter(0, displayOptions, filterOptions)); + QSharedPointer<CPrinter> printer(new CPrinter(0, displayOptions, filterOptions)); printer->printKeyTree(tree); return true; } -bool CExportManager::printKey( CSwordKey* key, CSwordBackend::DisplayOptions displayOptions, CSwordBackend::FilterOptions filterOptions) { +bool CExportManager::printKey(const CSwordKey *key, + const DisplayOptions &displayOptions, + const FilterOptions &filterOptions) +{ CPrinter::KeyTreeItem::Settings settings; settings.keyRenderingFace = displayOptions.verseNumbers @@ -375,13 +416,15 @@ bool CExportManager::printKey( CSwordKey* key, CSwordBackend::DisplayOptions dis CPrinter::KeyTree tree; tree.append( new CPrinter::KeyTreeItem(key->key(), key->module(), settings) ); - boost::scoped_ptr<CPrinter> printer(new CPrinter(0, displayOptions, filterOptions)); + QSharedPointer<CPrinter> printer(new CPrinter(0, displayOptions, filterOptions)); printer->printKeyTree(tree); return true; } -/** Prints a key using the hyperlink created by CReferenceManager. */ -bool CExportManager::printByHyperlink( const QString& hyperlink, CSwordBackend::DisplayOptions displayOptions, CSwordBackend::FilterOptions filterOptions ) { +bool CExportManager::printByHyperlink(const QString &hyperlink, + const DisplayOptions &displayOptions, + const FilterOptions &filterOptions) +{ QString moduleName; QString keyName; ReferenceManager::Type type; @@ -398,7 +441,7 @@ bool CExportManager::printByHyperlink( const QString& hyperlink, CSwordBackend:: ? CPrinter::KeyTreeItem::Settings::SimpleKey : CPrinter::KeyTreeItem::Settings::NoKey; - CSwordModuleInfo* module = backend()->findModuleByName(moduleName); + CSwordModuleInfo* module = CSwordBackend::instance()->findModuleByName(moduleName); Q_ASSERT(module); if (module) { @@ -426,12 +469,16 @@ bool CExportManager::printByHyperlink( const QString& hyperlink, CSwordBackend:: } } - boost::scoped_ptr<CPrinter> printer(new CPrinter(0, displayOptions, filterOptions)); + QSharedPointer<CPrinter> printer(new CPrinter(0, displayOptions, filterOptions)); printer->printKeyTree(tree); return true; } -bool CExportManager::printKeyList(const QStringList& list, CSwordModuleInfo* module, CSwordBackend::DisplayOptions displayOptions, CSwordBackend::FilterOptions filterOptions) { +bool CExportManager::printKeyList(const QStringList &list, + const CSwordModuleInfo *module, + const DisplayOptions &displayOptions, + const FilterOptions &filterOptions) +{ CPrinter::KeyTreeItem::Settings settings; settings.keyRenderingFace = displayOptions.verseNumbers @@ -447,7 +494,7 @@ bool CExportManager::printKeyList(const QStringList& list, CSwordModuleInfo* mod incProgress(); } - boost::scoped_ptr<CPrinter> printer(new CPrinter(0, displayOptions, filterOptions)); + QSharedPointer<CPrinter> printer(new CPrinter(0, displayOptions, filterOptions)); if (!progressWasCancelled()) { printer->printKeyTree(tree); @@ -475,14 +522,6 @@ const QString CExportManager::getSaveFileName(const Format format) { return QFileDialog::getSaveFileName(0, QObject::tr("Save file"), "", filterString(format), 0); } -/** Returns a string containing the linebreak for the current format. */ -const QString CExportManager::lineBreak(const Format format) { - if (static_cast<bool>(m_displayOptions.lineBreaks)) - return (format == HTML) ? QString::fromLatin1("<br/>\n") : QString::fromLatin1("\n"); - - return QString::null; -} - /** No descriptions */ void CExportManager::setProgressRange( const int items ) { if (QProgressDialog* dlg = progressDialog()) { |