diff options
Diffstat (limited to 'src/backend')
-rw-r--r-- | src/backend/config/cbtconfig.cpp | 1343 | ||||
-rw-r--r-- | src/backend/config/cbtconfig.h | 334 | ||||
-rw-r--r-- | src/backend/drivers/cswordbiblemoduleinfo.cpp | 36 | ||||
-rw-r--r-- | src/backend/filters/bt_osishtml.cpp | 14 | ||||
-rw-r--r-- | src/backend/filters/bt_plainhtml.cpp | 2 | ||||
-rw-r--r-- | src/backend/keys/cswordversekey.cpp | 16 | ||||
-rw-r--r-- | src/backend/managers/cswordbackend.cpp | 4 |
7 files changed, 823 insertions, 926 deletions
diff --git a/src/backend/config/cbtconfig.cpp b/src/backend/config/cbtconfig.cpp index a0fb4f2..9dff6c1 100644 --- a/src/backend/config/cbtconfig.cpp +++ b/src/backend/config/cbtconfig.cpp @@ -7,714 +7,675 @@ * **********/ -//BibleTime includes #include "cbtconfig.h" -#include "backend/drivers/cswordmoduleinfo.h" -#include "backend/managers/clanguagemgr.h" -#include "backend/managers/cdisplaytemplatemgr.h" -#include "backend/btmoduletreeitem.h" -#include "util/cpointers.h" -#include "util/directoryutil.h" -#include "frontend/searchdialog/btsearchoptionsarea.h" - -//Qt includes -#include <QApplication> -#include <QString> -#include <QStringList> -#include <QMap> -#include <QList> +// Qt includes #include <QDebug> -#include <QSettings> #include <QLocale> +#include <QSettings> +#include <QVariant> #include <QWebSettings> -//Sword includes -#include <versekey.h> //for range configuration - -//init statics -QFont* CBTConfig::m_defaultFont = 0; -CBTConfig::FontCache CBTConfig::fontConfigMap; - -/* No constructor and destructor, because this class only contains static methods. - It won't be instantiated. */ - -QString CBTConfig::getKey( const CBTConfig::strings ID) { - switch ( ID ) { - case bibletimeVersion: return "bibletimeVersion"; - case language: return "language"; - case displayStyle: return "displayStyle"; - case bookshelfCurrentItem: return "bookshelfCurrentItem"; - } - Q_ASSERT(false); - return QString::null; -} - -QString CBTConfig::getDefault( const CBTConfig::strings ID) { - switch ( ID ) { - case bibletimeVersion: return "0.0"; // main() will realize this and set the value to VERSION - case language: return QLocale::system().name(); - case displayStyle: return CDisplayTemplateMgr::defaultTemplate(); - case bookshelfCurrentItem: return QString(); - } - return QString::null; -} - -QString CBTConfig::getKey( const CBTConfig::modules ID) { - switch ( ID ) { - case standardBible: return "standardBible"; - case standardCommentary: return "standardCommentary"; - case standardLexicon: return "standardLexicon"; - case standardDailyDevotional: return "standardDailyDevotional"; - case standardHebrewStrongsLexicon: return "standardHebrewLexicon"; - case standardGreekStrongsLexicon: return "standardGreekLexicon"; - case standardHebrewMorphLexicon: return "standardHebrewMorphLexicon"; - case standardGreekMorphLexicon: return "standardGreekMorphLexicon"; - } - Q_ASSERT(false); - return QString::null; -} - -QString CBTConfig::getDefault( const CBTConfig::modules ID) { - // CSwordBackend* b = CPointers::backend(); - switch ( ID ) { - case standardBible: return "KJV"; - case standardCommentary: return "MHC"; - case standardLexicon: return "ISBE"; - case standardDailyDevotional: return ""; //no default - - case standardHebrewStrongsLexicon: return "StrongsHebrew"; - case standardGreekStrongsLexicon: return "StrongsGreek"; - case standardHebrewMorphLexicon: return "StrongsHebrew"; - case standardGreekMorphLexicon: return "StrongsGreek"; - } - - return QString::null; -} - -QString CBTConfig::getKey( const CBTConfig::bools ID) { - switch ( ID ) { - case firstSearchDialog: return "firstSearchDialog"; - case readOldBookmarks: return "readOldBookmarks"; - - case toolbar: return "toolbar"; - case mainIndex: return "mainIndex"; - case infoDisplay: return "infoDisplay"; - - case autoTileVertical: return "autoTileVertical"; - case autoTileHorizontal: return "autoTileHorizontal"; - case autoCascade: return "autoCascade"; - - case lineBreaks: return "lineBreaks"; - case verseNumbers: return "verseNumbers"; - - case logo: return "logo"; - case autoDeleteOrphanedIndices: return "autoDeleteOrphanedIndices"; - case crashedLastTime: return "crashedLastTime"; - case crashedTwoTimes: return "crashedTwoTimes"; - - case bookshelfShowHidden: return "bookshelfShowHidden"; - case allowNetworkConnection: return "allowNetworkConnection"; - } - Q_ASSERT(false); - return false; -} - -QString CBTConfig::getKey( const CBTConfig::ints ID) { - switch ( ID ) { - case footnotes: return "footnotes"; - case strongNumbers: return "strongNumbers"; - case headings: return "headings"; - case morphTags: return "morphTags"; - case lemmas: return "lemmas"; - case hebrewPoints: return "hebrewPoints"; - case hebrewCantillation: return "hebrewCantillation"; - case greekAccents: return "greekAccents"; - case textualVariants: return "textualVariants"; - case scriptureReferences: return "scriptureReferences"; - case morphSegmentation: return "morphSegmentation"; - case bookshelfContentsX: return "bookshelfContentsX"; - case bookshelfContentsY: return "bookshelfContentsY"; - case magDelay: return "magDelay"; - case bookshelfGrouping: return "bookshelfGrouping"; - case mainindexActiveTab: return "mainindexActiveTab"; - case searchDialogWidth: return "searchDialogWidth"; - case searchDialogHeight: return "searchDialogHeight"; - case searchDialogX: return "searchDialogX"; - case searchDialogY: return "searchDialogY"; - case searchType: return "searchType"; - case installPathIndex: return "installPathIndex"; - } - Q_ASSERT(false); - return QString::null; -} - -bool CBTConfig::getDefault( const CBTConfig::bools ID) { - switch ( ID ) { - case firstSearchDialog: return true; - case readOldBookmarks: return false; - - case toolbar: return true; - case mainIndex: return true; - case infoDisplay: return true; - - case autoTileVertical: return true; - case autoTileHorizontal: return false; - case autoCascade: return false; - - case lineBreaks: return false; - case verseNumbers: return true; - - case logo: return true; - case autoDeleteOrphanedIndices: return true; - case crashedLastTime: return false; - case crashedTwoTimes: return false; - case bookshelfShowHidden: return false; - case allowNetworkConnection: return false; - } - return false; -} - -int CBTConfig::getDefault( const CBTConfig::ints ID) { - switch ( ID ) { - case footnotes: return int(true); - case strongNumbers: return int(true); - case headings: return int(true); - case morphTags: return int(true); - case lemmas: return int(true); - case hebrewPoints: return int(true); - case hebrewCantillation: return int(true); - case greekAccents: return int(true); - case textualVariants: return int(false); - case scriptureReferences: return int(true); - case morphSegmentation: return int(true); - case bookshelfContentsX: return 0; - case bookshelfContentsY: return 0; - case magDelay: return 400; - case bookshelfGrouping: return BTModuleTreeItem::CatLangMod; - case searchDialogWidth: return 200; - case searchDialogHeight: return 400; - case searchDialogX: return 200; - case searchDialogY: return 200; - case searchType: return Search::BtSearchOptionsArea::AndType; - case mainindexActiveTab: return 0; - case installPathIndex: return 0; - } - return 0; -} - -QString CBTConfig::getKey( const CBTConfig::intLists ID) { - switch ( ID ) { - case leftPaneSplitterSizes: return "leftPaneSplitterSizes"; - case mainSplitterSizes: return "mainSplitterSizes"; - case searchMainSplitterSizes: return "searchMainSplitterSizes"; - case searchResultSplitterSizes: return "searchResultSplitterSizes"; - } - Q_ASSERT(false); - return QString::null; -} - -QList<int> CBTConfig::getDefault( const CBTConfig::intLists /*ID*/) { - QList<int> result; - /*switch ( ID ) { - case leftPaneSplitterSizes: break; - case mainSplitterSizes: break; - case searchMainSplitterSizes: break; - case searchResultSplitterSizes: break;*/ - return result; -} - -QString CBTConfig::getKey( const CBTConfig::stringLists ID) { - switch ( ID ) { - case searchCompletionTexts: return QString("searchCompletionTexts"); - case searchTexts: return QString("searchTexts"); - case searchModulesHistory: return QString("searchModulesHistory"); - case bookshelfOpenGroups: return QString("bookshelfOpenGroups"); - case hiddenModules: return QString("hiddenModules"); - } - Q_ASSERT(false); - return QString::null; -} - -QStringList CBTConfig::getDefault( const CBTConfig::stringLists ID) { - switch ( ID ) { - case searchTexts: { - QStringList list; - list.append(QString::null); - return list; - } - case searchCompletionTexts: return QStringList(); - case bookshelfOpenGroups: return QStringList(); - case hiddenModules: return QStringList(); - case searchModulesHistory: return QStringList(); - } - return QStringList(); -} - -QString CBTConfig::getKey( const CBTConfig::stringMaps ID) { - switch (ID) { - case searchScopes: - return QString("SearchScopes"); - }; - Q_ASSERT(false); - return QString::null; -} - -CBTConfig::StringMap CBTConfig::getDefault( const CBTConfig::stringMaps ID) { - switch ( ID ) { - case searchScopes: { - CBTConfig::StringMap map; - map.insert(QObject::tr("Old testament"), QString("Gen - Mal")); - map.insert(QObject::tr("Moses/Pentateuch/Torah"),QString("Gen - Deut")); - map.insert(QObject::tr("History"), QString("Jos - Est")); - map.insert(QObject::tr("Prophets"), QString("Isa - Mal")); - map.insert(QObject::tr("New testament"), QString("Mat - Rev")); - map.insert(QObject::tr("Gospels"), QString("Mat - Joh")); - map.insert(QObject::tr("Letters/Epistles"), QString("Rom - Jude")); - map.insert(QObject::tr("Paul's Epistles"), QString("Rom - Phile")); - - //make the list to the current bookname language! - CBTConfig::StringMap::Iterator it; - sword::VerseKey vk; - vk.setLocale("en_US"); - - for (it = map.begin(); it != map.end(); ++it) { - sword::ListKey list = vk.ParseVerseList(it.value().toLocal8Bit(), "Genesis 1:1", true); - QString data; - for (int i = 0; i < list.Count(); ++i) { - data += QString::fromUtf8(list.GetElement(i)->getRangeText()) + "; "; - } - map[it.key()] = data; //set the new data - }; - - return map; - }; - default: - return CBTConfig::StringMap(); - } - - return CBTConfig::StringMap(); -} - - -QString CBTConfig::getKey( const CLanguageMgr::Language* const language ) { - Q_ASSERT(!language->name().isEmpty()); - return language->name(); -} - -QFont& CBTConfig::getDefault( const CLanguageMgr::Language* const) -{ - //language specific lookup of the font name - if (m_defaultFont) - { - return *m_defaultFont; - } - -// TODO - make the font name and size a configuration option - //int fontSize = QWebSettings::globalSettings()->fontSize(QWebSettings::DefaultFontSize); - int fontSize = 12; - QString fontName = QWebSettings::globalSettings()->fontFamily(QWebSettings::StandardFont); - - m_defaultFont = new QFont(fontName, fontSize); //TODO: there may be a mem leak here! - return *m_defaultFont; -} - -QString CBTConfig::get( const CBTConfig::strings ID) -{ - QString result; - getConfig()->beginGroup("strings"); - result = getConfig()->value(getKey(ID), getDefault(ID)).toString(); - getConfig()->endGroup(); - return result; - -} - -CSwordModuleInfo* CBTConfig::get( const CBTConfig::modules ID) -{ - CSwordModuleInfo* result; - getConfig()->beginGroup("modules"); - result = CPointers::backend()->findModuleByName( getConfig()->value(getKey(ID), getDefault(ID)).toString() ); - getConfig()->endGroup(); - return result; -} - -bool CBTConfig::get( const CBTConfig::bools ID) -{ - bool result; - getConfig()->beginGroup("bools"); - result = getConfig()->value(getKey(ID), getDefault(ID)).toBool(); - getConfig()->endGroup(); - return result; -} - -int CBTConfig::get( const CBTConfig::ints ID) -{ - int result; - getConfig()->beginGroup("ints"); - result = getConfig()->value(getKey(ID), getDefault(ID)).toInt(); - getConfig()->endGroup(); - return result; -} - -QList<int> CBTConfig::get( const CBTConfig::intLists ID ) -{ - QList<int> result; - getConfig()->beginGroup("intlists"); - result = StringToIntList( getConfig()->value(getKey(ID), IntListToString( getDefault(ID) )).toString() ); - getConfig()->endGroup(); - return result; -} - -QStringList CBTConfig::get( const CBTConfig::stringLists ID ) -{ - QStringList result; - getConfig()->beginGroup("stringlists"); - result = getConfig()->value(getKey(ID), getDefault(ID)).toStringList(); - getConfig()->endGroup(); - return result; -} - -CBTConfig::StringMap CBTConfig::get( const CBTConfig::stringMaps ID ) -{ - getConfig()->beginGroup(getKey(ID)); - CBTConfig::StringMap map; - - QStringList keys(getConfig()->childKeys()); - if (!keys.isEmpty()) { - switch (ID) { - case searchScopes: { //make sure we return the scopes in the chosen language. saved keys are in english - sword::VerseKey vk; - foreach (QString key, keys) { - Q_ASSERT(!key.isEmpty()); - sword::ListKey list = vk.ParseVerseList(getConfig()->value(key).toString().toUtf8(), "Genesis 1:1", true); - QString data; - for (int i = 0; i < list.Count(); ++i) { - data += QString::fromUtf8(list.GetElement(i)->getRangeText()) + "; "; - } - map[key] = data; //set the new data - } - } - default: break; - } - } - else - { - map = getDefault(ID); - } - getConfig()->endGroup(); - return map; -} - -CBTConfig::FontSettingsPair CBTConfig::get( const CLanguageMgr::Language* const language ) -{ - if (fontConfigMap.contains(language)) { - return fontConfigMap.find(language).value(); - } - - FontSettingsPair settings; - - getConfig()->beginGroup("font standard settings"); - settings.first = getConfig()->value(getKey(language), QVariant(false)).toBool(); - getConfig()->endGroup(); - getConfig()->beginGroup("fonts"); - - QFont font; - if (settings.first) - font.fromString(getConfig()->value(getKey(language), getDefault(language)).toString()); - else - font = getDefault(language); - - settings.second = font; - getConfig()->endGroup(); - - fontConfigMap.insert(language, settings); //cache the value - return settings; -} - -void CBTConfig::set( const CBTConfig::strings ID, const QString value ) -{ -// KConfigGroup cg = CBTConfig::getConfig()->group("strings"); -// cg.writeEntry(getKey(ID), value); - getConfig()->beginGroup("strings"); - getConfig()->setValue(getKey(ID), value); - getConfig()->endGroup(); -} - -void CBTConfig::set( const CBTConfig::modules ID, CSwordModuleInfo* const value ) -{ -// KConfigGroup cg = CBTConfig::getConfig()->group("modules"); -// cg.writeEntry(getKey(ID), value ? value->name() : QString::null); - getConfig()->beginGroup("modules"); - getConfig()->setValue(getKey(ID), value ? value->name() : QString::null); - getConfig()->endGroup(); -} - -void CBTConfig::set( const CBTConfig::modules ID, const QString& value ) -{ - CSwordModuleInfo* module = CPointers::backend()->findModuleByName(value); - if (module) { - CBTConfig::set(ID, module); - } -} - -void CBTConfig::set(const CBTConfig::bools ID,const bool value ) -{ - getConfig()->beginGroup("bools"); - getConfig()->setValue(getKey(ID), value); - getConfig()->endGroup(); -} - -void CBTConfig::set(const CBTConfig::ints ID, const int value ) -{ - getConfig()->beginGroup("ints"); - getConfig()->setValue(getKey(ID), value); - getConfig()->endGroup(); -} - -void CBTConfig::set( const CBTConfig::intLists ID, const QList<int> value ) -{ - getConfig()->beginGroup("intlists"); - getConfig()->setValue(getKey(ID), IntListToString(value)); - getConfig()->endGroup(); -} - -void CBTConfig::set( const CBTConfig::stringLists ID, const QStringList value ) -{ - getConfig()->beginGroup("stringlists"); - getConfig()->setValue(getKey(ID), value); - getConfig()->endGroup(); -} - -void CBTConfig::set( const CBTConfig::stringMaps ID, const CBTConfig::StringMap value ) -{ - getConfig()->beginGroup(getKey(ID)); - getConfig()->remove(""); //clear all entries of this group to make sure old stuff gets removed - - switch (ID) { - case searchScopes: { - /** - * We want to make sure that the search scopes are saved with english key names so loading them - * will always work with each locale set. - */ - CBTConfig::StringMap::ConstIterator it; - QString data;// = QString::null; - - sword::VerseKey vk; - for (it = value.begin(); it != value.end(); ++it) { - sword::ListKey list = vk.ParseVerseList(it.value().toUtf8(), "Genesis 1:1", true); - data = QString::null; - for (int i = 0; i < list.Count(); ++i) { - if ( sword::VerseKey* range = dynamic_cast<sword::VerseKey*>(list.GetElement(i)) ) { - range->setLocale("en"); - data += QString::fromUtf8( range->getRangeText() ) + ";"; - } - } - getConfig()->setValue(it.key(), data); - } - break; - } - default: { - for (CBTConfig::StringMap::ConstIterator it = value.begin(); it != value.end(); ++it) { - getConfig()->setValue(it.key(), it.value()); - } - break; - } - } - getConfig()->endGroup(); -} - - -void CBTConfig::set( const CLanguageMgr::Language* const language, const FontSettingsPair& value ) -{ - getConfig()->beginGroup("fonts"); - getConfig()->setValue(getKey(language), value.second.toString()); - getConfig()->endGroup(); - getConfig()->beginGroup("font standard settings"); - getConfig()->setValue(getKey(language), value.first); - getConfig()->endGroup(); +// Sword includes +#include <versekey.h> // For range configuration - if (fontConfigMap.contains(language)) { - fontConfigMap.remove - (language); //remove it from the cache - } -} +// BibleTime includes +#include "backend/btmoduletreeitem.h" +#include "backend/managers/cdisplaytemplatemgr.h" +#include "frontend/displaywindow/btactioncollection.h" +#include "frontend/searchdialog/btsearchoptionsarea.h" +#include "util/cpointers.h" +#include "util/directoryutil.h" -CSwordBackend::DisplayOptions CBTConfig::getDisplayOptionDefaults() +namespace CBTConfig { +namespace { + +typedef QMap<const CLanguageMgr::Language*, FontSettingsPair> FontCacheMap; + +QFont *m_defaultFont = 0; +FontCacheMap m_fontCache; + +QString getKey(const strings ID) { + switch (ID) { + case bibletimeVersion: return "bibletimeVersion"; + case language: return "language"; + case displayStyle: return "displayStyle"; + case bookshelfCurrentItem: return "bookshelfCurrentItem"; + } + Q_ASSERT(false); + return QString::null; +} + +QString getKey(const modules ID) { + switch (ID) { + case standardBible: return "standardBible"; + case standardCommentary: return "standardCommentary"; + case standardLexicon: return "standardLexicon"; + case standardDailyDevotional: return "standardDailyDevotional"; + case standardHebrewStrongsLexicon: return "standardHebrewLexicon"; + case standardGreekStrongsLexicon: return "standardGreekLexicon"; + case standardHebrewMorphLexicon: return "standardHebrewMorphLexicon"; + case standardGreekMorphLexicon: return "standardGreekMorphLexicon"; + } + Q_ASSERT(false); + return QString::null; +} + +QString getKey(const bools ID) { + switch (ID) { + case firstSearchDialog: return "firstSearchDialog"; + case readOldBookmarks: return "readOldBookmarks"; + + case toolbar: return "toolbar"; + case mainIndex: return "mainIndex"; + case infoDisplay: return "infoDisplay"; + + case autoTileVertical: return "autoTileVertical"; + case autoTileHorizontal: return "autoTileHorizontal"; + case autoCascade: return "autoCascade"; + + case lineBreaks: return "lineBreaks"; + case verseNumbers: return "verseNumbers"; + + case logo: return "logo"; + case autoDeleteOrphanedIndices: return "autoDeleteOrphanedIndices"; + case crashedLastTime: return "crashedLastTime"; + case crashedTwoTimes: return "crashedTwoTimes"; + + case bookshelfShowHidden: return "bookshelfShowHidden"; + case allowNetworkConnection: return "allowNetworkConnection"; + } + Q_ASSERT(false); + return false; +} + +QString getKey(const ints ID) { + switch (ID) { + case footnotes: return "footnotes"; + case strongNumbers: return "strongNumbers"; + case headings: return "headings"; + case morphTags: return "morphTags"; + case lemmas: return "lemmas"; + case hebrewPoints: return "hebrewPoints"; + case hebrewCantillation: return "hebrewCantillation"; + case greekAccents: return "greekAccents"; + case textualVariants: return "textualVariants"; + case scriptureReferences: return "scriptureReferences"; + case morphSegmentation: return "morphSegmentation"; + case bookshelfContentsX: return "bookshelfContentsX"; + case bookshelfContentsY: return "bookshelfContentsY"; + case magDelay: return "magDelay"; + case bookshelfGrouping: return "bookshelfGrouping"; + case mainindexActiveTab: return "mainindexActiveTab"; + case searchDialogWidth: return "searchDialogWidth"; + case searchDialogHeight: return "searchDialogHeight"; + case searchDialogX: return "searchDialogX"; + case searchDialogY: return "searchDialogY"; + case searchType: return "searchType"; + case installPathIndex: return "installPathIndex"; + case bookshelfPosX: return "bookshelfPosX"; + case bookshelfPosY: return "bookshelfPosY"; + case bookshelfHeight: return "bookshelfHeight"; + case bookshelfWidth: return "bookshelfWidth"; + case configDialogPosX: return "configDialogPosX"; + case configDialogPosY: return "configDialogPosY"; + case configDialogHeight: return "configDialogHeight"; + case configDialogWidth: return "configDialogWidth"; + } + Q_ASSERT(false); + return QString::null; +} + +QString getKey(const intLists ID) { + switch (ID) { + case leftPaneSplitterSizes: return "leftPaneSplitterSizes"; + case mainSplitterSizes: return "mainSplitterSizes"; + case searchMainSplitterSizes: return "searchMainSplitterSizes"; + case searchResultSplitterSizes: return "searchResultSplitterSizes"; + } + Q_ASSERT(false); + return QString::null; +} + +QString getKey(const stringLists ID) { + switch (ID) { + case searchCompletionTexts: return "searchCompletionTexts"; + case searchTexts: return "searchTexts"; + case searchModulesHistory: return "searchModulesHistory"; + case bookshelfOpenGroups: return "bookshelfOpenGroups"; + case hiddenModules: return "hiddenModules"; + } + Q_ASSERT(false); + return QString::null; +} + +QString getKey(const stringMaps ID) { + switch (ID) { + case searchScopes: return "SearchScopes"; + }; + Q_ASSERT(false); + return QString::null; +} + +QString getKey(const CLanguageMgr::Language * const language) { + Q_ASSERT(!language->name().isEmpty()); + return language->name(); +} + +} // anonymous namespace + +QString IntListToString(const QList<int> intList) { + QStringList intStrings; + foreach(int i, intList) { + intStrings << QString::number(i); + } + return intStrings.join(","); +} + +QList<int> StringToIntList(const QString intListString) { + QList<int> intList; + if (!intListString.isEmpty() && intListString.contains(',')) { + foreach(QString intString, intListString.split(',')) { + intList << intString.trimmed().toInt(); + } + } + return intList; +} + +QString getDefault(const strings ID) { + switch (ID) { + case bibletimeVersion: return "0.0"; // main() will realize this and set the value to VERSION + case language: return QLocale::system().name(); + case displayStyle: return CDisplayTemplateMgr::defaultTemplate(); + case bookshelfCurrentItem: return QString(); + } + return QString::null; +} + +QString getDefault(const modules ID) { + // CSwordBackend *b = CPointers::backend(); + switch (ID) { + case standardBible: return "KJV"; + case standardCommentary: return "MHC"; + case standardLexicon: return "ISBE"; + case standardDailyDevotional: return ""; // No default + + case standardHebrewStrongsLexicon: return "StrongsHebrew"; + case standardGreekStrongsLexicon: return "StrongsGreek"; + case standardHebrewMorphLexicon: return "StrongsHebrew"; + case standardGreekMorphLexicon: return "StrongsGreek"; + } + + return QString::null; +} + +bool getDefault(const bools ID) { + switch (ID) { + case firstSearchDialog: return true; + case readOldBookmarks: return false; + + case toolbar: return true; + case mainIndex: return true; + case infoDisplay: return true; + + case autoTileVertical: return true; + case autoTileHorizontal: return false; + case autoCascade: return false; + + case lineBreaks: return false; + case verseNumbers: return true; + + case logo: return true; + case autoDeleteOrphanedIndices: return true; + case crashedLastTime: return false; + case crashedTwoTimes: return false; + case bookshelfShowHidden: return false; + case allowNetworkConnection: return false; + } + return false; +} + +int getDefault(const ints ID) { + switch (ID) { + case footnotes: return int(true); + case strongNumbers: return int(true); + case headings: return int(true); + case morphTags: return int(true); + case lemmas: return int(true); + case hebrewPoints: return int(true); + case hebrewCantillation: return int(true); + case greekAccents: return int(true); + case textualVariants: return int(false); + case scriptureReferences: return int(true); + case morphSegmentation: return int(true); + case bookshelfContentsX: return 0; + case bookshelfContentsY: return 0; + case magDelay: return 400; + case bookshelfGrouping: return BTModuleTreeItem::CatLangMod; + case searchDialogWidth: return 200; + case searchDialogHeight: return 400; + case searchDialogX: return 200; + case searchDialogY: return 200; + case searchType: return Search::BtSearchOptionsArea::AndType; + case mainindexActiveTab: return 0; + case installPathIndex: return 0; + case bookshelfPosX: return 1; + case bookshelfPosY: return 1; + case bookshelfHeight: return 1; + case bookshelfWidth: return 1; + case configDialogPosX: return 1; + case configDialogPosY: return 1; + case configDialogHeight: return 1; + case configDialogWidth: return 1; + } + return 0; +} + +QList<int> getDefault(const intLists /*ID*/) { + QList<int> result; + /*switch ( ID ) { + case leftPaneSplitterSizes: break; + case mainSplitterSizes: break; + case searchMainSplitterSizes: break; + case searchResultSplitterSizes: break;*/ + return result; +} + +QStringList getDefault(const stringLists ID) { + switch (ID) { + case searchTexts: { + QStringList list; + list.append(QString::null); + return list; + } + case searchCompletionTexts: return QStringList(); + case bookshelfOpenGroups: return QStringList(); + case hiddenModules: return QStringList(); + case searchModulesHistory: return QStringList(); + } + return QStringList(); +} + +StringMap getDefault(const stringMaps ID) { + if (ID != searchScopes) return StringMap(); + + StringMap map; + map.insert(QObject::tr("Old testament"), QString("Gen - Mal")); + map.insert(QObject::tr("Moses/Pentateuch/Torah"), QString("Gen - Deut")); + map.insert(QObject::tr("History"), QString("Jos - Est")); + map.insert(QObject::tr("Prophets"), QString("Isa - Mal")); + map.insert(QObject::tr("New testament"), QString("Mat - Rev")); + map.insert(QObject::tr("Gospels"), QString("Mat - Joh")); + map.insert(QObject::tr("Letters/Epistles"), QString("Rom - Jude")); + map.insert(QObject::tr("Paul's Epistles"), QString("Rom - Phile")); + + // Make the list to the current bookname language! + sword::VerseKey vk; + vk.setLocale("en_US"); + + for (StringMap::Iterator it(map.begin()); it != map.end(); it++) { + sword::ListKey list(vk.ParseVerseList(it.value().toLocal8Bit(), "Genesis 1:1", true)); + QString data; + for (int i(0); i < list.Count(); i++) { + data.append(QString::fromUtf8(list.GetElement(i)->getRangeText())); + data.append("; "); + } + map[it.key()] = data; + }; + + return map; +} + +QFont &getDefault(const CLanguageMgr::Language * const) { + // Language specific lookup of the font name + if (m_defaultFont) return *m_defaultFont; + + /// \todo make the font name and size a configuration option + // int fontSize = QWebSettings::globalSettings()->fontSize(QWebSettings::DefaultFontSize); + int fontSize(12); + QString fontName(QWebSettings::globalSettings()->fontFamily(QWebSettings::StandardFont)); + + m_defaultFont = new QFont(fontName, fontSize); /// \todo there may be a mem leak here! + return *m_defaultFont; +} + +QString get(const strings ID) { + getConfig()->beginGroup("strings"); + QString result(getConfig()->value(getKey(ID), getDefault(ID)).toString()); + getConfig()->endGroup(); + return result; +} + +CSwordModuleInfo *get(const modules ID) { + getConfig()->beginGroup("modules"); + CSwordModuleInfo *result(CPointers::backend()->findModuleByName( + getConfig()->value(getKey(ID), getDefault(ID)).toString() + )); + getConfig()->endGroup(); + return result; +} + +bool get(const bools ID) { + getConfig()->beginGroup("bools"); + bool result(getConfig()->value(getKey(ID), getDefault(ID)).toBool()); + getConfig()->endGroup(); + return result; +} + +int get(const ints ID) { + getConfig()->beginGroup("ints"); + int result(getConfig()->value(getKey(ID), getDefault(ID)).toInt()); + getConfig()->endGroup(); + return result; +} + +QList<int> get(const intLists ID) { + getConfig()->beginGroup("intlists"); + QList<int> result(StringToIntList( + getConfig()->value(getKey(ID), IntListToString(getDefault(ID))) + .toString() + )); + getConfig()->endGroup(); + return result; +} + +QStringList get(const stringLists ID) { + getConfig()->beginGroup("stringlists"); + QStringList result( + getConfig()->value(getKey(ID), getDefault(ID)).toStringList() + ); + getConfig()->endGroup(); + return result; +} + +StringMap get(const stringMaps ID) { + StringMap map; + + getConfig()->beginGroup(getKey(ID)); + QStringList keys(getConfig()->childKeys()); + + if (!keys.isEmpty()) { + switch (ID) { + case searchScopes: { + /** + Make sure we return the scopes in the chosen language. saved + keys are in english. + */ + sword::VerseKey vk; + foreach (QString key, keys) { + Q_ASSERT(!key.isEmpty()); + QByteArray b(getConfig()->value(key).toString().toUtf8()); + sword::ListKey list(vk.ParseVerseList(b, "Genesis 1:1", true)); + QString data; + for (int i(0); i < list.Count(); i++) { + data.append(QString::fromUtf8(list.GetElement(i)->getRangeText())); + data.append("; "); + } + map[key] = data; // Set the new data + } + } + default: break; + } + } else { + map = getDefault(ID); + } + getConfig()->endGroup(); + return map; +} + +FontSettingsPair get(const CLanguageMgr::Language * const language) { + // Check the cache first: + FontCacheMap::const_iterator it(m_fontCache.find(language)); + if (it != m_fontCache.end()) return *it; + + FontSettingsPair settings; + + getConfig()->beginGroup("font standard settings"); + settings.first = getConfig()->value(getKey(language), false).toBool(); + getConfig()->endGroup(); + + getConfig()->beginGroup("fonts"); + QFont font; + if (settings.first) { + font.fromString(getConfig()->value(getKey(language), getDefault(language)).toString()); + } else { + font = getDefault(language); + } + settings.second = font; + getConfig()->endGroup(); + + // Cache the value: + m_fontCache.insert(language, settings); + + return settings; +} + +void set(const strings ID, const QString value) { +// KConfigGroup cg = getConfig()->group("strings"); +// cg.writeEntry(getKey(ID), value); + getConfig()->beginGroup("strings"); + getConfig()->setValue(getKey(ID), value); + getConfig()->endGroup(); +} + +void set(const modules ID, CSwordModuleInfo * const value) { +// KConfigGroup cg = getConfig()->group("modules"); +// cg.writeEntry(getKey(ID), value ? value->name() : QString::null); + getConfig()->beginGroup("modules"); + getConfig()->setValue(getKey(ID), value ? value->name() : QString::null); + getConfig()->endGroup(); +} + +void set(const modules ID, const QString& value) { + CSwordModuleInfo *module(CPointers::backend()->findModuleByName(value)); + if (module) { + set(ID, module); + } +} + +void set(const bools ID, const bool value) { + getConfig()->beginGroup("bools"); + getConfig()->setValue(getKey(ID), value); + getConfig()->endGroup(); +} + +void set(const ints ID, const int value) { + getConfig()->beginGroup("ints"); + getConfig()->setValue(getKey(ID), value); + getConfig()->endGroup(); +} + +void set(const intLists ID, const QList<int> value) { + getConfig()->beginGroup("intlists"); + getConfig()->setValue(getKey(ID), IntListToString(value)); + getConfig()->endGroup(); +} + +void set(const stringLists ID, const QStringList value) { + getConfig()->beginGroup("stringlists"); + getConfig()->setValue(getKey(ID), value); + getConfig()->endGroup(); +} + +void set(const stringMaps ID, const StringMap value) { + typedef StringMap::ConstIterator SMCI; + using namespace sword; + + getConfig()->beginGroup(getKey(ID)); + + // Clear all entries of this group to make sure old stuff gets removed: + getConfig()->remove(""); + + switch (ID) { + case searchScopes: { + /** + We want to make sure that the search scopes are saved with english + key names so loading them will always work with each locale set. + */ + VerseKey vk; + for (SMCI it(value.begin()); it != value.end(); it++) { + QString data; + ListKey list(vk.ParseVerseList(it.value().toUtf8(), "Genesis 1:1", true)); + for (int i(0); i < list.Count(); i++) { + VerseKey *range(dynamic_cast<VerseKey*>(list.GetElement(i))); + if (range) { + range->setLocale("en"); + data.append(QString::fromUtf8( range->getRangeText() )); + data.append(";"); + } + } + getConfig()->setValue(it.key(), data); + } + break; + } + default: { + for (SMCI it(value.begin()); it != value.end(); it++) { + getConfig()->setValue(it.key(), it.value()); + } + break; + } + } + getConfig()->endGroup(); +} + +void set(const CLanguageMgr::Language * const language, + const FontSettingsPair& value) { - CSwordBackend::DisplayOptions options; - options.lineBreaks = get(CBTConfig::lineBreaks); - options.verseNumbers = get(CBTConfig::verseNumbers); + getConfig()->beginGroup("fonts"); + getConfig()->setValue(getKey(language), value.second.toString()); + getConfig()->endGroup(); + getConfig()->beginGroup("font standard settings"); + getConfig()->setValue(getKey(language), value.first); + getConfig()->endGroup(); - return options; + // Remove language from the cache: + m_fontCache.remove(language); } -CSwordBackend::FilterOptions CBTConfig::getFilterOptionDefaults() -{ - CSwordBackend::FilterOptions options; - - options.footnotes = true; //required for the info display - options.strongNumbers = true; //get(CBTConfig::strongNumbers); - options.headings = get(CBTConfig::headings); - options.morphTags = true;//required for the info display - options.lemmas = true;//required for the info display - options.redLetterWords = true; - options.hebrewPoints = get(CBTConfig::hebrewPoints); - options.hebrewCantillation = get(CBTConfig::hebrewCantillation); - options.greekAccents = get(CBTConfig::greekAccents); - options.textualVariants = get(CBTConfig::textualVariants); - options.scriptureReferences = get(CBTConfig::scriptureReferences); - options.morphSegmentation = get(CBTConfig::morphSegmentation); - - return options; -} - -//void CBTConfig::setupAccelSettings(const CBTConfig::keys /*type*/, KActionCollection* const /*actionCollection*/) -//{ -// qDebug("CBTConfig::setupAccelSettings"); -// QString groupName; -// switch (type) { -// case allWindows : { -// groupName = "Displaywindow shortcuts"; -// break; -// }; -// case writeWindow : { -// groupName = "Writewindow shortcuts"; -// break; -// }; -// case readWindow : { -// groupName = "Readwindow shortcuts"; -// break; -// }; -// case bookWindow : { -// groupName = "Book shortcuts"; -// break; -// }; -// case bibleWindow : { -// groupName = "Bible shortcuts"; -// break; -// }; -// case commentaryWindow : { -// groupName = "Commentary shortcuts"; -// break; -// }; -// case lexiconWindow : { -// groupName = "Lexicon shortcuts"; -// break; -// }; -// case application : { -// groupName = "Application shortcuts"; -// break; -// }; -// }; -// qDebug() << groupName; -// Q_ASSERT(CBTConfig::getConfig()); -// //buggy??? -// KConfigGroup* cg = &(CBTConfig::getConfig()->group(groupName)); -// //KConfigGroup* cg; -// -// Q_ASSERT(cg); -// Q_ASSERT(actionCollection); -// //actionCollection->readSettings(cg); -// actionCollection->setConfigGroup(groupName); -// -// actionCollection->readSettings(); -// qDebug("CBTConfig::setupAccelSettings end"); -//} - -//void CBTConfig::saveAccelSettings(const CBTConfig::keys /*type*/, KActionCollection* const /*actionCollection*/) -//{ -// qDebug("CBTConfig::saveAccelSettings"); -// QString groupName; -// switch (type) { -// case allWindows : { -// groupName = "Displaywindow shortcuts"; -// break; -// }; -// case writeWindow : { -// groupName = "Writewindow shortcuts"; -// break; -// }; -// case readWindow : { -// groupName = "Readwindow shortcuts"; -// break; -// }; -// case bookWindow : { -// groupName = "Book shortcuts"; -// break; -// }; -// case bibleWindow : { -// groupName = "Bible shortcuts"; -// break; -// }; -// case commentaryWindow : { -// groupName = "Commentary shortcuts"; -// break; -// }; -// case lexiconWindow : { -// groupName = "Lexicon shortcuts"; -// break; -// }; -// case application : { -// groupName = "Application shortcuts"; -// break; -// }; -// }; -// -// // KConfigGroup* cg = &(CBTConfig::getConfig()->group(groupName)); -// -// qDebug("NOT saving accelerators!"); -// //actionCollection->writeSettings(cg); -// qDebug("CBTConfig::saveAccelSettings end"); -//} - - -QString CBTConfig::getModuleEncryptionKey( const QString& module ) -{ - Q_ASSERT(!module.isEmpty()); - QString result; - getConfig()->beginGroup("Module keys"); - result = getConfig()->value(module, QVariant(QString::null)).toString(); - getConfig()->endGroup(); - return result; +CSwordBackend::DisplayOptions getDisplayOptionDefaults() { + CSwordBackend::DisplayOptions options; + options.lineBreaks = get(lineBreaks); + options.verseNumbers = get(verseNumbers); + return options; } -void CBTConfig::setModuleEncryptionKey( const QString& module, const QString& key ) -{ - getConfig()->beginGroup("Module keys"); - getConfig()->setValue(module, key); - getConfig()->endGroup(); -} +CSwordBackend::FilterOptions getFilterOptionDefaults() { + CSwordBackend::FilterOptions options; -QSettings* CBTConfig::getConfig() -{ - static QSettings config(util::filesystem::DirectoryUtil::getUserBaseDir().absolutePath() + "/bibletimerc", QSettings::IniFormat); - return &config; -} + options.footnotes = true; // Required for the info display + options.strongNumbers = true; // get(strongNumbers); + options.headings = get(headings); + options.morphTags = true; // Required for the info display + options.lemmas = true; // Required for the info display + options.redLetterWords = true; + options.hebrewPoints = get(hebrewPoints); + options.hebrewCantillation = get(hebrewCantillation); + options.greekAccents = get(greekAccents); + options.textualVariants = get(textualVariants); + options.scriptureReferences = get(scriptureReferences); + options.morphSegmentation = get(morphSegmentation); -void CBTConfig::syncConfig() -{ - CBTConfig::getConfig()->sync(); + return options; } -QString CBTConfig::IntListToString( const QList<int> intList ) +void setupAccelSettings(const keys type, + BtActionCollection * const actionCollection) { - QStringList intStrings; - foreach(int i, intList) - { - intStrings << QString::number(i); - } - return intStrings.join(","); -} - -QList<int> CBTConfig::StringToIntList( const QString intListString ) + qDebug("CBTConfig::setupAccelSettings begin"); + QString groupName; + switch (type) { + case allWindows: + groupName = "Displaywindow shortcuts"; + break; + case writeWindow: + groupName = "Writewindow shortcuts"; + break; + case readWindow: + groupName = "Readwindow shortcuts"; + break; + case bookWindow: + groupName = "Book shortcuts"; + break; + case bibleWindow: + groupName = "Bible shortcuts"; + break; + case commentaryWindow: + groupName = "Commentary shortcuts"; + break; + case lexiconWindow: + groupName = "Lexicon shortcuts"; + break; + case application: + groupName = "Application shortcuts"; + break; + } + qDebug() << groupName; + Q_ASSERT(getConfig()); + + actionCollection->setConfigGroup(groupName); + actionCollection->readSettings(); + qDebug("CBTConfig::setupAccelSettings end"); +} + +void saveAccelSettings(const keys type, + BtActionCollection * const actionCollection) { - QList<int> intList; - if (!intListString.isEmpty() && intListString.contains(',')) - { - foreach(QString intString, intListString.split(",")) - { - intList << intString.trimmed().toInt(); - } - } - return intList; -} + qDebug("CBTConfig::saveAccelSettings begin"); + QString groupName; + switch (type) { + case allWindows: + groupName = "Displaywindow shortcuts"; + break; + case writeWindow: + groupName = "Writewindow shortcuts"; + break; + case readWindow: + groupName = "Readwindow shortcuts"; + break; + case bookWindow: + groupName = "Book shortcuts"; + break; + case bibleWindow: + groupName = "Bible shortcuts"; + break; + case commentaryWindow: + groupName = "Commentary shortcuts"; + break; + case lexiconWindow: + groupName = "Lexicon shortcuts"; + break; + case application: + groupName = "Application shortcuts"; + break; + } + + actionCollection->setConfigGroup(groupName); + actionCollection->writeSettings(); + qDebug("CBTConfig::saveAccelSettings end"); +} + + +QString getModuleEncryptionKey(const QString &module) { + Q_ASSERT(!module.isEmpty()); + getConfig()->beginGroup("Module keys"); + QString result(getConfig()->value(module, QVariant(QString::null)).toString()); + getConfig()->endGroup(); + return result; +} + +void setModuleEncryptionKey(const QString &module, const QString &key) { + getConfig()->beginGroup("Module keys"); + getConfig()->setValue(module, key); + getConfig()->endGroup(); +} + +QSettings *getConfig() { + static QSettings config(util::filesystem::DirectoryUtil::getUserBaseDir().absolutePath() + "/bibletimerc", QSettings::IniFormat); + return &config; +} + +void syncConfig() { + getConfig()->sync(); +} + +} // namespace CBTConfig diff --git a/src/backend/config/cbtconfig.h b/src/backend/config/cbtconfig.h index 0ded865..d4d075b 100644 --- a/src/backend/config/cbtconfig.h +++ b/src/backend/config/cbtconfig.h @@ -10,188 +10,182 @@ #ifndef CBTCONFIG_H #define CBTCONFIG_H -#include "backend/managers/cswordbackend.h" - -//Qt includes #include <QString> #include <QFont> #include <QList> #include <QMap> +#include "backend/managers/cswordbackend.h" -//Forward declarations class QSettings; -//class CLanguageMgr::Language; +class BtActionCollection; /** * This class is the interface to the config object of BibleTime * @author The BibleTime team */ -class CBTConfig { -public: - typedef QMap<QString, QString> StringMap; - - enum strings { - bibletimeVersion, - language, - displayStyle, - bookshelfCurrentItem - }; - enum modules { - standardBible = 0, //just to make sure, default is IMHO 0, so that's redundant here - standardCommentary, - standardLexicon, - standardDailyDevotional, - standardHebrewStrongsLexicon, - standardGreekStrongsLexicon, - standardHebrewMorphLexicon, - standardGreekMorphLexicon, - lastModuleType = standardGreekMorphLexicon - }; - enum bools { - firstSearchDialog, - readOldBookmarks, - - toolbar, - mainIndex, - infoDisplay, - - autoTileVertical, - autoTileHorizontal, - autoCascade, - - lineBreaks, - verseNumbers, - - logo, - autoDeleteOrphanedIndices, - crashedLastTime, - crashedTwoTimes, - - bookshelfShowHidden, - - allowNetworkConnection - }; - enum ints { - footnotes, - strongNumbers, - headings, - morphTags, - lemmas, - hebrewPoints, - hebrewCantillation, - greekAccents, - textualVariants, - scriptureReferences, - morphSegmentation, - - bookshelfContentsX, - bookshelfContentsY, - magDelay, /* The delay until a mouse move makes the content appear in the mag */ - bookshelfGrouping, - mainindexActiveTab, - - searchDialogWidth, - searchDialogHeight, - searchDialogX, - searchDialogY, - searchType, - - installPathIndex - }; - enum intLists { - leftPaneSplitterSizes, - mainSplitterSizes, - searchMainSplitterSizes, - searchResultSplitterSizes - }; - enum stringLists { - searchCompletionTexts, - searchTexts, - searchModulesHistory, - bookshelfOpenGroups, - hiddenModules - }; - enum keys { - allWindows, - readWindow, - writeWindow, - bookWindow, - bibleWindow, - commentaryWindow, - lexiconWindow, - application - }; - enum stringMaps { - searchScopes - }; - typedef std::pair<bool, QFont> FontSettingsPair; - - static QString get( const CBTConfig::strings ); - static CSwordModuleInfo* get( const CBTConfig::modules ); - static bool get( const CBTConfig::bools ); - static int get( const CBTConfig::ints ); - static QList<int> get( const CBTConfig::intLists ); - static QStringList get( const CBTConfig::stringLists ); - static CBTConfig::StringMap get( const CBTConfig::stringMaps ); - - static FontSettingsPair get( const CLanguageMgr::Language* const ); - - static QString getDefault( const CBTConfig::strings ); - static QString getDefault( const CBTConfig::modules ); - static bool getDefault( const CBTConfig::bools ); - static int getDefault( const CBTConfig::ints ); - static QList<int> getDefault( const CBTConfig::intLists ); - static QStringList getDefault( const CBTConfig::stringLists ); - static CBTConfig::StringMap getDefault( const CBTConfig::stringMaps ); - static QFont& getDefault( const CLanguageMgr::Language* const ); - - static void set( const CBTConfig::strings, const QString value ); - static void set( const CBTConfig::modules, CSwordModuleInfo* const module ); - static void set( const CBTConfig::modules, const QString& moduleName ); - static void set( const CBTConfig::bools, const bool value ); - static void set( const CBTConfig::ints, const int value ); - static void set( const CBTConfig::intLists, const QList<int> value ); - static void set( const CBTConfig::stringLists, const QStringList value); - static void set( const CBTConfig::stringMaps, const CBTConfig::StringMap value); - static void set( const CLanguageMgr::Language* const language, const FontSettingsPair& fontSettings ); - - static CSwordBackend::FilterOptions getFilterOptionDefaults(); - static CSwordBackend::DisplayOptions getDisplayOptionDefaults(); - -// static void setupAccelSettings(const CBTConfig::keys type, KActionCollection* const actionCollection); -// static void saveAccelSettings(const CBTConfig::keys type, KActionCollection* const actionCollection); - - static QString getModuleEncryptionKey( const QString& name ); - static void setModuleEncryptionKey( const QString& name, const QString& key ); - - /** Re-reads the config from disk */ - static void syncConfig(); - -private: - friend class BibleTimeTest; - /** The config object. - * @return A config object which is used currently, may be the global config or the session config - */ - static QSettings* getConfig(); - - static QString getKey( const CBTConfig::strings ); - static QString getKey( const CBTConfig::modules ); - static QString getKey( const CBTConfig::bools ); - static QString getKey( const CBTConfig::ints ); - static QString getKey( const CBTConfig::intLists ); - static QString getKey( const CBTConfig::stringLists ); - static QString getKey( const CBTConfig::stringMaps ); - static QString getKey( const CLanguageMgr::Language* const ); - - static QString IntListToString( const QList<int> ); - static QList<int> StringToIntList( const QString ); - - //static caches - static QFont* m_defaultFont; - - typedef QMap<const CLanguageMgr::Language*, CBTConfig::FontSettingsPair> FontCache; - static QMap<const CLanguageMgr::Language*, CBTConfig::FontSettingsPair> fontConfigMap; +namespace CBTConfig { + +typedef QMap<QString, QString> StringMap; +typedef std::pair<bool, QFont> FontSettingsPair; + +enum strings { + bibletimeVersion, + language, + displayStyle, + bookshelfCurrentItem +}; +enum modules { + standardBible = 0, // Just to make sure, default is IMHO 0, so that's redundant here + standardCommentary, + standardLexicon, + standardDailyDevotional, + standardHebrewStrongsLexicon, + standardGreekStrongsLexicon, + standardHebrewMorphLexicon, + standardGreekMorphLexicon, + lastModuleType = standardGreekMorphLexicon }; +enum bools { + firstSearchDialog, + readOldBookmarks, + + toolbar, + mainIndex, + infoDisplay, + + autoTileVertical, + autoTileHorizontal, + autoCascade, + + lineBreaks, + verseNumbers, + + logo, + autoDeleteOrphanedIndices, + crashedLastTime, + crashedTwoTimes, + + bookshelfShowHidden, + + allowNetworkConnection +}; +enum ints { + footnotes, + strongNumbers, + headings, + morphTags, + lemmas, + hebrewPoints, + hebrewCantillation, + greekAccents, + textualVariants, + scriptureReferences, + morphSegmentation, + + bookshelfContentsX, + bookshelfContentsY, + magDelay, /* The delay until a mouse move makes the content appear in the mag */ + bookshelfGrouping, + mainindexActiveTab, + + searchDialogWidth, + searchDialogHeight, + searchDialogX, + searchDialogY, + searchType, + + installPathIndex, + + bookshelfPosX, + bookshelfPosY, + bookshelfHeight, + bookshelfWidth, + + configDialogPosX, + configDialogPosY, + configDialogHeight, + configDialogWidth +}; +enum intLists { + leftPaneSplitterSizes, + mainSplitterSizes, + searchMainSplitterSizes, + searchResultSplitterSizes +}; +enum stringLists { + searchCompletionTexts, + searchTexts, + searchModulesHistory, + bookshelfOpenGroups, + hiddenModules +}; +enum keys { + allWindows, + readWindow, + writeWindow, + bookWindow, + bibleWindow, + commentaryWindow, + lexiconWindow, + application +}; +enum stringMaps { + searchScopes +}; + +QString IntListToString(const QList<int> intList); +QList<int> StringToIntList(const QString intListString); + +QString getDefault(const strings); +QString getDefault(const modules); +bool getDefault(const bools); +int getDefault(const ints); +QList<int> getDefault(const intLists); +QStringList getDefault(const stringLists); +StringMap getDefault(const stringMaps); +QFont &getDefault(const CLanguageMgr::Language * const); + +QString get(const strings); +CSwordModuleInfo *get(const modules); +bool get(const bools); +int get(const ints); +QList<int> get(const intLists); +QStringList get(const stringLists); +StringMap get(const stringMaps); +FontSettingsPair get(const CLanguageMgr::Language * const); + +void set(const strings, const QString value); +void set(const modules, CSwordModuleInfo * const module); +void set(const modules, const QString& moduleName); +void set(const bools, const bool value); +void set(const ints, const int value); +void set(const intLists, const QList<int> value); +void set(const stringLists, const QStringList value); +void set(const stringMaps, const StringMap value); +void set(const CLanguageMgr::Language * const language, + const FontSettingsPair &fontSettings); + +CSwordBackend::FilterOptions getFilterOptionDefaults(); +CSwordBackend::DisplayOptions getDisplayOptionDefaults(); + +void setupAccelSettings(const keys type, + BtActionCollection * const actionCollection); +void saveAccelSettings (const keys type, + BtActionCollection * const actionCollection); + +QString getModuleEncryptionKey(const QString &name); +void setModuleEncryptionKey(const QString &name, const QString &key); + +/** + Re-reads the config from disk. +*/ +void syncConfig(); + +/** + Returns the config object. +*/ +QSettings* getConfig(); +} // namespace CBTConfig #endif diff --git a/src/backend/drivers/cswordbiblemoduleinfo.cpp b/src/backend/drivers/cswordbiblemoduleinfo.cpp index adf88b0..a7b89ba 100644 --- a/src/backend/drivers/cswordbiblemoduleinfo.cpp +++ b/src/backend/drivers/cswordbiblemoduleinfo.cpp @@ -174,45 +174,9 @@ unsigned int CSwordBibleModuleInfo::bookNumber(const QString &book) { boost::scoped_ptr<sword::VerseKey> key((sword::VerseKey *)module()->CreateKey()); (*key) = sword::TOP; -#ifdef SWORD_MULTIVERSE key->setBookName(book.toUtf8().constData()); bookNumber = ((key->Testament() > 1) ? key->BMAX[0] : 0) + key->Book(); -#else - bool found = false; - int min = 0; - int max = 1; - - if ((m_hasOT>0 && m_hasNT>0) || (m_hasOT == -1 && m_hasNT == -1)) { - min = 0; - max = 1; - bookNumber = 0; - } - else if (m_hasOT>0 && !m_hasNT) { - min = 0; - max = 0; - bookNumber = 0; - } - else if (!m_hasOT && m_hasNT>0) { - min = 1; - max = 1; - bookNumber = key->BMAX[0]; - } - else if (!m_hasOT && !m_hasNT) { - min = 0; - max = -1; //no loop - bookNumber = 0; - } - - for (int i = min; i <= max && !found; ++i) { - for ( int j = 0; j < key->BMAX[i] && !found; ++j) { - ++bookNumber; - - if (book == QString::fromUtf8( key->books[i][j].name) ) - found = true; - } - } -#endif return bookNumber; } diff --git a/src/backend/filters/bt_osishtml.cpp b/src/backend/filters/bt_osishtml.cpp index bbcf8e5..8ee0b40 100644 --- a/src/backend/filters/bt_osishtml.cpp +++ b/src/backend/filters/bt_osishtml.cpp @@ -114,7 +114,7 @@ bool Filters::BT_OSISHTML::handleToken(sword::SWBuf &buf, const char *token, swo const int countSplit1 = tag.getAttributePartCount("lemma", '|'); const int countSplit2 = tag.getAttributePartCount("lemma", ' '); //TODO: not allowed, remove soon int count = 0; - + if (countSplit1 > countSplit2) { //| split char splitChar = '|'; //TODO: not allowed, remove soon count = countSplit1; @@ -123,7 +123,7 @@ bool Filters::BT_OSISHTML::handleToken(sword::SWBuf &buf, const char *token, swo splitChar = ' '; count = countSplit2; } - + int i = (count > 1) ? 0 : -1; // -1 for whole value cuz it's faster, but does the same thing as 0 attrValue = ""; @@ -155,7 +155,7 @@ bool Filters::BT_OSISHTML::handleToken(sword::SWBuf &buf, const char *token, swo const int countSplit1 = tag.getAttributePartCount("morph", '|'); const int countSplit2 = tag.getAttributePartCount("morph", ' '); //TODO: not allowed, remove soon int count = 0; - + if (countSplit1 > countSplit2) { //| split char splitChar = '|'; count = countSplit1; @@ -260,11 +260,9 @@ bool Filters::BT_OSISHTML::handleToken(sword::SWBuf &buf, const char *token, swo }*/ buf.append("<span class=\"crossreference\">"); -#ifdef SWORD_SIMPLERENDER sword::SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); sword::SWBuf footnoteBody = myUserData->entryAttributes["Footnote"][footnoteNumber]["body"]; buf += myModule->RenderText(footnoteBody); -#endif } /* else if (type == "explanation") { @@ -290,7 +288,7 @@ bool Filters::BT_OSISHTML::handleToken(sword::SWBuf &buf, const char *token, swo buf.append( QString::number(myUserData->swordFootnote++).toUtf8().constData() ); //inefficient const sword::SWBuf n = tag.getAttribute("n"); - + buf.append("\">"); buf.append( (n.length() > 0) ? n.c_str() : "*" ); buf.append("</span> "); @@ -543,7 +541,7 @@ bool Filters::BT_OSISHTML::handleToken(sword::SWBuf &buf, const char *token, swo } //qWarning(QString("handled <seg> token. result: %1").arg(buf.c_str()).latin1()); } - + //divine name, don't use simple tag replacing because it may have attributes else if (!strcmp(tag.getName(), "divineName")) { if (!tag.isEndTag()) { @@ -553,7 +551,7 @@ bool Filters::BT_OSISHTML::handleToken(sword::SWBuf &buf, const char *token, swo buf.append("</span></span>"); } } - + else { //all tokens handled by OSISHTMLHref will run through the filter now return sword::OSISHTMLHREF::handleToken(buf, token, userData); } diff --git a/src/backend/filters/bt_plainhtml.cpp b/src/backend/filters/bt_plainhtml.cpp index 67557cc..4ee98b4 100644 --- a/src/backend/filters/bt_plainhtml.cpp +++ b/src/backend/filters/bt_plainhtml.cpp @@ -50,7 +50,7 @@ char Filters::BT_PLAINHTML::processText(sword::SWBuf& text, const sword::SWKey* continue; } else if (*from == '{') { //footnote start - text += "<FONT COLOR=\"#80000\"><SMALL> ("; + text += "<FONT COLOR=\"#800000\"><SMALL> ("; /// \bug Possible color conflict continue; } else if (*from == '}') //footnote end diff --git a/src/backend/keys/cswordversekey.cpp b/src/backend/keys/cswordversekey.cpp index 424b268..8db5d74 100644 --- a/src/backend/keys/cswordversekey.cpp +++ b/src/backend/keys/cswordversekey.cpp @@ -81,23 +81,7 @@ QString CSwordVerseKey::book( const QString& newBook ) { } if (!newBook.isEmpty()) { - -#ifdef SWORD_MULTIVERSE setBookName(newBook.toUtf8().constData()); -#else - - bool finished = false; - - for (int testament = min; testament <= max && !finished; ++testament) { - for (int book = 0; book < BMAX[testament] && !finished; ++book) { - if ( !strcmp(newBook.toUtf8().constData(), books[testament][book].name ) ) { - Testament(testament+1); - Book(book+1); - finished = true; - } - } - } -#endif } if ( (Testament() >= min+1) && (Testament() <= max+1) && (Book() <= BMAX[min]) ) { diff --git a/src/backend/managers/cswordbackend.cpp b/src/backend/managers/cswordbackend.cpp index 0afe467..f17538a 100644 --- a/src/backend/managers/cswordbackend.cpp +++ b/src/backend/managers/cswordbackend.cpp @@ -494,11 +494,7 @@ void CSwordBackend::reloadModules(SetupChangedReason reason) { delete myconfig; config = myconfig = 0; // we need to call findConfig to make sure that augPaths are reloaded -#ifdef SWORD_SYSCONF_CHANGED findConfig(&configType, &prefixPath, &configPath, &augPaths, &sysConfig); -#else - findConfig(&configType, &prefixPath, &configPath, &augPaths, sysconfig); -#endif // now re-read module configuration files loadConfigDir(configPath); } |