summaryrefslogtreecommitdiff
path: root/src/backend/drivers
diff options
context:
space:
mode:
authorRoberto C. Sanchez <roberto@connexer.com>2014-10-21 22:48:29 -0400
committerRoberto C. Sanchez <roberto@connexer.com>2014-10-21 22:48:29 -0400
commite8a196082586bb68e0bf254a8f6f4b8f39071f32 (patch)
treeb03dbbd1b5be6092ed5e9bcb3806aa2d4938bba3 /src/backend/drivers
parentdd2f7ce46df53f2c377c02d1bf4df8adcf092072 (diff)
Imported Upstream version 2.3.3
Diffstat (limited to 'src/backend/drivers')
-rw-r--r--src/backend/drivers/cswordbiblemoduleinfo.cpp282
-rw-r--r--src/backend/drivers/cswordbiblemoduleinfo.h160
-rw-r--r--src/backend/drivers/cswordbookmoduleinfo.cpp58
-rw-r--r--src/backend/drivers/cswordbookmoduleinfo.h66
-rw-r--r--src/backend/drivers/cswordcommentarymoduleinfo.cpp16
-rw-r--r--src/backend/drivers/cswordcommentarymoduleinfo.h28
-rw-r--r--src/backend/drivers/cswordlexiconmoduleinfo.cpp254
-rw-r--r--src/backend/drivers/cswordlexiconmoduleinfo.h76
-rw-r--r--src/backend/drivers/cswordmoduleinfo.cpp1328
-rw-r--r--src/backend/drivers/cswordmoduleinfo.h636
10 files changed, 1460 insertions, 1444 deletions
diff --git a/src/backend/drivers/cswordbiblemoduleinfo.cpp b/src/backend/drivers/cswordbiblemoduleinfo.cpp
index a7b89ba..f00a580 100644
--- a/src/backend/drivers/cswordbiblemoduleinfo.cpp
+++ b/src/backend/drivers/cswordbiblemoduleinfo.cpp
@@ -22,204 +22,204 @@
CSwordBibleModuleInfo::CSwordBibleModuleInfo( sword::SWModule* module, CSwordBackend* const usedBackend )
-: CSwordModuleInfo(module, usedBackend),
-m_lowerBound(0),
-m_upperBound(0),
-m_bookList(0),
-m_cachedLocale("unknown"),
-m_hasOT(-1),
-m_hasNT(-1) {}
+ : CSwordModuleInfo(module, usedBackend),
+ m_lowerBound(0),
+ m_upperBound(0),
+ m_bookList(0),
+ m_cachedLocale("unknown"),
+ m_hasOT(-1),
+ m_hasNT(-1) {}
CSwordBibleModuleInfo::CSwordBibleModuleInfo( const CSwordBibleModuleInfo& m ) :
-CSwordModuleInfo(m),
-m_lowerBound(0),
-m_upperBound(0),
-m_bookList(0) {
- if (m.m_bookList) {
- m_bookList = new QStringList();
- *m_bookList = *m.m_bookList;
- }
-
- m_hasOT = m.m_hasOT;
- m_hasNT = m.m_hasNT;
- m_cachedLocale = m.m_cachedLocale;
+ CSwordModuleInfo(m),
+ m_lowerBound(0),
+ m_upperBound(0),
+ m_bookList(0) {
+ if (m.m_bookList) {
+ m_bookList = new QStringList();
+ *m_bookList = *m.m_bookList;
+ }
+
+ m_hasOT = m.m_hasOT;
+ m_hasNT = m.m_hasNT;
+ m_cachedLocale = m.m_cachedLocale;
}
CSwordModuleInfo* CSwordBibleModuleInfo::clone() {
- return new CSwordBibleModuleInfo(*this);
+ return new CSwordBibleModuleInfo(*this);
}
CSwordBibleModuleInfo::~CSwordBibleModuleInfo() {
- delete m_bookList;
+ delete m_bookList;
}
void CSwordBibleModuleInfo::initBounds() {
- if (m_hasOT == -1) {
- m_hasOT = hasTestament(OldTestament);
- }
-
- if (m_hasNT == -1) {
- m_hasNT = hasTestament(NewTestament);
- }
-
- if (m_hasOT) {
- m_lowerBound.key("Genesis 1:1");
- }
- else {
- m_lowerBound.key("Matthew 1:1");
- }
-
- if (!m_hasNT) {
- m_upperBound.key("Malachi 4:6");
- }
- else {
- m_upperBound.key("Revelation of John 22:21");
- }
+ if (m_hasOT == -1) {
+ m_hasOT = hasTestament(OldTestament);
+ }
+
+ if (m_hasNT == -1) {
+ m_hasNT = hasTestament(NewTestament);
+ }
+
+ if (m_hasOT) {
+ m_lowerBound.key("Genesis 1:1");
+ }
+ else {
+ m_lowerBound.key("Matthew 1:1");
+ }
+
+ if (!m_hasNT) {
+ m_upperBound.key("Malachi 4:6");
+ }
+ else {
+ m_upperBound.key("Revelation of John 22:21");
+ }
}
/** Returns the books available in this module */
QStringList* CSwordBibleModuleInfo::books() {
- if (m_cachedLocale != backend()->booknameLanguage()) { //if the locale has changed
- delete m_bookList;
- m_bookList = 0;
- }
-
- if (!m_bookList) {
- m_bookList = new QStringList();
-
- initBounds();
- int min = 0;
- int max = 1;
-
- //find out if we have ot and nt, only ot or only nt
-
- if (m_hasOT>0 && m_hasNT>0) { //both
- min = 0;
- max = 1;
- }
- else if (m_hasOT>0 && !m_hasNT) { //only OT
- min = 0;
- max = 0;
- }
- else if (!m_hasOT && m_hasNT>0) { //only NT
- min = 1;
- max = 1;
- }
- else if (!m_hasOT && !m_hasNT) { //somethings wrong here! - no OT and no NT
- qWarning("CSwordBibleModuleInfo (%s) no OT and not NT! Check your config!", module()->Name());
- min = 0;
- max = -1;
- }
-
- boost::scoped_ptr<sword::VerseKey> key((sword::VerseKey *)module()->CreateKey());
- (*key) = sword::TOP;
-
- for (key->Testament(min+1); !key->Error() && (key->Testament()-1) <= max; key->Book(key->Book()+1)) {
- m_bookList->append( QString::fromUtf8(key->getBookName()) );
- }
-
- m_cachedLocale = backend()->booknameLanguage();
- }
-
- return m_bookList;
+ if (m_cachedLocale != backend()->booknameLanguage()) { //if the locale has changed
+ delete m_bookList;
+ m_bookList = 0;
+ }
+
+ if (!m_bookList) {
+ m_bookList = new QStringList();
+
+ initBounds();
+ int min = 0;
+ int max = 1;
+
+ //find out if we have ot and nt, only ot or only nt
+
+ if (m_hasOT > 0 && m_hasNT > 0) { //both
+ min = 0;
+ max = 1;
+ }
+ else if (m_hasOT > 0 && !m_hasNT) { //only OT
+ min = 0;
+ max = 0;
+ }
+ else if (!m_hasOT && m_hasNT > 0) { //only NT
+ min = 1;
+ max = 1;
+ }
+ else if (!m_hasOT && !m_hasNT) { //somethings wrong here! - no OT and no NT
+ qWarning("CSwordBibleModuleInfo (%s) no OT and not NT! Check your config!", module()->Name());
+ min = 0;
+ max = -1;
+ }
+
+ boost::scoped_ptr<sword::VerseKey> key((sword::VerseKey *)module()->CreateKey());
+ (*key) = sword::TOP;
+
+ for (key->Testament(min + 1); !key->Error() && (key->Testament() - 1) <= max; key->Book(key->Book() + 1)) {
+ m_bookList->append( QString::fromUtf8(key->getBookName()) );
+ }
+
+ m_cachedLocale = backend()->booknameLanguage();
+ }
+
+ return m_bookList;
}
/** Returns the number of chapters for the given book. */
unsigned int CSwordBibleModuleInfo::chapterCount(const unsigned int book) {
- int result = 0;
+ int result = 0;
- boost::scoped_ptr<sword::VerseKey> key((sword::VerseKey *)module()->CreateKey());
- (*key) = sword::TOP;
+ boost::scoped_ptr<sword::VerseKey> key((sword::VerseKey *)module()->CreateKey());
+ (*key) = sword::TOP;
- // works for old and new versions
- key->Book(book);
- (*key) = sword::MAXCHAPTER;
- result = key->Chapter();
+ // works for old and new versions
+ key->Book(book);
+ (*key) = sword::MAXCHAPTER;
+ result = key->Chapter();
- return result;
+ return result;
}
unsigned int CSwordBibleModuleInfo::chapterCount(const QString& book) {
- return chapterCount( bookNumber(book) );
+ return chapterCount( bookNumber(book) );
}
/** Returns the number of verses for the given chapter. */
unsigned int CSwordBibleModuleInfo::verseCount( const unsigned int book, const unsigned int chapter ) {
- unsigned int result = 0;
+ unsigned int result = 0;
- boost::scoped_ptr<sword::VerseKey> key((sword::VerseKey *)module()->CreateKey());
- (*key) = sword::TOP;
+ boost::scoped_ptr<sword::VerseKey> key((sword::VerseKey *)module()->CreateKey());
+ (*key) = sword::TOP;
- // works for old and new versions
- key->Book(book);
- key->Chapter(chapter);
- (*key) = sword::MAXVERSE;
- result = key->Verse();
+ // works for old and new versions
+ key->Book(book);
+ key->Chapter(chapter);
+ (*key) = sword::MAXVERSE;
+ result = key->Verse();
- return result;
+ return result;
}
unsigned int CSwordBibleModuleInfo::verseCount( const QString& book, const unsigned int chapter ) {
- return verseCount( bookNumber(book), chapter );
+ return verseCount( bookNumber(book), chapter );
}
unsigned int CSwordBibleModuleInfo::bookNumber(const QString &book) {
- unsigned int bookNumber = 0;
+ unsigned int bookNumber = 0;
- //find out if we have ot and nt, only ot or only nt
- initBounds();
+ //find out if we have ot and nt, only ot or only nt
+ initBounds();
- boost::scoped_ptr<sword::VerseKey> key((sword::VerseKey *)module()->CreateKey());
- (*key) = sword::TOP;
+ boost::scoped_ptr<sword::VerseKey> key((sword::VerseKey *)module()->CreateKey());
+ (*key) = sword::TOP;
- key->setBookName(book.toUtf8().constData());
+ key->setBookName(book.toUtf8().constData());
- bookNumber = ((key->Testament() > 1) ? key->BMAX[0] : 0) + key->Book();
+ bookNumber = ((key->Testament() > 1) ? key->BMAX[0] : 0) + key->Book();
- return bookNumber;
+ return bookNumber;
}
/** Returns true if his module has the text of desired type of testament */
bool CSwordBibleModuleInfo::hasTestament( CSwordBibleModuleInfo::Testament type ) {
- if (m_hasOT == -1 || m_hasNT == -1) {
- const bool oldStatus = module()->getSkipConsecutiveLinks();
- module()->setSkipConsecutiveLinks(true);
+ if (m_hasOT == -1 || m_hasNT == -1) {
+ const bool oldStatus = module()->getSkipConsecutiveLinks();
+ module()->setSkipConsecutiveLinks(true);
- *module() = sword::TOP; //position to first entry
- sword::VerseKey key( module()->KeyText() );
+ *module() = sword::TOP; //position to first entry
+ sword::VerseKey key( module()->KeyText() );
- if (key.Testament() == 1) { // OT && NT
- m_hasOT = 1;
- }
- else if (key.Testament() == 2) { //no OT
- m_hasOT = 0;
- }
+ if (key.Testament() == 1) { // OT && NT
+ m_hasOT = 1;
+ }
+ else if (key.Testament() == 2) { //no OT
+ m_hasOT = 0;
+ }
- *module() = sword::BOTTOM;
- key = module()->KeyText();
+ *module() = sword::BOTTOM;
+ key = module()->KeyText();
- if (key.Testament() == 1) { // only OT, no NT
- m_hasNT = 0;
- }
- else if (key.Testament() == 2) { //has NT
- m_hasNT = 1;
- }
+ if (key.Testament() == 1) { // only OT, no NT
+ m_hasNT = 0;
+ }
+ else if (key.Testament() == 2) { //has NT
+ m_hasNT = 1;
+ }
- module()->setSkipConsecutiveLinks(oldStatus);
- }
+ module()->setSkipConsecutiveLinks(oldStatus);
+ }
- switch (type) {
+ switch (type) {
- case OldTestament:
- return m_hasOT>0;
+ case OldTestament:
+ return m_hasOT > 0;
- case NewTestament:
- return m_hasNT>0;
+ case NewTestament:
+ return m_hasNT > 0;
- default:
- return false;
- }
+ default:
+ return false;
+ }
}
diff --git a/src/backend/drivers/cswordbiblemoduleinfo.h b/src/backend/drivers/cswordbiblemoduleinfo.h
index c25eb37..10d05bb 100644
--- a/src/backend/drivers/cswordbiblemoduleinfo.h
+++ b/src/backend/drivers/cswordbiblemoduleinfo.h
@@ -26,101 +26,101 @@
class CSwordBibleModuleInfo : public CSwordModuleInfo {
-public:
- enum Testament {
- OldTestament = 1,
- NewTestament = 2
- };
+ public:
+ enum Testament {
+ OldTestament = 1,
+ NewTestament = 2
+ };
- /**
- * The constructor of this class
- */
- CSwordBibleModuleInfo( sword::SWModule* module, CSwordBackend* const );
- /** The copy constructor for this Bible module.
- */
- CSwordBibleModuleInfo( const CSwordBibleModuleInfo& m );
- /**
- * The destructor of this class
- */
- ~CSwordBibleModuleInfo();
- /**
- * Returns the number of avalable verses for the given chapter and book.
- *
- * @param book The number book we should use
- * @param chapter The chapter we should use
- * @return The number of verses for the given book and chapter
- */
- virtual unsigned int verseCount( const unsigned int book, const unsigned int chapter );
- /**
- * Returns the number of avalable verses for the given chapter and book.
- *
- * @param book The name of the book we use
- * @param chapter The number of the chapter we use
- * @return The number of verses for the given book and chapter
- */
- virtual unsigned int verseCount( const QString& book, const unsigned int chapter );
- /** Information about the chapters in a book.
- * @return The number of available chapters of the given book.
- * @return The number of chapters for the given book
- */
- virtual unsigned int chapterCount( const unsigned int book );
- /** Information about the chapters in a book.
- * @return The number of available chapters of the given book.
- */
- virtual unsigned int chapterCount( const QString& book );
- /** Return all book of this module.
- * @return A QStringList containing the books which are available in this module.
- */
- virtual QStringList* books();
- /**
- * Reimplementation, Returns the type
- */
- virtual CSwordModuleInfo::ModuleType type() const;
- /**
- * @return the book number, values starting with 1; 0 if not found
- */
- unsigned int bookNumber(const QString &book);
- /**
- * Returns true if his module has the text of desired type of testament
- */
- bool hasTestament( CSwordBibleModuleInfo::Testament );
- /** Reimplementation to clone this object. */
- virtual CSwordModuleInfo* clone();
- /**
- * Returns the key which represents the lower bound of this module.
- */
- inline const CSwordVerseKey& lowerBound();
- /**
- * Returns the key which represents the upper bound of this module.
- */
- inline const CSwordVerseKey& upperBound();
+ /**
+ * The constructor of this class
+ */
+ CSwordBibleModuleInfo( sword::SWModule* module, CSwordBackend* const );
+ /** The copy constructor for this Bible module.
+ */
+ CSwordBibleModuleInfo( const CSwordBibleModuleInfo& m );
+ /**
+ * The destructor of this class
+ */
+ ~CSwordBibleModuleInfo();
+ /**
+ * Returns the number of avalable verses for the given chapter and book.
+ *
+ * @param book The number book we should use
+ * @param chapter The chapter we should use
+ * @return The number of verses for the given book and chapter
+ */
+ virtual unsigned int verseCount( const unsigned int book, const unsigned int chapter );
+ /**
+ * Returns the number of avalable verses for the given chapter and book.
+ *
+ * @param book The name of the book we use
+ * @param chapter The number of the chapter we use
+ * @return The number of verses for the given book and chapter
+ */
+ virtual unsigned int verseCount( const QString& book, const unsigned int chapter );
+ /** Information about the chapters in a book.
+ * @return The number of available chapters of the given book.
+ * @return The number of chapters for the given book
+ */
+ virtual unsigned int chapterCount( const unsigned int book );
+ /** Information about the chapters in a book.
+ * @return The number of available chapters of the given book.
+ */
+ virtual unsigned int chapterCount( const QString& book );
+ /** Return all book of this module.
+ * @return A QStringList containing the books which are available in this module.
+ */
+ virtual QStringList* books();
+ /**
+ * Reimplementation, Returns the type
+ */
+ virtual CSwordModuleInfo::ModuleType type() const;
+ /**
+ * @return the book number, values starting with 1; 0 if not found
+ */
+ unsigned int bookNumber(const QString &book);
+ /**
+ * Returns true if his module has the text of desired type of testament
+ */
+ bool hasTestament( CSwordBibleModuleInfo::Testament );
+ /** Reimplementation to clone this object. */
+ virtual CSwordModuleInfo* clone();
+ /**
+ * Returns the key which represents the lower bound of this module.
+ */
+ inline const CSwordVerseKey& lowerBound();
+ /**
+ * Returns the key which represents the upper bound of this module.
+ */
+ inline const CSwordVerseKey& upperBound();
-private:
- void initBounds();
+ private:
+ void initBounds();
- CSwordVerseKey m_lowerBound;
- CSwordVerseKey m_upperBound;
+ CSwordVerseKey m_lowerBound;
+ CSwordVerseKey m_upperBound;
- QStringList* m_bookList; //This booklist is cached
- QString m_cachedLocale;
- short int m_hasOT;
- short int m_hasNT;
+ QStringList* m_bookList; //This booklist is cached
+ QString m_cachedLocale;
+ short int m_hasOT;
+ short int m_hasNT;
};
inline CSwordModuleInfo::ModuleType CSwordBibleModuleInfo::type() const {
- return CSwordModuleInfo::Bible;
+ return CSwordModuleInfo::Bible;
}
/** Returns the key which represents the lower bound of this module. */
inline const CSwordVerseKey& CSwordBibleModuleInfo::lowerBound() {
- initBounds();
- return m_lowerBound;
+ initBounds();
+ return m_lowerBound;
}
/** Returns the key which represents the lower bound of this module. */
inline const CSwordVerseKey& CSwordBibleModuleInfo::upperBound() {
- initBounds();
- return m_upperBound;
+ initBounds();
+ return m_upperBound;
}
#endif
diff --git a/src/backend/drivers/cswordbookmoduleinfo.cpp b/src/backend/drivers/cswordbookmoduleinfo.cpp
index 0a8c1e6..b67015b 100644
--- a/src/backend/drivers/cswordbookmoduleinfo.cpp
+++ b/src/backend/drivers/cswordbookmoduleinfo.cpp
@@ -16,53 +16,53 @@
#include <treekey.h>
CSwordBookModuleInfo::CSwordBookModuleInfo( sword::SWModule* module, CSwordBackend* const usedBackend )
-: CSwordModuleInfo(module, usedBackend),
-m_depth(-1) {}
+ : CSwordModuleInfo(module, usedBackend),
+ m_depth(-1) {}
CSwordBookModuleInfo::CSwordBookModuleInfo( const CSwordBookModuleInfo& module )
-: CSwordModuleInfo(module) {
- m_depth = module.m_depth;
+ : CSwordModuleInfo(module) {
+ m_depth = module.m_depth;
}
CSwordBookModuleInfo::~CSwordBookModuleInfo() {}
int CSwordBookModuleInfo::depth() {
- if (m_depth == -1) {
- sword::TreeKeyIdx* key = tree();
+ if (m_depth == -1) {
+ sword::TreeKeyIdx* key = tree();
- if (key) {
- key->root();
- computeDepth(key, 0);
- }
- }
+ if (key) {
+ key->root();
+ computeDepth(key, 0);
+ }
+ }
- return m_depth;
+ return m_depth;
}
void CSwordBookModuleInfo::computeDepth(sword::TreeKeyIdx* key, int level ) {
- std::string savedKey;
- // savedKey = key->getFullName(); //sword 1.5.8
- savedKey = key->getText();
+ std::string savedKey;
+ // savedKey = key->getFullName(); //sword 1.5.8
+ savedKey = key->getText();
- if (level > m_depth) {
- m_depth = level;
- }
+ if (level > m_depth) {
+ m_depth = level;
+ }
- if (key->hasChildren()) {
- key->firstChild();
- computeDepth(key, level+1);
+ if (key->hasChildren()) {
+ key->firstChild();
+ computeDepth(key, level + 1);
- key->setText( savedKey.c_str() );//return to the initial value
- }
+ key->setText( savedKey.c_str() );//return to the initial value
+ }
- if (key->nextSibling()) {
- computeDepth(key, level);
- }
+ if (key->nextSibling()) {
+ computeDepth(key, level);
+ }
}
/** Returns a treekey filled with the structure of this module */
sword::TreeKeyIdx* CSwordBookModuleInfo::tree() const {
- sword::TreeKeyIdx* treeKey = dynamic_cast<sword::TreeKeyIdx*>((sword::SWKey*)*(module()));
- Q_ASSERT(treeKey);
- return treeKey;
+ sword::TreeKeyIdx* treeKey = dynamic_cast<sword::TreeKeyIdx*>((sword::SWKey*) * (module()));
+ Q_ASSERT(treeKey);
+ return treeKey;
}
diff --git a/src/backend/drivers/cswordbookmoduleinfo.h b/src/backend/drivers/cswordbookmoduleinfo.h
index f471d61..cd18efc 100644
--- a/src/backend/drivers/cswordbookmoduleinfo.h
+++ b/src/backend/drivers/cswordbookmoduleinfo.h
@@ -21,43 +21,43 @@
class CSwordBookModuleInfo : public CSwordModuleInfo {
-public:
- /** Constructor.
- * @param module The module which belongs to this object
- * @param backend The parent backend for this book module.
- */
- CSwordBookModuleInfo( sword::SWModule* module, CSwordBackend* const backend );
- /** Copy constructor.
- * Copy constructor to copy the passed parameter.
- * @param module The module which should be copied.
- */
- CSwordBookModuleInfo( const CSwordBookModuleInfo& module );
- /** Destructor.
- */
- ~CSwordBookModuleInfo();
- /**
- * Returns the type of the module.
- */
- virtual CSwordModuleInfo::ModuleType type() const;
- /**
- * Returns the maximal depth of sections and subsections.
- */
- int depth();
- /**
- * @return A treekey filled with the structure of this module. Don't delete the returned key because it's casted from the module object.
- */
- sword::TreeKeyIdx* tree() const;
+ public:
+ /** Constructor.
+ * @param module The module which belongs to this object
+ * @param backend The parent backend for this book module.
+ */
+ CSwordBookModuleInfo( sword::SWModule* module, CSwordBackend* const backend );
+ /** Copy constructor.
+ * Copy constructor to copy the passed parameter.
+ * @param module The module which should be copied.
+ */
+ CSwordBookModuleInfo( const CSwordBookModuleInfo& module );
+ /** Destructor.
+ */
+ ~CSwordBookModuleInfo();
+ /**
+ * Returns the type of the module.
+ */
+ virtual CSwordModuleInfo::ModuleType type() const;
+ /**
+ * Returns the maximal depth of sections and subsections.
+ */
+ int depth();
+ /**
+ * @return A treekey filled with the structure of this module. Don't delete the returned key because it's casted from the module object.
+ */
+ sword::TreeKeyIdx* tree() const;
-private:
- /**
- * A recursive helper function to help computng the module depth!
- */
- void computeDepth(sword::TreeKeyIdx* key, int level = 0 );
- int m_depth;
+ private:
+ /**
+ * A recursive helper function to help computng the module depth!
+ */
+ void computeDepth(sword::TreeKeyIdx* key, int level = 0 );
+ int m_depth;
};
inline CSwordBookModuleInfo::ModuleType CSwordBookModuleInfo::type() const {
- return CSwordModuleInfo::GenericBook;
+ return CSwordModuleInfo::GenericBook;
}
diff --git a/src/backend/drivers/cswordcommentarymoduleinfo.cpp b/src/backend/drivers/cswordcommentarymoduleinfo.cpp
index b09e2f3..bb19a23 100644
--- a/src/backend/drivers/cswordcommentarymoduleinfo.cpp
+++ b/src/backend/drivers/cswordcommentarymoduleinfo.cpp
@@ -10,23 +10,23 @@
#include "cswordcommentarymoduleinfo.h"
CSwordCommentaryModuleInfo::CSwordCommentaryModuleInfo( sword::SWModule* module, CSwordBackend* const usedBackend)
-: CSwordBibleModuleInfo(module, usedBackend) {}
+ : CSwordBibleModuleInfo(module, usedBackend) {}
CSwordCommentaryModuleInfo::~CSwordCommentaryModuleInfo() {}
/** No descriptions */
CSwordModuleInfo* CSwordCommentaryModuleInfo::clone() {
- return new CSwordCommentaryModuleInfo(*this);
+ return new CSwordCommentaryModuleInfo(*this);
}
/** Returns true if this module may be written by the write display windows. */
bool CSwordCommentaryModuleInfo::isWritable() const {
- // qWarning(module()->getConfigEntry("ModDrv"));
- //a module is only writable if it's a RawFiles module with writable returning true
+ // qWarning(module()->getConfigEntry("ModDrv"));
+ //a module is only writable if it's a RawFiles module with writable returning true
- if ( (std::string(module()->getConfigEntry("ModDrv")) == std::string("RawFiles")) && module()->isWritable()) {
- return true;
- };
+ if ( (std::string(module()->getConfigEntry("ModDrv")) == std::string("RawFiles")) && module()->isWritable()) {
+ return true;
+ };
- return false;
+ return false;
}
diff --git a/src/backend/drivers/cswordcommentarymoduleinfo.h b/src/backend/drivers/cswordcommentarymoduleinfo.h
index 7ebf23f..eb9db83 100644
--- a/src/backend/drivers/cswordcommentarymoduleinfo.h
+++ b/src/backend/drivers/cswordcommentarymoduleinfo.h
@@ -21,23 +21,23 @@
class CSwordCommentaryModuleInfo : public CSwordBibleModuleInfo {
-public:
- CSwordCommentaryModuleInfo( sword::SWModule* module, CSwordBackend* const );
- ~CSwordCommentaryModuleInfo();
- /** Reimplementation to return the commentary type.
- */
- virtual CSwordModuleInfo::ModuleType type() const;
- /** Reimplementation to clone the current object.
- */
- virtual CSwordModuleInfo* clone();
- /**
- * Returns true if this module may be written by the write display windows.
- */
- virtual bool isWritable() const;
+ public:
+ CSwordCommentaryModuleInfo( sword::SWModule* module, CSwordBackend* const );
+ ~CSwordCommentaryModuleInfo();
+ /** Reimplementation to return the commentary type.
+ */
+ virtual CSwordModuleInfo::ModuleType type() const;
+ /** Reimplementation to clone the current object.
+ */
+ virtual CSwordModuleInfo* clone();
+ /**
+ * Returns true if this module may be written by the write display windows.
+ */
+ virtual bool isWritable() const;
};
inline CSwordModuleInfo::ModuleType CSwordCommentaryModuleInfo::type() const {
- return CSwordModuleInfo::Commentary;
+ return CSwordModuleInfo::Commentary;
}
#endif
diff --git a/src/backend/drivers/cswordlexiconmoduleinfo.cpp b/src/backend/drivers/cswordlexiconmoduleinfo.cpp
index c84cd07..28874b6 100644
--- a/src/backend/drivers/cswordlexiconmoduleinfo.cpp
+++ b/src/backend/drivers/cswordlexiconmoduleinfo.cpp
@@ -25,151 +25,151 @@
#define CACHE_FORMAT "2"
CSwordLexiconModuleInfo::CSwordLexiconModuleInfo( sword::SWModule* module, CSwordBackend* const backend ) : CSwordModuleInfo(module, backend) {
- m_entryList = 0;
+ m_entryList = 0;
}
CSwordLexiconModuleInfo::CSwordLexiconModuleInfo( const CSwordLexiconModuleInfo& m ) : CSwordModuleInfo(m) {
- delete m_entryList;
- m_entryList = 0;
+ delete m_entryList;
+ m_entryList = 0;
- if (m.m_entryList) {
- m_entryList = new QStringList();
- *m_entryList = *m.m_entryList;//copy list items
- }
+ if (m.m_entryList) {
+ m_entryList = new QStringList();
+ *m_entryList = *m.m_entryList;//copy list items
+ }
}
CSwordLexiconModuleInfo::~CSwordLexiconModuleInfo() {
- delete m_entryList;
- m_entryList = 0;
+ delete m_entryList;
+ m_entryList = 0;
}
/** Returns the entries of the module. */
QStringList* CSwordLexiconModuleInfo::entries() {
- if (!module()) {
- return 0;
- }
-
- sword::SWModule* my_module = module();
- bool is_unicode = isUnicode();
-
- if (!m_entryList) {
- m_entryList = new QStringList();
- bool read = false;
-
- //Check for buggy modules! They will not be loaded any more.
-
- if ( name() == QString("ZhEnglish")) {
- qWarning("Module ZhEnglish is buggy and will not be loaded.");
- return m_entryList;
- }
-
- if ( name() == QString("EReo_en")) {
- qWarning("Module EReo_en is buggy and will not be loaded.");
- return m_entryList;
- }
-
- QString dir(util::filesystem::DirectoryUtil::getUserCacheDir().absolutePath());
- QFile f1(
- QString(dir)
- .append("/")
- .append(name())
- );
-
- if ( f1.open( QIODevice::ReadOnly ) ) {
- QDataStream s( &f1 );
- QString mod_ver, prog_ver;
- s >> mod_ver;
- s >> prog_ver;
-
- if ((mod_ver == config(ModuleVersion)) && (prog_ver == CACHE_FORMAT)) {
- s >> *m_entryList;
- read = true;
- }
-
- f1.close();
- // qWarning("read entries %d",m_entryList->count());
- }
-
- // Q_ASSERT(read);
- // Q_ASSERT(m_entryList->count());
- if (!read || !m_entryList->count()) {
- my_module->setSkipConsecutiveLinks(true);
- (*my_module) = sword::TOP;
- snap(); //snap to top entry
-
- // qWarning("Reading in module" );
- int i = 0;
-
- do {
- if ( is_unicode ) {
- m_entryList->append(QString::fromUtf8(my_module->KeyText()));
- // qWarning("Entry: %s", my_module->KeyText() );
- }
- else { //for latin1 modules use fromLatin1 because of speed
- // m_entryList->append(QString::fromLatin1(my_module->KeyText()));
- QTextCodec* codec = QTextCodec::codecForName("Windows-1252");
- m_entryList->append(codec->toUnicode(my_module->KeyText()));
- }
-
- (*my_module)++;
- i++;
- }
- while ( !my_module->Error() );
-
- // qWarning("Reading finished. Module has %d entries.", i );
-
- (*my_module) = sword::TOP; //back to the first entry
-
- my_module->setSkipConsecutiveLinks(false);
-
- if (m_entryList->count()) {
- m_entryList->first().simplified();
-
- if (m_entryList->first().trimmed().isEmpty()) {
- m_entryList->erase( m_entryList->begin() );
- }
-
- //now sort the list, this is necesssary because Sword doesn't do Unicode ordering
- // qWarning("sorting");
- // QStringList::iterator start(m_entryList->begin());
- // QStringList::iterator end(m_entryList->end());
- // std::sort( start, end, myLocaleAwareCompare() ); //stl sort
- // m_entryList->sort(); //make sure the module is sorted by utf-8
- }
-
- qWarning("Writing cache file.");
-
- if (m_entryList->count()) {
- //create cache
- QString dir = util::filesystem::DirectoryUtil::getUserCacheDir().absolutePath();
- //QFile f2( QString::fromLatin1("%1/%2").arg(dir).arg( name() ) );
- QFile f2( QString(dir).append("/").append(name()) );
-
-
- if (f2.open( QIODevice::WriteOnly )) {
- QDataStream s( &f2 );
- s << config(CSwordModuleInfo::ModuleVersion); //store module version
- s << QString(CACHE_FORMAT); //store BT version -- format may change
- s << *m_entryList;
- f2.close();
- }
- }
- }
- }
-
- return m_entryList;
+ if (!module()) {
+ return 0;
+ }
+
+ sword::SWModule* my_module = module();
+ bool is_unicode = isUnicode();
+
+ if (!m_entryList) {
+ m_entryList = new QStringList();
+ bool read = false;
+
+ //Check for buggy modules! They will not be loaded any more.
+
+ if ( name() == QString("ZhEnglish")) {
+ qWarning("Module ZhEnglish is buggy and will not be loaded.");
+ return m_entryList;
+ }
+
+ if ( name() == QString("EReo_en")) {
+ qWarning("Module EReo_en is buggy and will not be loaded.");
+ return m_entryList;
+ }
+
+ QString dir(util::filesystem::DirectoryUtil::getUserCacheDir().absolutePath());
+ QFile f1(
+ QString(dir)
+ .append("/")
+ .append(name())
+ );
+
+ if ( f1.open( QIODevice::ReadOnly ) ) {
+ QDataStream s( &f1 );
+ QString mod_ver, prog_ver;
+ s >> mod_ver;
+ s >> prog_ver;
+
+ if ((mod_ver == config(ModuleVersion)) && (prog_ver == CACHE_FORMAT)) {
+ s >> *m_entryList;
+ read = true;
+ }
+
+ f1.close();
+ // qWarning("read entries %d",m_entryList->count());
+ }
+
+ // Q_ASSERT(read);
+ // Q_ASSERT(m_entryList->count());
+ if (!read || !m_entryList->count()) {
+ my_module->setSkipConsecutiveLinks(true);
+ (*my_module) = sword::TOP;
+ snap(); //snap to top entry
+
+ // qWarning("Reading in module" );
+ int i = 0;
+
+ do {
+ if ( is_unicode ) {
+ m_entryList->append(QString::fromUtf8(my_module->KeyText()));
+ // qWarning("Entry: %s", my_module->KeyText() );
+ }
+ else { //for latin1 modules use fromLatin1 because of speed
+ // m_entryList->append(QString::fromLatin1(my_module->KeyText()));
+ QTextCodec* codec = QTextCodec::codecForName("Windows-1252");
+ m_entryList->append(codec->toUnicode(my_module->KeyText()));
+ }
+
+ (*my_module)++;
+ i++;
+ }
+ while ( !my_module->Error() );
+
+ // qWarning("Reading finished. Module has %d entries.", i );
+
+ (*my_module) = sword::TOP; //back to the first entry
+
+ my_module->setSkipConsecutiveLinks(false);
+
+ if (m_entryList->count()) {
+ m_entryList->first().simplified();
+
+ if (m_entryList->first().trimmed().isEmpty()) {
+ m_entryList->erase( m_entryList->begin() );
+ }
+
+ //now sort the list, this is necesssary because Sword doesn't do Unicode ordering
+ // qWarning("sorting");
+ // QStringList::iterator start(m_entryList->begin());
+ // QStringList::iterator end(m_entryList->end());
+ // std::sort( start, end, myLocaleAwareCompare() ); //stl sort
+ // m_entryList->sort(); //make sure the module is sorted by utf-8
+ }
+
+ qWarning("Writing cache file.");
+
+ if (m_entryList->count()) {
+ //create cache
+ QString dir = util::filesystem::DirectoryUtil::getUserCacheDir().absolutePath();
+ //QFile f2( QString::fromLatin1("%1/%2").arg(dir).arg( name() ) );
+ QFile f2( QString(dir).append("/").append(name()) );
+
+
+ if (f2.open( QIODevice::WriteOnly )) {
+ QDataStream s( &f2 );
+ s << config(CSwordModuleInfo::ModuleVersion); //store module version
+ s << QString(CACHE_FORMAT); //store BT version -- format may change
+ s << *m_entryList;
+ f2.close();
+ }
+ }
+ }
+ }
+
+ return m_entryList;
}
/** Jumps to the closest entry in the module. */
bool CSwordLexiconModuleInfo::snap() {
- if(module()->getRawEntry()) { // Snap to the current entry
- return true;
- }
+ if (module()->getRawEntry()) { // Snap to the current entry
+ return true;
+ }
- return false;
+ return false;
}
/** No descriptions */
CSwordModuleInfo* CSwordLexiconModuleInfo::clone() {
- return new CSwordLexiconModuleInfo(*this);
+ return new CSwordLexiconModuleInfo(*this);
}
diff --git a/src/backend/drivers/cswordlexiconmoduleinfo.h b/src/backend/drivers/cswordlexiconmoduleinfo.h
index 13f72e4..e5a5535 100644
--- a/src/backend/drivers/cswordlexiconmoduleinfo.h
+++ b/src/backend/drivers/cswordlexiconmoduleinfo.h
@@ -24,48 +24,48 @@
class CSwordLexiconModuleInfo : public CSwordModuleInfo {
-public:
- /**
- * The standard constructor fot this object.
- * A default constructor doesn't exist. Use this one.
- */
- CSwordLexiconModuleInfo( sword::SWModule* module, CSwordBackend* const );
- /**
- * The copy constructor
- */
- CSwordLexiconModuleInfo( const CSwordLexiconModuleInfo& m );
- /** Reimplementation to return a valid clone.
- */
- virtual CSwordModuleInfo* clone();
- /** Destructor.
- */
- virtual ~CSwordLexiconModuleInfo();
- /**
- * Returns the entries of the module.
- * This function returns the entries of the modules represented by this object.
- * If this function is called for the first time the list is load from disk and stored in a list which cahes it.
- * If the function is called again, the cached list is returned so we have a major speed improvement.
- * @return The list of lexicon entries
- */
- QStringList* entries();
- /**
- * Reimplementation, to return the right type for this lexicon.
- */
- virtual CSwordModuleInfo::ModuleType type() const;
- /**
- * Jumps to the closest entry in the module.
- */
- bool snap();
+ public:
+ /**
+ * The standard constructor fot this object.
+ * A default constructor doesn't exist. Use this one.
+ */
+ CSwordLexiconModuleInfo( sword::SWModule* module, CSwordBackend* const );
+ /**
+ * The copy constructor
+ */
+ CSwordLexiconModuleInfo( const CSwordLexiconModuleInfo& m );
+ /** Reimplementation to return a valid clone.
+ */
+ virtual CSwordModuleInfo* clone();
+ /** Destructor.
+ */
+ virtual ~CSwordLexiconModuleInfo();
+ /**
+ * Returns the entries of the module.
+ * This function returns the entries of the modules represented by this object.
+ * If this function is called for the first time the list is load from disk and stored in a list which cahes it.
+ * If the function is called again, the cached list is returned so we have a major speed improvement.
+ * @return The list of lexicon entries
+ */
+ QStringList* entries();
+ /**
+ * Reimplementation, to return the right type for this lexicon.
+ */
+ virtual CSwordModuleInfo::ModuleType type() const;
+ /**
+ * Jumps to the closest entry in the module.
+ */
+ bool snap();
-private:
- /**
- * This is the list which caches the entres of the module.
- */
- QStringList* m_entryList;
+ private:
+ /**
+ * This is the list which caches the entres of the module.
+ */
+ QStringList* m_entryList;
};
inline CSwordModuleInfo::ModuleType CSwordLexiconModuleInfo::type() const {
- return CSwordModuleInfo::Lexicon;
+ return CSwordModuleInfo::Lexicon;
}
#endif
diff --git a/src/backend/drivers/cswordmoduleinfo.cpp b/src/backend/drivers/cswordmoduleinfo.cpp
index c76f5ef..5861a2b 100644
--- a/src/backend/drivers/cswordmoduleinfo.cpp
+++ b/src/backend/drivers/cswordmoduleinfo.cpp
@@ -53,96 +53,96 @@
//Increment this, if the index format changes
//Then indices on the user's systems will be rebuilt
-const unsigned int INDEX_VERSION = 6;
+const unsigned int INDEX_VERSION = 7;
//Maximum index entry size, 1MiB for now
//Lucene default is too small
-const unsigned long BT_MAX_LUCENE_FIELD_LENGTH = 1024*1024;
+const unsigned long BT_MAX_LUCENE_FIELD_LENGTH = 1024 * 1024;
CSwordModuleInfo::CSwordModuleInfo(sword::SWModule * module, CSwordBackend * const usedBackend) {
- m_module = module;
- Q_ASSERT(module);
-
- m_hidden = false;
- m_cancelIndexing = false;
- m_searchResult.ClearList();
- m_backend = usedBackend ? usedBackend : CPointers::backend();
- m_dataCache.name = module ? QString(module->Name()) : QString::null;
- m_dataCache.isUnicode = module ? module->isUnicode() : false;
- m_dataCache.category = UnknownCategory;
- m_dataCache.language = 0;
- m_dataCache.hasVersion = !QString((*m_backend->getConfig())[module->Name()]["Version"]).isEmpty();
-
- if (backend()) {
- if (hasVersion() && (minimumSwordVersion() > sword::SWVersion::currentVersion)) {
- qWarning("The module \"%s\" requires a newer Sword library. Please update to \"Sword %s\".",
- name().toUtf8().constData(), (const char *)minimumSwordVersion());
- }
- }
-}
-
-CSwordModuleInfo::CSwordModuleInfo(const CSwordModuleInfo & m) : QObject(){
- m_module = m.m_module;
- m_backend = m.m_backend;
- m_dataCache = m.m_dataCache;
- m_searchResult = m.m_searchResult;
- m_hidden = m.m_hidden;
- m_cancelIndexing = m.m_cancelIndexing;
+ m_module = module;
+ Q_ASSERT(module);
+
+ m_hidden = false;
+ m_cancelIndexing = false;
+ m_searchResult.ClearList();
+ m_backend = usedBackend ? usedBackend : CPointers::backend();
+ m_dataCache.name = module ? QString(module->Name()) : QString::null;
+ m_dataCache.isUnicode = module ? module->isUnicode() : false;
+ m_dataCache.category = UnknownCategory;
+ m_dataCache.language = 0;
+ m_dataCache.hasVersion = !QString((*m_backend->getConfig())[module->Name()]["Version"]).isEmpty();
+
+ if (backend()) {
+ if (hasVersion() && (minimumSwordVersion() > sword::SWVersion::currentVersion)) {
+ qWarning("The module \"%s\" requires a newer Sword library. Please update to \"Sword %s\".",
+ name().toUtf8().constData(), (const char *)minimumSwordVersion());
+ }
+ }
+}
+
+CSwordModuleInfo::CSwordModuleInfo(const CSwordModuleInfo & m) : QObject() {
+ m_module = m.m_module;
+ m_backend = m.m_backend;
+ m_dataCache = m.m_dataCache;
+ m_searchResult = m.m_searchResult;
+ m_hidden = m.m_hidden;
+ m_cancelIndexing = m.m_cancelIndexing;
}
/** No descriptions */
CSwordModuleInfo *CSwordModuleInfo::clone() {
- return new CSwordModuleInfo(*this);
+ return new CSwordModuleInfo(*this);
}
CSwordModuleInfo::~CSwordModuleInfo() {
- m_searchResult.ClearList();
- m_module = 0; //the Sword module object is deleted by the backend
+ m_searchResult.ClearList();
+ m_module = 0; //the Sword module object is deleted by the backend
}
/** Sets the unlock key of the modules and writes the key into the cofig file.*/
bool CSwordModuleInfo::unlock(const QString & unlockKey) {
- if (!isEncrypted()) {
- return false;
- }
+ if (!isEncrypted()) {
+ return false;
+ }
- CBTConfig::setModuleEncryptionKey(name(), unlockKey);
- backend()->setCipherKey(m_module->Name(), unlockKey.toUtf8().constData());
- //TODO: write to Sword config as well
+ CBTConfig::setModuleEncryptionKey(name(), unlockKey);
+ backend()->setCipherKey(m_module->Name(), unlockKey.toUtf8().constData());
+ //TODO: write to Sword config as well
- return true;
+ return true;
}
/** This function returns true if this module is locked, otherwise return false. */
bool CSwordModuleInfo::isLocked() {
- //still works, but the cipherkey is stored in CBTConfig.
- //Works because it is set in sword on program startup.
+ //still works, but the cipherkey is stored in CBTConfig.
+ //Works because it is set in sword on program startup.
- if (isEncrypted()) {
- if (unlockKeyIsValid()) {
- return false;
- }
- return true;
- }
- return false;
+ if (isEncrypted()) {
+ if (unlockKeyIsValid()) {
+ return false;
+ }
+ return true;
+ }
+ return false;
}
/** This functions returns true if this module is encrypted (locked or unlocked). */
bool CSwordModuleInfo::isEncrypted() const {
- /**
- * If we have the CipherKey entry the module
- * is encrypted but not necessarily locked
- */
+ /**
+ * If we have the CipherKey entry the module
+ * is encrypted but not necessarily locked
+ */
- //This code is still right, though we do no longer write to the module config files any more
- sword::ConfigEntMap config = backend()->getConfig()->Sections.find(name().toUtf8().constData())->second;
- sword::ConfigEntMap::iterator it = config.find("CipherKey");
+ //This code is still right, though we do no longer write to the module config files any more
+ sword::ConfigEntMap config = backend()->getConfig()->Sections.find(name().toUtf8().constData())->second;
+ sword::ConfigEntMap::iterator it = config.find("CipherKey");
- if (it != config.end()) {
- return true;
- }
+ if (it != config.end()) {
+ return true;
+ }
- return false;
+ return false;
}
/** This function makes an estimate if a module was properly unlocked.
@@ -154,757 +154,773 @@ bool CSwordModuleInfo::isEncrypted() const {
*/
bool CSwordModuleInfo::unlockKeyIsValid() {
- (*m_module) = sword::TOP;
+ (*m_module) = sword::TOP;
- // This needs to use ::fromLatin1 because if the text is still locked,
- // a lot of garbage will show up. It will also work with properly decrypted
- // Unicode text, because all non-ASCII Unicode chars consist of bytes >127
- // and therefore contain no control (nonprintable) characters, which are all <127.
- QString test = isUnicode()
- ? QString::fromUtf8(m_module->getRawEntryBuf().c_str())
- : QString::fromLatin1( m_module->getRawEntryBuf().c_str() );
+ // This needs to use ::fromLatin1 because if the text is still locked,
+ // a lot of garbage will show up. It will also work with properly decrypted
+ // Unicode text, because all non-ASCII Unicode chars consist of bytes >127
+ // and therefore contain no control (nonprintable) characters, which are all <127.
+ QString test = isUnicode()
+ ? QString::fromUtf8(m_module->getRawEntryBuf().c_str())
+ : QString::fromLatin1( m_module->getRawEntryBuf().c_str() );
- if (test.isEmpty()) {
- qWarning() << "Unlock key of module" << name() << "is NOT valid!";
- return false;
- }
+ if (test.isEmpty()) {
+ qWarning() << "Unlock key of module" << name() << "is NOT valid!";
+ return false;
+ }
- for (int i = 0; i <= test.length() && i < 100; i++) {
- if ( !test[i].isPrint() && !test[i].isNull() ) {
- qWarning() << "Unlock key of module" << name() << "is NOT valid!";
- return false;
- }
- }
+ for (int i = 0; i <= test.length() && i < 100; i++) {
+ if ( !test[i].isPrint() && !test[i].isNull() ) {
+ qWarning() << "Unlock key of module" << name() << "is NOT valid!";
+ return false;
+ }
+ }
- qDebug() << "Unlock key of module" << name() << "is valid";
- return true;
+ qDebug() << "Unlock key of module" << name() << "is valid";
+ return true;
}
QString CSwordModuleInfo::getGlobalBaseIndexLocation() {
- return util::filesystem::DirectoryUtil::getUserIndexDir().absolutePath();
+ return util::filesystem::DirectoryUtil::getUserIndexDir().absolutePath();
}
QString CSwordModuleInfo::getModuleBaseIndexLocation() const {
- return getGlobalBaseIndexLocation() + QString("/") + name().toLocal8Bit();
+ return getGlobalBaseIndexLocation() + QString("/") + name().toLocal8Bit();
}
QString CSwordModuleInfo::getModuleStandardIndexLocation() const { //this for now returns the location of the main index
- return getModuleBaseIndexLocation() + QString("/standard");
+ return getModuleBaseIndexLocation() + QString("/standard");
}
bool CSwordModuleInfo::hasIndex() {
- //this will return true only
- //if the index exists and has correct version information for both index and module
- QDir d;
- if (!d.exists( getModuleStandardIndexLocation() )) {
- return false;
- }
-
- //first check if the index version and module version are ok
- QSettings module_config(getModuleBaseIndexLocation() + QString("/bibletime-index.conf"), QSettings::IniFormat);
-
- if (hasVersion()) {
- if (module_config.value("module-version") != QString(config(CSwordModuleInfo::ModuleVersion)) ) {
- return false;
- }
- }
- if (module_config.value("index-version") != QString::number( INDEX_VERSION )) {
- qDebug("%s: INDEX_VERSION is not compatible with this version of BibleTime.", name().toUtf8().constData());
- return false;
- }
-
- //then check if the index is there
- return lucene::index::IndexReader::indexExists(getModuleStandardIndexLocation().toAscii().constData());
-}
-
+ //this will return true only
+ //if the index exists and has correct version information for both index and module
+ QDir d;
+ if (!d.exists( getModuleStandardIndexLocation() )) {
+ return false;
+ }
+
+ //first check if the index version and module version are ok
+ QSettings module_config(getModuleBaseIndexLocation() + QString("/bibletime-index.conf"), QSettings::IniFormat);
+
+ if (hasVersion()) {
+ if (module_config.value("module-version") != QString(config(CSwordModuleInfo::ModuleVersion)) ) {
+ return false;
+ }
+ }
+ if (module_config.value("index-version") != QString::number( INDEX_VERSION )) {
+ qDebug("%s: INDEX_VERSION is not compatible with this version of BibleTime.", name().toUtf8().constData());
+ return false;
+ }
+
+ //then check if the index is there
+ return lucene::index::IndexReader::indexExists(getModuleStandardIndexLocation().toAscii().constData());
+}
+
+// HELPER Method: this dumps all current EntryAttributes of a module
+//#include <iostream>
+//void dumpEntryAttributes(sword::SWModule *module) {
+// std::cout << "Attributes for key: " << module->getKeyText() << std::endl;
+// 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";
+// for (i2 = i1->second.begin(); i2 != i1->second.end(); i2++) {
+// std::cout << "\t[ " << i2->first << " ]\n";
+// for (i3 = i2->second.begin(); i3 != i2->second.end(); i3++) {
+// std::cout << "\t\t" << i3->first << " = " << i3->second << "\n";
+// }
+// }
+// }
+// std::cout << std::endl;
+//}
void CSwordModuleInfo::buildIndex() {
- m_cancelIndexing = false;
-
- try
- {
- //Without this we don't get strongs, lemmas, etc
- backend()->setFilterOptions ( CBTConfig::getFilterOptionDefaults() );
- //make sure we reset all important filter options which influcence the plain filters.
- backend()->setOption( CSwordModuleInfo::strongNumbers, false );
- backend()->setOption( CSwordModuleInfo::morphTags, false );
- backend()->setOption( CSwordModuleInfo::morphSegmentation, false );
- backend()->setOption( CSwordModuleInfo::footnotes, false );
- backend()->setOption( CSwordModuleInfo::headings, false );
- backend()->setOption( CSwordModuleInfo::scriptureReferences, false );
- backend()->setOption( CSwordModuleInfo::redLetterWords, false );
-
- // do not use any stop words
- const TCHAR* stop_words[] = { NULL };
- lucene::analysis::standard::StandardAnalyzer an( (const TCHAR**)stop_words );
- QString index = getModuleStandardIndexLocation();
-
- QDir dir("/");
- dir.mkpath( getGlobalBaseIndexLocation() );
- dir.mkpath( getModuleBaseIndexLocation() );
- dir.mkpath( getModuleStandardIndexLocation() );
-
- if (lucene::index::IndexReader::indexExists(index.toAscii().constData())) {
- if (lucene::index::IndexReader::isLocked(index.toAscii().constData()) ) {
- lucene::index::IndexReader::unlock(index.toAscii().constData());
- }
- }
-
- boost::scoped_ptr<lucene::index::IndexWriter> writer( new lucene::index::IndexWriter(index.toAscii().constData(), &an, true) ); //always create a new index
- writer->setMaxFieldLength(BT_MAX_LUCENE_FIELD_LENGTH);
- writer->setUseCompoundFile(true); //merge segments into a single file
- writer->setMinMergeDocs(1000);
-
- *m_module = sword::TOP;
- unsigned long verseLowIndex = m_module->Index();
- *m_module = sword::BOTTOM;
- unsigned long verseHighIndex = m_module->Index();
-
- //verseLowIndex is not 0 in all cases (i.e. NT-only modules)
- unsigned long verseIndex = verseLowIndex + 1;
- unsigned long verseSpan = verseHighIndex - verseLowIndex;
-
- //Index() is not implemented properly for lexicons, so we use a
- //workaround.
- if (type() == CSwordModuleInfo::Lexicon){
- verseIndex = 0;
- verseLowIndex = 0;
- verseSpan = ((CSwordLexiconModuleInfo*)this)->entries()->size();
- }
-
- emit indexingProgress(0);
-
- sword::SWKey* key = m_module->getKey();
- //VerseKey for bibles
- sword::VerseKey* vk = dynamic_cast<sword::VerseKey*>(key);
-
- if (vk) {
- // we have to be sure to insert the english key into the index, otherwise we'd be in trouble if the language changes
- vk->setLocale("en_US");
- //If we have a verse based module, we want to include the pre-chapter etc. headings in the search
- vk->Headings(1);
- }
-
- //holds UTF-8 data and is faster than QString.
- QByteArray textBuffer;
-
- // we start with the first module entry, key is automatically updated
- // because key is a pointer to the modules key
- m_module->setSkipConsecutiveLinks(true);
-
- wchar_t wcharBuffer[BT_MAX_LUCENE_FIELD_LENGTH + 1];
-
- for (*m_module = sword::TOP; !(m_module->Error()) && !m_cancelIndexing; (*m_module)++) {
-
- //If it is a sword-heading, store in buffer and index later in Verse X:1
- if (vk) {
- if (vk->Verse() == 0) {
- textBuffer.append( m_module->StripText() );
- continue;
- }
- }
-
- boost::scoped_ptr<lucene::document::Document> doc(new lucene::document::Document());
-
- //index the key
- lucene_utf8towcs(wcharBuffer, key->getText(), BT_MAX_LUCENE_FIELD_LENGTH);
- //doc->add(*lucene::document::Field::UnIndexed((const TCHAR*)_T("key"), (const TCHAR*)wcharBuffer));
- doc->add(*(new lucene::document::Field((const TCHAR*)_T("key"), (const TCHAR*)wcharBuffer, lucene::document::Field::STORE_YES | lucene::document::Field::INDEX_NO)));
- // index the main text
- //at this point we have to make sure we disabled the strongs and the other options
- //so the plain filters won't include the numbers somehow.
- lucene_utf8towcs(wcharBuffer, (const char*) textBuffer.append(m_module->StripText()), BT_MAX_LUCENE_FIELD_LENGTH);
- //doc->add(*lucene::document::Field::UnStored((const TCHAR*)_T("content"), (const TCHAR*)wcharBuffer));
- doc->add(*(new lucene::document::Field((const TCHAR*)_T("content"), (const TCHAR*)wcharBuffer, lucene::document::Field::STORE_NO | lucene::document::Field::INDEX_TOKENIZED)));
- textBuffer.resize(0); //clean up
-
- // index attributes
- sword::AttributeList::iterator attListI;
- sword::AttributeValue::iterator attValueI;
- // Footnotes
- for (attListI = m_module->getEntryAttributes()["Footnote"].begin();
- attListI != m_module->getEntryAttributes()["Footnote"].end();
- attListI++) {
- lucene_utf8towcs(wcharBuffer, attListI->second["body"], BT_MAX_LUCENE_FIELD_LENGTH);
- //doc->add(*lucene::document::Field::UnStored((const TCHAR*)_T("footnote"), wcharBuffer));
- doc->add(*(new lucene::document::Field((const TCHAR*)_T("footnote"), (const TCHAR*)wcharBuffer, lucene::document::Field::STORE_NO | lucene::document::Field::INDEX_TOKENIZED)));
- } // for attListI
-
- // Headings
- for (attValueI = m_module->getEntryAttributes()["Heading"]["Preverse"].begin();
- attValueI != m_module->getEntryAttributes()["Heading"]["Preverse"].end();
- attValueI++) {
- lucene_utf8towcs(wcharBuffer, attValueI->second, BT_MAX_LUCENE_FIELD_LENGTH);
- //doc->add(*lucene::document::Field::UnStored((const TCHAR*)_T("heading"), wcharBuffer));
- doc->add(*(new lucene::document::Field((const TCHAR*)_T("heading"), (const TCHAR*)wcharBuffer, lucene::document::Field::STORE_NO | lucene::document::Field::INDEX_TOKENIZED)));
- } // for attValueI
-
- // Strongs/Morphs
- for (attListI = m_module->getEntryAttributes()["Word"].begin();
- attListI != m_module->getEntryAttributes()["Word"].end();
- attListI++) {
- // for each attribute
- if (attListI->second["LemmaClass"] == "strong") {
- lucene_utf8towcs(wcharBuffer, attListI->second["Lemma"], BT_MAX_LUCENE_FIELD_LENGTH);
- //doc->add(*lucene::document::Field::UnStored((const TCHAR*)_T("strong"), wcharBuffer));
- doc->add(*(new lucene::document::Field((const TCHAR*)_T("strong"), (const TCHAR*)wcharBuffer, lucene::document::Field::STORE_NO | lucene::document::Field::INDEX_TOKENIZED)));
- //qWarning("Adding strong %s", attListI->second["Lemma"].c_str());
- }
- if (attListI->second.find("Morph") != attListI->second.end()) {
- lucene_utf8towcs(wcharBuffer, attListI->second["Morph"], BT_MAX_LUCENE_FIELD_LENGTH);
- //doc->add(*lucene::document::Field::UnStored((const TCHAR*)_T("morph"), wcharBuffer));
- doc->add(*(new lucene::document::Field((const TCHAR*)_T("morph"), (const TCHAR*)wcharBuffer, lucene::document::Field::STORE_NO | lucene::document::Field::INDEX_TOKENIZED)));
- }
- } // for attListI
-
- writer->addDocument(doc.get());
- //Index() is not implemented properly for lexicons, so we use a
- //workaround.
- if (type() == CSwordModuleInfo::Lexicon){
- verseIndex++;
- }
- else{
- verseIndex = m_module->Index();
- }
-
- if (verseIndex % 200 == 0) {
- int indexingProgressValue;
- if (verseSpan == 0) { //prevent division by zero
- //m_indexingProgress.setValue( QVariant(0) );
- indexingProgressValue = 0;
- } else {
- //m_indexingProgress.setValue( QVariant((int)((100*(verseIndex-verseLowIndex))/(verseHighIndex-verseLowIndex))) );
- indexingProgressValue = (int)((100*(verseIndex-verseLowIndex)) / (verseSpan));
- }
- //m_indexingProgress.activate();
- emit indexingProgress(indexingProgressValue);
- }
- }
-
- if (!m_cancelIndexing)
- {
- writer->optimize();
- }
- writer->close();
-
- if (m_cancelIndexing){
- deleteIndexForModule(name());
- m_cancelIndexing = false;
- }
- else
- {
- QSettings module_config(getModuleBaseIndexLocation() + QString("/bibletime-index.conf"), QSettings::IniFormat);
- if (hasVersion()) module_config.setValue("module-version", config(CSwordModuleInfo::ModuleVersion) );
- module_config.setValue("index-version", INDEX_VERSION );
- }
- }
- catch(...)
- {
- qWarning("CLucene exception occurred while indexing");
- QMessageBox::warning(0, QCoreApplication::tr("Indexing aborted"), QCoreApplication::tr("An internal error occurred while building the index."));
- deleteIndexForModule(name());
- m_cancelIndexing = false;
- }
+ m_cancelIndexing = false;
+
+ try {
+ //Without this we don't get strongs, lemmas, etc
+ backend()->setFilterOptions ( CBTConfig::getFilterOptionDefaults() );
+ //make sure we reset all important filter options which influcence the plain filters.
+ // turn on these options, they are needed for the EntryAttributes population
+ backend()->setOption( CSwordModuleInfo::strongNumbers, true );
+ backend()->setOption( CSwordModuleInfo::morphTags, true );
+ backend()->setOption( CSwordModuleInfo::footnotes, true );
+ backend()->setOption( CSwordModuleInfo::headings, true );
+ // we don't want the following in the text, the do not carry searchable information
+ backend()->setOption( CSwordModuleInfo::morphSegmentation, false );
+ backend()->setOption( CSwordModuleInfo::scriptureReferences, false );
+ backend()->setOption( CSwordModuleInfo::redLetterWords, false );
+
+ // do not use any stop words
+ const TCHAR* stop_words[] = { NULL };
+ lucene::analysis::standard::StandardAnalyzer an( (const TCHAR**)stop_words );
+ QString index = getModuleStandardIndexLocation();
+
+ QDir dir("/");
+ dir.mkpath( getGlobalBaseIndexLocation() );
+ dir.mkpath( getModuleBaseIndexLocation() );
+ dir.mkpath( getModuleStandardIndexLocation() );
+
+ if (lucene::index::IndexReader::indexExists(index.toAscii().constData())) {
+ if (lucene::index::IndexReader::isLocked(index.toAscii().constData()) ) {
+ lucene::index::IndexReader::unlock(index.toAscii().constData());
+ }
+ }
+
+ boost::scoped_ptr<lucene::index::IndexWriter> writer( new lucene::index::IndexWriter(index.toAscii().constData(), &an, true) ); //always create a new index
+ writer->setMaxFieldLength(BT_MAX_LUCENE_FIELD_LENGTH);
+ writer->setUseCompoundFile(true); //merge segments into a single file
+ writer->setMinMergeDocs(1000);
+
+ *m_module = sword::TOP;
+ unsigned long verseLowIndex = m_module->Index();
+ *m_module = sword::BOTTOM;
+ unsigned long verseHighIndex = m_module->Index();
+
+ //verseLowIndex is not 0 in all cases (i.e. NT-only modules)
+ unsigned long verseIndex = verseLowIndex + 1;
+ unsigned long verseSpan = verseHighIndex - verseLowIndex;
+
+ //Index() is not implemented properly for lexicons, so we use a
+ //workaround.
+ if (type() == CSwordModuleInfo::Lexicon) {
+ verseIndex = 0;
+ verseLowIndex = 0;
+ verseSpan = ((CSwordLexiconModuleInfo*)this)->entries()->size();
+ }
+
+ emit indexingProgress(0);
+
+ sword::SWKey* key = m_module->getKey();
+ //VerseKey for bibles
+ sword::VerseKey* vk = dynamic_cast<sword::VerseKey*>(key);
+
+ if (vk) {
+ // we have to be sure to insert the english key into the index, otherwise we'd be in trouble if the language changes
+ vk->setLocale("en_US");
+ //If we have a verse based module, we want to include the pre-chapter etc. headings in the search
+ vk->Headings(1);
+ }
+
+ //holds UTF-8 data and is faster than QString.
+ QByteArray textBuffer;
+
+ // we start with the first module entry, key is automatically updated
+ // because key is a pointer to the modules key
+ m_module->setSkipConsecutiveLinks(true);
+
+ wchar_t wcharBuffer[BT_MAX_LUCENE_FIELD_LENGTH + 1];
+
+ for (*m_module = sword::TOP; !(m_module->Error()) && !m_cancelIndexing; (*m_module)++) {
+
+ // Also index Chapter 0 and Verse 0, because they might have information in the entry attributes
+ // We used to just put their content into the textBuffer and continue to the next verse, but
+ // with entry attributes this doesn't work any more.
+ // Hits in the search dialog will show up as 1:1 (instead of 0)
+
+ boost::scoped_ptr<lucene::document::Document> doc(new lucene::document::Document());
+
+ //index the key
+ lucene_utf8towcs(wcharBuffer, key->getText(), BT_MAX_LUCENE_FIELD_LENGTH);
+
+ //doc->add(*lucene::document::Field::UnIndexed((const TCHAR*)_T("key"), (const TCHAR*)wcharBuffer));
+ doc->add(*(new lucene::document::Field((const TCHAR*)_T("key"), (const TCHAR*)wcharBuffer, lucene::document::Field::STORE_YES | lucene::document::Field::INDEX_NO)));
+
+ // index the main text
+ //at this point we have to make sure we disabled the strongs and the other options
+ //so the plain filters won't include the numbers somehow.
+ lucene_utf8towcs(wcharBuffer, (const char*) textBuffer.append(m_module->StripText()), BT_MAX_LUCENE_FIELD_LENGTH);
+ doc->add(*(new lucene::document::Field((const TCHAR*)_T("content"), (const TCHAR*)wcharBuffer, lucene::document::Field::STORE_NO | lucene::document::Field::INDEX_TOKENIZED)));
+ textBuffer.resize(0); //clean up
+
+ // index attributes
+ sword::AttributeList::iterator attListI;
+ sword::AttributeValue::iterator attValueI;
+ // Footnotes
+ for (attListI = m_module->getEntryAttributes()["Footnote"].begin();
+ attListI != m_module->getEntryAttributes()["Footnote"].end();
+ attListI++) {
+ lucene_utf8towcs(wcharBuffer, attListI->second["body"], BT_MAX_LUCENE_FIELD_LENGTH);
+ //doc->add(*lucene::document::Field::UnStored((const TCHAR*)_T("footnote"), wcharBuffer));
+ doc->add(*(new lucene::document::Field((const TCHAR*)_T("footnote"), (const TCHAR*)wcharBuffer, lucene::document::Field::STORE_NO | lucene::document::Field::INDEX_TOKENIZED)));
+ } // for attListI
+
+ // Headings
+ for (attValueI = m_module->getEntryAttributes()["Heading"]["Preverse"].begin();
+ attValueI != m_module->getEntryAttributes()["Heading"]["Preverse"].end();
+ attValueI++) {
+ lucene_utf8towcs(wcharBuffer, attValueI->second, BT_MAX_LUCENE_FIELD_LENGTH);
+ //doc->add(*lucene::document::Field::UnStored((const TCHAR*)_T("heading"), wcharBuffer));
+ doc->add(*(new lucene::document::Field((const TCHAR*)_T("heading"), (const TCHAR*)wcharBuffer, lucene::document::Field::STORE_NO | lucene::document::Field::INDEX_TOKENIZED)));
+ } // for attValueI
+
+ // Strongs/Morphs
+ for (attListI = m_module->getEntryAttributes()["Word"].begin();
+ attListI != m_module->getEntryAttributes()["Word"].end();
+ attListI++) {
+ // for each attribute
+ if (attListI->second["LemmaClass"] == "strong") {
+ lucene_utf8towcs(wcharBuffer, attListI->second["Lemma"], BT_MAX_LUCENE_FIELD_LENGTH);
+ //doc->add(*lucene::document::Field::UnStored((const TCHAR*)_T("strong"), wcharBuffer));
+ doc->add(*(new lucene::document::Field((const TCHAR*)_T("strong"), (const TCHAR*)wcharBuffer, lucene::document::Field::STORE_NO | lucene::document::Field::INDEX_TOKENIZED)));
+ //qWarning("Adding strong %s", attListI->second["Lemma"].c_str());
+ }
+ if (attListI->second.find("Morph") != attListI->second.end()) {
+ lucene_utf8towcs(wcharBuffer, attListI->second["Morph"], BT_MAX_LUCENE_FIELD_LENGTH);
+ //doc->add(*lucene::document::Field::UnStored((const TCHAR*)_T("morph"), wcharBuffer));
+ doc->add(*(new lucene::document::Field((const TCHAR*)_T("morph"), (const TCHAR*)wcharBuffer, lucene::document::Field::STORE_NO | lucene::document::Field::INDEX_TOKENIZED)));
+ }
+ } // for attListI
+
+ writer->addDocument(doc.get());
+ //Index() is not implemented properly for lexicons, so we use a
+ //workaround.
+ if (type() == CSwordModuleInfo::Lexicon) {
+ verseIndex++;
+ }
+ else {
+ verseIndex = m_module->Index();
+ }
+
+ if (verseIndex % 200 == 0) {
+ int indexingProgressValue;
+ if (verseSpan == 0) { //prevent division by zero
+ //m_indexingProgress.setValue( QVariant(0) );
+ indexingProgressValue = 0;
+ }
+ else {
+ //m_indexingProgress.setValue( QVariant((int)((100*(verseIndex-verseLowIndex))/(verseHighIndex-verseLowIndex))) );
+ indexingProgressValue = (int)((100 * (verseIndex - verseLowIndex)) / (verseSpan));
+ }
+ //m_indexingProgress.activate();
+ emit indexingProgress(indexingProgressValue);
+ }
+ }
+
+ if (!m_cancelIndexing) {
+ writer->optimize();
+ }
+ writer->close();
+
+ if (m_cancelIndexing) {
+ deleteIndexForModule(name());
+ m_cancelIndexing = false;
+ }
+ else {
+ QSettings module_config(getModuleBaseIndexLocation() + QString("/bibletime-index.conf"), QSettings::IniFormat);
+ if (hasVersion()) module_config.setValue("module-version", config(CSwordModuleInfo::ModuleVersion) );
+ module_config.setValue("index-version", INDEX_VERSION );
+ }
+ }
+ catch (...) {
+ qWarning("CLucene exception occurred while indexing");
+ QMessageBox::warning(0, QCoreApplication::tr("Indexing aborted"), QCoreApplication::tr("An internal error occurred while building the index."));
+ deleteIndexForModule(name());
+ m_cancelIndexing = false;
+ }
}
void CSwordModuleInfo::deleteIndexForModule( QString name ) {
- util::filesystem::DirectoryUtil::removeRecursive( getGlobalBaseIndexLocation() + "/" + name );
+ util::filesystem::DirectoryUtil::removeRecursive( getGlobalBaseIndexLocation() + "/" + name );
}
unsigned long CSwordModuleInfo::indexSize() const {
- return util::filesystem::DirectoryUtil::getDirSizeRecursive( getModuleBaseIndexLocation() );
+ return util::filesystem::DirectoryUtil::getDirSizeRecursive( getModuleBaseIndexLocation() );
}
bool CSwordModuleInfo::searchIndexed(const QString& searchedText, sword::ListKey& scope) {
- char utfBuffer[BT_MAX_LUCENE_FIELD_LENGTH + 1];
- wchar_t wcharBuffer[BT_MAX_LUCENE_FIELD_LENGTH + 1];
+ char utfBuffer[BT_MAX_LUCENE_FIELD_LENGTH + 1];
+ wchar_t wcharBuffer[BT_MAX_LUCENE_FIELD_LENGTH + 1];
- // work around Swords thread insafety for Bibles and Commentaries
- boost::scoped_ptr < CSwordKey > key(CSwordKey::createInstance(this));
- sword::SWKey* s = dynamic_cast < sword::SWKey * >(key.get());
- QList<sword::VerseKey*> list;
+ // work around Swords thread insafety for Bibles and Commentaries
+ boost::scoped_ptr < CSwordKey > key(CSwordKey::createInstance(this));
+ sword::SWKey* s = dynamic_cast < sword::SWKey * >(key.get());
+ QList<sword::VerseKey*> list;
- if (s) {
- m_module->SetKey(*s);
- }
+ if (s) {
+ m_module->SetKey(*s);
+ }
- m_searchResult.ClearList();
+ m_searchResult.ClearList();
- try {
- // do not use any stop words
- const TCHAR* stop_words[] = { NULL };
- lucene::analysis::standard::StandardAnalyzer analyzer( stop_words );
- lucene::search::IndexSearcher searcher(getModuleStandardIndexLocation().toAscii().constData());
- lucene_utf8towcs(wcharBuffer, searchedText.toUtf8().constData(), BT_MAX_LUCENE_FIELD_LENGTH);
- boost::scoped_ptr<lucene::search::Query> q( lucene::queryParser::QueryParser::parse((const TCHAR*)wcharBuffer, (const TCHAR*)_T("content"), &analyzer) );
+ try {
+ // do not use any stop words
+ const TCHAR* stop_words[] = { NULL };
+ lucene::analysis::standard::StandardAnalyzer analyzer( stop_words );
+ lucene::search::IndexSearcher searcher(getModuleStandardIndexLocation().toAscii().constData());
+ lucene_utf8towcs(wcharBuffer, searchedText.toUtf8().constData(), BT_MAX_LUCENE_FIELD_LENGTH);
+ boost::scoped_ptr<lucene::search::Query> q( lucene::queryParser::QueryParser::parse((const TCHAR*)wcharBuffer, (const TCHAR*)_T("content"), &analyzer) );
- boost::scoped_ptr<lucene::search::Hits> h( searcher.search(q.get(), lucene::search::Sort::INDEXORDER) );
+ boost::scoped_ptr<lucene::search::Hits> h( searcher.search(q.get(), lucene::search::Sort::INDEXORDER) );
- const bool useScope = (scope.Count() > 0);
+ const bool useScope = (scope.Count() > 0);
// const bool isVerseModule = (type() == CSwordModuleInfo::Bible) || (type() == CSwordModuleInfo::Commentary);
- lucene::document::Document* doc = 0;
- boost::scoped_ptr<sword::SWKey> swKey( module()->CreateKey() );
+ lucene::document::Document* doc = 0;
+ boost::scoped_ptr<sword::SWKey> swKey( module()->CreateKey() );
- for (int i = 0; i < h->length(); ++i) {
- doc = &h->doc(i);
- lucene_wcstoutf8(utfBuffer, (const wchar_t*)doc->get((const TCHAR*)_T("key")), BT_MAX_LUCENE_FIELD_LENGTH);
+ for (int i = 0; i < h->length(); ++i) {
+ doc = &h->doc(i);
+ lucene_wcstoutf8(utfBuffer, (const wchar_t*)doc->get((const TCHAR*)_T("key")), BT_MAX_LUCENE_FIELD_LENGTH);
- swKey->setText(utfBuffer);
+ swKey->setText(utfBuffer);
- // limit results based on scope
- //if (searchOptions & CSwordModuleSearch::useScope && scope.Count() > 0){
- if (useScope) {
- for (int j = 0; j < scope.Count(); j++) {
- sword::VerseKey* vkey = dynamic_cast<sword::VerseKey*>(scope.getElement(j));
- if (vkey->LowerBound().compare(*swKey) <= 0 && vkey->UpperBound().compare(*swKey) >= 0) {
- m_searchResult.add(*swKey);
- }
- }
- } else { // no scope, give me all buffers
- m_searchResult.add(*swKey);
- }
- }
- }
- catch (...) {
- qWarning("CLucene exception occurred");
- QMessageBox::warning(0, QCoreApplication::tr("Search aborted"), QCoreApplication::tr("An internal error occurred while executing your search."));
- return false;
- }
+ // limit results based on scope
+ //if (searchOptions & CSwordModuleSearch::useScope && scope.Count() > 0){
+ if (useScope) {
+ for (int j = 0; j < scope.Count(); j++) {
+ sword::VerseKey* vkey = dynamic_cast<sword::VerseKey*>(scope.getElement(j));
+ if (vkey->LowerBound().compare(*swKey) <= 0 && vkey->UpperBound().compare(*swKey) >= 0) {
+ m_searchResult.add(*swKey);
+ }
+ }
+ }
+ else { // no scope, give me all buffers
+ m_searchResult.add(*swKey);
+ }
+ }
+ }
+ catch (...) {
+ qWarning("CLucene exception occurred");
+ QMessageBox::warning(0, QCoreApplication::tr("Search aborted"), QCoreApplication::tr("An internal error occurred while executing your search."));
+ return false;
+ }
- qDeleteAll(list);
- list.clear();
+ qDeleteAll(list);
+ list.clear();
- return (m_searchResult.Count() > 0);
+ return (m_searchResult.Count() > 0);
}
/** Returns the last search result for this module. */
sword::ListKey & CSwordModuleInfo::searchResult(const sword::ListKey * newResult) {
- if (newResult) {
- m_searchResult.copyFrom(*newResult);
- }
+ if (newResult) {
+ m_searchResult.copyFrom(*newResult);
+ }
- return m_searchResult;
+ return m_searchResult;
}
/** Clears the last search result. */
void CSwordModuleInfo::clearSearchResult() {
- m_searchResult.ClearList();
+ m_searchResult.ClearList();
}
/** Returns the required Sword version for this module. Returns -1 if no special Sword version is required. */
sword::SWVersion CSwordModuleInfo::minimumSwordVersion() {
- return sword::SWVersion(config(CSwordModuleInfo::MinimumSwordVersion).toUtf8().constData());
+ return sword::SWVersion(config(CSwordModuleInfo::MinimumSwordVersion).toUtf8().constData());
}
QString CSwordModuleInfo::config(const CSwordModuleInfo::ConfigEntry entry) const {
- switch (entry) {
+ switch (entry) {
- case AboutInformation:
- return getFormattedConfigEntry("About");
+ case AboutInformation:
+ return getFormattedConfigEntry("About");
- case CipherKey: {
- if (CBTConfig::getModuleEncryptionKey(name()).isNull()) { //fall back!
- return QString(m_module->getConfigEntry("CipherKey"));
- }
- else {
- return CBTConfig::getModuleEncryptionKey(name());
- }
- }
+ case CipherKey: {
+ if (CBTConfig::getModuleEncryptionKey(name()).isNull()) { //fall back!
+ return QString(m_module->getConfigEntry("CipherKey"));
+ }
+ else {
+ return CBTConfig::getModuleEncryptionKey(name());
+ }
+ }
- case AbsoluteDataPath: {
- QString path( getSimpleConfigEntry("AbsoluteDataPath") );
- path.replace(QRegExp("/./"), "/"); // make /abs/path/./modules/ looking better
- //make sure we have a trailing slash!
+ case AbsoluteDataPath: {
+ QString path( getSimpleConfigEntry("AbsoluteDataPath") );
+ path.replace(QRegExp("/./"), "/"); // make /abs/path/./modules/ looking better
+ //make sure we have a trailing slash!
- if (path.right(1) != "/") {
- path.append('/');
- }
+ if (path.right(1) != "/") {
+ path.append('/');
+ }
- return path;
- }
+ return path;
+ }
- case DataPath: { //make sure we remove the dataFile part if it's a Lexicon
- QString path(getSimpleConfigEntry("DataPath"));
+ case DataPath: { //make sure we remove the dataFile part if it's a Lexicon
+ QString path(getSimpleConfigEntry("DataPath"));
- if ((type() == CSwordModuleInfo::GenericBook) || (type() == CSwordModuleInfo::Lexicon)) {
- int pos = path.lastIndexOf("/"); //last slash in the string
+ if ((type() == CSwordModuleInfo::GenericBook) || (type() == CSwordModuleInfo::Lexicon)) {
+ int pos = path.lastIndexOf("/"); //last slash in the string
- if (pos != -1) {
- path = path.left(pos + 1); //include the slash
- }
- }
+ if (pos != -1) {
+ path = path.left(pos + 1); //include the slash
+ }
+ }
- return path;
- }
+ return path;
+ }
- case Description:
- return getFormattedConfigEntry("Description");
+ case Description:
+ return getFormattedConfigEntry("Description");
- case ModuleVersion: {
- QString version(getSimpleConfigEntry("Version"));
+ case ModuleVersion: {
+ QString version(getSimpleConfigEntry("Version"));
- if (version.isEmpty()) {
- version = "1.0";
- }
+ if (version.isEmpty()) {
+ version = "1.0";
+ }
- return version;
- }
+ return version;
+ }
- case MinimumSwordVersion: {
- const QString minimumVersion(getSimpleConfigEntry("MinimumVersion"));
- return !minimumVersion.isEmpty()? minimumVersion : QString("0.0");
- }
+ case MinimumSwordVersion: {
+ const QString minimumVersion(getSimpleConfigEntry("MinimumVersion"));
+ return !minimumVersion.isEmpty() ? minimumVersion : QString("0.0");
+ }
- case TextDir: {
- const QString dir(getSimpleConfigEntry("Direction"));
- return !dir.isEmpty()? dir : QString("LtoR");
- }
+ case TextDir: {
+ const QString dir(getSimpleConfigEntry("Direction"));
+ return !dir.isEmpty() ? dir : QString("LtoR");
+ }
- case DisplayLevel: {
- const QString level(getSimpleConfigEntry("DisplayLevel"));
- return !level.isEmpty()? level : QString("1");
- }
+ case DisplayLevel: {
+ const QString level(getSimpleConfigEntry("DisplayLevel"));
+ return !level.isEmpty() ? level : QString("1");
+ }
- case GlossaryFrom: {
- if (!category() == Glossary) {
- return QString::null;
- };
+ case GlossaryFrom: {
+ if (category() != Glossary) {
+ return QString::null;
+ };
- const QString lang(getSimpleConfigEntry("GlossaryFrom"));
+ const QString lang(getSimpleConfigEntry("GlossaryFrom"));
- return !lang.isEmpty()? lang : QString::null;
- }
+ return !lang.isEmpty() ? lang : QString::null;
+ }
- case GlossaryTo: {
- if (!category() == Glossary) {
- return QString::null;
- };
+ case GlossaryTo: {
+ if (category() != Glossary) {
+ return QString::null;
+ };
- const QString lang(getSimpleConfigEntry("GlossaryTo"));
+ const QString lang(getSimpleConfigEntry("GlossaryTo"));
- return !lang.isEmpty()? lang : QString::null;
- }
+ return !lang.isEmpty() ? lang : QString::null;
+ }
- case Markup: {
- const QString markup(getSimpleConfigEntry("SourceType"));
- return !markup.isEmpty()? markup : QString("Unknown");
- }
+ case Markup: {
+ const QString markup(getSimpleConfigEntry("SourceType"));
+ return !markup.isEmpty() ? markup : QString("Unknown");
+ }
- case DistributionLicense:
- return getSimpleConfigEntry("DistributionLicense");
+ case DistributionLicense:
+ return getSimpleConfigEntry("DistributionLicense");
- case DistributionSource:
- return getSimpleConfigEntry("DistributionSource");
+ case DistributionSource:
+ return getSimpleConfigEntry("DistributionSource");
- case DistributionNotes:
- return getSimpleConfigEntry("DistributionNotes");
+ case DistributionNotes:
+ return getSimpleConfigEntry("DistributionNotes");
- case TextSource:
- return getSimpleConfigEntry("TextSource");
+ case TextSource:
+ return getSimpleConfigEntry("TextSource");
- case CopyrightNotes:
- return getSimpleConfigEntry("CopyrightNotes");
+ case CopyrightNotes:
+ return getSimpleConfigEntry("CopyrightNotes");
- case CopyrightHolder:
- return getSimpleConfigEntry("CopyrightHolder");
+ case CopyrightHolder:
+ return getSimpleConfigEntry("CopyrightHolder");
- case CopyrightDate:
- return getSimpleConfigEntry("CopyrightDate");
+ case CopyrightDate:
+ return getSimpleConfigEntry("CopyrightDate");
- case CopyrightContactName:
- return getSimpleConfigEntry("CopyrightContactName");
+ case CopyrightContactName:
+ return getSimpleConfigEntry("CopyrightContactName");
- case CopyrightContactAddress:
- return getSimpleConfigEntry("CopyrightContactAddress");
+ case CopyrightContactAddress:
+ return getSimpleConfigEntry("CopyrightContactAddress");
- case CopyrightContactEmail:
- return getSimpleConfigEntry("CopyrightContactEmail");
+ case CopyrightContactEmail:
+ return getSimpleConfigEntry("CopyrightContactEmail");
- default:
- return QString::null;
- }
+ default:
+ return QString::null;
+ }
}
/** Returns true if the module supports the feature given as parameter. */
bool CSwordModuleInfo::has(const CSwordModuleInfo::Feature feature) const {
- switch (feature) {
+ switch (feature) {
- // case StrongsNumbers:
- // return m_module->getConfig().has("Feature", "StrongsNumber");
+ // case StrongsNumbers:
+ // return m_module->getConfig().has("Feature", "StrongsNumber");
- case GreekDef:
- return m_module->getConfig().has("Feature", "GreekDef");
+ case GreekDef:
+ return m_module->getConfig().has("Feature", "GreekDef");
- case HebrewDef:
- return m_module->getConfig().has("Feature", "HebrewDef");
+ case HebrewDef:
+ return m_module->getConfig().has("Feature", "HebrewDef");
- case GreekParse:
- return m_module->getConfig().has("Feature", "GreekParse");
+ case GreekParse:
+ return m_module->getConfig().has("Feature", "GreekParse");
- case HebrewParse:
- return m_module->getConfig().has("Feature", "HebrewParse");
- }
+ case HebrewParse:
+ return m_module->getConfig().has("Feature", "HebrewParse");
+ }
- return false;
+ return false;
}
bool CSwordModuleInfo::has(const CSwordModuleInfo::FilterTypes option) const {
- //BAD workaround to see if the filter is GBF, OSIS or ThML!
- const QString name = backend()->configOptionName(option);
+ //BAD workaround to see if the filter is GBF, OSIS or ThML!
+ const QString name = backend()->configOptionName(option);
- if (m_module->getConfig().has("GlobalOptionFilter", QString("OSIS").append(name).toUtf8().constData())) {
- return true;
- }
+ if (m_module->getConfig().has("GlobalOptionFilter", QString("OSIS").append(name).toUtf8().constData())) {
+ return true;
+ }
- if (m_module->getConfig().has("GlobalOptionFilter", QString("GBF").append(name).toUtf8().constData())) {
- return true;
- }
+ if (m_module->getConfig().has("GlobalOptionFilter", QString("GBF").append(name).toUtf8().constData())) {
+ return true;
+ }
- if (m_module->getConfig().has("GlobalOptionFilter", QString("ThML").append(name).toUtf8().constData())) {
- return true;
- }
+ if (m_module->getConfig().has("GlobalOptionFilter", QString("ThML").append(name).toUtf8().constData())) {
+ return true;
+ }
- if (m_module->getConfig().has("GlobalOptionFilter", QString("UTF8").append(name).toUtf8().constData())) {
- return true;
- }
+ if (m_module->getConfig().has("GlobalOptionFilter", QString("UTF8").append(name).toUtf8().constData())) {
+ return true;
+ }
- if (m_module->getConfig().has("GlobalOptionFilter", name.toUtf8().constData())) {
- return true;
- }
+ if (m_module->getConfig().has("GlobalOptionFilter", name.toUtf8().constData())) {
+ return true;
+ }
- return false;
+ return false;
}
/** Returns the text direction of the module's text., */
CSwordModuleInfo::TextDirection CSwordModuleInfo::textDirection() {
- if (config(TextDir) == "RtoL") {
- return CSwordModuleInfo::RightToLeft;
- }
- else {
- return CSwordModuleInfo::LeftToRight;
- }
+ if (config(TextDir) == "RtoL") {
+ return CSwordModuleInfo::RightToLeft;
+ }
+ else {
+ return CSwordModuleInfo::LeftToRight;
+ }
}
/** Writes the new text at the given position into the module. This does only work for writable modules. */
void CSwordModuleInfo::write(CSwordKey * key, const QString & newText) {
- module()->KeyText(key->key().toUtf8().constData());
+ module()->KeyText(key->key().toUtf8().constData());
- //don't store a pointer to the const char* value somewhere because QCString doesn't keep the value of it
- module()->setEntry(isUnicode()? newText.toUtf8().constData() : newText.toLocal8Bit().constData());
+ //don't store a pointer to the const char* value somewhere because QCString doesn't keep the value of it
+ module()->setEntry(isUnicode() ? newText.toUtf8().constData() : newText.toLocal8Bit().constData());
}
/** Deletes the current entry and removes it from the module. */
bool CSwordModuleInfo::deleteEntry(CSwordKey * const key) {
- module()->KeyText(isUnicode()? key->key().toUtf8().constData() : key->key().toLocal8Bit().constData());
+ module()->KeyText(isUnicode() ? key->key().toUtf8().constData() : key->key().toLocal8Bit().constData());
- if (module()) {
- module()->deleteEntry();
- return true;
- }
+ if (module()) {
+ module()->deleteEntry();
+ return true;
+ }
- return false;
+ return false;
}
/** Returns the category of this module. See CSwordModuleInfo::Category for possible values. */
CSwordModuleInfo::Category CSwordModuleInfo::category() const {
- //qDebug("CSwordModuleInfo::category");
- if (m_dataCache.category == CSwordModuleInfo::UnknownCategory) {
- const QString cat(m_module->getConfigEntry("Category"));
- //qDebug() << "the category was unknown, add a category "<< cat << "for module" << m_module->Name();
-
- if (cat == "Cults / Unorthodox / Questionable Material") {
- m_dataCache.category = Cult;
- }
- else if (cat == "Daily Devotional" || m_module->getConfig().has("Feature", "DailyDevotion")) {
- m_dataCache.category = DailyDevotional;
- }
- else if (cat == "Glossaries" || m_module->getConfig().has("Feature", "Glossary")) { //allow both
- m_dataCache.category = Glossary;
- }
- else if (cat == "Images" || cat == "Maps") {
- m_dataCache.category = Images;
- }
- else if (type() == Commentary) {
- m_dataCache.category = Commentaries;
- }
- else if (type() == Bible) {
- m_dataCache.category = Bibles;
- }
- else if (type() == Lexicon) {
- m_dataCache.category = Lexicons;
- }
- else if (type() == GenericBook) {
- m_dataCache.category = Books;
- }
- }
- //qDebug() << "assigned category: " << m_dataCache.category;
- return m_dataCache.category;
+ //qDebug("CSwordModuleInfo::category");
+ if (m_dataCache.category == CSwordModuleInfo::UnknownCategory) {
+ const QString cat(m_module->getConfigEntry("Category"));
+ //qDebug() << "the category was unknown, add a category "<< cat << "for module" << m_module->Name();
+
+ if (cat == "Cults / Unorthodox / Questionable Material") {
+ m_dataCache.category = Cult;
+ }
+ else if (cat == "Daily Devotional" || m_module->getConfig().has("Feature", "DailyDevotion")) {
+ m_dataCache.category = DailyDevotional;
+ }
+ else if (cat == "Glossaries" || m_module->getConfig().has("Feature", "Glossary")) { //allow both
+ m_dataCache.category = Glossary;
+ }
+ else if (cat == "Images" || cat == "Maps") {
+ m_dataCache.category = Images;
+ }
+ else if (type() == Commentary) {
+ m_dataCache.category = Commentaries;
+ }
+ else if (type() == Bible) {
+ m_dataCache.category = Bibles;
+ }
+ else if (type() == Lexicon) {
+ m_dataCache.category = Lexicons;
+ }
+ else if (type() == GenericBook) {
+ m_dataCache.category = Books;
+ }
+ }
+ //qDebug() << "assigned category: " << m_dataCache.category;
+ return m_dataCache.category;
}
/** Returns the display object for this module. */
Rendering::CEntryDisplay * CSwordModuleInfo::getDisplay() const {
- return dynamic_cast < Rendering::CEntryDisplay * >(m_module->Disp());
+ return dynamic_cast < Rendering::CEntryDisplay * >(m_module->Disp());
}
QString CSwordModuleInfo::aboutText() const {
- QString text;
- text += "<table>";
+ QString text;
+ text += "<table>";
- text += QString("<tr><td><b>%1</b></td><td>%2</td><tr>")
- .arg(tr("Version"))
- .arg(hasVersion()? config(CSwordModuleInfo::ModuleVersion) : tr("unknown"));
+ text += QString("<tr><td><b>%1</b></td><td>%2</td><tr>")
+ .arg(tr("Version"))
+ .arg(hasVersion() ? config(CSwordModuleInfo::ModuleVersion) : tr("unknown"));
- text += QString("<tr><td><b>%1</b></td><td>%2</td></tr>")
- .arg(tr("Markup"))
- .arg(!QString(m_module->getConfigEntry("SourceType")).isEmpty()? QString(m_module->
- getConfigEntry("SourceType")) : tr("unknown"));
+ text += QString("<tr><td><b>%1</b></td><td>%2</td></tr>")
+ .arg(tr("Markup"))
+ .arg(!QString(m_module->getConfigEntry("SourceType")).isEmpty() ? QString(m_module->
+ getConfigEntry("SourceType")) : tr("unknown"));
- text += QString("<tr><td><b>%1</b></td><td>%2</td></tr>")
- .arg(tr("Location"))
- .arg(config(CSwordModuleInfo::AbsoluteDataPath));
+ text += QString("<tr><td><b>%1</b></td><td>%2</td></tr>")
+ .arg(tr("Location"))
+ .arg(config(CSwordModuleInfo::AbsoluteDataPath));
- text += QString("<tr><td><b>%1</b></td><td>%2</td></tr>")
- .arg(tr("Language"))
- .arg(language()->translatedName());
+ text += QString("<tr><td><b>%1</b></td><td>%2</td></tr>")
+ .arg(tr("Language"))
+ .arg(language()->translatedName());
- if (m_module->getConfigEntry("Category"))
- text += QString("<tr><td><b>%1</b></td><td>%2</td></tr>")
- .arg(tr("Category"))
- .arg(m_module->getConfigEntry("Category"));
+ if (m_module->getConfigEntry("Category"))
+ text += QString("<tr><td><b>%1</b></td><td>%2</td></tr>")
+ .arg(tr("Category"))
+ .arg(m_module->getConfigEntry("Category"));
- if (m_module->getConfigEntry("LCSH"))
- text += QString("<tr><td><b>%1</b></td><td>%2</td></tr>")
- .arg(tr("LCSH"))
- .arg(m_module->getConfigEntry("LCSH"));
+ if (m_module->getConfigEntry("LCSH"))
+ text += QString("<tr><td><b>%1</b></td><td>%2</td></tr>")
+ .arg(tr("LCSH"))
+ .arg(m_module->getConfigEntry("LCSH"));
- text += QString("<tr><td><b>%1</b></td><td>%2</td></tr>")
- .arg(tr("Writable"))
- .arg(isWritable()? tr("yes") : tr("no"));
+ text += QString("<tr><td><b>%1</b></td><td>%2</td></tr>")
+ .arg(tr("Writable"))
+ .arg(isWritable() ? tr("yes") : tr("no"));
- if (isEncrypted())
- text += QString("<tr><td><b>%1</b></td><td>%2</td></tr>")
- .arg(tr("Unlock key"))
- .arg(config(CSwordModuleInfo::CipherKey));
+ if (isEncrypted())
+ text += QString("<tr><td><b>%1</b></td><td>%2</td></tr>")
+ .arg(tr("Unlock key"))
+ .arg(config(CSwordModuleInfo::CipherKey));
- QString options;
+ QString options;
- unsigned int opts;
+ unsigned int opts;
- for (opts = CSwordModuleInfo::filterTypesMIN; opts <= CSwordModuleInfo::filterTypesMAX; ++opts) {
- if (has(static_cast < CSwordModuleInfo::FilterTypes > (opts))) {
- if (!options.isEmpty()) {
- options += QString::fromLatin1(", ");
- }
+ for (opts = CSwordModuleInfo::filterTypesMIN; opts <= CSwordModuleInfo::filterTypesMAX; ++opts) {
+ if (has(static_cast < CSwordModuleInfo::FilterTypes > (opts))) {
+ if (!options.isEmpty()) {
+ options += QString::fromLatin1(", ");
+ }
- options += CSwordBackend::translatedOptionName(static_cast < CSwordModuleInfo::FilterTypes > (opts));
- }
- }
+ options += CSwordBackend::translatedOptionName(static_cast < CSwordModuleInfo::FilterTypes > (opts));
+ }
+ }
- if (!options.isEmpty()) {
- text += QString("<tr><td><b>%1</b></td><td>%2</td></tr>")
- .arg(tr("Features"))
- .arg(options);
- }
+ if (!options.isEmpty()) {
+ text += QString("<tr><td><b>%1</b></td><td>%2</td></tr>")
+ .arg(tr("Features"))
+ .arg(options);
+ }
- text += "</table><hr>";
+ text += "</table><hr>";
- if (category() == Cult) //clearly say the module contains cult/questionable materials
- text += QString("<br/><b>%1</b><br/><br/>")
- .arg(tr("Take care, this work contains cult / questionable material!"));
+ if (category() == Cult) //clearly say the module contains cult/questionable materials
+ text += QString("<br/><b>%1</b><br/><br/>")
+ .arg(tr("Take care, this work contains cult / questionable material!"));
- text += QString("<b>%1:</b><br>%2</font>")
- .arg(tr("About"))
- .arg(config(AboutInformation));
+ text += QString("<b>%1:</b><br>%2</font>")
+ .arg(tr("About"))
+ .arg(config(AboutInformation));
- typedef QList<CSwordModuleInfo::ConfigEntry> ListConfigEntry;
+ typedef QList<CSwordModuleInfo::ConfigEntry> ListConfigEntry;
- ListConfigEntry entries;
+ ListConfigEntry entries;
- entries.append(DistributionLicense);
+ entries.append(DistributionLicense);
- entries.append(DistributionSource);
+ entries.append(DistributionSource);
- entries.append(DistributionNotes);
+ entries.append(DistributionNotes);
- entries.append(TextSource);
+ entries.append(TextSource);
- entries.append(CopyrightNotes);
+ entries.append(CopyrightNotes);
- entries.append(CopyrightHolder);
+ entries.append(CopyrightHolder);
- entries.append(CopyrightDate);
+ entries.append(CopyrightDate);
- entries.append(CopyrightContactName);
+ entries.append(CopyrightContactName);
- entries.append(CopyrightContactAddress);
+ entries.append(CopyrightContactAddress);
- entries.append(CopyrightContactEmail);
+ entries.append(CopyrightContactEmail);
- typedef QMap<CSwordModuleInfo::ConfigEntry, QString> MapConfigEntry;
+ typedef QMap<CSwordModuleInfo::ConfigEntry, QString> MapConfigEntry;
- MapConfigEntry entryMap;
+ MapConfigEntry entryMap;
- entryMap[DistributionLicense] = tr("Distribution license");
+ entryMap[DistributionLicense] = tr("Distribution license");
- entryMap[DistributionSource] = tr("Distribution source");
+ entryMap[DistributionSource] = tr("Distribution source");
- entryMap[DistributionNotes] = tr("Distribution notes");
+ entryMap[DistributionNotes] = tr("Distribution notes");
- entryMap[TextSource] = tr("Text source");
+ entryMap[TextSource] = tr("Text source");
- entryMap[CopyrightNotes] = tr("Copyright notes");
+ entryMap[CopyrightNotes] = tr("Copyright notes");
- entryMap[CopyrightHolder] = tr("Copyright holder");
+ entryMap[CopyrightHolder] = tr("Copyright holder");
- entryMap[CopyrightDate] = tr("Copyright date");
+ entryMap[CopyrightDate] = tr("Copyright date");
- entryMap[CopyrightContactName] = tr("Copyright contact name");
+ entryMap[CopyrightContactName] = tr("Copyright contact name");
- entryMap[CopyrightContactAddress] = tr("Copyright contact address");
+ entryMap[CopyrightContactAddress] = tr("Copyright contact address");
- entryMap[CopyrightContactEmail] = tr("Copyright contact email");
+ entryMap[CopyrightContactEmail] = tr("Copyright contact email");
- text += ("<hr><table>");
+ text += ("<hr><table>");
- for (ListConfigEntry::iterator it(entries.begin()); it != entries.end(); ++it) {
- QString t( config(*it) );
+ for (ListConfigEntry::iterator it(entries.begin()); it != entries.end(); ++it) {
+ QString t( config(*it) );
- if (!t.isEmpty()) {
- text += QString("<tr><td><b>%1</b></td><td>%2</td></tr>")
- .arg(entryMap[*it])
- .arg(config(*it));
- }
+ if (!t.isEmpty()) {
+ text += QString("<tr><td><b>%1</b></td><td>%2</td></tr>")
+ .arg(entryMap[*it])
+ .arg(config(*it));
+ }
- }
+ }
- text += "</table></font>";
+ text += "</table></font>";
- return text;
+ return text;
}
/** Returns the language of the module. */
const CLanguageMgr::Language* CSwordModuleInfo::language() const {
- if (!m_dataCache.language) {
- if (module()) {
- if (category() == Glossary) {
- //special handling for glossaries, we use the "from language" as language for the module
- m_dataCache.language = (CPointers::languageMgr())->languageForAbbrev(config(GlossaryFrom));
- }
- else {
- m_dataCache.language = (CPointers::languageMgr())->languageForAbbrev(module()->Lang());
- }
- }
- else {
- m_dataCache.language = (CPointers::languageMgr())->defaultLanguage(); //default language
- }
- }
+ if (!m_dataCache.language) {
+ if (module()) {
+ if (category() == Glossary) {
+ //special handling for glossaries, we use the "from language" as language for the module
+ m_dataCache.language = (CPointers::languageMgr())->languageForAbbrev(config(GlossaryFrom));
+ }
+ else {
+ m_dataCache.language = (CPointers::languageMgr())->languageForAbbrev(module()->Lang());
+ }
+ }
+ else {
+ m_dataCache.language = (CPointers::languageMgr())->defaultLanguage(); //default language
+ }
+ }
- return m_dataCache.language;
+ return m_dataCache.language;
}
@@ -912,44 +928,42 @@ const CLanguageMgr::Language* CSwordModuleInfo::language() const {
\fn CSwordModuleInfo::getSimpleConfigEntry(char* name)
*/
QString CSwordModuleInfo::getSimpleConfigEntry(const QString& name) const {
- QString ret = isUnicode()
- ? QString::fromUtf8(m_module->getConfigEntry(name.toUtf8().constData()))
- : QString::fromLatin1(m_module->getConfigEntry(name.toUtf8().constData()));
+ QString ret = isUnicode()
+ ? QString::fromUtf8(m_module->getConfigEntry(name.toUtf8().constData()))
+ : QString::fromLatin1(m_module->getConfigEntry(name.toUtf8().constData()));
- return ret.isEmpty() ? QString::null : ret;
+ return ret.isEmpty() ? QString::null : ret;
}
QString CSwordModuleInfo::getFormattedConfigEntry(const QString& name) const {
- sword::SWBuf RTF_Buffer(m_module->getConfigEntry(name.toUtf8().constData()));
- sword::RTFHTML RTF_Filter;
- RTF_Filter.processText(RTF_Buffer, 0, 0);
- QString ret = isUnicode()
- ? QString::fromUtf8(RTF_Buffer.c_str())
- : QString::fromLatin1(RTF_Buffer.c_str());
-
- return ret.isEmpty() ? QString::null : ret;
-}
-
-void CSwordModuleInfo::setHidden(bool hidden)
-{
- //qDebug("CSwordModuleInfo::setHidden");
- QStringList hiddenModules = CBTConfig::get(CBTConfig::hiddenModules);
- if (hidden && !hiddenModules.contains(this->name())) {
- hiddenModules.append(this->name());
- CBTConfig::set(CBTConfig::hiddenModules, hiddenModules);
- }
- if (!hidden && hiddenModules.contains(this->name()) ) {
- hiddenModules.removeAll(this->name());
- CBTConfig::set(CBTConfig::hiddenModules, hiddenModules);
- }
-}
-
-bool CSwordModuleInfo::isHidden() const
-{
- //qDebug("CSwordModuleInfo::isHidden");
- QStringList hiddenModules = CBTConfig::get(CBTConfig::hiddenModules);
- if (hiddenModules.contains(this->name())) {
- return true;
- }
- return false;
+ sword::SWBuf RTF_Buffer(m_module->getConfigEntry(name.toUtf8().constData()));
+ sword::RTFHTML RTF_Filter;
+ RTF_Filter.processText(RTF_Buffer, 0, 0);
+ QString ret = isUnicode()
+ ? QString::fromUtf8(RTF_Buffer.c_str())
+ : QString::fromLatin1(RTF_Buffer.c_str());
+
+ return ret.isEmpty() ? QString::null : ret;
+}
+
+void CSwordModuleInfo::setHidden(bool hidden) {
+ //qDebug("CSwordModuleInfo::setHidden");
+ QStringList hiddenModules = CBTConfig::get(CBTConfig::hiddenModules);
+ if (hidden && !hiddenModules.contains(this->name())) {
+ hiddenModules.append(this->name());
+ CBTConfig::set(CBTConfig::hiddenModules, hiddenModules);
+ }
+ if (!hidden && hiddenModules.contains(this->name()) ) {
+ hiddenModules.removeAll(this->name());
+ CBTConfig::set(CBTConfig::hiddenModules, hiddenModules);
+ }
+}
+
+bool CSwordModuleInfo::isHidden() const {
+ //qDebug("CSwordModuleInfo::isHidden");
+ QStringList hiddenModules = CBTConfig::get(CBTConfig::hiddenModules);
+ if (hiddenModules.contains(this->name())) {
+ return true;
+ }
+ return false;
}
diff --git a/src/backend/drivers/cswordmoduleinfo.h b/src/backend/drivers/cswordmoduleinfo.h
index 0f612f9..ba4b8f6 100644
--- a/src/backend/drivers/cswordmoduleinfo.h
+++ b/src/backend/drivers/cswordmoduleinfo.h
@@ -28,7 +28,7 @@ class CSwordKey;
namespace Rendering {
- class CEntryDisplay;
+class CEntryDisplay;
}
/**
@@ -40,329 +40,331 @@ namespace Rendering {
* @version $Id: cswordmoduleinfo.h,v 1.83 2007/02/04 23:12:32 joachim Exp $
*/
-class CSwordModuleInfo: public QObject
-{
- Q_OBJECT
-
-public:
- /**
- * These are the options which could be supported by modules and by this backend.
- * It's used in @ref CSwordBackend::setOption.
- */
- enum FilterTypes {
- footnotes, /**< Footnotes embedded in the module's text */
- strongNumbers, /**< strong numbers, usually in the text for the info display */
- headings, /**< additional section headings */
- morphTags, /**< morphology */
- lemmas, /**< lemma tags */
- hebrewPoints,/**< Hebrew vowel points */
- hebrewCantillation, /**<Hewbrew caantillation points */
- greekAccents, /**< Greek accents may be switched on and off */
- scriptureReferences, /**< scripture references may be switched on and off, just makes sense in Bibles */
- redLetterWords, /**< Jesus words in red, color is template specific */
- textualVariants, /**< variants */
- morphSegmentation, /**< morph word segmentation, supported by OSIS */
- filterTypesMIN = footnotes, /**< first entry of this enum */
- filterTypesMAX = morphSegmentation /**< last item in this enum */
- // transliteration /* The following are handled in a special way */
- };
- /** The text direction of a module */
- enum TextDirection { /* The text direction of the modules's text */
- LeftToRight, /**< Left to right text direction, the default setting */
- RightToLeft /**< Right to left text directin, e.g. for hebrew */
- };
- /** The module type.
- */
- enum ModuleType {
- Bible, /**< Bible module */
- Commentary, /**< Commentary module */
- Lexicon, /**< Lexicon module */
- GenericBook, /**< Generic book module */
- Unknown /**< Fall back type for unknown modules */
- };
- /**
- * This enum is used to give
- * back an error code after unlocking the module
- * BibleTime stores the unlock key not in the module's config file but in BibleTime's
- * configuration file.
- */
- enum UnlockErrorCode {
- noError, /**< No error occured, everything worked ok. The key was written to the BibleTime config */
- wrongUnlockKey, /**< The wrong key was used. Module is not unlocked */
- notLocked, /**< The module was not locked so it can't be unlocked */
- noPermission /**< The key was not written to config because we have no permissions */
- };
- enum ConfigEntry {
- AboutInformation, /**< The about information of a module which is stored in the config file*/
- AbsoluteDataPath, /**< The absolute data path stored in the config object */
- CipherKey, /**< The cipher key which was used to unlock the module. Not necessarily set.*/
- DataPath, /**< The relative path. See AbsoluteDataPath*/
- Description, /**< The module description stored in the config file */
- ModuleVersion, /**< The module's version.*/
- MinimumSwordVersion, /**< The required Sword Version of this module. Otherwise some things may not work (compression etc.).*/
- TextDir, /**< The text direction */
- DisplayLevel, /**< Mostly used for books. Gives the level which should contain the connected entries.*/
- GlossaryFrom, /**< lamguage from which the Glosaary tramslates */
- GlossaryTo, /**< lamguages to which the glossary maps to */
- DistributionLicense,
- DistributionSource,
- DistributionNotes,
- TextSource,
- CopyrightNotes,
- CopyrightHolder,
- CopyrightDate,
- CopyrightContactName,
- CopyrightContactAddress,
- CopyrightContactEmail,
- Markup /**< The markup of this module */
- };
- enum Feature {
- //StrongsNumbers, /**< Use for Bibles which have embedded strong numbers */ BT does not use this as a user option
- GreekDef,
- HebrewDef,
- GreekParse,
- HebrewParse,
- featureMin = GreekDef,
- featureMax = HebrewParse
- };
- enum Category {
- UnknownCategory = 0, /**< The category wasn't set or has an unknwon value */
- Bibles,
- Commentaries,
- Books,
- Lexicons,
- Glossary,
- DailyDevotional,
- Images,
- Cult /**< The module is a cult / sect / questionable module */
- };
-
- /**
- * Returns the base directory for search indices
- */
- static QString getGlobalBaseIndexLocation();
- /**
- * Removes search index for this module, even if the module is not there any more
- */
- static void deleteIndexForModule( QString name );
-
-
- /**
- * Returns the config entry which is pecified by the parameter.
- */
- QString config( const CSwordModuleInfo::ConfigEntry entry ) const;
-
- CSwordModuleInfo( sword::SWModule* module, CSwordBackend* const = 0 );
- /** Copy constructor to copy the passed parameter.
- * @param m The module to be copied
- */
- CSwordModuleInfo( const CSwordModuleInfo& m );
- /** Reimplementation to return a valid clone.
- */
- virtual CSwordModuleInfo* clone();
- /** Destructor.
- */
- virtual ~CSwordModuleInfo();
-
- /**
- * Returns the module object so all objects can access the original Sword module.
- */
- sword::SWModule* module() const;
- /**
- * Sets the unlock key of the modules and writes the key into the cofig file.
- * @return True if the unlock process was succesful, if the key was wrong, or if the config file was write protected return false.
- */
- bool unlock( const QString& unlockKey );
- /**
- * Returns the display object for this module. Normally every module should have a Display object.
- * Please don't use module()->Display() because this function does return the Sword display and does
- * render the text, too.
- * This function performs some casts to return the correct display. If it returns 0 there's no valid
- * display object.
- */
- Rendering::CEntryDisplay* getDisplay() const;
- /**
- * This function does return true if the data files of the module are encrypted by the module author
- * (the on who made the module) no matter if it's locked or not.
- * @return True if this module is encryped
- */
- bool isEncrypted() const;
- /**
- * This function returns true if this module is locked (encrypted + correct cipher key),
- * otherwise return false.
- * @return True if this module is locked, i.e. encrypted but without a key set
- */
- bool isLocked();
-
- bool unlockKeyIsValid();
-
- /** The module version.
- * @return true if this module has a version number and false if it doesn't have one.
- */
- inline bool hasVersion() const;
-
- /**
- * Returns true if the module's index has been built.
- */
- virtual bool hasIndex();
- /**
- * Returns the path to this module's index base dir
- */
- virtual QString getModuleBaseIndexLocation() const;
- /**
- * Returns the path to this module's standard index
- */
- virtual QString getModuleStandardIndexLocation() const;
- /**
- * Builds a search index for this module
- */
- virtual void buildIndex();
- /**
- * Returns index size
- */
- virtual unsigned long indexSize() const;
- /**
- * Returns true if something was found, otherwise return false.
- * This function uses CLucene to perform and index based search. It also
- * overwrites the variable containing the last search result.
- */
- virtual bool searchIndexed(const QString& searchedText, sword::ListKey& scope);
- /**
- * Returns the last search result for this module.
- * The last result is cleared by @ref search
- */
- virtual sword::ListKey& searchResult( const sword::ListKey* newResult = 0 );
- /**
- * Clears the last search result.
- * This does immediately clean the last search result,
- * no matter if search is in progress or not.
- */
- void clearSearchResult();
- /**
- * Returns the type of the module.
- */
- virtual CSwordModuleInfo::ModuleType type() const;
- /**
- * Returns the required Sword version for this module.
- * Returns -1 if no special Sword version is required.
- */
- sword::SWVersion minimumSwordVersion();
- /**
- * Returns the name of the module.
- * @return The name of this module.
- */
- QString name() const;
- /**
- * Snaps to the closest entry in the module if the current key is
- * not present in the data files.
- */
- virtual bool snap() {
- return false;
- };
-
- bool has( const CSwordModuleInfo::Feature ) const;
- bool has( const CSwordModuleInfo::FilterTypes ) const;
- /**
- * Returns the text direction of the module's text.,
- */
- virtual CSwordModuleInfo::TextDirection textDirection();
- /**
- * Writes the new text at the given position into the module. This does only work for writabe modules.
- */
- virtual void write( CSwordKey* key, const QString& newText );
- /**
- * Deletes the current entry and removes it from the module.
- */
- bool deleteEntry( CSwordKey* const key );
- /**
- * Returns the language of the module.
- */
- const CLanguageMgr::Language* language() const;
- /**
- * Returns true if this module may be written by the write display windows.
- */
- inline virtual bool isWritable() const;
- /**
- * Returns true if this module is hidden (not to be shown with other modules in certain views).
- */
- bool isHidden() const;
-
- void setHidden(bool hidden);
-
- /**
- * Returns the category of this module. See CSwordModuleInfo::Category for possible values.
- */
- CSwordModuleInfo::Category category() const;
- /**
- * The about text which belongs to this module.
- */
- QString aboutText() const;
- /**
- * Returns true if this module is Unicode encoded. False if the charset is iso8859-1.
- * Protected because it should not be used outside of the CSword*ModuleInfo classes.
- */
- inline bool isUnicode() const {
- return m_dataCache.isUnicode;
- }
-
-public slots:
- inline void cancelIndexing() { m_cancelIndexing = true; };
-
-protected:
- friend class CSwordBackend;
-
- inline CSwordBackend* backend() const {
- return m_backend;
- }
-
- inline void backend( CSwordBackend* newBackend ) {
- if (newBackend) {
- m_backend = newBackend;
- }
- }
-
- QString getSimpleConfigEntry(const QString& name) const;
- QString getFormattedConfigEntry(const QString& name) const;
-
-signals:
- void indexingFinished();
- void indexingProgress(int);
-
-private:
- sword::SWModule* m_module;
- sword::ListKey m_searchResult;
-
- mutable struct DataCache {
- DataCache() {
- language = 0;
- }
-
- QString name;
- bool isUnicode;
- CSwordModuleInfo::Category category;
- const CLanguageMgr::Language* language;
- bool hasVersion;
- }
-
- m_dataCache;
-
- CSwordBackend* m_backend;
-
- bool m_hidden;
-
- bool m_cancelIndexing;
+class CSwordModuleInfo: public QObject {
+ Q_OBJECT
+
+ public:
+ /**
+ * These are the options which could be supported by modules and by this backend.
+ * It's used in @ref CSwordBackend::setOption.
+ */
+ enum FilterTypes {
+ footnotes, /**< Footnotes embedded in the module's text */
+ strongNumbers, /**< strong numbers, usually in the text for the info display */
+ headings, /**< additional section headings */
+ morphTags, /**< morphology */
+ lemmas, /**< lemma tags */
+ hebrewPoints,/**< Hebrew vowel points */
+ hebrewCantillation, /**<Hewbrew caantillation points */
+ greekAccents, /**< Greek accents may be switched on and off */
+ scriptureReferences, /**< scripture references may be switched on and off, just makes sense in Bibles */
+ redLetterWords, /**< Jesus words in red, color is template specific */
+ textualVariants, /**< variants */
+ morphSegmentation, /**< morph word segmentation, supported by OSIS */
+ filterTypesMIN = footnotes, /**< first entry of this enum */
+ filterTypesMAX = morphSegmentation /**< last item in this enum */
+ // transliteration /* The following are handled in a special way */
+ };
+ /** The text direction of a module */
+ enum TextDirection { /* The text direction of the modules's text */
+ LeftToRight, /**< Left to right text direction, the default setting */
+ RightToLeft /**< Right to left text directin, e.g. for hebrew */
+ };
+ /** The module type.
+ */
+ enum ModuleType {
+ Bible, /**< Bible module */
+ Commentary, /**< Commentary module */
+ Lexicon, /**< Lexicon module */
+ GenericBook, /**< Generic book module */
+ Unknown /**< Fall back type for unknown modules */
+ };
+ /**
+ * This enum is used to give
+ * back an error code after unlocking the module
+ * BibleTime stores the unlock key not in the module's config file but in BibleTime's
+ * configuration file.
+ */
+ enum UnlockErrorCode {
+ noError, /**< No error occured, everything worked ok. The key was written to the BibleTime config */
+ wrongUnlockKey, /**< The wrong key was used. Module is not unlocked */
+ notLocked, /**< The module was not locked so it can't be unlocked */
+ noPermission /**< The key was not written to config because we have no permissions */
+ };
+ enum ConfigEntry {
+ AboutInformation, /**< The about information of a module which is stored in the config file*/
+ AbsoluteDataPath, /**< The absolute data path stored in the config object */
+ CipherKey, /**< The cipher key which was used to unlock the module. Not necessarily set.*/
+ DataPath, /**< The relative path. See AbsoluteDataPath*/
+ Description, /**< The module description stored in the config file */
+ ModuleVersion, /**< The module's version.*/
+ MinimumSwordVersion, /**< The required Sword Version of this module. Otherwise some things may not work (compression etc.).*/
+ TextDir, /**< The text direction */
+ DisplayLevel, /**< Mostly used for books. Gives the level which should contain the connected entries.*/
+ GlossaryFrom, /**< lamguage from which the Glosaary tramslates */
+ GlossaryTo, /**< lamguages to which the glossary maps to */
+ DistributionLicense,
+ DistributionSource,
+ DistributionNotes,
+ TextSource,
+ CopyrightNotes,
+ CopyrightHolder,
+ CopyrightDate,
+ CopyrightContactName,
+ CopyrightContactAddress,
+ CopyrightContactEmail,
+ Markup /**< The markup of this module */
+ };
+ enum Feature {
+ //StrongsNumbers, /**< Use for Bibles which have embedded strong numbers */ BT does not use this as a user option
+ GreekDef,
+ HebrewDef,
+ GreekParse,
+ HebrewParse,
+ featureMin = GreekDef,
+ featureMax = HebrewParse
+ };
+ enum Category {
+ Bibles,
+ Commentaries,
+ Books,
+ Lexicons,
+ Glossary,
+ DailyDevotional,
+ Images,
+ Cult, /**< The module is a cult / sect / questionable module */
+ UnknownCategory /**< The category wasn't set or has an unknown value */
+ };
+
+ /**
+ * Returns the base directory for search indices
+ */
+ static QString getGlobalBaseIndexLocation();
+ /**
+ * Removes search index for this module, even if the module is not there any more
+ */
+ static void deleteIndexForModule( QString name );
+
+
+ /**
+ * Returns the config entry which is pecified by the parameter.
+ */
+ QString config( const CSwordModuleInfo::ConfigEntry entry ) const;
+
+ CSwordModuleInfo( sword::SWModule* module, CSwordBackend* const = 0 );
+ /** Copy constructor to copy the passed parameter.
+ * @param m The module to be copied
+ */
+ CSwordModuleInfo( const CSwordModuleInfo& m );
+ /** Reimplementation to return a valid clone.
+ */
+ virtual CSwordModuleInfo* clone();
+ /** Destructor.
+ */
+ virtual ~CSwordModuleInfo();
+
+ /**
+ * Returns the module object so all objects can access the original Sword module.
+ */
+ sword::SWModule* module() const;
+ /**
+ * Sets the unlock key of the modules and writes the key into the cofig file.
+ * @return True if the unlock process was succesful, if the key was wrong, or if the config file was write protected return false.
+ */
+ bool unlock( const QString& unlockKey );
+ /**
+ * Returns the display object for this module. Normally every module should have a Display object.
+ * Please don't use module()->Display() because this function does return the Sword display and does
+ * render the text, too.
+ * This function performs some casts to return the correct display. If it returns 0 there's no valid
+ * display object.
+ */
+ Rendering::CEntryDisplay* getDisplay() const;
+ /**
+ * This function does return true if the data files of the module are encrypted by the module author
+ * (the on who made the module) no matter if it's locked or not.
+ * @return True if this module is encryped
+ */
+ bool isEncrypted() const;
+ /**
+ * This function returns true if this module is locked (encrypted + correct cipher key),
+ * otherwise return false.
+ * \todo Make CSwordModuleInfo::isLocked() const.
+ * @return True if this module is locked, i.e. encrypted but without a key set
+ */
+ bool isLocked();
+
+ bool unlockKeyIsValid();
+
+ /** The module version.
+ * @return true if this module has a version number and false if it doesn't have one.
+ */
+ inline bool hasVersion() const;
+
+ /**
+ * Returns true if the module's index has been built.
+ */
+ virtual bool hasIndex();
+ /**
+ * Returns the path to this module's index base dir
+ */
+ virtual QString getModuleBaseIndexLocation() const;
+ /**
+ * Returns the path to this module's standard index
+ */
+ virtual QString getModuleStandardIndexLocation() const;
+ /**
+ * Builds a search index for this module
+ */
+ virtual void buildIndex();
+ /**
+ * Returns index size
+ */
+ virtual unsigned long indexSize() const;
+ /**
+ * Returns true if something was found, otherwise return false.
+ * This function uses CLucene to perform and index based search. It also
+ * overwrites the variable containing the last search result.
+ */
+ virtual bool searchIndexed(const QString& searchedText, sword::ListKey& scope);
+ /**
+ * Returns the last search result for this module.
+ * The last result is cleared by @ref search
+ */
+ virtual sword::ListKey& searchResult( const sword::ListKey* newResult = 0 );
+ /**
+ * Clears the last search result.
+ * This does immediately clean the last search result,
+ * no matter if search is in progress or not.
+ */
+ void clearSearchResult();
+ /**
+ * Returns the type of the module.
+ */
+ virtual CSwordModuleInfo::ModuleType type() const;
+ /**
+ * Returns the required Sword version for this module.
+ * Returns -1 if no special Sword version is required.
+ */
+ sword::SWVersion minimumSwordVersion();
+ /**
+ * Returns the name of the module.
+ * @return The name of this module.
+ */
+ QString name() const;
+ /**
+ * Snaps to the closest entry in the module if the current key is
+ * not present in the data files.
+ */
+ virtual bool snap() {
+ return false;
+ };
+
+ bool has( const CSwordModuleInfo::Feature ) const;
+ bool has( const CSwordModuleInfo::FilterTypes ) const;
+ /**
+ * Returns the text direction of the module's text.,
+ */
+ virtual CSwordModuleInfo::TextDirection textDirection();
+ /**
+ * Writes the new text at the given position into the module. This does only work for writabe modules.
+ */
+ virtual void write( CSwordKey* key, const QString& newText );
+ /**
+ * Deletes the current entry and removes it from the module.
+ */
+ bool deleteEntry( CSwordKey* const key );
+ /**
+ * Returns the language of the module.
+ */
+ const CLanguageMgr::Language* language() const;
+ /**
+ * Returns true if this module may be written by the write display windows.
+ */
+ inline virtual bool isWritable() const;
+ /**
+ * Returns true if this module is hidden (not to be shown with other modules in certain views).
+ */
+ bool isHidden() const;
+
+ void setHidden(bool hidden);
+
+ /**
+ * Returns the category of this module. See CSwordModuleInfo::Category for possible values.
+ */
+ CSwordModuleInfo::Category category() const;
+ /**
+ * The about text which belongs to this module.
+ */
+ QString aboutText() const;
+ /**
+ * Returns true if this module is Unicode encoded. False if the charset is iso8859-1.
+ * Protected because it should not be used outside of the CSword*ModuleInfo classes.
+ */
+ inline bool isUnicode() const {
+ return m_dataCache.isUnicode;
+ }
+
+ public slots:
+ inline void cancelIndexing() {
+ m_cancelIndexing = true;
+ };
+
+ protected:
+ friend class CSwordBackend;
+
+ inline CSwordBackend* backend() const {
+ return m_backend;
+ }
+
+ inline void backend( CSwordBackend* newBackend ) {
+ if (newBackend) {
+ m_backend = newBackend;
+ }
+ }
+
+ QString getSimpleConfigEntry(const QString& name) const;
+ QString getFormattedConfigEntry(const QString& name) const;
+
+ signals:
+ void indexingFinished();
+ void indexingProgress(int);
+
+ private:
+ sword::SWModule* m_module;
+ sword::ListKey m_searchResult;
+
+ mutable struct DataCache {
+ DataCache() {
+ language = 0;
+ }
+
+ QString name;
+ bool isUnicode;
+ CSwordModuleInfo::Category category;
+ const CLanguageMgr::Language* language;
+ bool hasVersion;
+ }
+
+ m_dataCache;
+
+ CSwordBackend* m_backend;
+
+ bool m_hidden;
+
+ bool m_cancelIndexing;
};
inline CSwordModuleInfo::ModuleType CSwordModuleInfo::type() const {
- return CSwordModuleInfo::Unknown;
+ return CSwordModuleInfo::Unknown;
}
inline sword::SWModule* CSwordModuleInfo::module() const {
- return m_module;
+ return m_module;
}
inline bool CSwordModuleInfo::hasVersion() const {
- return m_dataCache.hasVersion;
+ return m_dataCache.hasVersion;
}
@@ -371,12 +373,12 @@ inline bool CSwordModuleInfo::hasVersion() const {
* The Sword library takes care of the duplicate names: _n is added after each duplicate.
*/
inline QString CSwordModuleInfo::name() const {
- return m_dataCache.name;
+ return m_dataCache.name;
}
/** Returns true if this module may be written by the write display windows. */
inline bool CSwordModuleInfo::isWritable() const {
- return false;
+ return false;
}
//#include "util/cpointers.h"