summaryrefslogtreecommitdiff
path: root/src/backend/keys
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/keys')
-rw-r--r--src/backend/keys/cswordkey.cpp237
-rw-r--r--src/backend/keys/cswordkey.h147
-rw-r--r--src/backend/keys/cswordldkey.cpp100
-rw-r--r--src/backend/keys/cswordldkey.h102
-rw-r--r--src/backend/keys/cswordtreekey.cpp94
-rw-r--r--src/backend/keys/cswordtreekey.h94
-rw-r--r--src/backend/keys/cswordversekey.cpp461
-rw-r--r--src/backend/keys/cswordversekey.h140
8 files changed, 688 insertions, 687 deletions
diff --git a/src/backend/keys/cswordkey.cpp b/src/backend/keys/cswordkey.cpp
index acb6da9..546c55e 100644
--- a/src/backend/keys/cswordkey.cpp
+++ b/src/backend/keys/cswordkey.cpp
@@ -32,154 +32,147 @@
CSwordKey::CSwordKey(CSwordModuleInfo* const module) : m_module(module) {}
CSwordKey::CSwordKey(const CSwordKey& k) {
- m_module = k.m_module;
+ m_module = k.m_module;
}
QString CSwordKey::rawText() {
- if (!m_module) return QString::null;
+ if (!m_module) return QString::null;
- if (dynamic_cast<sword::SWKey*>(this)) {
- char * buffer = new char[strlen(rawKey()) + 1];
- strcpy(buffer, rawKey());
- m_module->module()->getKey()->setText( buffer );
- delete [] buffer;
- }
+ if (dynamic_cast<sword::SWKey*>(this)) {
+ m_module->module()->getKey()->setText( rawKey() );
+ }
- if (key().isNull()) return QString::null;
+ if (key().isNull()) return QString::null;
- return QString::fromUtf8( m_module->module()->getRawEntry() );
+ return QString::fromUtf8( m_module->module()->getRawEntry() );
}
QString CSwordKey::renderedText( const CSwordKey::TextRenderType mode ) {
- Q_ASSERT(m_module);
- if (!m_module) {
- return QString::null;
- }
-
- sword::SWKey* const k = dynamic_cast<sword::SWKey*>(this);
-
- if (k) {
- char * keyBuffer = new char[strlen(rawKey()) + 1];
- strcpy(keyBuffer, rawKey());
- sword::VerseKey* vk_mod = dynamic_cast<sword::VerseKey*>(m_module->module()->getKey());
-
- if (vk_mod) {
- vk_mod->Headings(1);
- }
-
- m_module->module()->getKey()->setText( keyBuffer );
-
- if (m_module->type() == CSwordModuleInfo::Lexicon) {
- m_module->snap();
- /* In lexicons make sure that our key (e.g. 123) was successfully set to the module,
- i.e. the module key contains this key (e.g. 0123 contains 123) */
-
- if ( sword::stricmp(m_module->module()->getKey()->getText(), keyBuffer)
- && !strstr(m_module->module()->getKey()->getText(), keyBuffer)
- ) {
- qDebug("return an empty key for %s", m_module->module()->getKey()->getText());
- return QString::null;
- }
- }
- delete [] keyBuffer;
- }
-
- //Q_ASSERT(!key().isNull());
- if (!key().isNull()) { //we have valid text
- QString text = QString::fromUtf8( m_module->module()->RenderText() );
-
- // This is yucky, but if we want strong lexicon refs we have to do it here.
- if (m_module->type() == CSwordModuleInfo::Lexicon) {
- QString t(text);
- QRegExp rx("(GREEK|HEBREW) for 0*([1-9]\\d*)"); // ignore 0's before number
- int pos = 0;
- while( (pos = rx.indexIn(t, pos)) != -1 ) {
- QString language = rx.cap(1);
- QString langcode = QString(language.at(0)); // "G" or "H"
- QString number = rx.cap(2);
- QString paddednumber = number.rightJustified(5, '0'); // Form 00123
-
- text.replace(
- QRegExp( QString(
- "(>[^<>]+)" // Avoid replacing inside tags
- "\\b(0*%1)\\b").arg(number) ), // And span around 0's
- QString("\\1<span lemma=\"%1%2\"><a href=\"strongs://%3/%4\">\\2</a></span>")
- .arg(langcode, paddednumber, language, paddednumber)
- );
- pos += rx.matchedLength();
- }
- }
-
- if (mode == HTMLEscaped) {
- //we have to encode all UTF-8 in HTML escapes
- // go though every character and write down the escaped HTML unicode entity
- // form is &#<decimal unicode value here>;
- QString ret;
- QChar c;
- const unsigned int length = text.length();
-
- for (unsigned int i = 0; i < length; ++i) {
- c = text.at(i);
-
- if (c.toLatin1()) { //normal latin1 character
- ret.append(c);
- }
- else {//unicode character, needs to be escaped
- ret.append("&#")
- .append(c.unicode())
- .append(";");
- }
- }
-
- return ret;
- }
- else {
- return text;
- }
- }
-
- return QString::null;
+ Q_ASSERT(m_module);
+
+ sword::SWKey* const k = dynamic_cast<sword::SWKey*>(this);
+
+ if (k) {
+ sword::VerseKey* vk_mod = dynamic_cast<sword::VerseKey*>(m_module->module()->getKey());
+
+ if (vk_mod) {
+ vk_mod->Headings(1);
+ }
+
+ m_module->module()->getKey()->setText( rawKey() );
+
+ if (m_module->type() == CSwordModuleInfo::Lexicon) {
+ m_module->snap();
+ /* In lexicons make sure that our key (e.g. 123) was successfully set to the module,
+ i.e. the module key contains this key (e.g. 0123 contains 123) */
+
+ if ( sword::stricmp(m_module->module()->getKey()->getText(), rawKey())
+ && !strstr(m_module->module()->getKey()->getText(), rawKey())
+ ) {
+ qDebug("return an empty key for %s", m_module->module()->getKey()->getText());
+ return QString::null;
+ }
+ }
+ }
+
+ //Q_ASSERT(!key().isNull());
+ if (!key().isNull()) { //we have valid text
+ bool DoRender = (mode == ProcessEntryAttributesOnly) ? 0 : 1;
+ QString text = QString::fromUtf8( m_module->module()->RenderText(0, -1, DoRender) );
+ if (!DoRender) return QString::null;
+
+ // This is yucky, but if we want strong lexicon refs we have to do it here.
+ if (m_module->type() == CSwordModuleInfo::Lexicon) {
+ QString t(text);
+ QRegExp rx("(GREEK|HEBREW) for 0*([1-9]\\d*)"); // ignore 0's before number
+ int pos = 0;
+ while ( (pos = rx.indexIn(t, pos)) != -1 ) {
+ QString language = rx.cap(1);
+ QString langcode = QString(language.at(0)); // "G" or "H"
+ QString number = rx.cap(2);
+ QString paddednumber = number.rightJustified(5, '0'); // Form 00123
+
+ text.replace(
+ QRegExp( QString(
+ "(>[^<>]+)" // Avoid replacing inside tags
+ "\\b(0*%1)\\b").arg(number) ), // And span around 0's
+ QString("\\1<span lemma=\"%1%2\"><a href=\"strongs://%3/%4\">\\2</a></span>")
+ .arg(langcode, paddednumber, language, paddednumber)
+ );
+ pos += rx.matchedLength();
+ }
+ }
+
+ if (mode == HTMLEscaped) {
+ //we have to encode all UTF-8 in HTML escapes
+ // go though every character and write down the escaped HTML unicode entity
+ // form is &#<decimal unicode value here>;
+ QString ret;
+ QChar c;
+ const unsigned int length = text.length();
+
+ for (unsigned int i = 0; i < length; ++i) {
+ c = text.at(i);
+
+ if (c.toLatin1()) { //normal latin1 character
+ ret.append(c);
+ }
+ else {//unicode character, needs to be escaped
+ ret.append("&#")
+ .append(c.unicode())
+ .append(";");
+ }
+ }
+
+ return ret;
+ }
+ else {
+ return text;
+ }
+ }
+
+ return QString::null;
}
QString CSwordKey::strippedText() {
- if (!m_module) return QString::null;
+ if (!m_module) return QString::null;
- if (dynamic_cast<sword::SWKey*>(this)) {
- char * buffer = new char[strlen(rawKey()) + 1];
- strcpy(buffer, rawKey());
- m_module->module()->getKey()->setText( buffer );
- delete [] buffer;
- }
+ if (dynamic_cast<sword::SWKey*>(this)) {
+ char * buffer = new char[strlen(rawKey()) + 1];
+ strcpy(buffer, rawKey());
+ m_module->module()->getKey()->setText( buffer );
+ delete [] buffer;
+ }
- return QString::fromUtf8( m_module->module()->StripText() );
+ return QString::fromUtf8( m_module->module()->StripText() );
}
const QTextCodec* CSwordKey::cp1252Codec() {
- static QTextCodec * codec = QTextCodec::codecForName("Windows-1252");
- return codec;
+ static QTextCodec * codec = QTextCodec::codecForName("Windows-1252");
+ return codec;
}
/** This will create a proper key object from a given module */
CSwordKey* CSwordKey::createInstance( CSwordModuleInfo* const module ) {
- if (!module) {
- return 0;
- }
+ if (!module) {
+ return 0;
+ }
- switch( module->type() ) {
+ switch ( module->type() ) {
- case CSwordModuleInfo::Bible://fall through
+ case CSwordModuleInfo::Bible://fall through
- case CSwordModuleInfo::Commentary:
- return new CSwordVerseKey( (sword::VerseKey *) ( (sword::SWKey *)(*module->module()) ), module );
+ case CSwordModuleInfo::Commentary:
+ return new CSwordVerseKey( (sword::VerseKey *) ( (sword::SWKey *)(*module->module()) ), module );
- case CSwordModuleInfo::Lexicon:
- return new CSwordLDKey( (sword::SWKey *)(*module->module()), module);
+ case CSwordModuleInfo::Lexicon:
+ return new CSwordLDKey( (sword::SWKey *)(*module->module()), module);
- case CSwordModuleInfo::GenericBook:
- return new CSwordTreeKey( (sword::TreeKeyIdx*)((sword::SWKey *)(*module->module())), module );
+ case CSwordModuleInfo::GenericBook:
+ return new CSwordTreeKey( (sword::TreeKeyIdx*)((sword::SWKey *)(*module->module())), module );
- default:
- return 0;
- }
+ default:
+ return 0;
+ }
}
diff --git a/src/backend/keys/cswordkey.h b/src/backend/keys/cswordkey.h
index e0e6300..af0075a 100644
--- a/src/backend/keys/cswordkey.h
+++ b/src/backend/keys/cswordkey.h
@@ -24,88 +24,89 @@ class QTextCodec;
class CSwordKey {
-protected:
- /** Constructor. May only be called from sublasses because this class contains pure virtual methods.
- * @param module The module which belongs to this key, may be NULL
- */
- CSwordKey(CSwordModuleInfo* const module = 0); //protected constructor, because CSwordKey shouldn't be used (it's an abstract base class).
- /** Copy constructor.
- */
- CSwordKey(const CSwordKey&); //copy constructor
+ protected:
+ /** Constructor. May only be called from sublasses because this class contains pure virtual methods.
+ * @param module The module which belongs to this key, may be NULL
+ */
+ CSwordKey(CSwordModuleInfo* const module = 0); //protected constructor, because CSwordKey shouldn't be used (it's an abstract base class).
+ /** Copy constructor.
+ */
+ CSwordKey(const CSwordKey&); //copy constructor
-public:
- enum TextRenderType {
- Normal = 0,
- HTMLEscaped
- };
- /** Destructor.
- * Public, not protected like the constructor, because CSwordKey pointers may be deleted by all others.
- */
- virtual ~CSwordKey() {};
+ public:
+ enum TextRenderType {
+ Normal = 0,
+ HTMLEscaped = 1,
+ ProcessEntryAttributesOnly = 2 // in this case, renderText() will not return text, but only cause EntryAttribute processing
+ };
+ /** Destructor.
+ * Public, not protected like the constructor, because CSwordKey pointers may be deleted by all others.
+ */
+ virtual ~CSwordKey() {};
- //pure virtual functions
- /** Returns the current key.
- * @return The current key which belongs to the current object.
- */
- virtual QString key() const = 0;
- /** Sets the current key. Sets the key using a utf8 enabled QString.
- * @param key The key which should be used to set the current one
- */
- virtual bool key(const QString& key) = 0;
- /** Set the key using a utf8-decoded c-string
- * @param key The key which should be used to set the current one
- */
- virtual bool key(const char* key) = 0;
- /** Clone this object. Clone this current object and return it.
- * @return A clone of the current object.
- */
- virtual CSwordKey* copy() const = 0;
+ //pure virtual functions
+ /** Returns the current key.
+ * @return The current key which belongs to the current object.
+ */
+ virtual QString key() const = 0;
+ /** Sets the current key. Sets the key using a utf8 enabled QString.
+ * @param key The key which should be used to set the current one
+ */
+ virtual bool key(const QString& key) = 0;
+ /** Set the key using a utf8-decoded c-string
+ * @param key The key which should be used to set the current one
+ */
+ virtual bool key(const char* key) = 0;
+ /** Clone this object. Clone this current object and return it.
+ * @return A clone of the current object.
+ */
+ virtual CSwordKey* copy() const = 0;
- //implemented functions
- /** Set/get the module. Set and get the module which belongs to this key.
- * @return The module which belongs to this key.
- */
- inline virtual CSwordModuleInfo* module(CSwordModuleInfo* const newModule = 0);
- /** Returns the raw, unchanged text. Returns the text without any filter modifications,
- * just in the way it comes out of the module.
- */
- virtual QString rawText();
- /** Returns the rendered text. Returns the text of the current key after passign it through the
- * modules filters.
- */
- virtual QString renderedText( const CSwordKey::TextRenderType mode = CSwordKey::Normal );
- /** Stripped down text. Returns the text after removing all markup tags from it.
- */
- virtual QString strippedText();
- /**
- * This returns a new object of the right CSwordKey* implementation
- * (e.g. CSwordVerseKey or CSwordLDKey)
- * The type is determined by the type of the module.
- * @see CSwordModuleInfo, CSwordBibleModuleInfo, CSwordCommentaryModuleInfo, CSwordLexiconModukleInfo
- */
- static CSwordKey* createInstance(CSwordModuleInfo * const module);
+ //implemented functions
+ /** Set/get the module. Set and get the module which belongs to this key.
+ * @return The module which belongs to this key.
+ */
+ inline virtual CSwordModuleInfo* module(CSwordModuleInfo* const newModule = 0);
+ /** Returns the raw, unchanged text. Returns the text without any filter modifications,
+ * just in the way it comes out of the module.
+ */
+ virtual QString rawText();
+ /** Returns the rendered text. Returns the text of the current key after passign it through the
+ * modules filters.
+ */
+ virtual QString renderedText( const CSwordKey::TextRenderType mode = CSwordKey::Normal );
+ /** Stripped down text. Returns the text after removing all markup tags from it.
+ */
+ virtual QString strippedText();
+ /**
+ * This returns a new object of the right CSwordKey* implementation
+ * (e.g. CSwordVerseKey or CSwordLDKey)
+ * The type is determined by the type of the module.
+ * @see CSwordModuleInfo, CSwordBibleModuleInfo, CSwordCommentaryModuleInfo, CSwordLexiconModukleInfo
+ */
+ static CSwordKey* createInstance(CSwordModuleInfo * const module);
-protected:
- /**
- * Returns the encoded key appropriate for use directly with Sword.
- */
- virtual const char * rawKey() const = 0;
- static const QTextCodec* cp1252Codec();
- CSwordModuleInfo* m_module; //module pointer used by all keys
+ protected:
+ /**
+ * Returns the encoded key appropriate for use directly with Sword.
+ */
+ virtual const char * rawKey() const = 0;
+ static const QTextCodec* cp1252Codec();
+ CSwordModuleInfo* m_module; //module pointer used by all keys
-private:
- /**
- * Disable the assignment operator
- */
- CSwordKey& operator= ( const CSwordKey & );
+ private:
+ /**
+ * Disable the assignment operator
+ */
+ CSwordKey& operator= ( const CSwordKey & );
};
inline CSwordModuleInfo* CSwordKey::module(CSwordModuleInfo* const newModule) {
- if (newModule) {
- m_module = newModule;
- }
- return m_module;
+ if (newModule) {
+ m_module = newModule;
+ }
+ return m_module;
}
#endif
diff --git a/src/backend/keys/cswordldkey.cpp b/src/backend/keys/cswordldkey.cpp
index 3205827..4aa95cb 100644
--- a/src/backend/keys/cswordldkey.cpp
+++ b/src/backend/keys/cswordldkey.cpp
@@ -19,11 +19,11 @@
#include <QTextCodec>
CSwordLDKey::CSwordLDKey( CSwordModuleInfo* module ) {
- if ((m_module = dynamic_cast<CSwordLexiconModuleInfo*>(module))) {
- // *(m_module->module()) = TOP;
- }
+ if ((m_module = dynamic_cast<CSwordLexiconModuleInfo*>(module))) {
+ // *(m_module->module()) = TOP;
+ }
- SWKey::operator= (" ");
+ SWKey::operator= (" ");
}
/** No descriptions */
@@ -34,85 +34,87 @@ CSwordLDKey::CSwordLDKey( const SWKey *k, CSwordModuleInfo* module) : CSwordKey(
/** Clones this object by copying the members. */
CSwordLDKey* CSwordLDKey::copy() const {
- return new CSwordLDKey(*this);
+ return new CSwordLDKey(*this);
}
/** Sets the module of this key. */
CSwordModuleInfo* CSwordLDKey::module(CSwordModuleInfo* const newModule) {
- if (newModule && newModule->type() == CSwordModuleInfo::Lexicon) {
- const QString oldKey = key();
- m_module = newModule;
- key(oldKey);
- }
+ if (newModule && newModule->type() == CSwordModuleInfo::Lexicon) {
+ const QString oldKey = key();
+ m_module = newModule;
+ key(oldKey);
+ }
- return m_module;
+ return m_module;
}
QString CSwordLDKey::key() const {
- //return QString::fromUtf8((const char*)*this);
- Q_ASSERT(m_module);
-
- if (m_module->isUnicode()) {
- return QString::fromUtf8((const char*)*this);
- } else {
- return cp1252Codec()->toUnicode((const char*)*this);
- }
+ //return QString::fromUtf8((const char*)*this);
+ Q_ASSERT(m_module);
+
+ if (m_module->isUnicode()) {
+ return QString::fromUtf8((const char*)*this);
+ }
+ else {
+ return cp1252Codec()->toUnicode((const char*)*this);
+ }
}
const char * CSwordLDKey::rawKey() const {
- return (const char*)*this;
+ return (const char*)*this;
}
bool CSwordLDKey::key( const QString& newKey ) {
- Q_ASSERT(m_module);
-
- if (m_module->isUnicode()) {
- return key(newKey.toUtf8().constData());
- } else {
- return key((const char*)cp1252Codec()->fromUnicode(newKey));
- }
+ Q_ASSERT(m_module);
+
+ if (m_module->isUnicode()) {
+ return key(newKey.toUtf8().constData());
+ }
+ else {
+ return key((const char*)cp1252Codec()->fromUnicode(newKey));
+ }
}
/** Sets the key of this instance */
bool CSwordLDKey::key( const char* newKey ) {
- Q_ASSERT(newKey);
+ Q_ASSERT(newKey);
- if (newKey) {
- SWKey::operator = (newKey); //set the key
- m_module->module()->SetKey(this);
- m_module->snap();
- }
+ if (newKey) {
+ SWKey::operator = (newKey); //set the key
+ m_module->module()->SetKey(this);
+ m_module->snap();
+ }
- return !Error();
+ return !Error();
}
/** Uses the parameter to returns the next entry afer this key. */
CSwordLDKey* CSwordLDKey::NextEntry() {
- m_module->module()->SetKey(this); //use this key as base for the next one!
- // m_module->module()->getKey()->setText( (const char*)key().utf8() );
+ m_module->module()->SetKey(this); //use this key as base for the next one!
+ // m_module->module()->getKey()->setText( (const char*)key().utf8() );
- m_module->module()->setSkipConsecutiveLinks(true);
- ( *( m_module->module() ) )++;
- m_module->module()->setSkipConsecutiveLinks(false);
+ m_module->module()->setSkipConsecutiveLinks(true);
+ ( *( m_module->module() ) )++;
+ m_module->module()->setSkipConsecutiveLinks(false);
- key(m_module->module()->KeyText());
- SWKey::operator = (m_module->module()->KeyText());
+ key(m_module->module()->KeyText());
+ SWKey::operator = (m_module->module()->KeyText());
- return this;
+ return this;
}
/** Uses the parameter to returns the next entry afer this key. */
CSwordLDKey* CSwordLDKey::PreviousEntry() {
- m_module->module()->SetKey(this); //use this key as base for the next one!
- // m_module->module()->getKey()->setText( (const char*)key().utf8() );
+ m_module->module()->SetKey(this); //use this key as base for the next one!
+ // m_module->module()->getKey()->setText( (const char*)key().utf8() );
- m_module->module()->setSkipConsecutiveLinks(true);
- ( *( m_module->module() ) )--;
- m_module->module()->setSkipConsecutiveLinks(false);
+ m_module->module()->setSkipConsecutiveLinks(true);
+ ( *( m_module->module() ) )--;
+ m_module->module()->setSkipConsecutiveLinks(false);
- SWKey::operator = (m_module->module()->KeyText());
+ SWKey::operator = (m_module->module()->KeyText());
- return this;
+ return this;
}
diff --git a/src/backend/keys/cswordldkey.h b/src/backend/keys/cswordldkey.h
index 0349597..1cb3382 100644
--- a/src/backend/keys/cswordldkey.h
+++ b/src/backend/keys/cswordldkey.h
@@ -49,59 +49,59 @@ class CSwordModuleInfo;
class CSwordLDKey : public CSwordKey, public sword::SWKey {
-public:
- /**
- * Constructor of CSwordLDKey
- */
- CSwordLDKey( CSwordModuleInfo* module );
- /**
- * Copy constructor for this key class.
- */
- CSwordLDKey( const CSwordLDKey &k );
- /**
- * Copy constructor for this key class.
- */
- CSwordLDKey( const sword::SWKey *k, CSwordModuleInfo* module);
- /**
- * Clones this object by copying the members.
- */
- virtual CSwordLDKey* copy() const;
- /**
- * Uses the parameter to returns the next entry afer this key.
- */
- CSwordLDKey* NextEntry( void );
- /**
- * Uses the parameter to returns the previous entry afer this key.
- */
- CSwordLDKey* PreviousEntry( void );
- /**
- * Sets the module of this key.
- */
- virtual CSwordModuleInfo* module( CSwordModuleInfo* const module = 0 );
- /**
- * Returns the current key as a QString
- */
- virtual QString key() const;
- /**
- * Set the current key using unicode decoded QString.
- */
- virtual bool key( const QString& newKey );
- /**
- * Set the current key from char*. To avoid encoding problems use key(QString) instead.
- */
- virtual bool key( const char* );
+ public:
+ /**
+ * Constructor of CSwordLDKey
+ */
+ CSwordLDKey( CSwordModuleInfo* module );
+ /**
+ * Copy constructor for this key class.
+ */
+ CSwordLDKey( const CSwordLDKey &k );
+ /**
+ * Copy constructor for this key class.
+ */
+ CSwordLDKey( const sword::SWKey *k, CSwordModuleInfo* module);
+ /**
+ * Clones this object by copying the members.
+ */
+ virtual CSwordLDKey* copy() const;
+ /**
+ * Uses the parameter to returns the next entry afer this key.
+ */
+ CSwordLDKey* NextEntry( void );
+ /**
+ * Uses the parameter to returns the previous entry afer this key.
+ */
+ CSwordLDKey* PreviousEntry( void );
+ /**
+ * Sets the module of this key.
+ */
+ virtual CSwordModuleInfo* module( CSwordModuleInfo* const module = 0 );
+ /**
+ * Returns the current key as a QString
+ */
+ virtual QString key() const;
+ /**
+ * Set the current key using unicode decoded QString.
+ */
+ virtual bool key( const QString& newKey );
+ /**
+ * Set the current key from char*. To avoid encoding problems use key(QString) instead.
+ */
+ virtual bool key( const char* );
-protected:
- /**
- * Returns the raw key appropriate for use directly with Sword.
- */
- virtual const char* rawKey() const;
+ protected:
+ /**
+ * Returns the raw key appropriate for use directly with Sword.
+ */
+ virtual const char* rawKey() const;
-private:
- /**
- * Disable assignment operator
- */
- CSwordLDKey& operator= (const CSwordLDKey& );
+ private:
+ /**
+ * Disable assignment operator
+ */
+ CSwordLDKey& operator= (const CSwordLDKey& );
};
diff --git a/src/backend/keys/cswordtreekey.cpp b/src/backend/keys/cswordtreekey.cpp
index 6e02806..e845bf6 100644
--- a/src/backend/keys/cswordtreekey.cpp
+++ b/src/backend/keys/cswordtreekey.cpp
@@ -19,75 +19,77 @@ CSwordTreeKey::CSwordTreeKey( const CSwordTreeKey& k ) : CSwordKey(k), TreeKeyId
CSwordTreeKey::CSwordTreeKey( const TreeKeyIdx *k, CSwordModuleInfo* module ) : CSwordKey(module), TreeKeyIdx(*k) {}
CSwordTreeKey* CSwordTreeKey::copy() const {
- return new CSwordTreeKey(*this);
+ return new CSwordTreeKey(*this);
}
/** Sets the key of this instance */
QString CSwordTreeKey::key() const {
- //return getTextUnicode();
- Q_ASSERT(m_module);
- if (m_module->isUnicode()) {
- return QString::fromUtf8(getText());
- } else {
- return cp1252Codec()->toUnicode(getText());
- }
+ //return getTextUnicode();
+ Q_ASSERT(m_module);
+ if (m_module->isUnicode()) {
+ return QString::fromUtf8(getText());
+ }
+ else {
+ return cp1252Codec()->toUnicode(getText());
+ }
}
const char * CSwordTreeKey::rawKey() const {
- return getText();
+ return getText();
}
bool CSwordTreeKey::key( const QString& newKey ) {
- //return key( newKey.toLocal8Bit().constData() );
- //return key(m_module->getTextCodec()->fromUnicode(newKey).constData());
- Q_ASSERT(m_module);
- if (m_module->isUnicode()) {
- return key(newKey.toUtf8().constData());
- } else {
- return key((const char*)cp1252Codec()->fromUnicode(newKey));
- }
+ //return key( newKey.toLocal8Bit().constData() );
+ //return key(m_module->getTextCodec()->fromUnicode(newKey).constData());
+ Q_ASSERT(m_module);
+ if (m_module->isUnicode()) {
+ return key(newKey.toUtf8().constData());
+ }
+ else {
+ return key((const char*)cp1252Codec()->fromUnicode(newKey));
+ }
}
bool CSwordTreeKey::key( const char* newKey ) {
- Q_ASSERT(newKey);
+ Q_ASSERT(newKey);
- if (newKey) {
- TreeKeyIdx::operator = (newKey);
- }
- else {
- root();
- }
+ if (newKey) {
+ TreeKeyIdx::operator = (newKey);
+ }
+ else {
+ root();
+ }
- return !Error();
+ return !Error();
}
-QString CSwordTreeKey::getLocalNameUnicode()
-{
- //return m_module->getTextCodec()->toUnicode(getLocalName());
- //Only UTF-8 and latin1 are legal Sword module encodings
- Q_ASSERT(m_module);
- if (m_module->isUnicode()) {
- return QString::fromUtf8(getLocalName());
- } else {
- return cp1252Codec()->toUnicode(getLocalName());
- }
+QString CSwordTreeKey::getLocalNameUnicode() {
+ //return m_module->getTextCodec()->toUnicode(getLocalName());
+ //Only UTF-8 and latin1 are legal Sword module encodings
+ Q_ASSERT(m_module);
+ if (m_module->isUnicode()) {
+ return QString::fromUtf8(getLocalName());
+ }
+ else {
+ return cp1252Codec()->toUnicode(getLocalName());
+ }
}
CSwordModuleInfo* CSwordTreeKey::module( CSwordModuleInfo* const newModule ) {
- if (newModule && (newModule != m_module) && (newModule->type() == CSwordModuleInfo::GenericBook) ) {
- m_module = newModule;
+ if (newModule && (newModule != m_module) && (newModule->type() == CSwordModuleInfo::GenericBook) ) {
+ m_module = newModule;
- const QString oldKey = key();
+ const QString oldKey = key();
- CSwordBookModuleInfo* newBook = dynamic_cast<CSwordBookModuleInfo*>(newModule);
- copyFrom( *(newBook->tree()) );
+ CSwordBookModuleInfo* newBook = dynamic_cast<CSwordBookModuleInfo*>(newModule);
+ copyFrom( *(newBook->tree()) );
- key(oldKey); //try to restore our old key
+ key(oldKey); //try to restore our old key
- //set the key to the root node
- root();
- firstChild();
- }
+ //set the key to the root node
+ root();
+ firstChild();
+ }
- return m_module;
+ return m_module;
}
diff --git a/src/backend/keys/cswordtreekey.h b/src/backend/keys/cswordtreekey.h
index 4114652..c0c9e45 100644
--- a/src/backend/keys/cswordtreekey.h
+++ b/src/backend/keys/cswordtreekey.h
@@ -25,55 +25,57 @@ class CSwordModuleInfo;
class CSwordTreeKey : public CSwordKey, public sword::TreeKeyIdx {
-public:
- /** Constructor of this CSwordKey implementation.
- * @param k The Sword tree key which belongs to this key
- * @param module The module which belongs to this key
- */
- CSwordTreeKey( const sword::TreeKeyIdx *k, CSwordModuleInfo* module );
- /** Copy constructor.
- */
- CSwordTreeKey( const CSwordTreeKey& k );
- /** The module which belongs to this key.
- * @return The module.
- */
- virtual CSwordModuleInfo* module( CSwordModuleInfo* const newModule );
- /** Copy method.
- * @return A new copy of this object.
- */
- virtual CSwordTreeKey* copy() const;
+ public:
+ /** Constructor of this CSwordKey implementation.
+ * @param k The Sword tree key which belongs to this key
+ * @param module The module which belongs to this key
+ */
+ CSwordTreeKey( const sword::TreeKeyIdx *k, CSwordModuleInfo* module );
+ /** Copy constructor.
+ */
+ CSwordTreeKey( const CSwordTreeKey& k );
+ /** The module which belongs to this key.
+ * @return The module.
+ */
+ virtual CSwordModuleInfo* module( CSwordModuleInfo* const newModule );
+ /** Copy method.
+ * @return A new copy of this object.
+ */
+ virtual CSwordTreeKey* copy() const;
- /**
- * Returns the TreeKeyIdx::getLocalKey value in unicode.
- * Local key is the last part of the tree key, for example "Subsection1" from "/Section1/Subsection1".
- * Use this instead of getLocalKey() to avoid encoding problems.
- */
- QString getLocalNameUnicode();
- /**
- * Returns the current key as unicode decoded QString.
- */
- virtual QString key() const;
- /**
- * Set the key. If the parameter is empty or null, the key will be set to "/"
- */
- virtual bool key( const QString& key );
- /**
- * Set the key from char* To avoid encoding problems use key(QString instead),
- * otherwise it is caller's responsibility to ensure the correct encoding (utf8/latin1).
- */
- virtual bool key( const char* key );
+ /**
+ * Returns the TreeKeyIdx::getLocalKey value in unicode.
+ * Local key is the last part of the tree key, for example "Subsection1" from "/Section1/Subsection1".
+ * Use this instead of getLocalKey() to avoid encoding problems.
+ */
+ QString getLocalNameUnicode();
+ /**
+ * Returns the current key as unicode decoded QString.
+ */
+ virtual QString key() const;
+ /**
+ * Set the key. If the parameter is empty or null, the key will be set to "/"
+ */
+ virtual bool key( const QString& key );
+ /**
+ * Set the key from char* To avoid encoding problems use key(QString instead),
+ * otherwise it is caller's responsibility to ensure the correct encoding (utf8/latin1).
+ */
+ virtual bool key( const char* key );
-protected:
- /**
- * Returns the raw key appropriate for use directly with Sword.
- */
- virtual const char * rawKey() const;
+ protected:
+ /**
+ * Returns the raw key appropriate for use directly with Sword.
+ */
+ virtual const char * rawKey() const;
-private:
- /** Disable assignment operator */
- CSwordTreeKey& operator= (const CSwordTreeKey&);
- /** Disable from base class to prevent compiler warnings */
- inline virtual CSwordTreeKey& operator= (const sword::TreeKeyIdx&) { return (*this); };
+ private:
+ /** Disable assignment operator */
+ CSwordTreeKey& operator= (const CSwordTreeKey&);
+ /** Disable from base class to prevent compiler warnings */
+ inline virtual CSwordTreeKey& operator= (const sword::TreeKeyIdx&) {
+ return (*this);
+ };
};
#endif
diff --git a/src/backend/keys/cswordversekey.cpp b/src/backend/keys/cswordversekey.cpp
index 8008a7f..01cfd31 100644
--- a/src/backend/keys/cswordversekey.cpp
+++ b/src/backend/keys/cswordversekey.cpp
@@ -19,14 +19,13 @@
#include <localemgr.h>
CSwordVerseKey::CSwordVerseKey( CSwordModuleInfo* const module ) :
- CSwordKey(module)
-{
- if ( CSwordBibleModuleInfo* bible = dynamic_cast<CSwordBibleModuleInfo*>(module) ) {
- // Copy important settings like versification system
- copyFrom((sword::VerseKey*) bible->module()->getKey());
-
- key( bible->lowerBound().key() );
- }
+ CSwordKey(module) {
+ if ( CSwordBibleModuleInfo* bible = dynamic_cast<CSwordBibleModuleInfo*>(module) ) {
+ // Copy important settings like versification system
+ copyFrom((sword::VerseKey*) bible->module()->getKey());
+
+ key( bible->lowerBound().key() );
+ }
}
CSwordVerseKey::CSwordVerseKey( const CSwordVerseKey& k ) : CSwordKey(k), VerseKey(k) {}
@@ -35,258 +34,258 @@ CSwordVerseKey::CSwordVerseKey( const VerseKey* const k, CSwordModuleInfo* const
/** Clones this object. */
CSwordKey* CSwordVerseKey::copy() const {
- return new CSwordVerseKey(*this);
+ return new CSwordVerseKey(*this);
}
/** Sets the module for this key */
CSwordModuleInfo* CSwordVerseKey::module( CSwordModuleInfo* const newModule ) {
- if (newModule && ((newModule->type() == CSwordModuleInfo::Bible) || (newModule->type() == CSwordModuleInfo::Commentary) ) ) {
- m_module = newModule;
+ if (newModule && ((newModule->type() == CSwordModuleInfo::Bible) || (newModule->type() == CSwordModuleInfo::Commentary) ) ) {
+ m_module = newModule;
- //check if the module contains the key we present
- CSwordBibleModuleInfo* bible = dynamic_cast<CSwordBibleModuleInfo*>(newModule);
+ //check if the module contains the key we present
+ CSwordBibleModuleInfo* bible = dynamic_cast<CSwordBibleModuleInfo*>(newModule);
- if (_compare(bible->lowerBound()) < 0) {
- key( bible->lowerBound() );
- }
+ if (_compare(bible->lowerBound()) < 0) {
+ key( bible->lowerBound() );
+ }
- if (_compare(bible->upperBound()) > 0) {
- key( bible->upperBound() );
- }
- }
+ if (_compare(bible->upperBound()) > 0) {
+ key( bible->upperBound() );
+ }
+ }
- return dynamic_cast<CSwordBibleModuleInfo*>(m_module);
+ return dynamic_cast<CSwordBibleModuleInfo*>(m_module);
}
/** Returns the current book as Text, not as integer. */
QString CSwordVerseKey::book( const QString& newBook ) {
- int min = 0;
- int max = 1;
-
- if (CSwordBibleModuleInfo* bible = dynamic_cast<CSwordBibleModuleInfo*>(module())) {
- const bool hasOT = bible->hasTestament(CSwordBibleModuleInfo::OldTestament);
- const bool hasNT = bible->hasTestament(CSwordBibleModuleInfo::NewTestament);
-
- if (hasOT && hasNT) {
- min = 0;
- max = 1;
- }
- else if (hasOT && !hasNT) {
- min = 0;
- max = 0;
- }
- else if (!hasOT && hasNT) {
- min = 1;
- max = 1;
- }
- else if (!hasOT && !hasNT) {
- min = 0;
- max = -1; //no loop
- }
- }
-
- if (!newBook.isEmpty()) {
- setBookName(newBook.toUtf8().constData());
- }
-
- if ( (Testament() >= min+1) && (Testament() <= max+1) && (Book() <= BMAX[min]) ) {
- return QString::fromUtf8( getBookName() );
- }
-
- //return QString::fromUtf8( books[min][0].name ); //return the first book, i.e. Genesis
- return QString::null;
+ int min = 0;
+ int max = 1;
+
+ if (CSwordBibleModuleInfo* bible = dynamic_cast<CSwordBibleModuleInfo*>(module())) {
+ const bool hasOT = bible->hasTestament(CSwordBibleModuleInfo::OldTestament);
+ const bool hasNT = bible->hasTestament(CSwordBibleModuleInfo::NewTestament);
+
+ if (hasOT && hasNT) {
+ min = 0;
+ max = 1;
+ }
+ else if (hasOT && !hasNT) {
+ min = 0;
+ max = 0;
+ }
+ else if (!hasOT && hasNT) {
+ min = 1;
+ max = 1;
+ }
+ else if (!hasOT && !hasNT) {
+ min = 0;
+ max = -1; //no loop
+ }
+ }
+
+ if (!newBook.isEmpty()) {
+ setBookName(newBook.toUtf8().constData());
+ }
+
+ if ( (Testament() >= min + 1) && (Testament() <= max + 1) && (Book() <= BMAX[min]) ) {
+ return QString::fromUtf8( getBookName() );
+ }
+
+ //return QString::fromUtf8( books[min][0].name ); //return the first book, i.e. Genesis
+ return QString::null;
}
/** Sets the key we use to the parameter. */
QString CSwordVerseKey::key() const {
- return QString::fromUtf8(getText());
+ return QString::fromUtf8(getText());
}
const char * CSwordVerseKey::rawKey() const {
- return getText();
+ return getText();
}
bool CSwordVerseKey::key( const QString& newKey ) {
- return key( newKey.toUtf8().constData() );
+ return key( newKey.toUtf8().constData() );
}
bool CSwordVerseKey::key( const char* newKey ) {
- if (newKey && (strlen(newKey)>0) ) {
- VerseKey::operator = (newKey);
- }
- else if (newKey && !strlen(newKey)) {
- CSwordBibleModuleInfo* bible = dynamic_cast<CSwordBibleModuleInfo*>(module());
-
- if ( bible ) {
- VerseKey::operator = (bible->lowerBound().key().toUtf8().constData());
- }
- }
-
- return !Error();
+ if (newKey && (strlen(newKey) > 0) ) {
+ VerseKey::operator = (newKey);
+ }
+ else if (newKey && !strlen(newKey)) {
+ CSwordBibleModuleInfo* bible = dynamic_cast<CSwordBibleModuleInfo*>(module());
+
+ if ( bible ) {
+ VerseKey::operator = (bible->lowerBound().key().toUtf8().constData());
+ }
+ }
+
+ return !Error();
}
bool CSwordVerseKey::next( const JumpType type ) {
- Error(); //clear Error status
- bool ret = true;
-
- switch (type) {
-
- case UseBook: {
- const int currentTestament = Testament();
- const int currentBook = Book();
-
- if ((currentTestament == 2) && (currentBook >= BMAX[currentTestament-1])) { //Revelation, i.e. end of navigation
- return false;
- }
- else if ((currentTestament == 1) && (currentBook >= BMAX[currentTestament-1])) { //Malachi, switch to the NT
- Testament(currentTestament+1);
- Book(1);
- }
- else {
- Book(Book()+1);
- }
- break;
- }
-
- case UseChapter: {
- Chapter(Chapter()+1);
- break;
- }
-
- case UseVerse: {
- if (m_module && m_module->module()) {
- const bool oldStatus = m_module->module()->getSkipConsecutiveLinks();
- m_module->module()->setSkipConsecutiveLinks(true);
-
- //disable headings for next verse
- const bool useHeaders = (Verse() == 0);
- const bool oldHeadingsStatus = ((VerseKey*)(m_module->module()->getKey()))->Headings( useHeaders );
- //don't use setKey(), that would create a new key without Headings set
- m_module->module()->getKey()->setText( key().toUtf8().constData() );
-
- (*(m_module->module()) )++;
-
- ((VerseKey*)(m_module->module()->getKey()))->Headings(oldHeadingsStatus);
- m_module->module()->setSkipConsecutiveLinks(oldStatus);
-
- if (!m_module->module()->Error()) {
- key( QString::fromUtf8(m_module->module()->KeyText()) );
- }
- else {
- // Verse(Verse()+1);
- //don't change the key, restore the module's position
- m_module->module()->getKey()->setText( key().toUtf8().constData() );
- ret = false;
- break;
- }
-
- }
- else {
- Verse(Verse()+1);
- }
-
- break;
- }
-
- default:
- return false;
- }
-
- if ( CSwordBibleModuleInfo* bible = dynamic_cast<CSwordBibleModuleInfo*>(module()) ) {
- if (_compare(bible->lowerBound()) < 0 ) {
- key( bible->lowerBound() );
- ret = false;
- }
-
- if (_compare(bible->upperBound()) > 0 ) {
- key( bible->upperBound() );
- ret = false;
- }
-
- return ret;
- }
- else if (Error()) { //we have no module, so take care of VerseKey::Error()
- return false;
- }
-
- return ret;
+ Error(); //clear Error status
+ bool ret = true;
+
+ switch (type) {
+
+ case UseBook: {
+ const int currentTestament = Testament();
+ const int currentBook = Book();
+
+ if ((currentTestament == 2) && (currentBook >= BMAX[currentTestament-1])) { //Revelation, i.e. end of navigation
+ return false;
+ }
+ else if ((currentTestament == 1) && (currentBook >= BMAX[currentTestament-1])) { //Malachi, switch to the NT
+ Testament(currentTestament + 1);
+ Book(1);
+ }
+ else {
+ Book(Book() + 1);
+ }
+ break;
+ }
+
+ case UseChapter: {
+ Chapter(Chapter() + 1);
+ break;
+ }
+
+ case UseVerse: {
+ if (m_module && m_module->module()) {
+ const bool oldStatus = m_module->module()->getSkipConsecutiveLinks();
+ m_module->module()->setSkipConsecutiveLinks(true);
+
+ //disable headings for next verse
+ const bool useHeaders = (Verse() == 0);
+ const bool oldHeadingsStatus = ((VerseKey*)(m_module->module()->getKey()))->Headings( useHeaders );
+ //don't use setKey(), that would create a new key without Headings set
+ m_module->module()->getKey()->setText( key().toUtf8().constData() );
+
+ (*(m_module->module()) )++;
+
+ ((VerseKey*)(m_module->module()->getKey()))->Headings(oldHeadingsStatus);
+ m_module->module()->setSkipConsecutiveLinks(oldStatus);
+
+ if (!m_module->module()->Error()) {
+ key( QString::fromUtf8(m_module->module()->KeyText()) );
+ }
+ else {
+ // Verse(Verse()+1);
+ //don't change the key, restore the module's position
+ m_module->module()->getKey()->setText( key().toUtf8().constData() );
+ ret = false;
+ break;
+ }
+
+ }
+ else {
+ Verse(Verse() + 1);
+ }
+
+ break;
+ }
+
+ default:
+ return false;
+ }
+
+ if ( CSwordBibleModuleInfo* bible = dynamic_cast<CSwordBibleModuleInfo*>(module()) ) {
+ if (_compare(bible->lowerBound()) < 0 ) {
+ key( bible->lowerBound() );
+ ret = false;
+ }
+
+ if (_compare(bible->upperBound()) > 0 ) {
+ key( bible->upperBound() );
+ ret = false;
+ }
+
+ return ret;
+ }
+ else if (Error()) { //we have no module, so take care of VerseKey::Error()
+ return false;
+ }
+
+ return ret;
}
bool CSwordVerseKey::previous( const JumpType type ) {
- bool ret = true;
-
- switch (type) {
-
- case UseBook: {
- if ( (Book() == 1) && (Testament() == 1) ) { //Genesis
- return false;
- }
- else if ( (Book() == 1) && (Testament() == 2) ){ //Matthew
- Testament(1);
- Book(BMAX[0]);
- }
- else{
- Book( Book()-1 );
- }
-
- break;
- }
-
- case UseChapter: {
- Chapter(Chapter()-1);
- break;
- }
-
- case UseVerse: {
- if (m_module && m_module->module()) {
- const bool useHeaders = (Verse() == 0);
- const bool oldHeadingsStatus = ((VerseKey*)(m_module->module()->getKey()))->Headings( useHeaders );
-
- m_module->module()->getKey()->setText( key().toUtf8().constData() );
-
- const bool oldStatus = m_module->module()->getSkipConsecutiveLinks();
- m_module->module()->setSkipConsecutiveLinks(true);
- ( *( m_module->module() ) )--;
-
- ((VerseKey*)(m_module->module()->getKey()))->Headings( oldHeadingsStatus );
- m_module->module()->setSkipConsecutiveLinks(oldStatus);
-
- if (!m_module->module()->Error()) {
- key( QString::fromUtf8(m_module->module()->KeyText()) );//don't use fromUtf8
- }
- else {
- ret = false;
- // Verse(Verse()-1);
- m_module->module()->getKey()->setText( key().toUtf8().constData() ); //restore module's key
- }
- }
- else {
- Verse(Verse()-1);
- }
-
- break;
- }
-
- default:
- return false;
- }
-
- if ( CSwordBibleModuleInfo* bible = dynamic_cast<CSwordBibleModuleInfo*>(module()) ) {
- if (_compare(bible->lowerBound()) < 0 ) {
- key( bible->lowerBound() );
- ret = false;
- }
-
- if (_compare(bible->upperBound()) > 0 ) {
- key( bible->upperBound() );
- ret = false;
- }
-
- return ret;
- }
- else if (Error()) {
- return false;
- }
-
- return ret;
+ bool ret = true;
+
+ switch (type) {
+
+ case UseBook: {
+ if ( (Book() == 1) && (Testament() == 1) ) { //Genesis
+ return false;
+ }
+ else if ( (Book() == 1) && (Testament() == 2) ) { //Matthew
+ Testament(1);
+ Book(BMAX[0]);
+ }
+ else {
+ Book( Book() - 1 );
+ }
+
+ break;
+ }
+
+ case UseChapter: {
+ Chapter(Chapter() - 1);
+ break;
+ }
+
+ case UseVerse: {
+ if (m_module && m_module->module()) {
+ const bool useHeaders = (Verse() == 0);
+ const bool oldHeadingsStatus = ((VerseKey*)(m_module->module()->getKey()))->Headings( useHeaders );
+
+ m_module->module()->getKey()->setText( key().toUtf8().constData() );
+
+ const bool oldStatus = m_module->module()->getSkipConsecutiveLinks();
+ m_module->module()->setSkipConsecutiveLinks(true);
+ ( *( m_module->module() ) )--;
+
+ ((VerseKey*)(m_module->module()->getKey()))->Headings( oldHeadingsStatus );
+ m_module->module()->setSkipConsecutiveLinks(oldStatus);
+
+ if (!m_module->module()->Error()) {
+ key( QString::fromUtf8(m_module->module()->KeyText()) );//don't use fromUtf8
+ }
+ else {
+ ret = false;
+ // Verse(Verse()-1);
+ m_module->module()->getKey()->setText( key().toUtf8().constData() ); //restore module's key
+ }
+ }
+ else {
+ Verse(Verse() - 1);
+ }
+
+ break;
+ }
+
+ default:
+ return false;
+ }
+
+ if ( CSwordBibleModuleInfo* bible = dynamic_cast<CSwordBibleModuleInfo*>(module()) ) {
+ if (_compare(bible->lowerBound()) < 0 ) {
+ key( bible->lowerBound() );
+ ret = false;
+ }
+
+ if (_compare(bible->upperBound()) > 0 ) {
+ key( bible->upperBound() );
+ ret = false;
+ }
+
+ return ret;
+ }
+ else if (Error()) {
+ return false;
+ }
+
+ return ret;
}
diff --git a/src/backend/keys/cswordversekey.h b/src/backend/keys/cswordversekey.h
index e421b6c..0f286dc 100644
--- a/src/backend/keys/cswordversekey.h
+++ b/src/backend/keys/cswordversekey.h
@@ -44,79 +44,81 @@ class CSwordModuleInfo;
class CSwordVerseKey : public CSwordKey, public sword::VerseKey {
-public:
- enum JumpType {
- UseBook,
- UseChapter,
- UseVerse
- };
+ public:
+ enum JumpType {
+ UseBook,
+ UseChapter,
+ UseVerse
+ };
- /**
- * Constructor of this class.
- *
- * This function will construct a versekey with the current module position
- * and it will setup the m_module members.
- *
- */
- CSwordVerseKey( CSwordModuleInfo* const module );
- /**
- * Copy constructor.
- */
- CSwordVerseKey( const CSwordVerseKey& k );
- /**
- * VerseKey based constructor.
- */
- CSwordVerseKey( const sword::VerseKey* const k, CSwordModuleInfo* const module );
- /**
- * Clones this object.
- */
- virtual CSwordKey* copy() const;
- /**
- * Set/get the key. If the parameter is not set (means equal to QString::null)
- * the used key is returned. Otherwise the key is set and the new on ei returned.
- */
- virtual QString key() const;
- /**
- * Set the current key.
- */
- virtual bool key( const QString& );
- /**
- * Set/get the key. If the parameter is not set (means equal to QString::null)
- * the used key is returned. Otherwise the key is set and the new on ei returned.
- */
- virtual bool key( const char* key );
+ /**
+ * Constructor of this class.
+ *
+ * This function will construct a versekey with the current module position
+ * and it will setup the m_module members.
+ *
+ */
+ CSwordVerseKey( CSwordModuleInfo* const module );
+ /**
+ * Copy constructor.
+ */
+ CSwordVerseKey( const CSwordVerseKey& k );
+ /**
+ * VerseKey based constructor.
+ */
+ CSwordVerseKey( const sword::VerseKey* const k, CSwordModuleInfo* const module );
+ /**
+ * Clones this object.
+ */
+ virtual CSwordKey* copy() const;
+ /**
+ * Set/get the key. If the parameter is not set (means equal to QString::null)
+ * the used key is returned. Otherwise the key is set and the new on ei returned.
+ */
+ virtual QString key() const;
+ /**
+ * Set the current key.
+ */
+ virtual bool key( const QString& );
+ /**
+ * Set/get the key. If the parameter is not set (means equal to QString::null)
+ * the used key is returned. Otherwise the key is set and the new on ei returned.
+ */
+ virtual bool key( const char* key );
- /**
- * Jumps to the next entry of the given type
- */
- bool next( const JumpType type );
- /**
- * Jumps to the previous entry of the given type
- */
- bool previous ( const JumpType type );
- /**
- * This functions returns the current book as localised text, not as book numer.
- *
- * Use "char Book()" to retrieve the book number of the current book.
- * @return The name of the current book
- */
- QString book(const QString& newBook = QString::null);
- /**
- * Sets the module for this key
- */
- virtual CSwordModuleInfo* module( CSwordModuleInfo* const newModule = 0 );
+ /**
+ * Jumps to the next entry of the given type
+ */
+ bool next( const JumpType type );
+ /**
+ * Jumps to the previous entry of the given type
+ */
+ bool previous ( const JumpType type );
+ /**
+ * This functions returns the current book as localised text, not as book numer.
+ *
+ * Use "char Book()" to retrieve the book number of the current book.
+ * @return The name of the current book
+ */
+ QString book(const QString& newBook = QString::null);
+ /**
+ * Sets the module for this key
+ */
+ virtual CSwordModuleInfo* module( CSwordModuleInfo* const newModule = 0 );
-protected:
- /**
- * Returns the raw key appropriate for use directly with Sword.
- */
- virtual const char * rawKey() const;
+ protected:
+ /**
+ * Returns the raw key appropriate for use directly with Sword.
+ */
+ virtual const char * rawKey() const;
-private:
- /** Disable assignment operator */
- CSwordVerseKey& operator= (const CSwordVerseKey&);
- /** Disable from base class to prevent compiler warnings */
- inline virtual CSwordVerseKey& operator= (const sword::VerseKey&) { return (*this); };
+ private:
+ /** Disable assignment operator */
+ CSwordVerseKey& operator= (const CSwordVerseKey&);
+ /** Disable from base class to prevent compiler warnings */
+ inline virtual CSwordVerseKey& operator= (const sword::VerseKey&) {
+ return (*this);
+ };
};
#endif