3
* This file is part of BibleTime's source code, http://www.bibletime.info/.
5
* Copyright 1999-2007 by the BibleTime developers.
6
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
13
#include "cswordldkey.h"
14
#include "cswordlexiconmoduleinfo.h"
17
#include <qtextcodec.h>
25
CSwordLDKey::CSwordLDKey( CSwordModuleInfo* module ) {
26
if ((m_module = dynamic_cast<CSwordLexiconModuleInfo*>(module))) {
27
// *(m_module->module()) = TOP;
30
SWKey::operator = (" ");
33
/** No descriptions */
34
CSwordLDKey::CSwordLDKey( const CSwordLDKey &k ) : CSwordKey(k), SWKey((const char*)k) {}
36
/** No descriptions */
37
CSwordLDKey::CSwordLDKey( const SWKey *k, CSwordModuleInfo* module) : CSwordKey(module), SWKey(*k) {}
39
/** Clones this object by copying the members. */
40
CSwordLDKey* CSwordLDKey::copy() const {
41
return new CSwordLDKey(*this);
44
/** Sets the module of this key. */
45
CSwordModuleInfo* const CSwordLDKey::module(CSwordModuleInfo* const newModule) {
46
if (newModule && newModule->type() == CSwordModuleInfo::Lexicon) {
47
const QString oldKey = key();
55
/** Sets the key of this instance */
56
const QString CSwordLDKey::key() const {
58
if (!m_module || m_module->isUnicode()) {
59
return QString::fromUtf8((const char*)*this);
61
QTextCodec *codec = QTextCodec::codecForName("CP1252");
62
return codec->toUnicode((const char*)*this);
66
const char * CSwordLDKey::rawKey() const {
67
return (const char*)*this;
70
const bool CSwordLDKey::key( const QString& newKey ) {
74
if (!m_module || m_module->isUnicode()) {
75
return key((const char*)newKey.utf8());
77
QTextCodec *codec = QTextCodec::codecForName("CP1252");
78
return key((const char*)codec->fromUnicode(newKey));
83
/** Sets the key of this instance */
84
const bool CSwordLDKey::key( const char* newKey ) {
88
SWKey::operator = (newKey); //set the key
90
m_module->module()->SetKey(this);
91
// m_module->module()->getKey()->setText( (const char*)key().utf8() );
93
// SWKey::operator = (m_module->module()->KeyText());
99
/** Uses the parameter to returns the next entry afer this key. */
100
CSwordLDKey* CSwordLDKey::NextEntry() {
101
m_module->module()->SetKey(this); //use this key as base for the next one!
103
m_module->module()->setSkipConsecutiveLinks(true);
104
( *( m_module->module() ) )++;
105
m_module->module()->setSkipConsecutiveLinks(false);
107
key(m_module->module()->KeyText());
108
SWKey::operator = (m_module->module()->KeyText());
113
/** Uses the parameter to returns the next entry afer this key. */
114
CSwordLDKey* CSwordLDKey::PreviousEntry() {
115
m_module->module()->SetKey(this); //use this key as base for the next one!
117
m_module->module()->setSkipConsecutiveLinks(true);
118
( *( m_module->module() ) )--;
119
m_module->module()->setSkipConsecutiveLinks(false);
121
SWKey::operator = (m_module->module()->KeyText());
126
/** Assignment operator for more ease of use of this class. */
127
CSwordLDKey& CSwordLDKey::operator = (const QString& keyname ) {