summaryrefslogtreecommitdiff
path: root/src/backend/drivers
diff options
context:
space:
mode:
authorRoberto C. Sanchez <roberto@connexer.com>2014-10-21 22:48:31 -0400
committerRoberto C. Sanchez <roberto@connexer.com>2014-10-21 22:48:31 -0400
commit294b5ec5834affa57641475946b8d2aeca53c577 (patch)
treeca25b634d0f24ab5b1fc38eb805e72e0e993e0f1 /src/backend/drivers
parente8a196082586bb68e0bf254a8f6f4b8f39071f32 (diff)
Imported Upstream version 2.4
Diffstat (limited to 'src/backend/drivers')
-rw-r--r--src/backend/drivers/cswordbiblemoduleinfo.cpp13
-rw-r--r--src/backend/drivers/cswordbiblemoduleinfo.h6
-rw-r--r--src/backend/drivers/cswordbookmoduleinfo.cpp9
-rw-r--r--src/backend/drivers/cswordbookmoduleinfo.h5
-rw-r--r--src/backend/drivers/cswordcommentarymoduleinfo.cpp3
-rw-r--r--src/backend/drivers/cswordcommentarymoduleinfo.h4
-rw-r--r--src/backend/drivers/cswordlexiconmoduleinfo.cpp16
-rw-r--r--src/backend/drivers/cswordlexiconmoduleinfo.h5
-rw-r--r--src/backend/drivers/cswordmoduleinfo.cpp132
-rw-r--r--src/backend/drivers/cswordmoduleinfo.h49
10 files changed, 111 insertions, 131 deletions
diff --git a/src/backend/drivers/cswordbiblemoduleinfo.cpp b/src/backend/drivers/cswordbiblemoduleinfo.cpp
index f00a580..4a65c4d 100644
--- a/src/backend/drivers/cswordbiblemoduleinfo.cpp
+++ b/src/backend/drivers/cswordbiblemoduleinfo.cpp
@@ -7,19 +7,16 @@
*
**********/
-//BibleTime includes
-#include "cswordbiblemoduleinfo.h"
-#include "backend/managers/cswordbackend.h"
-#include "backend/keys/cswordversekey.h"
+#include "backend/drivers/cswordbiblemoduleinfo.h"
-//Qt
+#include <boost/scoped_ptr.hpp>
#include <QFile>
+#include "backend/managers/cswordbackend.h"
+#include "backend/keys/cswordversekey.h"
-//Sword
+// Sword includes:
#include <versekey.h>
-#include <boost/scoped_ptr.hpp>
-
CSwordBibleModuleInfo::CSwordBibleModuleInfo( sword::SWModule* module, CSwordBackend* const usedBackend )
: CSwordModuleInfo(module, usedBackend),
diff --git a/src/backend/drivers/cswordbiblemoduleinfo.h b/src/backend/drivers/cswordbiblemoduleinfo.h
index 10d05bb..2780558 100644
--- a/src/backend/drivers/cswordbiblemoduleinfo.h
+++ b/src/backend/drivers/cswordbiblemoduleinfo.h
@@ -10,11 +10,11 @@
#ifndef CSWORDBIBLEMODULEINFO_H
#define CSWORDBIBLEMODULEINFO_H
-#include "cswordmoduleinfo.h"
-#include "backend/keys/cswordversekey.h"
+#include "backend/drivers/cswordmoduleinfo.h"
-//Qt
#include <QStringList>
+#include "backend/keys/cswordversekey.h"
+
/**
* This is the CModuleInfo imlementation for Bible modules managed by Sword.
diff --git a/src/backend/drivers/cswordbookmoduleinfo.cpp b/src/backend/drivers/cswordbookmoduleinfo.cpp
index b67015b..6371de1 100644
--- a/src/backend/drivers/cswordbookmoduleinfo.cpp
+++ b/src/backend/drivers/cswordbookmoduleinfo.cpp
@@ -7,13 +7,14 @@
*
**********/
-//BibleTime includes
-#include "cswordbookmoduleinfo.h"
+#include "backend/drivers/cswordbookmoduleinfo.h"
+
#include "backend/keys/cswordtreekey.h"
-//Sword includes
-#include <treekeyidx.h>
+// Sword includes:
#include <treekey.h>
+#include <treekeyidx.h>
+
CSwordBookModuleInfo::CSwordBookModuleInfo( sword::SWModule* module, CSwordBackend* const usedBackend )
: CSwordModuleInfo(module, usedBackend),
diff --git a/src/backend/drivers/cswordbookmoduleinfo.h b/src/backend/drivers/cswordbookmoduleinfo.h
index cd18efc..77adb29 100644
--- a/src/backend/drivers/cswordbookmoduleinfo.h
+++ b/src/backend/drivers/cswordbookmoduleinfo.h
@@ -10,11 +10,12 @@
#ifndef CSWORDGENBOOKMODULEINFO_H
#define CSWORDGENBOOKMODULEINFO_H
-#include "cswordmoduleinfo.h"
+#include "backend/drivers/cswordmoduleinfo.h"
-//Sword
+// Sword includes:
#include <treekeyidx.h>
+
/** Class for generic book support
* @author The BibleTime team
*/
diff --git a/src/backend/drivers/cswordcommentarymoduleinfo.cpp b/src/backend/drivers/cswordcommentarymoduleinfo.cpp
index bb19a23..8b74ffa 100644
--- a/src/backend/drivers/cswordcommentarymoduleinfo.cpp
+++ b/src/backend/drivers/cswordcommentarymoduleinfo.cpp
@@ -7,7 +7,8 @@
*
**********/
-#include "cswordcommentarymoduleinfo.h"
+#include "backend/drivers/cswordcommentarymoduleinfo.h"
+
CSwordCommentaryModuleInfo::CSwordCommentaryModuleInfo( sword::SWModule* module, CSwordBackend* const usedBackend)
: CSwordBibleModuleInfo(module, usedBackend) {}
diff --git a/src/backend/drivers/cswordcommentarymoduleinfo.h b/src/backend/drivers/cswordcommentarymoduleinfo.h
index eb9db83..a297538 100644
--- a/src/backend/drivers/cswordcommentarymoduleinfo.h
+++ b/src/backend/drivers/cswordcommentarymoduleinfo.h
@@ -10,8 +10,8 @@
#ifndef CSWORDCOMMENTARYMODULEINFO_H
#define CSWORDCOMMENTARYMODULEINFO_H
-//own includes
-#include "cswordbiblemoduleinfo.h"
+#include "backend/drivers/cswordbiblemoduleinfo.h"
+
/** Commentary module implementation.
* This CSwordModule implementation provides access to Sword's commentary modules.
diff --git a/src/backend/drivers/cswordlexiconmoduleinfo.cpp b/src/backend/drivers/cswordlexiconmoduleinfo.cpp
index 28874b6..776be9c 100644
--- a/src/backend/drivers/cswordlexiconmoduleinfo.cpp
+++ b/src/backend/drivers/cswordlexiconmoduleinfo.cpp
@@ -7,19 +7,17 @@
*
**********/
-#include "cswordlexiconmoduleinfo.h"
-#include "util/directoryutil.h"
+#include "backend/drivers/cswordlexiconmoduleinfo.h"
-//Qt
+#include <algorithm>
#include <QFile>
#include <QDataStream>
#include <QTextCodec>
+#include "util/directory.h"
-//Sword
+// Sword includes:
#include <swmodule.h>
-//STL includes
-#include <algorithm>
//Change it once the format changed to make all systems rebuild their caches
#define CACHE_FORMAT "2"
@@ -45,6 +43,8 @@ CSwordLexiconModuleInfo::~CSwordLexiconModuleInfo() {
/** Returns the entries of the module. */
QStringList* CSwordLexiconModuleInfo::entries() {
+ namespace DU = util::directory;
+
if (!module()) {
return 0;
}
@@ -68,7 +68,7 @@ QStringList* CSwordLexiconModuleInfo::entries() {
return m_entryList;
}
- QString dir(util::filesystem::DirectoryUtil::getUserCacheDir().absolutePath());
+ QString dir(DU::getUserCacheDir().absolutePath());
QFile f1(
QString(dir)
.append("/")
@@ -141,7 +141,7 @@ QStringList* CSwordLexiconModuleInfo::entries() {
if (m_entryList->count()) {
//create cache
- QString dir = util::filesystem::DirectoryUtil::getUserCacheDir().absolutePath();
+ QString dir(DU::getUserCacheDir().absolutePath());
//QFile f2( QString::fromLatin1("%1/%2").arg(dir).arg( name() ) );
QFile f2( QString(dir).append("/").append(name()) );
diff --git a/src/backend/drivers/cswordlexiconmoduleinfo.h b/src/backend/drivers/cswordlexiconmoduleinfo.h
index e5a5535..36d30fb 100644
--- a/src/backend/drivers/cswordlexiconmoduleinfo.h
+++ b/src/backend/drivers/cswordlexiconmoduleinfo.h
@@ -10,12 +10,11 @@
#ifndef CSWORDLEXICONMODULEINFO_H
#define CSWORDLEXICONMODULEINFO_H
-//own includes
-#include "cswordmoduleinfo.h"
+#include "backend/drivers/cswordmoduleinfo.h"
-//Qt includes
#include <QStringList>
+
/**
* The implementation of CModuleInfo for the Sword lexiccons and citionaries.
* @author The BibleTime team
diff --git a/src/backend/drivers/cswordmoduleinfo.cpp b/src/backend/drivers/cswordmoduleinfo.cpp
index 5861a2b..bafe098 100644
--- a/src/backend/drivers/cswordmoduleinfo.cpp
+++ b/src/backend/drivers/cswordmoduleinfo.cpp
@@ -7,48 +7,39 @@
*
**********/
-//BibleTime includes
-#include "cswordmoduleinfo.h"
-#include "cswordlexiconmoduleinfo.h"
-
-#include "backend/managers/cswordbackend.h"
-#include "backend/cswordmodulesearch.h"
-#include "backend/keys/cswordkey.h"
-#include "backend/rendering/centrydisplay.h"
-#include "backend/managers/clanguagemgr.h"
-
-#include "util/directoryutil.h"
-#include "util/cpointers.h"
-#include "util/exceptions.h"
-#include "backend/config/cbtconfig.h"
-
+#include "backend/drivers/cswordmoduleinfo.h"
#include <boost/scoped_ptr.hpp>
-
-//Qt includes
-#include <QRegExp>
+#include <CLucene.h>
+#include <CLucene/util/Misc.h>
+#include <CLucene/util/Reader.h>
+#include <QByteArray>
+#include <QCoreApplication>
+#include <QDebug>
#include <QDir>
#include <QFileInfo>
#include <QList>
-#include <QByteArray>
-#include <QDebug>
+#include <QRegExp>
#include <QSettings>
-#include <QMessageBox>
-#include <QCoreApplication>
+#include "backend/config/cbtconfig.h"
+#include "backend/drivers/cswordlexiconmoduleinfo.h"
+#include "backend/keys/cswordkey.h"
+#include "backend/managers/clanguagemgr.h"
+#include "backend/managers/cswordbackend.h"
+#include "backend/rendering/centrydisplay.h"
+#include "backend/cswordmodulesearch.h"
+#include "util/directory.h"
+#include "util/cpointers.h"
+#include "util/exceptions.h"
+#include "util/dialogutil.h"
-//Sword includes
-#include <swbuf.h>
-#include <swkey.h>
+// Sword includes:
#include <listkey.h>
-#include <versekey.h>
+#include <swbuf.h>
#include <swconfig.h>
+#include <swkey.h>
#include <rtfhtml.h>
-
-//Lucence includes
-#include <CLucene.h>
-#include <CLucene/util/Reader.h>
-#include <CLucene/util/Misc.h>
-#include <CLucene/util/dirent.h>
+#include <versekey.h>
//Increment this, if the index format changes
@@ -63,7 +54,6 @@ CSwordModuleInfo::CSwordModuleInfo(sword::SWModule * module, CSwordBackend * con
m_module = module;
Q_ASSERT(module);
- m_hidden = false;
m_cancelIndexing = false;
m_searchResult.ClearList();
m_backend = usedBackend ? usedBackend : CPointers::backend();
@@ -72,6 +62,7 @@ CSwordModuleInfo::CSwordModuleInfo(sword::SWModule * module, CSwordBackend * con
m_dataCache.category = UnknownCategory;
m_dataCache.language = 0;
m_dataCache.hasVersion = !QString((*m_backend->getConfig())[module->Name()]["Version"]).isEmpty();
+ m_hidden = CBTConfig::get(CBTConfig::hiddenModules).contains(name());
if (backend()) {
if (hasVersion() && (minimumSwordVersion() > sword::SWVersion::currentVersion)) {
@@ -108,7 +99,7 @@ bool CSwordModuleInfo::unlock(const QString & unlockKey) {
CBTConfig::setModuleEncryptionKey(name(), unlockKey);
backend()->setCipherKey(m_module->Name(), unlockKey.toUtf8().constData());
- //TODO: write to Sword config as well
+ /// \todo write to Sword config as well
return true;
}
@@ -181,7 +172,7 @@ bool CSwordModuleInfo::unlockKeyIsValid() {
}
QString CSwordModuleInfo::getGlobalBaseIndexLocation() {
- return util::filesystem::DirectoryUtil::getUserIndexDir().absolutePath();
+ return util::directory::getUserIndexDir().absolutePath();
}
QString CSwordModuleInfo::getModuleBaseIndexLocation() const {
@@ -316,10 +307,10 @@ void CSwordModuleInfo::buildIndex() {
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)
+ // 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());
@@ -417,18 +408,19 @@ void CSwordModuleInfo::buildIndex() {
}
catch (...) {
qWarning("CLucene exception occurred while indexing");
- QMessageBox::warning(0, QCoreApplication::tr("Indexing aborted"), QCoreApplication::tr("An internal error occurred while building the index."));
+ util::showWarning(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::directory::removeRecursive( getGlobalBaseIndexLocation() + "/" + name );
}
unsigned long CSwordModuleInfo::indexSize() const {
- return util::filesystem::DirectoryUtil::getDirSizeRecursive( getModuleBaseIndexLocation() );
+ namespace DU = util::directory;
+ return DU::getDirSizeRecursive( getModuleBaseIndexLocation() );
}
@@ -487,7 +479,7 @@ bool CSwordModuleInfo::searchIndexed(const QString& searchedText, sword::ListKey
}
catch (...) {
qWarning("CLucene exception occurred");
- QMessageBox::warning(0, QCoreApplication::tr("Search aborted"), QCoreApplication::tr("An internal error occurred while executing your search."));
+ util::showWarning(0, QCoreApplication::tr("Search aborted"), QCoreApplication::tr("An internal error occurred while executing your search."));
return false;
}
@@ -727,7 +719,7 @@ bool CSwordModuleInfo::deleteEntry(CSwordKey * const key) {
/** Returns the category of this module. See CSwordModuleInfo::Category for possible values. */
CSwordModuleInfo::Category CSwordModuleInfo::category() const {
- //qDebug("CSwordModuleInfo::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();
@@ -832,7 +824,7 @@ QString CSwordModuleInfo::aboutText() const {
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>")
+ text += QString("<b>%1:</b><br/>%2</font>")
.arg(tr("About"))
.arg(config(AboutInformation));
@@ -841,23 +833,14 @@ QString CSwordModuleInfo::aboutText() const {
ListConfigEntry entries;
entries.append(DistributionLicense);
-
entries.append(DistributionSource);
-
entries.append(DistributionNotes);
-
entries.append(TextSource);
-
entries.append(CopyrightNotes);
-
entries.append(CopyrightHolder);
-
entries.append(CopyrightDate);
-
entries.append(CopyrightContactName);
-
entries.append(CopyrightContactAddress);
-
entries.append(CopyrightContactEmail);
typedef QMap<CSwordModuleInfo::ConfigEntry, QString> MapConfigEntry;
@@ -865,23 +848,14 @@ QString CSwordModuleInfo::aboutText() const {
MapConfigEntry entryMap;
entryMap[DistributionLicense] = tr("Distribution license");
-
entryMap[DistributionSource] = tr("Distribution source");
-
entryMap[DistributionNotes] = tr("Distribution notes");
-
entryMap[TextSource] = tr("Text source");
-
entryMap[CopyrightNotes] = tr("Copyright notes");
-
entryMap[CopyrightHolder] = tr("Copyright holder");
-
entryMap[CopyrightDate] = tr("Copyright date");
-
entryMap[CopyrightContactName] = tr("Copyright contact name");
-
entryMap[CopyrightContactAddress] = tr("Copyright contact address");
-
entryMap[CopyrightContactEmail] = tr("Copyright contact email");
text += ("<hr><table>");
@@ -897,7 +871,6 @@ QString CSwordModuleInfo::aboutText() const {
}
-
text += "</table></font>";
return text;
@@ -946,24 +919,19 @@ QString CSwordModuleInfo::getFormattedConfigEntry(const QString& name) const {
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::setHidden(bool hide) {
+ if (m_hidden == hide) return false;
-bool CSwordModuleInfo::isHidden() const {
- //qDebug("CSwordModuleInfo::isHidden");
- QStringList hiddenModules = CBTConfig::get(CBTConfig::hiddenModules);
- if (hiddenModules.contains(this->name())) {
- return true;
+ m_hidden = hide;
+ QStringList hiddenModules(CBTConfig::get(CBTConfig::hiddenModules));
+ if (hide) {
+ Q_ASSERT(!hiddenModules.contains(name()));
+ hiddenModules.append(name());
+ } else {
+ Q_ASSERT(hiddenModules.contains(name()));
+ hiddenModules.removeOne(name());
}
- return false;
+ CBTConfig::set(CBTConfig::hiddenModules, hiddenModules);
+ emit hiddenChanged(hide);
+ return true;
}
diff --git a/src/backend/drivers/cswordmoduleinfo.h b/src/backend/drivers/cswordmoduleinfo.h
index ba4b8f6..9f32b12 100644
--- a/src/backend/drivers/cswordmoduleinfo.h
+++ b/src/backend/drivers/cswordmoduleinfo.h
@@ -12,16 +12,17 @@
#include "backend/managers/clanguagemgr.h"
-//Qt
-#include <QString>
#include <QList>
+#include <QMetaType>
+#include <QString>
-//Sword
+// Sword includes:
#include <listkey.h>
-#include <swsearchable.h>
+#include <swdisp.h>
#include <swmodule.h>
+#include <swsearchable.h>
#include <swversion.h>
-#include <swdisp.h>
+
class CSwordBackend;
class CSwordKey;
@@ -125,16 +126,19 @@ class CSwordModuleInfo: public QObject {
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 */
+ UnknownCategory = 0x0, /**< Unknown or unset category. */
+ NoCategory = 0x0,
+ Bibles = 0x01,
+ Commentaries = 0x02,
+ Books = 0x04,
+ Lexicons = 0x08,
+ Glossary = 0x10,
+ DailyDevotional = 0x20,
+ Images = 0x40,
+ Cult = 0x80, /**< Cult / sect / questionable module. */
+ AllCategories = 0xff
};
+ Q_DECLARE_FLAGS(Categories, Category);
/**
* Returns the base directory for search indices
@@ -258,7 +262,7 @@ class CSwordModuleInfo: public QObject {
*/
virtual bool snap() {
return false;
- };
+ }
bool has( const CSwordModuleInfo::Feature ) const;
bool has( const CSwordModuleInfo::FilterTypes ) const;
@@ -285,9 +289,14 @@ class CSwordModuleInfo: public QObject {
/**
* Returns true if this module is hidden (not to be shown with other modules in certain views).
*/
- bool isHidden() const;
+ inline bool isHidden() const { return m_hidden; }
- void setHidden(bool hidden);
+ /**
+ Shows or hides the module.
+ \param hide Whether the module should be hidden.
+ \returns whether the hidden state was changed.
+ */
+ bool setHidden(bool hide);
/**
* Returns the category of this module. See CSwordModuleInfo::Category for possible values.
@@ -308,7 +317,7 @@ class CSwordModuleInfo: public QObject {
public slots:
inline void cancelIndexing() {
m_cancelIndexing = true;
- };
+ }
protected:
friend class CSwordBackend;
@@ -327,6 +336,7 @@ class CSwordModuleInfo: public QObject {
QString getFormattedConfigEntry(const QString& name) const;
signals:
+ void hiddenChanged(bool);
void indexingFinished();
void indexingProgress(int);
@@ -355,6 +365,9 @@ class CSwordModuleInfo: public QObject {
bool m_cancelIndexing;
};
+Q_DECLARE_METATYPE(CSwordModuleInfo::Category);
+Q_DECLARE_OPERATORS_FOR_FLAGS(CSwordModuleInfo::Categories)
+
inline CSwordModuleInfo::ModuleType CSwordModuleInfo::type() const {
return CSwordModuleInfo::Unknown;
}