summaryrefslogtreecommitdiff
path: root/src/backend/managers/referencemanager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/managers/referencemanager.cpp')
-rw-r--r--src/backend/managers/referencemanager.cpp46
1 files changed, 15 insertions, 31 deletions
diff --git a/src/backend/managers/referencemanager.cpp b/src/backend/managers/referencemanager.cpp
index 4fc5e53..de41af2 100644
--- a/src/backend/managers/referencemanager.cpp
+++ b/src/backend/managers/referencemanager.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.
*
**********/
@@ -10,12 +10,10 @@
#include "backend/managers/referencemanager.h"
#include <algorithm>
-
#include <QRegExp>
#include <QDebug>
#include "backend/config/cbtconfig.h"
#include "backend/keys/cswordversekey.h"
-#include "util/cpointers.h"
/** Returns a hyperlink used to be imbedded in the display windows. At the moment the format is sword://module/key */
@@ -87,15 +85,15 @@ const QString ReferenceManager::encodeHyperlink( const QString moduleName, const
case Bible: //bibles or commentary keys need parsing
case Commentary: {
- /* CSwordModuleInfo* mod = CPointers::backend()->findModuleByName(moduleName);
+ /* CSwordModuleInfo* mod = CSwordBackend::instance()()->findModuleByName(moduleName);
- ParseOptions options;
- options.refDestinationModule = mod->name();
- options.refBase =
- options.sourceLanguage = mod->module()->Lang();
- options.destinationLanguage = "en";
+ ParseOptions options;
+ options.refDestinationModule = mod->name();
+ options.refBase =
+ options.sourceLanguage = mod->module()->Lang();
+ options.destinationLanguage = "en";
- ret.append( parseVerseReference(key, options) ); //we add the english key, so drag and drop will work in all cases*/
+ ret.append( parseVerseReference(key, options) ); //we add the english key, so drag and drop will work in all cases*/
ret.append(key);
break;
}
@@ -237,20 +235,6 @@ bool ReferenceManager::decodeHyperlink( const QString& hyperlink, QString& modul
return true;
}
-const QString ReferenceManager::encodeReference(const QString &module, const QString &reference) {
- //return QString("(%1)%2").arg(module).arg(reference);
- return QString("(").append(module).append(")").append(reference);
-}
-
-void ReferenceManager::decodeReference(QString &dragreference, QString &module, QString &reference) {
- const int pos = dragreference.indexOf(")");
- const QString fallbackModule = dragreference.mid( 1, pos - 1);
- dragreference = dragreference.mid(pos + 1);
-
- module = fallbackModule;
- reference = dragreference;
-}
-
/** Returns true if the parameter is a hyperlink. */
bool ReferenceManager::isHyperlink( const QString& hyperlink ) {
return ( hyperlink.left(8) == "sword://")
@@ -341,7 +325,7 @@ ReferenceManager::Type ReferenceManager::typeFromModule( const CSwordModuleInfo:
/** Parses the given verse references using the given language and the module.*/
const QString ReferenceManager::parseVerseReference( const QString& ref, const ReferenceManager::ParseOptions& options) {
- CSwordModuleInfo* const mod = CPointers::backend()->findModuleByName(options.refDestinationModule);
+ CSwordModuleInfo* const mod = CSwordBackend::instance()->findModuleByName(options.refDestinationModule);
//Q_ASSERT(mod); tested later
if (!mod) {
@@ -371,19 +355,19 @@ const QString ReferenceManager::parseVerseReference( const QString& ref, const R
CSwordVerseKey baseKey(0);
baseKey.setLocale( sourceLanguage.toUtf8().constData() );
- baseKey.key( options.refBase ); //probably in the sourceLanguage
+ baseKey.setKey(options.refBase); //probably in the sourceLanguage
baseKey.setLocale( "en_US" ); //english works in all environments as base
-// CSwordVerseKey dummy(0);
+// CSwordVerseKey dummy(0);
//HACK: We have to workaround a Sword bug, we have to set the default locale to the same as the sourceLanguage !
- const QString oldLocaleName = CPointers::backend()->booknameLanguage();
- CPointers::backend()->booknameLanguage(sourceLanguage);
+ const QString oldLocaleName = CSwordBackend::instance()->booknameLanguage();
+ CSwordBackend::instance()->booknameLanguage(sourceLanguage);
sword::VerseKey dummy;
dummy.setLocale( sourceLanguage.toUtf8().constData() );
Q_ASSERT( !strcmp(dummy.getLocale(), sourceLanguage.toUtf8().constData()) );
-// qDebug("Parsing '%s' in '%s' using '%s' as base, source lang '%s', dest lang '%s'", ref.latin1(), options.refDestinationModule.latin1(), baseKey.key().latin1(), sourceLanguage.latin1(), destinationLanguage.latin1());
+// qDebug("Parsing '%s' in '%s' using '%s' as base, source lang '%s', dest lang '%s'", ref.latin1(), options.refDestinationModule.latin1(), baseKey.key().latin1(), sourceLanguage.latin1(), destinationLanguage.latin1());
for (QStringList::iterator it = refList.begin(); it != refList.end(); it++) {
//The listkey may contain more than one item, because a ref lik "Gen 1:3,5" is parsed into two single refs
@@ -416,6 +400,6 @@ const QString ReferenceManager::parseVerseReference( const QString& ref, const R
}
- CPointers::backend()->booknameLanguage(oldLocaleName);
+ CSwordBackend::instance()->booknameLanguage(oldLocaleName);
return ret;
}