diff options
Diffstat (limited to 'src/backend/drivers/cswordmoduleinfo.cpp')
-rw-r--r-- | src/backend/drivers/cswordmoduleinfo.cpp | 42 |
1 files changed, 20 insertions, 22 deletions
diff --git a/src/backend/drivers/cswordmoduleinfo.cpp b/src/backend/drivers/cswordmoduleinfo.cpp index bafe098..6096af2 100644 --- a/src/backend/drivers/cswordmoduleinfo.cpp +++ b/src/backend/drivers/cswordmoduleinfo.cpp @@ -109,13 +109,7 @@ bool CSwordModuleInfo::isLocked() { //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; + return isEncrypted() && !unlockKeyIsValid(); } /** This functions returns true if this module is encrypted (locked or unlocked). */ @@ -129,11 +123,7 @@ bool CSwordModuleInfo::isEncrypted() const { sword::ConfigEntMap config = backend()->getConfig()->Sections.find(name().toUtf8().constData())->second; sword::ConfigEntMap::iterator it = config.find("CipherKey"); - if (it != config.end()) { - return true; - } - - return false; + return it != config.end(); } /** This function makes an estimate if a module was properly unlocked. @@ -194,12 +184,13 @@ bool CSwordModuleInfo::hasIndex() { //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 (hasVersion() && + module_config.value("module-version").toString() != config(CSwordModuleInfo::ModuleVersion)) + { + return false; } - if (module_config.value("index-version") != QString::number( INDEX_VERSION )) { + + if (module_config.value("index-version").toUInt() != INDEX_VERSION) { qDebug("%s: INDEX_VERSION is not compatible with this version of BibleTime.", name().toUtf8().constData()); return false; } @@ -397,24 +388,30 @@ void CSwordModuleInfo::buildIndex() { writer->close(); if (m_cancelIndexing) { - deleteIndexForModule(name()); + deleteIndex(); 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 ); + module_config.setValue("index-version", INDEX_VERSION); + emit hasIndexChanged(true); } } catch (...) { qWarning("CLucene exception occurred while indexing"); util::showWarning(0, QCoreApplication::tr("Indexing aborted"), QCoreApplication::tr("An internal error occurred while building the index.")); - deleteIndexForModule(name()); + deleteIndex(); m_cancelIndexing = false; } } -void CSwordModuleInfo::deleteIndexForModule( QString name ) { +void CSwordModuleInfo::deleteIndex() { + deleteIndexForModule(name()); + emit hasIndexChanged(false); +} + +void CSwordModuleInfo::deleteIndexForModule(const QString &name) { util::directory::removeRecursive( getGlobalBaseIndexLocation() + "/" + name ); } @@ -927,7 +924,8 @@ bool CSwordModuleInfo::setHidden(bool hide) { if (hide) { Q_ASSERT(!hiddenModules.contains(name())); hiddenModules.append(name()); - } else { + } + else { Q_ASSERT(hiddenModules.contains(name())); hiddenModules.removeOne(name()); } |