summaryrefslogtreecommitdiff
path: root/src/backend
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend')
-rw-r--r--src/backend/bookshelfmodel/btbookshelfmodel.cpp74
-rw-r--r--src/backend/bookshelfmodel/btbookshelfmodel.h8
-rw-r--r--src/backend/bookshelfmodel/btbookshelftreemodel.cpp205
-rw-r--r--src/backend/bookshelfmodel/btbookshelftreemodel.h24
-rw-r--r--src/backend/bookshelfmodel/btmodulecategoryfilterproxymodel.cpp71
-rw-r--r--src/backend/bookshelfmodel/btmodulecategoryfilterproxymodel.h49
-rw-r--r--src/backend/bookshelfmodel/btmodulehiddenfilterproxymodel.cpp61
-rw-r--r--src/backend/bookshelfmodel/btmodulehiddenfilterproxymodel.h48
-rw-r--r--src/backend/bookshelfmodel/btmodulenamefilterproxymodel.cpp6
-rw-r--r--src/backend/bookshelfmodel/btmodulenamefilterproxymodel.h1
-rw-r--r--src/backend/bookshelfmodel/categoryitem.cpp8
-rw-r--r--src/backend/bookshelfmodel/categoryitem.h3
-rw-r--r--src/backend/bookshelfmodel/distributionitem.cpp1
-rw-r--r--src/backend/bookshelfmodel/distributionitem.h3
-rw-r--r--src/backend/bookshelfmodel/item.cpp9
-rw-r--r--src/backend/bookshelfmodel/item.h9
-rw-r--r--src/backend/bookshelfmodel/languageitem.cpp3
-rw-r--r--src/backend/bookshelfmodel/languageitem.h7
-rw-r--r--src/backend/bookshelfmodel/moduleitem.cpp3
-rw-r--r--src/backend/bookshelfmodel/moduleitem.h9
-rw-r--r--src/backend/btmoduletreeitem.cpp27
-rw-r--r--src/backend/btmoduletreeitem.h3
-rw-r--r--src/backend/config/cbtconfig.cpp25
-rw-r--r--src/backend/cswordmodulesearch.cpp17
-rw-r--r--src/backend/cswordmodulesearch.h16
-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
-rw-r--r--src/backend/filters/bt_gbfhtml.cpp12
-rw-r--r--src/backend/filters/bt_gbfhtml.h8
-rw-r--r--src/backend/filters/bt_osishtml.cpp37
-rw-r--r--src/backend/filters/bt_osishtml.h4
-rw-r--r--src/backend/filters/bt_plainhtml.cpp11
-rw-r--r--src/backend/filters/bt_plainhtml.h5
-rw-r--r--src/backend/filters/bt_teihtml.cpp143
-rw-r--r--src/backend/filters/bt_teihtml.h34
-rw-r--r--src/backend/filters/bt_thmlhtml.cpp46
-rw-r--r--src/backend/filters/bt_thmlhtml.h3
-rw-r--r--src/backend/filters/bt_thmlplain.cpp3
-rw-r--r--src/backend/filters/bt_thmlplain.h2
-rw-r--r--src/backend/filters/osismorphsegmentation.cpp8
-rw-r--r--src/backend/filters/osismorphsegmentation.h2
-rw-r--r--src/backend/keys/cswordkey.cpp25
-rw-r--r--src/backend/keys/cswordkey.h2
-rw-r--r--src/backend/keys/cswordldkey.cpp8
-rw-r--r--src/backend/keys/cswordldkey.h13
-rw-r--r--src/backend/keys/cswordtreekey.cpp6
-rw-r--r--src/backend/keys/cswordtreekey.h6
-rw-r--r--src/backend/keys/cswordversekey.cpp17
-rw-r--r--src/backend/keys/cswordversekey.h9
-rw-r--r--src/backend/managers/btstringmgr.cpp3
-rw-r--r--src/backend/managers/btstringmgr.h6
-rw-r--r--src/backend/managers/cdisplaytemplatemgr.cpp31
-rw-r--r--src/backend/managers/cdisplaytemplatemgr.h9
-rw-r--r--src/backend/managers/clanguagemgr.cpp7
-rw-r--r--src/backend/managers/clanguagemgr.h7
-rw-r--r--src/backend/managers/creferencemanager.h110
-rw-r--r--src/backend/managers/cswordbackend.cpp233
-rw-r--r--src/backend/managers/cswordbackend.h25
-rw-r--r--src/backend/managers/referencemanager.cpp (renamed from src/backend/managers/creferencemanager.cpp)71
-rw-r--r--src/backend/managers/referencemanager.h106
-rw-r--r--src/backend/rendering/cbookdisplay.cpp16
-rw-r--r--src/backend/rendering/cbookdisplay.h8
-rw-r--r--src/backend/rendering/cchapterdisplay.cpp9
-rw-r--r--src/backend/rendering/cchapterdisplay.h3
-rw-r--r--src/backend/rendering/cdisplayrendering.cpp24
-rw-r--r--src/backend/rendering/cdisplayrendering.h3
-rw-r--r--src/backend/rendering/centrydisplay.cpp36
-rw-r--r--src/backend/rendering/centrydisplay.h12
-rw-r--r--src/backend/rendering/chtmlexportrendering.cpp15
-rw-r--r--src/backend/rendering/chtmlexportrendering.h5
-rw-r--r--src/backend/rendering/cplaintextexportrendering.cpp9
-rw-r--r--src/backend/rendering/cplaintextexportrendering.h3
-rw-r--r--src/backend/rendering/ctextrendering.cpp37
-rw-r--r--src/backend/rendering/ctextrendering.h9
82 files changed, 1330 insertions, 803 deletions
diff --git a/src/backend/bookshelfmodel/btbookshelfmodel.cpp b/src/backend/bookshelfmodel/btbookshelfmodel.cpp
index 99f83ba..6882b90 100644
--- a/src/backend/bookshelfmodel/btbookshelfmodel.cpp
+++ b/src/backend/bookshelfmodel/btbookshelfmodel.cpp
@@ -14,7 +14,8 @@
#include <QSet>
#include "util/cresmgr.h"
-#include "util/directoryutil.h"
+#include "util/directory.h"
+
BtBookshelfModel::BtBookshelfModel(QObject *parent)
: QAbstractListModel(parent) {
@@ -29,25 +30,35 @@ int BtBookshelfModel::rowCount(const QModelIndex &parent) const {
return m_data.size();
}
-QVariant BtBookshelfModel::data(const QModelIndex &index, int role) const {
- if (!index.isValid() || index.column() != 0 || index.parent().isValid()) {
- return QVariant();
- }
- int row(index.row());
- if (row >= m_data.size()) return QVariant();
-
+QVariant BtBookshelfModel::data(CSwordModuleInfo *module, int role) const {
switch (role) {
case ModuleNameRole: // Qt::DisplayRole
- return m_data.at(row)->name();
+ return module->name();
case ModuleIconRole: // Qt::DecorationRole
- return moduleIcon(m_data.at(row));
+ return moduleIcon(module);
case ModulePointerRole:
- return qVariantFromValue((void*) m_data.at(row));
+ return qVariantFromValue((void*) module);
+ case ModuleCategoryRole:
+ return QVariant::fromValue(module->category());
+ case ModuleLanguageRole:
+ return QVariant(); /// \todo Unimplemented
+ case ModuleHiddenRole:
+ return module->isHidden();
default:
return QVariant();
}
}
+QVariant BtBookshelfModel::data(const QModelIndex &index, int role) const {
+ if (!index.isValid() || index.column() != 0 || index.parent().isValid()) {
+ return QVariant();
+ }
+ int row(index.row());
+ if (row >= m_data.size()) return QVariant();
+
+ return data(m_data.at(row), role);
+}
+
QVariant BtBookshelfModel::headerData(int section, Qt::Orientation orientation,
int role) const {
if (role == Qt::DisplayRole && orientation == Qt::Horizontal &&
@@ -58,8 +69,25 @@ QVariant BtBookshelfModel::headerData(int section, Qt::Orientation orientation,
return QVariant();
}
+bool BtBookshelfModel::setData(const QModelIndex &index, const QVariant &value,
+ int role) {
+ int row(index.row());
+ if (role == ModuleHiddenRole && row >= 0 && row < m_data.size()
+ && index.column() == 0)
+ {
+ /*
+ Emitting dataChanged here is actually mandatory, but were not doing it
+ directly. Since we're connected to the module, changing its hidden
+ state will emit a signal we catch in moduleHidden(), which in turn is
+ what will actually emit dataChanged().
+ */
+ return m_data.at(row)->setHidden(value.toBool());
+ }
+ return false;
+}
+
QIcon BtBookshelfModel::moduleIcon(const CSwordModuleInfo *m) {
- typedef util::filesystem::DirectoryUtil DU;
+ namespace DU = util::directory;
/// \todo Make CSwordModuleInfo::isLocked() const and remove const_cast:
CSwordModuleInfo *module(const_cast<CSwordModuleInfo*>(m));
@@ -101,7 +129,7 @@ QIcon BtBookshelfModel::moduleIcon(const CSwordModuleInfo *m) {
}
QIcon BtBookshelfModel::categoryIcon(const CSwordModuleInfo::Category &category) {
- typedef util::filesystem::DirectoryUtil DU;
+ namespace DU = util::directory;
switch (category) {
case CSwordModuleInfo::Bibles:
@@ -174,6 +202,8 @@ void BtBookshelfModel::addModule(CSwordModuleInfo * const module) {
const int index(m_data.size());
beginInsertRows(QModelIndex(), index, index);
m_data.append(module);
+ connect(module, SIGNAL(hiddenChanged(bool)),
+ this, SLOT(moduleHidden(bool)));
endInsertRows();
}
@@ -193,13 +223,11 @@ void BtBookshelfModel::addModules(const QSet<CSwordModuleInfo *> &modules) {
beginInsertRows(QModelIndex(), m_data.size(),
m_data.size() + newModules.size() - 1);
-#if QT_VERSION >= 0x040500
- m_data.append(newModules);
-#else
Q_FOREACH(CSwordModuleInfo *module, newModules) {
m_data.append(module);
+ connect(module, SIGNAL(hiddenChanged(bool)),
+ this, SLOT(moduleHidden(bool)));
}
-#endif
endInsertRows();
}
@@ -210,6 +238,8 @@ void BtBookshelfModel::removeModule(CSwordModuleInfo * const module,
if (index == -1) return;
beginRemoveRows(QModelIndex(), index, index);
+ disconnect(module, SIGNAL(hiddenChanged(bool)),
+ this, SLOT(moduleHidden(bool)));
m_data.removeAt(index);
endRemoveRows();
if (destroy) delete module;
@@ -236,3 +266,13 @@ CSwordModuleInfo* BtBookshelfModel::getModule(const QString &name) const {
}
return 0;
}
+
+void BtBookshelfModel::moduleHidden(bool) {
+ Q_ASSERT(qobject_cast<CSwordModuleInfo*>(sender()) != 0);
+
+ CSwordModuleInfo *module(static_cast<CSwordModuleInfo*>(sender()));
+ Q_ASSERT(m_data.count(module) == 1);
+
+ QModelIndex i(index(m_data.indexOf(module), 0));
+ emit dataChanged(i, i);
+}
diff --git a/src/backend/bookshelfmodel/btbookshelfmodel.h b/src/backend/bookshelfmodel/btbookshelfmodel.h
index 01fc260..16fdb13 100644
--- a/src/backend/bookshelfmodel/btbookshelfmodel.h
+++ b/src/backend/bookshelfmodel/btbookshelfmodel.h
@@ -17,6 +17,7 @@
#include "backend/drivers/cswordmoduleinfo.h"
+
class BtBookshelfModel: public QAbstractListModel {
Q_OBJECT
public:
@@ -26,6 +27,7 @@ class BtBookshelfModel: public QAbstractListModel {
ModulePointerRole = Qt::UserRole,
ModuleCategoryRole = Qt::UserRole + 1,
ModuleLanguageRole = Qt::UserRole + 2,
+ ModuleHiddenRole = Qt::UserRole + 3,
UserRole = Qt::UserRole + 100
};
@@ -33,9 +35,12 @@ class BtBookshelfModel: public QAbstractListModel {
virtual ~BtBookshelfModel();
virtual int rowCount(const QModelIndex &parent) const;
+ virtual QVariant data(CSwordModuleInfo *module, int role) const;
virtual QVariant data(const QModelIndex &index, int role) const;
virtual QVariant headerData(int section, Qt::Orientation orientation,
int role = Qt::DisplayRole) const;
+ bool setData(const QModelIndex &index, const QVariant &value,
+ int role = ModuleHiddenRole);
inline CSwordModuleInfo *module(const QModelIndex &index) const {
return (CSwordModuleInfo *)
@@ -64,6 +69,9 @@ class BtBookshelfModel: public QAbstractListModel {
return m_data;
}
+ protected slots:
+ void moduleHidden(bool hidden);
+
protected:
QList<CSwordModuleInfo *> m_data;
};
diff --git a/src/backend/bookshelfmodel/btbookshelftreemodel.cpp b/src/backend/bookshelfmodel/btbookshelftreemodel.cpp
index 8e457e7..5be1aec 100644
--- a/src/backend/bookshelfmodel/btbookshelftreemodel.cpp
+++ b/src/backend/bookshelfmodel/btbookshelftreemodel.cpp
@@ -12,25 +12,26 @@
#include "backend/bookshelfmodel/btbookshelftreemodel.h"
-#include <QQueue>
#include <QSet>
#include "backend/bookshelfmodel/categoryitem.h"
#include "backend/bookshelfmodel/distributionitem.h"
#include "backend/bookshelfmodel/languageitem.h"
#include "backend/bookshelfmodel/moduleitem.h"
+
using namespace BookshelfModel;
BtBookshelfTreeModel::BtBookshelfTreeModel(QObject *parent)
: QAbstractItemModel(parent), m_sourceModel(0), m_rootItem(new RootItem),
- m_checkable(false), m_defaultChecked(false) {
+ m_defaultChecked(MODULE_HIDDEN), m_checkable(false) {
m_groupingOrder.push_back(GROUP_CATEGORY);
m_groupingOrder.push_back(GROUP_LANGUAGE);
}
BtBookshelfTreeModel::BtBookshelfTreeModel(const Grouping &g, QObject *parent)
: QAbstractItemModel(parent), m_sourceModel(0), m_rootItem(new RootItem),
- m_groupingOrder(g), m_checkable(false), m_defaultChecked(false) {
+ m_groupingOrder(g), m_defaultChecked(MODULE_HIDDEN), m_checkable(false)
+{
// Intentionally empty
}
@@ -79,8 +80,6 @@ QModelIndex BtBookshelfTreeModel::parent(const QModelIndex &index) const {
}
QVariant BtBookshelfTreeModel::data(const QModelIndex &index, int role) const {
- typedef util::filesystem::DirectoryUtil DU;
-
if (!index.isValid() || index.column() != 0) {
return QVariant();
}
@@ -89,22 +88,33 @@ QVariant BtBookshelfTreeModel::data(const QModelIndex &index, int role) const {
Q_ASSERT(i != 0);
switch (role) {
case Qt::DisplayRole:
- return i->name();
+ if (i->type() == Item::ITEM_MODULE) {
+ return parentData(static_cast<ModuleItem *>(i), role);
+ } else {
+ return i->name();
+ }
case Qt::CheckStateRole:
if (!m_checkable) break;
case BtBookshelfTreeModel::CheckStateRole:
return i->checkState();
case Qt::DecorationRole:
- return i->icon();
+ if (i->type() == Item::ITEM_MODULE) {
+ return parentData(static_cast<ModuleItem *>(i), role);
+ } else {
+ return i->icon();
+ }
case BtBookshelfModel::ModulePointerRole:
if (i->type() == Item::ITEM_MODULE) {
- ModuleItem *mi(dynamic_cast<ModuleItem *>(i));
- if (mi != 0) {
- return qVariantFromValue((void*) mi->moduleInfo());
- }
+ ModuleItem *mi(static_cast<ModuleItem *>(i));
+ return qVariantFromValue((void*) mi->moduleInfo());
}
return 0;
+ case BtBookshelfModel::ModuleHiddenRole:
+ return i->isHidden();
default:
+ if (i->type() == Item::ITEM_MODULE) {
+ return parentData(static_cast<ModuleItem *>(i), role);
+ }
break;
}
return QVariant();
@@ -115,37 +125,47 @@ bool BtBookshelfTreeModel::setData(const QModelIndex &itemIndex,
int role) {
typedef QPair<Item *, QModelIndex> IP;
- if (role == Qt::CheckStateRole) {
+ Qt::CheckState newState;
+ if (role == BtBookshelfModel::ModuleHiddenRole) {
+ newState = value.toBool() ? Qt::Checked : Qt::Unchecked;
+ } else if (role == Qt::CheckStateRole) {
bool ok;
- Qt::CheckState newState((Qt::CheckState) value.toInt(&ok));
- if (ok && newState != Qt::PartiallyChecked) {
- Item *i(static_cast<Item*>(itemIndex.internalPointer()));
- Q_ASSERT(i != 0);
- // Recursively (un)check all children:
- QList<IP> q;
- q.append(IP(i, itemIndex));
- while (!q.isEmpty()) {
- const IP p(q.takeFirst());
- Item *item(p.first);
- item->setCheckState(newState);
- emit dataChanged(p.second, p.second);
+ newState = (Qt::CheckState) value.toInt(&ok);
+ if (!ok || newState == Qt::PartiallyChecked) return false;
+ } else {
+ return false;
+ }
+
+ Item *item(static_cast<Item*>(itemIndex.internalPointer()));
+ Q_ASSERT(item != 0);
+ if (item->checkState() == newState) return false;
+
+ // Recursively (un)check all children:
+ QList<IP> q;
+ IP p(item, itemIndex);
+ for (;;) {
+ if (item->checkState() != newState) {
+ item->setCheckState(newState);
+ emit dataChanged(p.second, p.second);
+ if (item->type() == Item::ITEM_MODULE) {
+ ModuleItem *mi(static_cast<ModuleItem*>(item));
+ emit moduleChecked(mi->moduleInfo(), newState == Qt::Checked);
+ } else {
const QList<Item*> &children(item->children());
for (int i(0); i < children.size(); i++) {
q.append(IP(children.at(i), index(i, 0, p.second)));
}
}
+ }
+ if (q.empty()) break;
+ p = q.takeFirst();
+ item = p.first;
+ }
- // Change check state of the item itself
- i->setCheckState(newState);
- emit dataChanged(itemIndex, itemIndex);
-
- // Recursively change parent check states.
- resetParentCheckStates(itemIndex.parent());
+ // Recursively change parent check states.
+ resetParentCheckStates(itemIndex.parent());
- return true;
- } // if (ok && newState != Qt::PartiallyChecked)
- } // if (role == Qt::CheckStateRole)
- return false;
+ return true;
}
Qt::ItemFlags BtBookshelfTreeModel::flags(const QModelIndex &index) const {
@@ -176,7 +196,7 @@ QVariant BtBookshelfTreeModel::headerData(int section,
return QVariant();
}
-void BtBookshelfTreeModel::setSourceModel(QAbstractListModel *sourceModel) {
+void BtBookshelfTreeModel::setSourceModel(QAbstractItemModel *sourceModel) {
if (m_sourceModel == sourceModel) return;
if (m_sourceModel != 0) {
@@ -186,6 +206,7 @@ void BtBookshelfTreeModel::setSourceModel(QAbstractListModel *sourceModel) {
beginRemoveRows(QModelIndex(), 0, m_rootItem->children().size() - 1);
delete m_rootItem;
m_modules.clear();
+ m_sourceIndexMap.clear();
m_rootItem = new RootItem;
endRemoveRows();
}
@@ -200,28 +221,25 @@ void BtBookshelfTreeModel::setSourceModel(QAbstractListModel *sourceModel) {
connect(sourceModel, SIGNAL(dataChanged(QModelIndex, QModelIndex)),
this, SLOT(moduleDataChanged(QModelIndex, QModelIndex)));
- BtBookshelfModel *m(dynamic_cast<BtBookshelfModel*>(sourceModel));
- if (m != 0) {
- Q_FOREACH(CSwordModuleInfo *module, m->modules()) {
- addModule(module, m_defaultChecked);
- }
- }
- else {
- for (int i(0); i < sourceModel->rowCount(); i++) {
- CSwordModuleInfo *module(
- static_cast<CSwordModuleInfo *>(
- sourceModel->data(
- sourceModel->index(i),
- BtBookshelfModel::ModulePointerRole
- ).value<void*>()
- )
- );
- Q_ASSERT(module != 0);
- addModule(
- module,
- m_defaultChecked
- );
+ for (int i(0); i < sourceModel->rowCount(); i++) {
+ typedef BtBookshelfModel::ModuleRole MRole;
+ static const MRole HR(BtBookshelfModel::ModuleHiddenRole);
+ static const MRole PR(BtBookshelfModel::ModulePointerRole);
+ QModelIndex moduleIndex(sourceModel->index(i, 0));
+ CSwordModuleInfo *module(
+ static_cast<CSwordModuleInfo *>(
+ sourceModel->data(moduleIndex, PR).value<void*>()
+ )
+ );
+ Q_ASSERT(module != 0);
+ bool checked;
+ if (m_defaultChecked == MODULE_HIDDEN) {
+ checked = !sourceModel->data(moduleIndex, HR).toBool();
+ } else {
+ checked = (m_defaultChecked == CHECKED);
}
+ m_sourceIndexMap[module] = moduleIndex;
+ addModule(module, checked);
}
}
}
@@ -249,7 +267,7 @@ void BtBookshelfTreeModel::setGroupingOrder(const Grouping &groupingOrder) {
CSwordModuleInfo *module(
static_cast<CSwordModuleInfo *>(
m_sourceModel->data(
- m_sourceModel->index(i),
+ m_sourceModel->index(i, 0),
BtBookshelfModel::ModulePointerRole
).value<void*>()
)
@@ -295,6 +313,14 @@ QList<CSwordModuleInfo*> BtBookshelfTreeModel::checkedModules() const {
return modules;
}
+QVariant BtBookshelfTreeModel::parentData(BookshelfModel::ModuleItem *item,
+ int role) const
+{
+ CSwordModuleInfo* m(item->moduleInfo());
+ Q_ASSERT(m_sourceIndexMap.contains(m));
+ return m_sourceModel->data(m_sourceIndexMap.value(m), role);
+}
+
void BtBookshelfTreeModel::addModule(CSwordModuleInfo *module, bool checked) {
if (m_modules.contains(module)) return;
Grouping g(m_groupingOrder);
@@ -345,8 +371,9 @@ void BtBookshelfTreeModel::addModule(CSwordModuleInfo *module,
}
void BtBookshelfTreeModel::removeModule(CSwordModuleInfo *module) {
- Item *i(m_modules.value(module, 0));
- if (i == 0) return;
+ if (!m_modules.contains(module)) return;
+
+ Item *i(m_modules[module]);
// Set i to be the lowest item (including empty groups) to remove:
Q_ASSERT(i->parent() != 0);
@@ -354,22 +381,11 @@ void BtBookshelfTreeModel::removeModule(CSwordModuleInfo *module) {
i = i->parent();
}
Q_ASSERT(i != 0);
-
- // Calculate index of parent item:
- QModelIndex parentIndex;
- {
- QList<int> indexes;
- for (Item *j(i->parent()); j != m_rootItem; j = j->parent()) {
- Q_ASSERT(j != 0);
- indexes.push_back(j->childIndex());
- }
- while (!indexes.isEmpty()) {
- parentIndex = index(indexes.takeLast(), 0, parentIndex);
- }
- }
+ Q_ASSERT(i->parent() != 0);
// Remove item:
int index(i->childIndex());
+ QModelIndex parentIndex(getIndex(i->parent()));
beginRemoveRows(parentIndex, index, index);
i->parent()->deleteChildAt(index);
m_modules.remove(module);
@@ -388,6 +404,24 @@ Item *BtBookshelfTreeModel::getItem(const QModelIndex &index) const {
}
}
+QModelIndex BtBookshelfTreeModel::getIndex(const BookshelfModel::Item *item) {
+ Q_ASSERT(item != 0);
+
+ QList<int> indexes;
+ for (;;) {
+ int i(item->childIndex());
+ if (i < 0) break;
+ indexes.append(i);
+ item = item->parent();
+ }
+
+ QModelIndex i;
+ while (!indexes.isEmpty()) {
+ i = index(indexes.takeLast(), 0, i);
+ }
+ return i;
+}
+
void BtBookshelfTreeModel::resetParentCheckStates(QModelIndex parentIndex) {
for ( ; parentIndex.isValid(); parentIndex = parentIndex.parent()) {
Item *parentItem(static_cast<Item*>(parentIndex.internalPointer()));
@@ -445,11 +479,19 @@ void BtBookshelfTreeModel::moduleDataChanged(const QModelIndex &topLeft,
QModelIndex moduleIndex(m_sourceModel->index(i, 0, topLeft.parent()));
QVariant data(m_sourceModel->data(moduleIndex, PR));
CSwordModuleInfo *module((CSwordModuleInfo *) (data.value<void*>()));
+ QModelIndex itemIndex(getIndex(m_modules[module]));
+ Q_ASSERT(itemIndex.isValid());
- /// \todo There might be a better way to do this.
- bool checked(m_modules.value(module)->checkState() == Qt::Checked);
- removeModule(module);
- addModule(module, checked);
+ emit dataChanged(itemIndex, itemIndex);
+
+ /*
+ Also emit signals for parent items because the change might alter them
+ as well, e.g. isHidden()
+ */
+ do {
+ itemIndex = itemIndex.parent();
+ emit dataChanged(itemIndex, itemIndex);
+ } while (itemIndex.isValid());
}
}
@@ -457,13 +499,21 @@ void BtBookshelfTreeModel::moduleInserted(const QModelIndex &parent, int start,
int end) {
typedef BtBookshelfModel BM;
static const BM::ModuleRole PR(BM::ModulePointerRole);
+ static const BM::ModuleRole HR(BM::ModuleHiddenRole);
for (int i(start); i <= end; i++) {
QModelIndex moduleIndex(m_sourceModel->index(i, 0, parent));
QVariant data(m_sourceModel->data(moduleIndex, PR));
CSwordModuleInfo *module((CSwordModuleInfo *) (data.value<void*>()));
- addModule(module, m_defaultChecked);
+ bool checked;
+ if (m_defaultChecked == MODULE_HIDDEN) {
+ checked = !m_sourceModel->data(moduleIndex, HR).toBool();
+ } else {
+ checked = (m_defaultChecked == CHECKED);
+ }
+ m_sourceIndexMap[module] = moduleIndex;
+ addModule(module, checked);
}
}
@@ -478,6 +528,7 @@ void BtBookshelfTreeModel::moduleRemoved(const QModelIndex &parent, int start,
CSwordModuleInfo *module((CSwordModuleInfo *) (data.value<void*>()));
removeModule(module);
+ m_sourceIndexMap.remove(module);
}
}
diff --git a/src/backend/bookshelfmodel/btbookshelftreemodel.h b/src/backend/bookshelfmodel/btbookshelftreemodel.h
index 84293e1..e73b154 100644
--- a/src/backend/bookshelfmodel/btbookshelftreemodel.h
+++ b/src/backend/bookshelfmodel/btbookshelftreemodel.h
@@ -16,9 +16,11 @@
#include <QAbstractItemModel>
#include <QMap>
+#include <QPersistentModelIndex>
#include "backend/bookshelfmodel/btbookshelfmodel.h"
#include "backend/bookshelfmodel/item.h"
+
namespace BookshelfModel {
class ModuleItem;
}
@@ -30,6 +32,7 @@ class BtBookshelfTreeModel: public QAbstractItemModel {
Q_ENUMS(Group)
typedef QMap<CSwordModuleInfo*, BookshelfModel::ModuleItem*> ModuleItemMap;
+ typedef QMap<CSwordModuleInfo*, QPersistentModelIndex> SourceIndexMap;
public:
enum ModuleRole {
@@ -37,6 +40,7 @@ class BtBookshelfTreeModel: public QAbstractItemModel {
UserRole = BtBookshelfModel::UserRole + 100
};
enum Group { GROUP_CATEGORY = 0, GROUP_LANGUAGE, GROUP_DISTRIBUTION };
+ enum CheckedBehavior { CHECKED, UNCHECKED, MODULE_HIDDEN };
typedef QList<Group> Grouping;
BtBookshelfTreeModel(QObject *parent = 0);
@@ -59,8 +63,8 @@ class BtBookshelfTreeModel: public QAbstractItemModel {
virtual bool setData(const QModelIndex &index, const QVariant &value,
int role);
- void setSourceModel(QAbstractListModel *sourceModel);
- inline QAbstractListModel *sourceModel() const {
+ void setSourceModel(QAbstractItemModel *sourceModel);
+ inline QAbstractItemModel *sourceModel() const {
return m_sourceModel;
}
void setGroupingOrder(const Grouping &groupingOrder);
@@ -71,22 +75,24 @@ class BtBookshelfTreeModel: public QAbstractItemModel {
inline bool checkable() const {
return m_checkable;
}
- inline void setDefaultChecked(bool defaultChecked) {
- m_defaultChecked = defaultChecked;
+ inline void setDefaultChecked(CheckedBehavior b) {
+ m_defaultChecked = b;
}
- inline bool defaultChecked() const {
+ inline CheckedBehavior defaultChecked() const {
return m_defaultChecked;
}
QList<CSwordModuleInfo*> checkedModules() const;
protected:
+ QVariant parentData(BookshelfModel::ModuleItem *item, int role) const;
void addModule(CSwordModuleInfo *module, bool checked);
void addModule(CSwordModuleInfo *module, QModelIndex parentIndex,
Grouping &intermediateGrouping, bool checked);
void removeModule(CSwordModuleInfo *module);
BookshelfModel::Item *getItem(const QModelIndex &index) const;
+ QModelIndex getIndex(const BookshelfModel::Item *item);
void resetParentCheckStates(QModelIndex parentIndex);
template <class T>
@@ -112,13 +118,17 @@ class BtBookshelfTreeModel: public QAbstractItemModel {
void moduleInserted(const QModelIndex &parent, int start, int end);
void moduleRemoved(const QModelIndex &parent, int start, int end);
+ signals:
+ void moduleChecked(CSwordModuleInfo *module, bool checked);
+
protected:
- QAbstractListModel *m_sourceModel;
+ QAbstractItemModel *m_sourceModel;
BookshelfModel::Item *m_rootItem;
ModuleItemMap m_modules;
+ SourceIndexMap m_sourceIndexMap;
Grouping m_groupingOrder;
+ CheckedBehavior m_defaultChecked;
bool m_checkable;
- bool m_defaultChecked;
};
QDataStream &operator<<(QDataStream &os, const BtBookshelfTreeModel::Grouping &o);
diff --git a/src/backend/bookshelfmodel/btmodulecategoryfilterproxymodel.cpp b/src/backend/bookshelfmodel/btmodulecategoryfilterproxymodel.cpp
new file mode 100644
index 0000000..a969218
--- /dev/null
+++ b/src/backend/bookshelfmodel/btmodulecategoryfilterproxymodel.cpp
@@ -0,0 +1,71 @@
+/*********
+*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2009 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License
+* version 2.0.
+*
+**********/
+
+#include "backend/bookshelfmodel/btmodulecategoryfilterproxymodel.h"
+
+#include "backend/bookshelfmodel/btbookshelfmodel.h"
+
+
+typedef CSwordModuleInfo::Categories CS;
+
+BtModuleCategoryFilterProxyModel::BtModuleCategoryFilterProxyModel(
+ QObject *parent)
+ : QSortFilterProxyModel(parent), m_filter(CSwordModuleInfo::AllCategories),
+ m_enabled(true)
+{
+ setFilterRole(BtBookshelfModel::ModuleCategoryRole);
+}
+
+BtModuleCategoryFilterProxyModel::~BtModuleCategoryFilterProxyModel() {
+ // Intentionally empty
+}
+
+void BtModuleCategoryFilterProxyModel::setEnabled(bool enable) {
+ m_enabled = enable;
+ invalidateFilter();
+}
+
+void BtModuleCategoryFilterProxyModel::setShownCategories(CS cs) {
+ if (m_filter == cs) return;
+ m_filter = cs;
+ invalidateFilter();
+}
+
+void BtModuleCategoryFilterProxyModel::setHiddenCategories(CS cs) {
+ cs ^= CSwordModuleInfo::AllCategories;
+ if (m_filter == cs) return;
+ m_filter = cs;
+ invalidateFilter();
+}
+
+bool BtModuleCategoryFilterProxyModel::filterAcceptsRow(int row,
+ const QModelIndex &parent) const
+{
+ typedef CSwordModuleInfo::Category C;
+
+ if (!m_enabled) return true;
+
+ const QAbstractItemModel *m(sourceModel());
+ Q_ASSERT(m != 0);
+
+ QModelIndex itemIndex(m->index(row, filterKeyColumn(), parent));
+ int numChildren(m->rowCount(itemIndex));
+ if (numChildren == 0) {
+ return m_filter.testFlag(m->data(itemIndex, filterRole()).value<C>());
+ }
+ else {
+ for (int i(0); i < numChildren; i++) {
+ if (filterAcceptsRow(i, itemIndex)) return true;
+ }
+ return false;
+ }
+}
diff --git a/src/backend/bookshelfmodel/btmodulecategoryfilterproxymodel.h b/src/backend/bookshelfmodel/btmodulecategoryfilterproxymodel.h
new file mode 100644
index 0000000..7517986
--- /dev/null
+++ b/src/backend/bookshelfmodel/btmodulecategoryfilterproxymodel.h
@@ -0,0 +1,49 @@
+/*********
+*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2009 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License
+* version 2.0.
+*
+**********/
+
+#ifndef BTMODULECATEGORYFILTERPROXYMODEL_H
+#define BTMODULECATEGORYFILTERPROXYMODEL_H
+
+#include <QSortFilterProxyModel>
+
+#include "backend/drivers/cswordmoduleinfo.h"
+
+
+class BtModuleCategoryFilterProxyModel: public QSortFilterProxyModel {
+ Q_OBJECT
+ public:
+ BtModuleCategoryFilterProxyModel(QObject *parent = 0);
+ virtual ~BtModuleCategoryFilterProxyModel();
+
+ inline bool enabled() const {
+ return m_enabled;
+ }
+ void setEnabled(bool enable);
+
+ inline CSwordModuleInfo::Categories shownCategories() const {
+ return m_filter;
+ }
+
+ inline CSwordModuleInfo::Categories hiddenCategories() const {
+ return ~m_filter & CSwordModuleInfo::AllCategories;
+ }
+ void setShownCategories(CSwordModuleInfo::Categories cs);
+ void setHiddenCategories(CSwordModuleInfo::Categories cs);
+
+ virtual bool filterAcceptsRow(int row, const QModelIndex &parent) const;
+
+ protected:
+ CSwordModuleInfo::Categories m_filter;
+ bool m_enabled;
+};
+
+#endif // BTMODULECATEGORYFILTERPROXYMODEL_H
diff --git a/src/backend/bookshelfmodel/btmodulehiddenfilterproxymodel.cpp b/src/backend/bookshelfmodel/btmodulehiddenfilterproxymodel.cpp
new file mode 100644
index 0000000..3a50300
--- /dev/null
+++ b/src/backend/bookshelfmodel/btmodulehiddenfilterproxymodel.cpp
@@ -0,0 +1,61 @@
+/*********
+*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2009 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License
+* version 2.0.
+*
+**********/
+
+#include "backend/bookshelfmodel/btmodulehiddenfilterproxymodel.h"
+
+#include "backend/bookshelfmodel/btbookshelfmodel.h"
+
+
+BtModuleHiddenFilterProxyModel::BtModuleHiddenFilterProxyModel(QObject *parent)
+ : QSortFilterProxyModel(parent), m_enabled(true), m_showHidden(false),
+ m_showShown(true) {
+ setFilterRole(BtBookshelfModel::ModuleHiddenRole);
+}
+
+BtModuleHiddenFilterProxyModel::~BtModuleHiddenFilterProxyModel() {
+ // Intentionally empty
+}
+
+void BtModuleHiddenFilterProxyModel::setEnabled(bool enable) {
+ if (enable == m_enabled) return;
+ m_enabled = enable;
+ invalidateFilter();
+}
+
+void BtModuleHiddenFilterProxyModel::setShowHidden(bool show) {
+ if (m_showHidden == show) return;
+ m_showHidden = show;
+ invalidateFilter();
+}
+
+void BtModuleHiddenFilterProxyModel::setShowShown(bool show) {
+ if (m_showShown == show) return;
+ m_showShown = show;
+ invalidateFilter();
+}
+
+bool BtModuleHiddenFilterProxyModel::filterAcceptsRow(int row,
+ const QModelIndex &parent) const {
+ typedef Qt::CheckState CS;
+
+ if (!m_enabled) return true;
+
+ QAbstractItemModel *m(sourceModel());
+
+ QModelIndex i(m->index(row, filterKeyColumn(), parent));
+ if ((CS) m->data(i, filterRole()).toBool()) {
+ return m_showHidden;
+ }
+ else {
+ return m_showShown;
+ }
+}
diff --git a/src/backend/bookshelfmodel/btmodulehiddenfilterproxymodel.h b/src/backend/bookshelfmodel/btmodulehiddenfilterproxymodel.h
new file mode 100644
index 0000000..8871930
--- /dev/null
+++ b/src/backend/bookshelfmodel/btmodulehiddenfilterproxymodel.h
@@ -0,0 +1,48 @@
+/*********
+*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2009 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License
+* version 2.0.
+*
+**********/
+
+#ifndef BTMODULEHIDDENFILTERPROXYMODEL_H
+#define BTMODULEHIDDENFILTERPROXYMODEL_H
+
+#include <QSortFilterProxyModel>
+
+
+class BtModuleHiddenFilterProxyModel: public QSortFilterProxyModel {
+ Q_OBJECT
+ public:
+ BtModuleHiddenFilterProxyModel(QObject *parent = 0);
+ virtual ~BtModuleHiddenFilterProxyModel();
+
+ inline bool enabled() const {
+ return m_enabled;
+ }
+ void setEnabled(bool enable);
+
+ inline bool showHidden() const {
+ return m_showHidden;
+ }
+ void setShowHidden(bool show);
+
+ inline bool showShown() const {
+ return m_showShown;
+ }
+ void setShowShown(bool show);
+
+ virtual bool filterAcceptsRow(int row, const QModelIndex &parent) const;
+
+ protected:
+ bool m_enabled;
+ bool m_showHidden;
+ bool m_showShown;
+};
+
+#endif // BTMODULEHIDDENFILTERPROXYMODEL_H
diff --git a/src/backend/bookshelfmodel/btmodulenamefilterproxymodel.cpp b/src/backend/bookshelfmodel/btmodulenamefilterproxymodel.cpp
index 31b93e1..1d20cdb 100644
--- a/src/backend/bookshelfmodel/btmodulenamefilterproxymodel.cpp
+++ b/src/backend/bookshelfmodel/btmodulenamefilterproxymodel.cpp
@@ -12,8 +12,12 @@
#include "backend/bookshelfmodel/btmodulenamefilterproxymodel.h"
+#include "backend/bookshelfmodel/btbookshelfmodel.h"
+
+
BtModuleNameFilterProxyModel::BtModuleNameFilterProxyModel(QObject *parent)
: QSortFilterProxyModel(parent), m_enabled(true) {
+ setFilterRole(BtBookshelfModel::ModuleNameRole);
setFilterCaseSensitivity(Qt::CaseInsensitive);
}
@@ -28,7 +32,7 @@ bool BtModuleNameFilterProxyModel::filterAcceptsRow(int row,
const QAbstractItemModel *m(sourceModel());
Q_ASSERT(m != 0);
- QModelIndex itemIndex(m->index(row, 0, p));
+ QModelIndex itemIndex(m->index(row, filterKeyColumn(), p));
int numChildren(m->rowCount(itemIndex));
if (numChildren == 0) {
return QSortFilterProxyModel::filterAcceptsRow(row, p);
diff --git a/src/backend/bookshelfmodel/btmodulenamefilterproxymodel.h b/src/backend/bookshelfmodel/btmodulenamefilterproxymodel.h
index e4499be..9b24dd6 100644
--- a/src/backend/bookshelfmodel/btmodulenamefilterproxymodel.h
+++ b/src/backend/bookshelfmodel/btmodulenamefilterproxymodel.h
@@ -15,6 +15,7 @@
#include <QSortFilterProxyModel>
+
class BtModuleNameFilterProxyModel: public QSortFilterProxyModel {
Q_OBJECT
public:
diff --git a/src/backend/bookshelfmodel/categoryitem.cpp b/src/backend/bookshelfmodel/categoryitem.cpp
index 3ce6e88..1788dfc 100644
--- a/src/backend/bookshelfmodel/categoryitem.cpp
+++ b/src/backend/bookshelfmodel/categoryitem.cpp
@@ -10,7 +10,8 @@
*
**********/
-#include "categoryitem.h"
+#include "backend/bookshelfmodel/categoryitem.h"
+
namespace BookshelfModel {
@@ -23,7 +24,10 @@ bool CategoryItem::operator<(const Item &other) const {
if (other.type() != ITEM_CATEGORY) {
return ITEM_CATEGORY < other.type();
}
- return m_category < static_cast<const CategoryItem &>(other).m_category;
+ const CategoryItem &o(static_cast<const CategoryItem &>(other));
+ if (m_category == CSwordModuleInfo::UnknownCategory) return false;
+ if (o.m_category == CSwordModuleInfo::UnknownCategory) return true;
+ return m_category < o.m_category;
}
} // namespace BookshelfModel
diff --git a/src/backend/bookshelfmodel/categoryitem.h b/src/backend/bookshelfmodel/categoryitem.h
index 40820a2..fcff12b 100644
--- a/src/backend/bookshelfmodel/categoryitem.h
+++ b/src/backend/bookshelfmodel/categoryitem.h
@@ -19,6 +19,7 @@
#include "backend/bookshelfmodel/btbookshelfmodel.h"
#include "backend/drivers/cswordmoduleinfo.h"
+
namespace BookshelfModel {
class CategoryItem: public Item {
@@ -41,7 +42,7 @@ class CategoryItem: public Item {
return BtBookshelfModel::categoryIcon(m_category);
}
- inline bool fitFor(CSwordModuleInfo *module) {
+ inline bool fitFor(CSwordModuleInfo *module) const {
return module->category() == m_category;
}
diff --git a/src/backend/bookshelfmodel/distributionitem.cpp b/src/backend/bookshelfmodel/distributionitem.cpp
index 4ae81c5..fee9c19 100644
--- a/src/backend/bookshelfmodel/distributionitem.cpp
+++ b/src/backend/bookshelfmodel/distributionitem.cpp
@@ -12,6 +12,7 @@
#include "backend/bookshelfmodel/distributionitem.h"
+
namespace BookshelfModel {
DistributionItem::DistributionItem(CSwordModuleInfo *module)
diff --git a/src/backend/bookshelfmodel/distributionitem.h b/src/backend/bookshelfmodel/distributionitem.h
index 44ae591..4ae1197 100644
--- a/src/backend/bookshelfmodel/distributionitem.h
+++ b/src/backend/bookshelfmodel/distributionitem.h
@@ -17,6 +17,7 @@
#include "backend/drivers/cswordmoduleinfo.h"
+
namespace BookshelfModel {
class DistributionItem: public Item {
@@ -33,7 +34,7 @@ class DistributionItem: public Item {
return m_distribution;
}
- inline bool fitFor(CSwordModuleInfo *module) {
+ inline bool fitFor(CSwordModuleInfo *module) const {
return module->config(CSwordModuleInfo::DistributionSource)
== m_distribution;
}
diff --git a/src/backend/bookshelfmodel/item.cpp b/src/backend/bookshelfmodel/item.cpp
index 8556274..ec2dcab 100644
--- a/src/backend/bookshelfmodel/item.cpp
+++ b/src/backend/bookshelfmodel/item.cpp
@@ -16,6 +16,7 @@
#include "backend/bookshelfmodel/distributionitem.h"
#include "backend/bookshelfmodel/languageitem.h"
+
namespace BookshelfModel {
Item::Item(Type type)
@@ -53,4 +54,12 @@ bool Item::operator<(const Item &other) const {
return name().localeAwareCompare(other.name()) < 0;
}
+bool Item::isHidden() const {
+ if (m_children.empty()) return true;
+ Q_FOREACH(Item *child, m_children) {
+ if (!child->isHidden()) return false;
+ }
+ return true;
+}
+
} // namespace BookshelfModel
diff --git a/src/backend/bookshelfmodel/item.h b/src/backend/bookshelfmodel/item.h
index b24b503..665343f 100644
--- a/src/backend/bookshelfmodel/item.h
+++ b/src/backend/bookshelfmodel/item.h
@@ -18,6 +18,7 @@
#include <QString>
#include <QtGlobal>
+
class CSwordModuleInfo;
namespace BookshelfModel {
@@ -71,9 +72,9 @@ class Item {
\brief Returns the index of this item under its parent.
\retval -1 if this item has no parent.
*/
- inline int childIndex() {
+ inline int childIndex() const {
if (m_parent == 0) return -1;
- return m_parent->m_children.indexOf(this);
+ return m_parent->m_children.indexOf(const_cast<Item*>(this));
}
/**
@@ -149,7 +150,7 @@ class Item {
\retval true If this item is a group and can contain the given module.
\retval false This item is not a group or a wrong group.
*/
- inline virtual bool fitFor(CSwordModuleInfo *module) {
+ inline virtual bool fitFor(CSwordModuleInfo *module) const {
Q_UNUSED(module);
return false;
}
@@ -159,6 +160,8 @@ class Item {
*/
virtual bool operator<(const Item &other) const;
+ virtual bool isHidden() const;
+
protected:
inline void setParent(Item *parent) {
Q_ASSERT(parent != 0);
diff --git a/src/backend/bookshelfmodel/languageitem.cpp b/src/backend/bookshelfmodel/languageitem.cpp
index 6758178..8d37891 100644
--- a/src/backend/bookshelfmodel/languageitem.cpp
+++ b/src/backend/bookshelfmodel/languageitem.cpp
@@ -10,7 +10,8 @@
*
**********/
-#include "languageitem.h"
+#include "backend/bookshelfmodel/languageitem.h"
+
namespace BookshelfModel {
diff --git a/src/backend/bookshelfmodel/languageitem.h b/src/backend/bookshelfmodel/languageitem.h
index 262ca65..b5696d9 100644
--- a/src/backend/bookshelfmodel/languageitem.h
+++ b/src/backend/bookshelfmodel/languageitem.h
@@ -17,7 +17,8 @@
#include "backend/bookshelfmodel/btbookshelfmodel.h"
#include "backend/drivers/cswordmoduleinfo.h"
-#include "util/directoryutil.h"
+#include "util/directory.h"
+
namespace BookshelfModel {
@@ -36,10 +37,10 @@ class LanguageItem: public Item {
}
inline QIcon icon() const {
- return util::filesystem::DirectoryUtil::getIcon("flag.svg");
+ return util::directory::getIcon("flag.svg");
}
- inline bool fitFor(CSwordModuleInfo *module) {
+ inline bool fitFor(CSwordModuleInfo *module) const {
return module->language() == m_language;
}
diff --git a/src/backend/bookshelfmodel/moduleitem.cpp b/src/backend/bookshelfmodel/moduleitem.cpp
index 8d02111..95e6f62 100644
--- a/src/backend/bookshelfmodel/moduleitem.cpp
+++ b/src/backend/bookshelfmodel/moduleitem.cpp
@@ -10,10 +10,11 @@
*
**********/
-#include "moduleitem.h"
+#include "backend/bookshelfmodel/moduleitem.h"
#include "util/cresmgr.h"
+
namespace BookshelfModel {
ModuleItem::ModuleItem(CSwordModuleInfo *module)
diff --git a/src/backend/bookshelfmodel/moduleitem.h b/src/backend/bookshelfmodel/moduleitem.h
index 40ecc79..9657423 100644
--- a/src/backend/bookshelfmodel/moduleitem.h
+++ b/src/backend/bookshelfmodel/moduleitem.h
@@ -18,6 +18,7 @@
#include "backend/bookshelfmodel/btbookshelfmodel.h"
#include "backend/drivers/cswordmoduleinfo.h"
+
namespace BookshelfModel {
class ModuleItem: public Item {
@@ -28,12 +29,8 @@ class ModuleItem: public Item {
return m_moduleInfo;
}
- inline QString name() const {
- return m_moduleInfo->name();
- }
-
- inline QIcon icon() const {
- return BtBookshelfModel::moduleIcon(m_moduleInfo);
+ inline bool isHidden() const {
+ return m_moduleInfo->isHidden();
}
protected:
diff --git a/src/backend/btmoduletreeitem.cpp b/src/backend/btmoduletreeitem.cpp
index d11ecbd..01e4446 100644
--- a/src/backend/btmoduletreeitem.cpp
+++ b/src/backend/btmoduletreeitem.cpp
@@ -7,19 +7,16 @@
*
**********/
-#include "btmoduletreeitem.h"
+#include "backend/btmoduletreeitem.h"
+#include <QDebug>
+#include <QList>
+#include <QString>
#include "backend/drivers/cswordmoduleinfo.h"
-#include "util/cpointers.h"
#include "backend/managers/cswordbackend.h"
+#include "util/cpointers.h"
#include "util/cresmgr.h"
-#include "util/ctoolclass.h"
-
-#include <QString>
-#include <QList>
-
-#include <QDebug>
-
+#include "util/tool.h"
//This ctor creates the root item and the tree.
@@ -68,7 +65,7 @@ BTModuleTreeItem::~BTModuleTreeItem() {
}
QList<BTModuleTreeItem*> BTModuleTreeItem::children() const {
- //qDebug("BTModuleTreeItem::children");
+ //qDebug() << "BTModuleTreeItem::children";
QList<BTModuleTreeItem*> childList;
if (m_firstChild) {
BTModuleTreeItem* child = m_firstChild;
@@ -81,7 +78,7 @@ QList<BTModuleTreeItem*> BTModuleTreeItem::children() const {
return childList;
}
-//TODO
+/// \todo
QString BTModuleTreeItem::iconName() const {
if (m_type == Category) {
switch ( m_category) {
@@ -114,10 +111,10 @@ QString BTModuleTreeItem::iconName() const {
}
}
else if (m_type == Module) {
- return CToolClass::getIconNameForModule(m_moduleInfo);
+ return util::tool::getIconNameForModule(m_moduleInfo);
}
else if (m_type == Language) {
- //TODO: don't hardcode here
+ /// \todo don't hardcode here
return "flag.svg";
}
@@ -126,7 +123,7 @@ QString BTModuleTreeItem::iconName() const {
void BTModuleTreeItem::create_tree(QList<BTModuleTreeItem::Filter*>& filters, BTModuleTreeItem::Grouping grouping) {
- qDebug("BTModuleTreeItem::create_tree");
+ qDebug() << "BTModuleTreeItem::create_tree";
static bool map_initialized = false;
static QMap<CSwordModuleInfo::Category, QString> CategoryNamesMap;
if (!map_initialized) {
@@ -218,7 +215,7 @@ BTModuleTreeItem* BTModuleTreeItem::create_parent_item(
}
void BTModuleTreeItem::sort_children(BTModuleTreeItem* parent) {
- //qDebug("BTModuleTreeItem::sort_children");
+ //qDebug() << "BTModuleTreeItem::sort_children";
// sort each child recursively depth-first
foreach(BTModuleTreeItem* item, parent->children()) {
diff --git a/src/backend/btmoduletreeitem.h b/src/backend/btmoduletreeitem.h
index b159c6f..5bcebf8 100644
--- a/src/backend/btmoduletreeitem.h
+++ b/src/backend/btmoduletreeitem.h
@@ -10,9 +10,8 @@
#ifndef BTMODULETREEITEM_H
#define BTMODULETREEITEM_H
-#include "backend/drivers/cswordmoduleinfo.h"
-
#include <QString>
+#include "backend/drivers/cswordmoduleinfo.h"
/**
diff --git a/src/backend/config/cbtconfig.cpp b/src/backend/config/cbtconfig.cpp
index db62863..98a2967 100644
--- a/src/backend/config/cbtconfig.cpp
+++ b/src/backend/config/cbtconfig.cpp
@@ -7,25 +7,23 @@
*
**********/
-#include "cbtconfig.h"
+#include "backend/config/cbtconfig.h"
-// Qt includes
#include <QDebug>
#include <QLocale>
#include <QSettings>
#include <QVariant>
#include <QWebSettings>
-
-// Sword includes
-#include <versekey.h> // For range configuration
-
-// 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"
+#include "util/directory.h"
+
+// Sword includes:
+#include <versekey.h> // For range configuration
+
namespace CBTConfig {
namespace {
@@ -712,7 +710,7 @@ CSwordBackend::FilterOptions getFilterOptionDefaults() {
void setupAccelSettings(const keys type,
BtActionCollection * const actionCollection) {
- qDebug("CBTConfig::setupAccelSettings begin");
+ qDebug() << "CBTConfig::setupAccelSettings begin";
QString groupName;
switch (type) {
case allWindows:
@@ -745,12 +743,12 @@ void setupAccelSettings(const keys type,
actionCollection->setConfigGroup(groupName);
actionCollection->readSettings();
- qDebug("CBTConfig::setupAccelSettings end");
+ qDebug() << "CBTConfig::setupAccelSettings end";
}
void saveAccelSettings(const keys type,
BtActionCollection * const actionCollection) {
- qDebug("CBTConfig::saveAccelSettings begin");
+ qDebug() << "CBTConfig::saveAccelSettings begin";
QString groupName;
switch (type) {
case allWindows:
@@ -781,7 +779,7 @@ void saveAccelSettings(const keys type,
actionCollection->setConfigGroup(groupName);
actionCollection->writeSettings();
- qDebug("CBTConfig::saveAccelSettings end");
+ qDebug() << "CBTConfig::saveAccelSettings end";
}
@@ -800,7 +798,8 @@ void setModuleEncryptionKey(const QString &module, const QString &key) {
}
QSettings *getConfig() {
- static QSettings config(util::filesystem::DirectoryUtil::getUserBaseDir().absolutePath() + "/bibletimerc", QSettings::IniFormat);
+ namespace DU = util::directory;
+ static QSettings config(DU::getUserBaseDir().absolutePath() + "/bibletimerc", QSettings::IniFormat);
return &config;
}
diff --git a/src/backend/cswordmodulesearch.cpp b/src/backend/cswordmodulesearch.cpp
index 220cac9..9348295 100644
--- a/src/backend/cswordmodulesearch.cpp
+++ b/src/backend/cswordmodulesearch.cpp
@@ -7,17 +7,16 @@
*
**********/
-//BibleTime includes
-#include "cswordmodulesearch.h"
+#include "backend/cswordmodulesearch.h"
+#include "backend/config/cbtconfig.h"
#include "backend/drivers/cswordmoduleinfo.h"
#include "backend/managers/cswordbackend.h"
-#include "backend/config/cbtconfig.h"
-//Sword includes
-#include <swmodule.h>
-#include <swkey.h>
+// Sword includes:
#include <listkey.h>
+#include <swkey.h>
+#include <swmodule.h>
CSwordModuleSearch* CSwordModuleSearch::searcher = 0;
@@ -102,12 +101,6 @@ void CSwordModuleSearch::connectFinished( QObject *receiver, const char *member
QObject::connect(this, SIGNAL(finished()), receiver, member);
}
-/** Should be called when the search finished. */
-void CSwordModuleSearch::searchFinished() {
- //m_finishedSig.activate();
- emit finished();
-}
-
bool CSwordModuleSearch::modulesHaveIndices( const QList<CSwordModuleInfo*>& modules ) {
bool hasIndices = true;
QList<CSwordModuleInfo*>::const_iterator end_it = modules.end();
diff --git a/src/backend/cswordmodulesearch.h b/src/backend/cswordmodulesearch.h
index cc0c8c1..d40e9fa 100644
--- a/src/backend/cswordmodulesearch.h
+++ b/src/backend/cswordmodulesearch.h
@@ -7,24 +7,19 @@
*
**********/
-
-
#ifndef CSWORDMODULESEARCH_H
#define CSWORDMODULESEARCH_H
-//BibleTime - backend
-class CSwordModuleInfo;
-
-//BibleTime - utils
-#include "util/cpointers.h"
-
-//Qt includes
#include <QObject>
#include <QString>
+#include "util/cpointers.h"
-//Sword includes
+// Sword includes:
#include <listkey.h>
+
+class CSwordModuleInfo;
+
/**
* CSwordModuleSearch manages the search on Sword modules. It manages the thread(s)
* and manages the different modules.
@@ -72,7 +67,6 @@ class CSwordModuleSearch: public QObject, CPointers {
const sword::ListKey& searchScope() const;
void connectFinished( QObject * receiver, const char * member );
- void searchFinished();
/**
* Returns true if all of the specified modules have indices already built.
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;
}
diff --git a/src/backend/filters/bt_gbfhtml.cpp b/src/backend/filters/bt_gbfhtml.cpp
index 6580bcd..8d6a36a 100644
--- a/src/backend/filters/bt_gbfhtml.cpp
+++ b/src/backend/filters/bt_gbfhtml.cpp
@@ -7,21 +7,17 @@
*
**********/
+#include "backend/filters/bt_gbfhtml.h"
-
-//BibleTime includes
-#include "bt_gbfhtml.h"
-
+#include <QRegExp>
+#include <QString>
#include "backend/drivers/cswordmoduleinfo.h"
#include "backend/managers/cswordbackend.h"
#include "util/cpointers.h"
-//Sword includes
+// Sword includes:
#include <utilxml.h>
-//Qt includes
-#include <QRegExp>
-#include <QString>
Filters::BT_GBFHTML::BT_GBFHTML() : sword::GBFHTML() {
diff --git a/src/backend/filters/bt_gbfhtml.h b/src/backend/filters/bt_gbfhtml.h
index ad23653..45e7e59 100644
--- a/src/backend/filters/bt_gbfhtml.h
+++ b/src/backend/filters/bt_gbfhtml.h
@@ -7,17 +7,13 @@
*
**********/
-
-
-/* $Header: /cvsroot/bibletime/bibletime/bibletime/backend/filters/bt_gbfhtml.h,v 1.24 2006/02/25 11:38:15 joachim Exp $ */
-/* $Revision: 1.24 $ */
-
#ifndef BT_GBFHTML_H
#define BT_GBFHTML_H
-//Sword includes
+// Sword includes:
#include <gbfhtml.h>
+
namespace Filters {
/** GBF to HTML filter,
diff --git a/src/backend/filters/bt_osishtml.cpp b/src/backend/filters/bt_osishtml.cpp
index 9026a94..7525aca 100644
--- a/src/backend/filters/bt_osishtml.cpp
+++ b/src/backend/filters/bt_osishtml.cpp
@@ -7,25 +7,20 @@
*
**********/
-//BibleTime includes
-#include "bt_osishtml.h"
-#include "backend/managers/clanguagemgr.h"
-#include "backend/managers/creferencemanager.h"
-#include "backend/drivers/cswordmoduleinfo.h"
+#include "backend/filters/bt_osishtml.h"
+#include <QString>
#include "backend/config/cbtconfig.h"
+#include "backend/drivers/cswordmoduleinfo.h"
+#include "backend/managers/clanguagemgr.h"
+#include "backend/managers/referencemanager.h"
#include "util/cpointers.h"
-//Sword
-#include <swmodule.h>
+// Sword includes:
#include <swbuf.h>
+#include <swmodule.h>
#include <utilxml.h>
-//Qt
-#include <QString>
-
-//KDE
-
Filters::BT_OSISHTML::BT_OSISHTML() : sword::OSISHTMLHREF() {
setPassThruUnknownEscapeString(true); //the HTML widget will render the HTML escape codes
@@ -39,7 +34,7 @@ Filters::BT_OSISHTML::BT_OSISHTML() : sword::OSISHTMLHREF() {
// addTokenSubstitute("divineName", "<span class=\"name\"><span class=\"divine\">");
// addTokenSubstitute("/divineName", "</span></span>");
- //TODO Move that down to the real tag handling, segs without the type morph would generate incorrect markup, as the end span is always inserted
+ /// \todo Move that down to the real tag handling, segs without the type morph would generate incorrect markup, as the end span is always inserted
// addTokenSubstitute("seg type=\"morph\"", "<span class=\"morphSegmentation\">");
// addTokenSubstitute("/seg", "</span>");
@@ -112,11 +107,11 @@ bool Filters::BT_OSISHTML::handleToken(sword::SWBuf &buf, const char *token, swo
if ((attrib = tag.getAttribute("lemma"))) {
char splitChar = '|';
const int countSplit1 = tag.getAttributePartCount("lemma", '|');
- const int countSplit2 = tag.getAttributePartCount("lemma", ' '); //TODO: not allowed, remove soon
+ 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
+ splitChar = '|'; /// \todo not allowed, remove soon
count = countSplit1;
}
else {
@@ -153,7 +148,7 @@ bool Filters::BT_OSISHTML::handleToken(sword::SWBuf &buf, const char *token, swo
if ((attrib = tag.getAttribute("morph"))) {
char splitChar = '|';
const int countSplit1 = tag.getAttributePartCount("morph", '|');
- const int countSplit2 = tag.getAttributePartCount("morph", ' '); //TODO: not allowed, remove soon
+ const int countSplit2 = tag.getAttributePartCount("morph", ' '); /// \todo not allowed, remove soon
int count = 0;
if (countSplit1 > countSplit2) { //| split char
@@ -574,7 +569,7 @@ void Filters::BT_OSISHTML::renderReference(const char *osisRef, sword::SWBuf &bu
}
if (mod) {
- CReferenceManager::ParseOptions options;
+ ReferenceManager::ParseOptions options;
options.refBase = QString::fromUtf8(myUserData->key->getText());
options.refDestinationModule = QString(mod->name());
options.sourceLanguage = QString(myModule->Lang());
@@ -582,14 +577,14 @@ void Filters::BT_OSISHTML::renderReference(const char *osisRef, sword::SWBuf &bu
buf.append("<a href=\"");
buf.append( //create the hyperlink with key and mod
- CReferenceManager::encodeHyperlink(
+ ReferenceManager::encodeHyperlink(
mod->name(),
- CReferenceManager::parseVerseReference(hrefRef, options),
- CReferenceManager::typeFromModule(mod->type())
+ ReferenceManager::parseVerseReference(hrefRef, options),
+ ReferenceManager::typeFromModule(mod->type())
).toUtf8().constData()
);
buf.append("\" crossrefs=\"");
- buf.append((const char*)CReferenceManager::parseVerseReference(ref, options).toUtf8().constData()); //ref must contain the osisRef module marker if there was any
+ buf.append((const char*)ReferenceManager::parseVerseReference(ref, options).toUtf8().constData()); //ref must contain the osisRef module marker if there was any
buf.append("\">");
}
// should we add something if there were no referenced module available?
diff --git a/src/backend/filters/bt_osishtml.h b/src/backend/filters/bt_osishtml.h
index 04b68ec..83bf0a9 100644
--- a/src/backend/filters/bt_osishtml.h
+++ b/src/backend/filters/bt_osishtml.h
@@ -10,10 +10,10 @@
#ifndef BT_OSISHTML_H
#define BT_OSISHTML_H
-//Sword includes
+// Sword includes:
+#include <osishtmlhref.h>
#include <swbuf.h>
#include <swmodule.h>
-#include <osishtmlhref.h>
namespace Filters {
diff --git a/src/backend/filters/bt_plainhtml.cpp b/src/backend/filters/bt_plainhtml.cpp
index d26d8ed..c70db79 100644
--- a/src/backend/filters/bt_plainhtml.cpp
+++ b/src/backend/filters/bt_plainhtml.cpp
@@ -7,7 +7,8 @@
*
**********/
-#include "bt_plainhtml.h"
+#include "backend/filters/bt_plainhtml.h"
+
Filters::BT_PLAINHTML::BT_PLAINHTML() : sword::SWFilter() {
}
@@ -32,7 +33,7 @@ char Filters::BT_PLAINHTML::processText(sword::SWBuf& text, const sword::SWKey*
continue;
}
else if ((*from == '\n')) { // only one new line
- text += "<BR>";
+ text += "<br/>";
continue;
}
else if (*from == '<') {
@@ -48,15 +49,15 @@ char Filters::BT_PLAINHTML::processText(sword::SWBuf& text, const sword::SWKey*
continue;
}
else if (*from == '{') { //footnote start
- text += "<FONT COLOR=\"#800000\"><SMALL> ("; /// \bug Possible color conflict
+ text += "<font color=\"#800000\"><small> ("; /// \bug Possible color conflict
continue;
}
else if (*from == '}') { //footnote end
- text += ") </SMALL></FONT>";
+ text += ") </small></font>";
continue;
}
else if ((*from == ' ') && (count > 5000)) {
- text += "<WBR>";
+ text += "<wbr/>";
count = 0;
continue;
}
diff --git a/src/backend/filters/bt_plainhtml.h b/src/backend/filters/bt_plainhtml.h
index 0430e51..c228660 100644
--- a/src/backend/filters/bt_plainhtml.h
+++ b/src/backend/filters/bt_plainhtml.h
@@ -10,9 +10,10 @@
#ifndef BT_PLAINHTML_H
#define BT_PLAINHTML_H
-//Sword includes
-#include <swfilter.h>
+// Sword includes:
#include <swbuf.h>
+#include <swfilter.h>
+
class SWKey;
class SWModule;
diff --git a/src/backend/filters/bt_teihtml.cpp b/src/backend/filters/bt_teihtml.cpp
new file mode 100644
index 0000000..340e8af
--- /dev/null
+++ b/src/backend/filters/bt_teihtml.cpp
@@ -0,0 +1,143 @@
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2008 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+#include "backend/filters/bt_teihtml.h"
+
+#include <QString>
+#include "backend/config/cbtconfig.h"
+#include "backend/drivers/cswordmoduleinfo.h"
+#include "backend/managers/clanguagemgr.h"
+#include "backend/managers/referencemanager.h"
+#include "util/cpointers.h"
+
+// Sword includes:
+#include <swbuf.h>
+#include <swmodule.h>
+#include <utilxml.h>
+
+
+
+Filters::BT_TEIHTML::BT_TEIHTML() : sword::TEIHTMLHREF() {
+ setPassThruUnknownEscapeString(true); //the HTML widget will render the HTML escape codes
+}
+
+bool Filters::BT_TEIHTML::handleToken(sword::SWBuf &buf, const char *token, sword::BasicFilterUserData *userData) {
+ // manually process if it wasn't a simple substitution
+
+ if (!substituteToken(buf, token)) {
+
+ sword::XMLTag tag(token);
+
+ if (0) {
+
+ }
+ else if (!strcmp(tag.getName(), "ref")) {
+
+ if (!tag.isEndTag() && !tag.isEmpty()) {
+
+ renderReference(tag.getAttribute("osisRef"), buf, userData);
+
+ }
+ else if (tag.isEndTag()) {
+ buf.append("</a>");
+ }
+ else { // empty reference marker
+ // -- what should we do? nothing for now.
+ }
+ }
+ // <hi> highlighted text
+ else if (!strcmp(tag.getName(), "hi")) {
+ const sword::SWBuf type = tag.getAttribute("rend");
+
+ if ((!tag.isEndTag()) && (!tag.isEmpty())) {
+ if (type == "bold") {
+ buf.append("<span class=\"bold\">");
+ }
+ else if (type == "illuminated") {
+ buf.append("<span class=\"illuminated\">");
+ }
+ else if (type == "italic") {
+ buf.append("<span class=\"italic\">");
+ }
+ else if (type == "line-through") {
+ buf.append("<span class=\"line-through\">");
+ }
+ else if (type == "normal") {
+ buf.append("<span class=\"normal\">");
+ }
+ else if (type == "small-caps") {
+ buf.append("<span class=\"small-caps\">");
+ }
+ else if (type == "underline") {
+ buf.append("<span class=\"underline\">");
+ }
+ else {
+ buf.append("<span>"); //don't break markup, </span> is inserted later
+ }
+ }
+ else if (tag.isEndTag()) { //all hi replacements are html spans
+ buf.append("</span>");
+ }
+ }
+ else { //all tokens handled by OSISHTMLHref will run through the filter now
+ return sword::TEIHTMLHREF::handleToken(buf, token, userData);
+ }
+ }
+
+ return false;
+}
+
+void Filters::BT_TEIHTML::renderReference(const char *osisRef, sword::SWBuf &buf, sword::BasicFilterUserData *myUserData) {
+ QString ref( osisRef );
+ QString hrefRef( ref );
+
+ if (!ref.isEmpty()) {
+ //find out the mod, using the current module makes sense if it's a bible or commentary because the refs link into a bible by default.
+ //If the osisRef is something like "ModuleID:key comes here" then the
+ // modulename is given, so we'll use that one
+
+ CSwordModuleInfo* mod = CBTConfig::get( CBTConfig::standardBible );
+
+ // Q_ASSERT(mod); There's no necessarily a module or standard Bible
+
+ //if the osisRef like "GerLut:key" contains a module, use that
+ int pos = ref.indexOf(":");
+
+ if ((pos >= 0) && ref.at(pos - 1).isLetter() && ref.at(pos + 1).isLetter()) {
+ QString newModuleName = ref.left(pos);
+ hrefRef = ref.mid(pos + 1);
+
+ if (CPointers::backend()->findModuleByName(newModuleName)) {
+ mod = CPointers::backend()->findModuleByName(newModuleName);
+ }
+ }
+
+ if (mod) {
+ ReferenceManager::ParseOptions options;
+ options.refBase = QString::fromUtf8(myUserData->key->getText());
+ options.refDestinationModule = QString(mod->name());
+ options.sourceLanguage = QString(mod->module()->Lang());
+ options.destinationLanguage = QString("en");
+
+ buf.append("<a href=\"");
+ buf.append( //create the hyperlink with key and mod
+ ReferenceManager::encodeHyperlink(
+ mod->name(),
+ ReferenceManager::parseVerseReference(hrefRef, options),
+ ReferenceManager::typeFromModule(mod->type())
+ ).toUtf8().constData()
+ );
+ buf.append("\" crossrefs=\"");
+ buf.append((const char*)ReferenceManager::parseVerseReference(ref, options).toUtf8().constData()); //ref must contain the osisRef module marker if there was any
+ buf.append("\">");
+ }
+ // should we add something if there were no referenced module available?
+ }
+}
+
diff --git a/src/backend/filters/bt_teihtml.h b/src/backend/filters/bt_teihtml.h
new file mode 100644
index 0000000..2160349
--- /dev/null
+++ b/src/backend/filters/bt_teihtml.h
@@ -0,0 +1,34 @@
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2008 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+#ifndef BT_TEIHTML_H
+#define BT_TEIHTML_H
+
+// Sword includes:
+#include <teihtmlhref.h>
+#include <swbuf.h>
+
+namespace Filters {
+
+/** BibleTime's TEI to HTMl filter.
+* This filter works on TEI tags and outputs HTML in the structure supported by BibleTime.
+*/
+
+class BT_TEIHTML : public sword::TEIHTMLHREF {
+
+ public:
+ BT_TEIHTML();
+ virtual bool handleToken(sword::SWBuf &buf, const char *token, sword::BasicFilterUserData *userData);
+ private:
+ void renderReference(const char *osisRef, sword::SWBuf &buf, sword::BasicFilterUserData *myUserData);
+};
+
+} //end of Filters namespace
+
+#endif
diff --git a/src/backend/filters/bt_thmlhtml.cpp b/src/backend/filters/bt_thmlhtml.cpp
index 4ee333d..478339c 100644
--- a/src/backend/filters/bt_thmlhtml.cpp
+++ b/src/backend/filters/bt_thmlhtml.cpp
@@ -7,25 +7,24 @@
*
**********/
-//BibleTime includes
-#include "bt_thmlhtml.h"
-#include "backend/managers/clanguagemgr.h"
-#include "backend/drivers/cswordmoduleinfo.h"
-#include "backend/managers/creferencemanager.h"
+#include "backend/filters/bt_thmlhtml.h"
+#include <QString>
+#include <QRegExp>
+#include <QUrl>
+#include <QTextCodec>
#include "backend/config/cbtconfig.h"
+#include "backend/drivers/cswordmoduleinfo.h"
+#include "backend/managers/clanguagemgr.h"
+#include "backend/managers/referencemanager.h"
#include "util/cpointers.h"
-#include <boost/scoped_ptr.hpp>
-//Sword includes
+// Sword includes:
#include <swmodule.h>
+#include <utilstr.h>
#include <utilxml.h>
#include <versekey.h>
-#include <utilstr.h>
-//Qt includes
-#include <QString>
-#include <QRegExp>
Filters::BT_ThMLHTML::BT_ThMLHTML() {
setEscapeStringCaseSensitive(true);
@@ -258,7 +257,7 @@ bool Filters::BT_ThMLHTML::handleToken(sword::SWBuf &buf, const char *token, swo
CSwordModuleInfo* mod = CBTConfig::get(CBTConfig::standardBible);
//Q_ASSERT(mod); tested later
if (mod) {
- CReferenceManager::ParseOptions options;
+ ReferenceManager::ParseOptions options;
options.refBase = QString::fromUtf8(myUserData->key->getText()); //current module key
options.refDestinationModule = QString(mod->name());
options.sourceLanguage = QString(myModule->Lang());
@@ -274,7 +273,7 @@ bool Filters::BT_ThMLHTML::handleToken(sword::SWBuf &buf, const char *token, swo
if (! oldRef.isEmpty() ) {
options.refBase = oldRef; //use the last ref as a base, e.g. Rom 1,2-3, when the next ref is only 3:3-10
}
- const QString completeRef( CReferenceManager::parseVerseReference((*it), options) );
+ const QString completeRef( ReferenceManager::parseVerseReference((*it), options) );
oldRef = completeRef; //use the parsed result as the base for the next ref.
@@ -284,10 +283,10 @@ bool Filters::BT_ThMLHTML::handleToken(sword::SWBuf &buf, const char *token, swo
buf.append("<a href=\"");
buf.append(
- CReferenceManager::encodeHyperlink(
+ ReferenceManager::encodeHyperlink(
mod->name(),
completeRef,
- CReferenceManager::typeFromModule(mod->type())
+ ReferenceManager::typeFromModule(mod->type())
).toUtf8().constData()
);
@@ -317,23 +316,23 @@ bool Filters::BT_ThMLHTML::handleToken(sword::SWBuf &buf, const char *token, swo
CSwordModuleInfo* mod = CBTConfig::get(CBTConfig::standardBible);
//Q_ASSERT(mod); tested later
- CReferenceManager::ParseOptions options;
+ ReferenceManager::ParseOptions options;
options.refBase = QString::fromUtf8(myUserData->key->getText());
options.sourceLanguage = myModule->Lang();
options.destinationLanguage = QString("en");
- const QString completeRef = CReferenceManager::parseVerseReference(QString::fromUtf8(ref), options);
+ const QString completeRef = ReferenceManager::parseVerseReference(QString::fromUtf8(ref), options);
if (mod) {
options.refDestinationModule = QString(mod->name());
buf.append("<span class=\"crossreference\">");
buf.append("<a href=\"");
buf.append(
- CReferenceManager::encodeHyperlink(
+ ReferenceManager::encodeHyperlink(
mod->name(),
completeRef,
- CReferenceManager::typeFromModule(mod->type())
+ ReferenceManager::typeFromModule(mod->type())
).toUtf8().constData()
);
buf.append("\" crossrefs=\"");
@@ -370,10 +369,11 @@ bool Filters::BT_ThMLHTML::handleToken(sword::SWBuf &buf, const char *token, swo
value++; //strip the first /
}
- buf.append("<img src=\"file:");
- buf.append(myUserData->module->getConfigEntry("AbsoluteDataPath"));
- buf.append('/');
- buf.append(value);
+ buf.append("<img src=\"");
+ QString absPath(QTextCodec::codecForLocale()->toUnicode(myUserData->module->getConfigEntry("AbsoluteDataPath")));
+ QString relPath(QString::fromUtf8(value));
+ QString url(QUrl::fromLocalFile(absPath.append('/').append(relPath)).toString());
+ buf.append(url.toUtf8().data());
buf.append("\" />");
}
else { // let unknown token pass thru
diff --git a/src/backend/filters/bt_thmlhtml.h b/src/backend/filters/bt_thmlhtml.h
index 25b168c..6a220b6 100644
--- a/src/backend/filters/bt_thmlhtml.h
+++ b/src/backend/filters/bt_thmlhtml.h
@@ -10,10 +10,11 @@
#ifndef BT_THMLHTML_H
#define BT_THMLHTML_H
-//Sword
+// Sword includes:
#include <swbuf.h>
#include <thmlhtml.h>
+
namespace Filters {
/** ThML to HTML filter.
diff --git a/src/backend/filters/bt_thmlplain.cpp b/src/backend/filters/bt_thmlplain.cpp
index 2cd3cf9..ecd7bbd 100644
--- a/src/backend/filters/bt_thmlplain.cpp
+++ b/src/backend/filters/bt_thmlplain.cpp
@@ -13,7 +13,8 @@
* ASCII rendered symbols.
*/
-#include "bt_thmlplain.h"
+#include "backend/filters/bt_thmlplain.h"
+
Filters::BT_ThMLPlain::BT_ThMLPlain() {
}
diff --git a/src/backend/filters/bt_thmlplain.h b/src/backend/filters/bt_thmlplain.h
index 7ef82d6..92c2c33 100644
--- a/src/backend/filters/bt_thmlplain.h
+++ b/src/backend/filters/bt_thmlplain.h
@@ -10,9 +10,11 @@
#ifndef BT_THMLPLAIN_H
#define BT_THMLPLAIN_H
+// Sword includes:
#include <swbuf.h>
#include <swfilter.h>
+
namespace Filters {
/** This filter converts ThML text to plain text
diff --git a/src/backend/filters/osismorphsegmentation.cpp b/src/backend/filters/osismorphsegmentation.cpp
index 26e7470..512fe2e 100644
--- a/src/backend/filters/osismorphsegmentation.cpp
+++ b/src/backend/filters/osismorphsegmentation.cpp
@@ -6,11 +6,13 @@
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
-#include "osismorphsegmentation.h"
-//Sword
+#include "backend/filters/osismorphsegmentation.h"
+
+// Sword includes:
#include <utilxml.h>
+
const char Filters::OSISMorphSegmentation::oName[] = "Morph segmentation";
const char Filters::OSISMorphSegmentation::oTip[] = "Toggles morph segmentation On and Off if they exist";
@@ -24,7 +26,7 @@ Filters::OSISMorphSegmentation::OSISMorphSegmentation() : sword::SWOptionFilter(
Filters::OSISMorphSegmentation::~OSISMorphSegmentation() {}
-char Filters::OSISMorphSegmentation::processText(sword::SWBuf &text, const sword::SWKey */*key*/, const sword::SWModule */*module*/) {
+char Filters::OSISMorphSegmentation::processText(sword::SWBuf &text, const sword::SWKey * /*key*/, const sword::SWModule * /*module*/) {
sword::SWBuf token;
bool intoken = false;
bool hide = false;
diff --git a/src/backend/filters/osismorphsegmentation.h b/src/backend/filters/osismorphsegmentation.h
index bc405f5..c5bbb18 100644
--- a/src/backend/filters/osismorphsegmentation.h
+++ b/src/backend/filters/osismorphsegmentation.h
@@ -10,9 +10,11 @@
#ifndef OSISMORPHSEGMENTATION_H
#define OSISMORPHSEGMENTATION_H
+// Sword includes:
#include <swbuf.h>
#include <swoptfilter.h>
+
namespace Filters {
/** This Filter shows/hides headings in a OSIS text.
diff --git a/src/backend/keys/cswordkey.cpp b/src/backend/keys/cswordkey.cpp
index 546c55e..24f4909 100644
--- a/src/backend/keys/cswordkey.cpp
+++ b/src/backend/keys/cswordkey.cpp
@@ -7,27 +7,24 @@
*
**********/
-#include "cswordkey.h"
+#include "backend/keys/cswordkey.h"
+#include <QRegExp>
+#include <QString>
+#include <QTextCodec>
#include "backend/drivers/cswordmoduleinfo.h"
-#include "cswordversekey.h"
-#include "cswordldkey.h"
-#include "cswordtreekey.h"
+#include "backend/keys/cswordldkey.h"
+#include "backend/keys/cswordtreekey.h"
+#include "backend/keys/cswordversekey.h"
-#include "util/ctoolclass.h"
-
-//Sword
-#include <swmodule.h>
+// Sword includes:
#include <swkey.h>
-#include <versekey.h>
+#include <swmodule.h>
#include <treekey.h>
#include <treekeyidx.h>
#include <utilstr.h>
+#include <versekey.h>
-//Qt
-#include <QRegExp>
-#include <QString>
-#include <QTextCodec>
CSwordKey::CSwordKey(CSwordModuleInfo* const module) : m_module(module) {}
@@ -77,7 +74,7 @@ QString CSwordKey::renderedText( const CSwordKey::TextRenderType mode ) {
//Q_ASSERT(!key().isNull());
if (!key().isNull()) { //we have valid text
- bool DoRender = (mode == ProcessEntryAttributesOnly) ? 0 : 1;
+ bool DoRender = (mode == ProcessEntryAttributesOnly) ? 0 : 1;
QString text = QString::fromUtf8( m_module->module()->RenderText(0, -1, DoRender) );
if (!DoRender) return QString::null;
diff --git a/src/backend/keys/cswordkey.h b/src/backend/keys/cswordkey.h
index af0075a..d1924d6 100644
--- a/src/backend/keys/cswordkey.h
+++ b/src/backend/keys/cswordkey.h
@@ -10,9 +10,9 @@
#ifndef CSWORDKEY_H
#define CSWORDKEY_H
-//Qt
#include <QString>
+
class CSwordModuleInfo;
class QTextCodec;
diff --git a/src/backend/keys/cswordldkey.cpp b/src/backend/keys/cswordldkey.cpp
index 4aa95cb..bc1e2c1 100644
--- a/src/backend/keys/cswordldkey.cpp
+++ b/src/backend/keys/cswordldkey.cpp
@@ -7,16 +7,16 @@
*
**********/
-#include "cswordldkey.h"
+#include "backend/keys/cswordldkey.h"
+
+#include <QTextCodec>
#include "backend/drivers/cswordlexiconmoduleinfo.h"
-//Sword includes
+// Sword includes:
#include <swmodule.h>
#include <swld.h>
#include <utilstr.h>
-//Qt includes
-#include <QTextCodec>
CSwordLDKey::CSwordLDKey( CSwordModuleInfo* module ) {
if ((m_module = dynamic_cast<CSwordLexiconModuleInfo*>(module))) {
diff --git a/src/backend/keys/cswordldkey.h b/src/backend/keys/cswordldkey.h
index 1cb3382..2e460d7 100644
--- a/src/backend/keys/cswordldkey.h
+++ b/src/backend/keys/cswordldkey.h
@@ -10,23 +10,24 @@
#ifndef CSWORDLDKEY_H
#define CSWORDLDKEY_H
-#include "cswordkey.h"
-class CSwordModuleInfo;
+#include "backend/keys/cswordkey.h"
-//Qt
#include <QString>
-//Sword includes
+// Sword includes:
#include <swkey.h>
+
+class CSwordModuleInfo;
+
/**
* This class is the implementation of CSwordKey used for dictionaries and lexicons.
*
* CSwordLDKey is the implementation of CKey for Lexicons and dictionaries.
* It provides a simple interface to set the current key,
* to get the text for the key and functions to get the next and previous items
- * of the used module in comparision to the current key.<BR>
- * Here's an example how to use this class:<BR>
+ * of the used module in comparision to the current key.<br/>
+ * Here's an example how to use this class:<br/>
* @code
* CSwordLexiconModuleInfo* m_module = backend()->findModuleByName("ISBE");
* CSwordLDKey ldKey(m_module);
diff --git a/src/backend/keys/cswordtreekey.cpp b/src/backend/keys/cswordtreekey.cpp
index e845bf6..e1ac9c3 100644
--- a/src/backend/keys/cswordtreekey.cpp
+++ b/src/backend/keys/cswordtreekey.cpp
@@ -7,12 +7,12 @@
*
**********/
-#include "cswordtreekey.h"
-#include "backend/drivers/cswordbookmoduleinfo.h"
+#include "backend/keys/cswordtreekey.h"
+#include <QDebug>
#include <QTextCodec>
+#include "backend/drivers/cswordbookmoduleinfo.h"
-#include <QDebug>
CSwordTreeKey::CSwordTreeKey( const CSwordTreeKey& k ) : CSwordKey(k), TreeKeyIdx(k) {}
diff --git a/src/backend/keys/cswordtreekey.h b/src/backend/keys/cswordtreekey.h
index c0c9e45..9a60d5b 100644
--- a/src/backend/keys/cswordtreekey.h
+++ b/src/backend/keys/cswordtreekey.h
@@ -10,12 +10,12 @@
#ifndef CSWORDTREEKEYIDX_H
#define CSWORDTREEKEYIDX_H
-//BibleTime
-#include "cswordkey.h"
+#include "backend/keys/cswordkey.h"
-//Sword
+// Sword includes:
#include <treekeyidx.h>
+
class CSwordModuleInfo;
/** BibleTime's implementation of Sword's TreeKeyIdx class.
diff --git a/src/backend/keys/cswordversekey.cpp b/src/backend/keys/cswordversekey.cpp
index 01cfd31..84c0b29 100644
--- a/src/backend/keys/cswordversekey.cpp
+++ b/src/backend/keys/cswordversekey.cpp
@@ -7,17 +7,19 @@
*
**********/
-#include "cswordversekey.h"
-#include "backend/drivers/cswordbiblemoduleinfo.h"
-#include "backend/drivers/cswordcommentarymoduleinfo.h"
+#include "backend/keys/cswordversekey.h"
-//Qt
#include <QStringList>
+#include <QDebug>
-//Sword
+#include "backend/drivers/cswordbiblemoduleinfo.h"
+#include "backend/drivers/cswordcommentarymoduleinfo.h"
+
+// Sword includes:
#include <swmodule.h>
#include <localemgr.h>
+
CSwordVerseKey::CSwordVerseKey( CSwordModuleInfo* const module ) :
CSwordKey(module) {
if ( CSwordBibleModuleInfo* bible = dynamic_cast<CSwordBibleModuleInfo*>(module) ) {
@@ -26,9 +28,12 @@ CSwordVerseKey::CSwordVerseKey( CSwordModuleInfo* const module ) :
key( bible->lowerBound().key() );
}
+ this->VerseKey::setAutoNormalize(true);
}
-CSwordVerseKey::CSwordVerseKey( const CSwordVerseKey& k ) : CSwordKey(k), VerseKey(k) {}
+CSwordVerseKey::CSwordVerseKey( const CSwordVerseKey& k ) : CSwordKey(k), VerseKey(k) {
+ this->VerseKey::setAutoNormalize(true);
+}
CSwordVerseKey::CSwordVerseKey( const VerseKey* const k, CSwordModuleInfo* const module ) : CSwordKey(module), VerseKey(*k) {}
diff --git a/src/backend/keys/cswordversekey.h b/src/backend/keys/cswordversekey.h
index 0f286dc..bfbfa25 100644
--- a/src/backend/keys/cswordversekey.h
+++ b/src/backend/keys/cswordversekey.h
@@ -10,15 +10,16 @@
#ifndef CSWORDVERSEKEY_H
#define CSWORDVERSEKEY_H
-#include "cswordkey.h"
-class CSwordModuleInfo;
+#include "backend/keys/cswordkey.h"
-//Qt
#include <QString>
-//Sword
+// Sword includes:
#include <versekey.h>
+
+class CSwordModuleInfo;
+
/**
* The CSwordKey implementation for verse based modules (Bibles and Commentaries)
*
diff --git a/src/backend/managers/btstringmgr.cpp b/src/backend/managers/btstringmgr.cpp
index a4fe381..a2abc7f 100644
--- a/src/backend/managers/btstringmgr.cpp
+++ b/src/backend/managers/btstringmgr.cpp
@@ -7,7 +7,8 @@
*
**********/
-#include "btstringmgr.h"
+#include "backend/managers/btstringmgr.h"
+
char* BTStringMgr::upperUTF8(char* text, unsigned int maxlen) const {
const int max = (maxlen > 0) ? maxlen : strlen(text);
diff --git a/src/backend/managers/btstringmgr.h b/src/backend/managers/btstringmgr.h
index 73b784d..7f44df8 100644
--- a/src/backend/managers/btstringmgr.h
+++ b/src/backend/managers/btstringmgr.h
@@ -10,11 +10,11 @@
#ifndef BTSTRINGMGR_H
#define BTSTRINGMGR_H
-//Sword includes
+#include <QString>
+
+// Sword includes:
#include <stringmgr.h>
-//Qt includes
-#include <QString>
/** Unicode string manager implementation.
* This is the StringManager implementation which works with QString.
diff --git a/src/backend/managers/cdisplaytemplatemgr.cpp b/src/backend/managers/cdisplaytemplatemgr.cpp
index 4722734..11d2a59 100644
--- a/src/backend/managers/cdisplaytemplatemgr.cpp
+++ b/src/backend/managers/cdisplaytemplatemgr.cpp
@@ -7,20 +7,19 @@
*
**********/
-#include "cdisplaytemplatemgr.h"
+#include "backend/managers/cdisplaytemplatemgr.h"
+#include <QDebug>
+#include <QFile>
+#include <QFileInfo>
+#include <QStringList>
+#include <QTextStream>
+#include "backend/config/cbtconfig.h"
#include "backend/drivers/cswordmoduleinfo.h"
#include "backend/managers/clanguagemgr.h"
-#include "backend/config/cbtconfig.h"
#include "util/cpointers.h"
-#include "util/directoryutil.h"
+#include "util/directory.h"
-//Qt
-#include <QStringList>
-#include <QFile>
-#include <QFileInfo>
-#include <QTextStream>
-#include <QDebug>
CDisplayTemplateMgr::CDisplayTemplateMgr() {
loadTemplates();
@@ -68,7 +67,7 @@ const QString CDisplayTemplateMgr::fillTemplate( const QString& name, const QStr
if (moduleCount >= 2) {
//create header for the modules
- qDebug("There were more than 1 module, create headers");
+ qDebug() << "There were more than 1 module, create headers";
QString header;
QList<CSwordModuleInfo*>::iterator end_it = settings.modules.end();
@@ -92,7 +91,7 @@ const QString CDisplayTemplateMgr::fillTemplate( const QString& name, const QStr
CLanguageMgr::LangMap langMap = CPointers::languageMgr()->availableLanguages();
qDebug() << "langMap length:" << langMap.count();
- qDebug("loop through langMap");
+ qDebug() << "loop through langMap";
foreach(const CLanguageMgr::Language* lang, langMap) {
//const CLanguageMgr::Language* lang = *it;
//qDebug() << "foreach, lang: ";
@@ -146,12 +145,14 @@ const QString CDisplayTemplateMgr::fillTemplate( const QString& name, const QStr
}
void CDisplayTemplateMgr::loadTemplates() {
+ namespace DU = util::directory;
+
QStringList files;
- foreach (QString file, util::filesystem::DirectoryUtil::getDisplayTemplatesDir().entryList(QStringList("*.tmpl"))) {
- files += util::filesystem::DirectoryUtil::getDisplayTemplatesDir().canonicalPath() + "/" + file;
+ foreach (QString file, DU::getDisplayTemplatesDir().entryList(QStringList("*.tmpl"))) {
+ files += DU::getDisplayTemplatesDir().canonicalPath() + "/" + file;
}
- foreach (QString file, util::filesystem::DirectoryUtil::getUserDisplayTemplatesDir().entryList(QStringList("*.tmpl"))) {
- files += util::filesystem::DirectoryUtil::getUserDisplayTemplatesDir().canonicalPath() + "/" + file;
+ foreach (QString file, DU::getUserDisplayTemplatesDir().entryList(QStringList("*.tmpl"))) {
+ files += DU::getUserDisplayTemplatesDir().canonicalPath() + "/" + file;
}
foreach (QString file, files) {
diff --git a/src/backend/managers/cdisplaytemplatemgr.h b/src/backend/managers/cdisplaytemplatemgr.h
index d048ecd..16725a5 100644
--- a/src/backend/managers/cdisplaytemplatemgr.h
+++ b/src/backend/managers/cdisplaytemplatemgr.h
@@ -10,21 +10,18 @@
#ifndef CDISPLAYTEMPLATEMGR_H
#define CDISPLAYTEMPLATEMGR_H
-//BibleTime include
-class CSwordModuleInfo;
-
-//Qt includes
#include <QMap>
#include <QString>
#include <QStringList>
+
+class CSwordModuleInfo;
+
/**
* Manages the display templates used in the filters and display classes.
* @author The BibleTime team
*/
-
class CDisplayTemplateMgr {
-
public:
/** Settings which are used to fill the content into the template.
*/
diff --git a/src/backend/managers/clanguagemgr.cpp b/src/backend/managers/clanguagemgr.cpp
index e7245e5..5c44405 100644
--- a/src/backend/managers/clanguagemgr.cpp
+++ b/src/backend/managers/clanguagemgr.cpp
@@ -7,15 +7,12 @@
*
**********/
-#include "clanguagemgr.h"
+#include "backend/managers/clanguagemgr.h"
#include "backend/drivers/cswordmoduleinfo.h"
-#include "cswordbackend.h"
-
+#include "backend/managers/cswordbackend.h"
#include "util/cpointers.h"
-//KDE
-
CLanguageMgr::Language::Language() {}
diff --git a/src/backend/managers/clanguagemgr.h b/src/backend/managers/clanguagemgr.h
index 6d3a5c3..de716c0 100644
--- a/src/backend/managers/clanguagemgr.h
+++ b/src/backend/managers/clanguagemgr.h
@@ -10,16 +10,15 @@
#ifndef CLANGUAGEMGR_H
#define CLANGUAGEMGR_H
-//Qt includes
+#include <QHash>
+#include <QList>
#include <QString>
#include <QStringList>
-#include <QList>
-#include <QHash>
+
/** Manages the languages of BibleTime and provides functions to work with them.
* @author The BibleTime team
*/
-
class CLanguageMgr {
public:
diff --git a/src/backend/managers/creferencemanager.h b/src/backend/managers/creferencemanager.h
deleted file mode 100644
index 85131d6..0000000
--- a/src/backend/managers/creferencemanager.h
+++ /dev/null
@@ -1,110 +0,0 @@
-/*********
-*
-* This file is part of BibleTime's source code, http://www.bibletime.info/.
-*
-* Copyright 1999-2008 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License version 2.0.
-*
-**********/
-
-#ifndef CREFERENCEMANAGER_H
-#define CREFERENCEMANAGER_H
-
-#include "backend/drivers/cswordmoduleinfo.h"
-
-//Qt includes
-#include <QString>
-
-/** Contains static functions to work with references used for Drag & Drop and for hyperlinks used in our
- * rendered HTML code.
- * @author The BibleTime team
- */
-
-class CReferenceManager {
-
- public:
- enum Type {
- Bible, /**< Bibles */
- Commentary, /**< Commentary */
- Lexicon, /**< Lexicon */
- GenericBook, /**< Generic Book */
- MorphHebrew, /**< Module for hebrew morphology*/
- MorphGreek, /**< Module for greek morphology */
- StrongsHebrew, /**< Module for hebrew strongs */
- StrongsGreek, /**< Module for greek strongs */
- Unknown /**< Unknown */
- };
-
- /** Turn a hyperlink into module, key and type.
- * Decodes the given hyperlink into module, key and type.
- * @param hyperlink The hyperlink to decode
- * @param module The string which will contain the module name after decoding
- * @param key The string which will contain the key after decoding
- * @param type The type param will contain the reference type after decoding
- */
- static bool decodeHyperlink( const QString& hyperlink, QString& module, QString& key, Type& type);
- /**
- * Returns a hyperlink used to be embedded in the display windows.
- * At the moment the format is sword://module/key
- * @param module The module which is used to encode the hyperlink
- * @param key The key which is used to encode the hyperlink
- * @param type The type which is used to encode the hyperlink
- * @return The encoded hyperlink
- */
- static const QString encodeHyperlink( const QString module, const QString key, const Type type);
- /**
- * Puts a module Name and a Reference together in the 'draggable' form
- * (module)reference
- * @param module The name of the module
- * @param reference The key reference as text
- * @return The encoded reference using module and reference
- * @author Martin Gruner
- */
- static const QString encodeReference(const QString &module, const QString &reference);
- /**
- * decodes a 'draggable' reference into a modulename and a reference
- * @author Martin Gruner
- */
- static void decodeReference(QString &dragreference, QString &module, QString &reference);
- /**
- * Returns true if the parameter is a hyperlink.
- * @param hyperlink The string which is tested
- * @return True if the passed string is a hyperlink
- */
- static bool isHyperlink( const QString& hyperlink );
- /**
- * Returns the preferred module name for the given type.
- * @param type The type which is used to find the module
- * @return The default module name for the passed type
- */
- static const QString preferredModule( const Type type );
- /**
- * Returns the type of the passed module type
- * @param type The CSwordModuleInfo module typpe
- * @return The ReferenceManager type
- */
- static CReferenceManager::Type typeFromModule( const CSwordModuleInfo::ModuleType type );
-
-
- struct ParseOptions {
- QString refDestinationModule;
- QString refBase; /* only valid for verse based destination modules*/
- QString sourceLanguage; /* only valid for verse based destination modules*/
- QString destinationLanguage; /* only valid for verse based destination modules*/
-
- ParseOptions() {
- destinationLanguage = "en";
- };
- };
-
- /** Parses the given verse references using the given language and the module.
- * @param moduleName The name of the module to use. Required for the language checking before parsing the key.
- * @param ref The verse reference.
- * @param lang The language of the verse reference
- * @param newLang The language of the reference, which will be returned. For example: If BibleTime using an english environment parses a spanish ref (lang=es) the returned ref should be in english (newLang=en), because his english standard module only understands en.
- */
- static const QString parseVerseReference( const QString& ref, const ParseOptions& options);
-};
-
-#endif
-
diff --git a/src/backend/managers/cswordbackend.cpp b/src/backend/managers/cswordbackend.cpp
index 6420627..ee74e4a 100644
--- a/src/backend/managers/cswordbackend.cpp
+++ b/src/backend/managers/cswordbackend.cpp
@@ -7,43 +7,40 @@
*
**********/
-#include "cswordbackend.h"
+#include "backend/managers/cswordbackend.h"
-#include "backend/rendering/centrydisplay.h"
-#include "backend/rendering/cbookdisplay.h"
-#include "backend/rendering/cchapterdisplay.h"
+#include <QDebug>
+#include <QDir>
+#include <QFileInfo>
+#include <QSet>
+#include <QString>
+#include <QTextCodec>
+#include "backend/config/cbtconfig.h"
#include "backend/drivers/cswordbiblemoduleinfo.h"
+#include "backend/drivers/cswordbookmoduleinfo.h"
#include "backend/drivers/cswordcommentarymoduleinfo.h"
#include "backend/drivers/cswordlexiconmoduleinfo.h"
-#include "backend/drivers/cswordbookmoduleinfo.h"
-#include "backend/filters/bt_thmlhtml.h"
-#include "backend/filters/bt_thmlplain.h"
-#include "backend/filters/bt_osishtml.h"
#include "backend/filters/bt_gbfhtml.h"
+#include "backend/filters/bt_osishtml.h"
+#include "backend/filters/bt_teihtml.h"
#include "backend/filters/bt_plainhtml.h"
+#include "backend/filters/bt_thmlhtml.h"
+#include "backend/filters/bt_thmlplain.h"
#include "backend/filters/osismorphsegmentation.h"
+#include "backend/rendering/cbookdisplay.h"
+#include "backend/rendering/cchapterdisplay.h"
+#include "backend/rendering/centrydisplay.h"
+#include "util/directory.h"
-#include "backend/config/cbtconfig.h"
-
-#include "util/directoryutil.h"
-
-#include <dirent.h>
-
-//Qt
-#include <QString>
-#include <QDir>
-#include <QFileInfo>
-#include <QSet>
-#include <QDebug>
-
-//Sword
-#include <swdisp.h>
-#include <swfiltermgr.h>
+// Sword includes:
#include <encfiltmgr.h>
-#include <rtfhtml.h>
#include <filemgr.h>
-#include <utilstr.h>
+#include <rtfhtml.h>
+#include <swdisp.h>
+#include <swfiltermgr.h>
#include <swfilter.h>
+#include <utilstr.h>
+
using namespace Filters;
using namespace Rendering;
@@ -56,6 +53,7 @@ CSwordBackend::CSwordBackend()
m_filters.plain = new BT_PLAINHTML();
m_filters.thml = new BT_ThMLHTML();
m_filters.osis = new BT_OSISHTML();
+ m_filters.tei = new BT_TEIHTML();
m_displays.entry = new CEntryDisplay();
m_displays.chapter = new CChapterDisplay();
@@ -70,6 +68,7 @@ CSwordBackend::CSwordBackend(const QString& path, const bool augmentHome)
m_filters.plain = new BT_PLAINHTML();
m_filters.thml = new BT_ThMLHTML();
m_filters.osis = new BT_OSISHTML();
+ m_filters.tei = new BT_TEIHTML();
m_displays.entry = new CEntryDisplay();
m_displays.chapter = new CChapterDisplay();
@@ -85,6 +84,7 @@ CSwordBackend::~CSwordBackend() {
delete m_filters.plain;
delete m_filters.thml;
delete m_filters.osis;
+ delete m_filters.tei;
delete m_displays.book;
delete m_displays.chapter;
@@ -194,20 +194,24 @@ void CSwordBackend::AddRenderFilters(sword::SWModule *module, sword::ConfigEntMa
sourceformat = ((entry = section.find("SourceType")) != section.end()) ? (*entry).second : (sword::SWBuf) "";
moduleDriver = ((entry = section.find("ModDrv")) != section.end()) ? (*entry).second : (sword::SWBuf) "";
- if (sourceformat == "GBF") {
- module->AddRenderFilter(m_filters.gbf);
- noDriver = false;
- }
- else if (sourceformat == "PLAIN") {
- module->AddRenderFilter(m_filters.plain);
+ if (sourceformat == "OSIS") {
+ module->AddRenderFilter(m_filters.osis);
noDriver = false;
}
else if (sourceformat == "ThML") {
module->AddRenderFilter(m_filters.thml);
noDriver = false;
}
- else if (sourceformat == "OSIS") {
- module->AddRenderFilter(m_filters.osis);
+ else if (sourceformat == "TEI") {
+ module->AddRenderFilter(m_filters.tei);
+ noDriver = false;
+ }
+ else if (sourceformat == "GBF") {
+ module->AddRenderFilter(m_filters.gbf);
+ noDriver = false;
+ }
+ else if (sourceformat == "PLAIN") {
+ module->AddRenderFilter(m_filters.plain);
noDriver = false;
}
@@ -325,30 +329,20 @@ CSwordModuleInfo* CSwordBackend::findModuleByPointer(const CSwordModuleInfo* con
/** Returns our local config object to store the cipher keys etc. locally for each user. The values of the config are merged with the global config. */
bool CSwordBackend::moduleConfig(const QString& module, sword::SWConfig& moduleConfig) {
- sword::SectionMap::iterator section;
- DIR *dir = opendir(configPath);
-
- struct dirent *ent;
+ sword::SectionMap::iterator section;
+ QDir dir(QString::fromUtf8(configPath));
bool foundConfig = false;
- QString modFile;
-
- if (dir) { // find and update .conf file
- rewinddir(dir);
- while ((ent = readdir(dir)) && !foundConfig) {
- if ((strcmp(ent->d_name, ".")) && (strcmp(ent->d_name, ".."))) {
- modFile = QString(configPath);
- modFile.append("/");
- modFile.append( QString::fromLocal8Bit(ent->d_name) );
+ QFileInfoList list = dir.entryInfoList();
+ if (dir.isReadable()) {
+ for (int i = 0; i < list.size(); ++i) {
+ QFileInfo fileInfo = list.at(i);
- moduleConfig = sword::SWConfig( modFile.toLocal8Bit().constData() );
- section = moduleConfig.Sections.find( module.toLocal8Bit().constData() );
- foundConfig = ( section != moduleConfig.Sections.end() );
- }
+ moduleConfig = sword::SWConfig( fileInfo.absoluteFilePath().toLocal8Bit().constData() );
+ section = moduleConfig.Sections.find( module.toLocal8Bit().constData() );
+ foundConfig = ( section != moduleConfig.Sections.end() );
}
-
- closedir(dir);
}
else { //try to read mods.conf
moduleConfig = sword::SWConfig("");//global config
@@ -367,25 +361,17 @@ bool CSwordBackend::moduleConfig(const QString& module, sword::SWConfig& moduleC
if (!foundConfig && configType != 2) { //search in $HOME/.sword/
- QString myPath = util::filesystem::DirectoryUtil::getUserHomeDir().absolutePath();
- myPath.append("/.sword/mods.d");
- dir = opendir(myPath.toUtf8().constData());
-
- if (dir) {
- rewinddir(dir);
-
- while ((ent = readdir(dir)) && !foundConfig) {
- if ((strcmp(ent->d_name, ".")) && (strcmp(ent->d_name, ".."))) {
- modFile = myPath;
- modFile.append('/');
- modFile.append(ent->d_name);
- moduleConfig = sword::SWConfig( modFile.toLocal8Bit().constData() );
- section = moduleConfig.Sections.find( module.toLocal8Bit().constData() );
- foundConfig = ( section != moduleConfig.Sections.end() );
- }
- }
+ QString myPath = util::directory::getUserHomeSwordModsDir().absolutePath();
+ dir.setPath(myPath);
- closedir(dir);
+ QFileInfoList list = dir.entryInfoList();
+ if (dir.isReadable()) {
+ for (int i = 0; i < list.size(); ++i) {
+ QFileInfo fileInfo = list.at(i);
+ moduleConfig = sword::SWConfig( fileInfo.absoluteFilePath().toLocal8Bit().constData() );
+ section = moduleConfig.Sections.find( module.toLocal8Bit().constData() );
+ foundConfig = ( section != moduleConfig.Sections.end() );
+ }
}
}
@@ -526,46 +512,91 @@ void CSwordBackend::reloadModules(SetupChangedReason reason) {
initModules(reason);
}
-const QStringList CSwordBackend::swordDirList() {
- QSet<QString> ret;
- const QString home = util::filesystem::DirectoryUtil::getUserHomeDir().absolutePath();
+// Get one or more shared sword config (sword.conf) files
+QStringList CSwordBackend::getSharedSwordConfigFiles() const
+{
+ QStringList configPath;
+#ifdef Q_WS_WIN
+ // %ALLUSERSPROFILE%\Sword\sword.conf
+ QString tmp = util::directory::getSharedSwordDir().filePath("sword.conf");
+ QString globalPath = util::directory::convertDirSeparators(QString(getenv("SWORD_PATH")));
+ configPath << globalPath.append("/Sword/sword.conf");
+#else
+ // /etc/sword.conf, /usr/local/etc/sword.conf
+ configPath = QString(globalConfPath).split(":");
+#endif
+ return configPath;
+}
- //return a list of used Sword dirs. Useful for the installer
- QString configPath = QString("%1/.sword/sword.conf").arg(home);
+// Get the private sword directory
+QString CSwordBackend::getPrivateSwordConfigPath() const
+{
+ return util::directory::getUserHomeSwordDir().absolutePath();
+}
- if (!QFile(configPath).exists()) {
- configPath = globalConfPath; //e.g. /etc/sword.conf, /usr/local/etc/sword.conf
- }
+QString CSwordBackend::getPrivateSwordConfigFile() const
+{
+ QString file(getPrivateSwordConfigPath() + "/sword.conf");
+ return util::directory::convertDirSeparators(file);
+}
- QStringList configs = configPath.split(":");
+// Return a list of used Sword dirs. Useful for the installer.
+QStringList CSwordBackend::swordDirList() const {
+ namespace DU = util::directory;
+ typedef QStringList::const_iterator SLCI;
+ typedef sword::ConfigEntMap::const_iterator CEMCI;
+
+ // Get the set of sword directories that could contain modules:
+ QSet<QString> swordDirSet;
+ QStringList configs;
+
+ if (QFile(getPrivateSwordConfigFile()).exists()) {
+ // Use the private sword.conf file:
+ configs << getPrivateSwordConfigFile();
+ } else {
+ /*
+ Did not find private sword.conf, will use shared sword.conf files to
+ build the private one. Once the private sword.conf exist, the shared
+ ones will not be searched again.
+ */
+ configs = getSharedSwordConfigFiles();
+
+#ifdef Q_WS_WIN
+ /*
+ On Windows, add the shared sword directory to the set so the new
+ private sword.conf will have it. The user could decide to delete this
+ shared path and it will not automatically come back.
+ */
+ swordDirSet << DU::convertDirSeparators(QString(getenv("SWORD_PATH")));
+#endif
+ }
- for (QStringList::const_iterator it = configs.begin(); it != configs.end(); ++it) {
+ // Search the sword.conf file(s) for sword directories that could contain modules
+ for (SLCI it(configs.begin()); it != configs.end(); it++) {
if (!QFileInfo(*it).exists()) {
continue;
}
- //get all DataPath and AugmentPath entries from the config file and add them to the list
- sword::SWConfig conf( (*it).toUtf8().constData() );
- ret << conf["Install"]["DataPath"].c_str();
- sword::ConfigEntMap group = conf["Install"];
- sword::ConfigEntMap::iterator start = group.equal_range("AugmentPath").first;
- sword::ConfigEntMap::iterator end = group.equal_range("AugmentPath").second;
-
- for (sword::ConfigEntMap::const_iterator it = start; it != end; ++it) {
- ret << QDir(it->second.c_str()).absolutePath(); //added augment path
+ /*
+ Get all DataPath and AugmentPath entries from the config file and add
+ them to the list:
+ */
+ sword::SWConfig conf((*it).toUtf8().constData());
+ swordDirSet << QDir(QTextCodec::codecForLocale()->toUnicode(conf["Install"]["DataPath"].c_str())).absolutePath();
+
+ sword::ConfigEntMap group(conf["Install"]);
+ const sword::ConfigEntMap::iterator start(group.equal_range("AugmentPath").first);
+ const sword::ConfigEntMap::iterator end(group.equal_range("AugmentPath").second);
+
+ for (CEMCI it(start); it != end; it++) {
+ QDir(QTextCodec::codecForLocale()->toUnicode(it->second.c_str())).absolutePath();
+ // Added augment path:
+ swordDirSet << QDir(QTextCodec::codecForLocale()->toUnicode(it->second.c_str())).absolutePath();
}
}
- if (!home.isEmpty()) {
- // This is added to the set if not there already. Notice that
- // this prevents duplication only if the QDir::absolutePath() returns
- // string without the prepended "/".
- ret << home + "/.sword";
- }
-
- return ret.values();
-}
+ // Add the private sword path to the set if not there already:
+ swordDirSet << getPrivateSwordConfigPath();
-void CSwordBackend::notifyChange(SetupChangedReason reason) {
- emit sigSwordSetupChanged(reason);
+ return swordDirSet.values();
}
diff --git a/src/backend/managers/cswordbackend.h b/src/backend/managers/cswordbackend.h
index 9169c33..3120694 100644
--- a/src/backend/managers/cswordbackend.h
+++ b/src/backend/managers/cswordbackend.h
@@ -10,17 +10,14 @@
#ifndef CSWORDBACKEND_H
#define CSWORDBACKEND_H
-//BibleTime includes
-#include "backend/drivers/cswordmoduleinfo.h"
-#include "backend/bookshelfmodel/btbookshelfmodel.h"
-
-//Qt includes
-#include <QObject>
#include <QMap>
+#include <QObject>
#include <QString>
#include <QStringList>
+#include "backend/drivers/cswordmoduleinfo.h"
+#include "backend/bookshelfmodel/btbookshelfmodel.h"
-//Sword includes
+// Sword includes:
#include <swmgr.h>
#include <swbuf.h>
#include <swmodule.h>
@@ -28,7 +25,6 @@
#include <localemgr.h>
#include <utilstr.h>
-//forward declarations
namespace Rendering {
class CEntryDisplay;
class CChapterDisplay;
@@ -43,7 +39,6 @@ class CBookDisplay;
* @author The BibleTime team
* @version $Id: cswordbackend.h,v 1.58 2007/03/14 21:32:47 joachim Exp $
*/
-
class CSwordBackend : public QObject, public sword::SWMgr {
Q_OBJECT
public:
@@ -219,12 +214,7 @@ class CSwordBackend : public QObject, public sword::SWMgr {
/** Sword prefix list.
* @return A list of all known Sword prefix dirs
*/
- const QStringList swordDirList();
-
- /** Emits the sigSwordSetupChanged signal.
- * This can be called directly from outside if there is no need to reload the backend.
- */
- void notifyChange(SetupChangedReason reason);
+ QStringList swordDirList() const;
signals:
void sigSwordSetupChanged(CSwordBackend::SetupChangedReason reason);
@@ -240,6 +230,10 @@ class CSwordBackend : public QObject, public sword::SWMgr {
*/
void filterInit();
+ QStringList getSharedSwordConfigFiles() const;
+ QString getPrivateSwordConfigPath() const;
+ QString getPrivateSwordConfigFile() const;
+
private:
// Filters
struct Filters {
@@ -247,6 +241,7 @@ class CSwordBackend : public QObject, public sword::SWMgr {
sword::SWFilter* plain;
sword::SWFilter* thml;
sword::SWFilter* osis;
+ sword::SWFilter* tei;
} m_filters;
struct Displays {
diff --git a/src/backend/managers/creferencemanager.cpp b/src/backend/managers/referencemanager.cpp
index 41f8954..4fc5e53 100644
--- a/src/backend/managers/creferencemanager.cpp
+++ b/src/backend/managers/referencemanager.cpp
@@ -7,20 +7,19 @@
*
**********/
-#include "creferencemanager.h"
-#include "backend/keys/cswordversekey.h"
+#include "backend/managers/referencemanager.h"
-#include "backend/config/cbtconfig.h"
-#include "util/cpointers.h"
+#include <algorithm>
-//QT
#include <QRegExp>
+#include <QDebug>
+#include "backend/config/cbtconfig.h"
+#include "backend/keys/cswordversekey.h"
+#include "util/cpointers.h"
-//stl
-#include <algorithm> // STL algorithms class library
/** Returns a hyperlink used to be imbedded in the display windows. At the moment the format is sword://module/key */
-const QString CReferenceManager::encodeHyperlink( const QString moduleName, const QString key, const CReferenceManager::Type type) {
+const QString ReferenceManager::encodeHyperlink( const QString moduleName, const QString key, const ReferenceManager::Type type) {
QString ret = QString::null;
switch (type) {
@@ -111,7 +110,7 @@ const QString CReferenceManager::encodeHyperlink( const QString moduleName, cons
}
/** Decodes the given hyperlink to module and key. */
-bool CReferenceManager::decodeHyperlink( const QString& hyperlink, QString& module, QString& key, CReferenceManager::Type& type ) {
+bool ReferenceManager::decodeHyperlink( const QString& hyperlink, QString& module, QString& key, ReferenceManager::Type& type ) {
/**
* We have to decide between three types of URLS: sword://Type/Module/Key, morph://Testament/key and strongs://Testament/Key
*/
@@ -130,19 +129,19 @@ bool CReferenceManager::decodeHyperlink( const QString& hyperlink, QString& modu
ref = ref.mid(8);
if (ref.left(5).toLower() == "bible") { //a bible hyperlink
- type = CReferenceManager::Bible;
+ type = ReferenceManager::Bible;
ref = ref.mid(6); //inclusive trailing slash
}
else if (ref.left(10).toLower() == "commentary") { // a Commentary hyperlink
- type = CReferenceManager::Commentary;
+ type = ReferenceManager::Commentary;
ref = ref.mid(11); //inclusive trailing slash
}
else if (ref.left(7).toLower() == "lexicon") { // a Lexicon hyperlink
- type = CReferenceManager::Lexicon;
+ type = ReferenceManager::Lexicon;
ref = ref.mid(8); //inclusive trailing slash
}
else if (ref.left(4).toLower() == "book") { // a Book hyperlink
- type = CReferenceManager::GenericBook;
+ type = ReferenceManager::GenericBook;
ref = ref.mid(5); //inclusive trailing slash
}
@@ -204,11 +203,11 @@ bool CReferenceManager::decodeHyperlink( const QString& hyperlink, QString& modu
switch (preType) {
case IsMorph:
- type = CReferenceManager::MorphHebrew;
+ type = ReferenceManager::MorphHebrew;
break;
case IsStrongs:
- type = CReferenceManager::StrongsHebrew;
+ type = ReferenceManager::StrongsHebrew;
break;
}
}
@@ -216,11 +215,11 @@ bool CReferenceManager::decodeHyperlink( const QString& hyperlink, QString& modu
switch (preType) {
case IsMorph:
- type = CReferenceManager::MorphGreek;
+ type = ReferenceManager::MorphGreek;
break;
case IsStrongs:
- type = CReferenceManager::StrongsGreek;
+ type = ReferenceManager::StrongsGreek;
break;
}
}
@@ -238,12 +237,12 @@ bool CReferenceManager::decodeHyperlink( const QString& hyperlink, QString& modu
return true;
}
-const QString CReferenceManager::encodeReference(const QString &module, const QString &reference) {
+const QString ReferenceManager::encodeReference(const QString &module, const QString &reference) {
//return QString("(%1)%2").arg(module).arg(reference);
return QString("(").append(module).append(")").append(reference);
}
-void CReferenceManager::decodeReference(QString &dragreference, QString &module, QString &reference) {
+void ReferenceManager::decodeReference(QString &dragreference, QString &module, QString &reference) {
const int pos = dragreference.indexOf(")");
const QString fallbackModule = dragreference.mid( 1, pos - 1);
dragreference = dragreference.mid(pos + 1);
@@ -253,57 +252,57 @@ void CReferenceManager::decodeReference(QString &dragreference, QString &module,
}
/** Returns true if the parameter is a hyperlink. */
-bool CReferenceManager::isHyperlink( const QString& hyperlink ) {
+bool ReferenceManager::isHyperlink( const QString& hyperlink ) {
return ( hyperlink.left(8) == "sword://")
|| (hyperlink.left(10) == "strongs://")
|| (hyperlink.left(8) == "morph://");
}
/** Returns the preferred module name for the given type. */
-const QString CReferenceManager::preferredModule( const CReferenceManager::Type type ) {
+const QString ReferenceManager::preferredModule( const ReferenceManager::Type type ) {
QString moduleName = QString::null;
CSwordModuleInfo* module = 0;
switch (type) {
- case CReferenceManager::Bible:
+ case ReferenceManager::Bible:
module = CBTConfig::get
( CBTConfig::standardBible );
break;
- case CReferenceManager::Commentary:
+ case ReferenceManager::Commentary:
module = CBTConfig::get
( CBTConfig::standardCommentary );
break;
- case CReferenceManager::Lexicon:
+ case ReferenceManager::Lexicon:
module = CBTConfig::get
( CBTConfig::standardLexicon );
break;
- case CReferenceManager::StrongsHebrew:
+ case ReferenceManager::StrongsHebrew:
module = CBTConfig::get
( CBTConfig::standardHebrewStrongsLexicon );
break;
- case CReferenceManager::StrongsGreek:
+ case ReferenceManager::StrongsGreek:
module = CBTConfig::get
( CBTConfig::standardGreekStrongsLexicon );
break;
- case CReferenceManager::MorphHebrew:
+ case ReferenceManager::MorphHebrew:
module = CBTConfig::get
( CBTConfig::standardHebrewMorphLexicon );
break;
- case CReferenceManager::MorphGreek:
+ case ReferenceManager::MorphGreek:
module = CBTConfig::get
( CBTConfig::standardGreekMorphLexicon );
@@ -319,28 +318,28 @@ const QString CReferenceManager::preferredModule( const CReferenceManager::Type
}
/** No descriptions */
-CReferenceManager::Type CReferenceManager::typeFromModule( const CSwordModuleInfo::ModuleType type) {
+ReferenceManager::Type ReferenceManager::typeFromModule( const CSwordModuleInfo::ModuleType type) {
switch (type) {
case CSwordModuleInfo::Bible:
- return CReferenceManager::Bible;
+ return ReferenceManager::Bible;
case CSwordModuleInfo::Commentary:
- return CReferenceManager::Commentary;
+ return ReferenceManager::Commentary;
case CSwordModuleInfo::Lexicon:
- return CReferenceManager::Lexicon;
+ return ReferenceManager::Lexicon;
case CSwordModuleInfo::GenericBook:
- return CReferenceManager::GenericBook;
+ return ReferenceManager::GenericBook;
default:
- return CReferenceManager::Unknown;
+ return ReferenceManager::Unknown;
}
}
/** Parses the given verse references using the given language and the module.*/
-const QString CReferenceManager::parseVerseReference( const QString& ref, const CReferenceManager::ParseOptions& options) {
+const QString ReferenceManager::parseVerseReference( const QString& ref, const ReferenceManager::ParseOptions& options) {
CSwordModuleInfo* const mod = CPointers::backend()->findModuleByName(options.refDestinationModule);
//Q_ASSERT(mod); tested later
@@ -351,7 +350,7 @@ const QString CReferenceManager::parseVerseReference( const QString& ref, const
}
if ((mod->type() != CSwordModuleInfo::Bible) && (mod->type() != CSwordModuleInfo::Commentary)) {
- qDebug("CReferenceManager: Only verse based modules are supported as ref destination module");
+ qDebug() << "CReferenceManager: Only verse based modules are supported as ref destination module";
return QString::null;
}
diff --git a/src/backend/managers/referencemanager.h b/src/backend/managers/referencemanager.h
new file mode 100644
index 0000000..a038130
--- /dev/null
+++ b/src/backend/managers/referencemanager.h
@@ -0,0 +1,106 @@
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2008 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+#ifndef REFERENCEMANAGER_H
+#define REFERENCEMANAGER_H
+
+#include <QString>
+#include "backend/drivers/cswordmoduleinfo.h"
+
+
+/** Contains functions to work with references used for Drag & Drop and for hyperlinks used in our
+ * rendered HTML code.
+ */
+namespace ReferenceManager {
+enum Type {
+ Bible, /**< Bibles */
+ Commentary, /**< Commentary */
+ Lexicon, /**< Lexicon */
+ GenericBook, /**< Generic Book */
+ MorphHebrew, /**< Module for hebrew morphology*/
+ MorphGreek, /**< Module for greek morphology */
+ StrongsHebrew, /**< Module for hebrew strongs */
+ StrongsGreek, /**< Module for greek strongs */
+ Unknown /**< Unknown */
+};
+
+/** Turn a hyperlink into module, key and type.
+* Decodes the given hyperlink into module, key and type.
+* @param hyperlink The hyperlink to decode
+* @param module The string which will contain the module name after decoding
+* @param key The string which will contain the key after decoding
+* @param type The type param will contain the reference type after decoding
+*/
+bool decodeHyperlink( const QString& hyperlink, QString& module, QString& key, Type& type);
+/**
+* Returns a hyperlink used to be embedded in the display windows.
+* At the moment the format is sword://module/key
+* @param module The module which is used to encode the hyperlink
+* @param key The key which is used to encode the hyperlink
+* @param type The type which is used to encode the hyperlink
+* @return The encoded hyperlink
+*/
+const QString encodeHyperlink( const QString module, const QString key, const Type type);
+/**
+* Puts a module Name and a Reference together in the 'draggable' form
+* (module)reference
+* @param module The name of the module
+* @param reference The key reference as text
+* @return The encoded reference using module and reference
+* @author Martin Gruner
+*/
+const QString encodeReference(const QString &module, const QString &reference);
+/**
+* decodes a 'draggable' reference into a modulename and a reference
+* @author Martin Gruner
+*/
+void decodeReference(QString &dragreference, QString &module, QString &reference);
+/**
+* Returns true if the parameter is a hyperlink.
+* @param hyperlink The string which is tested
+* @return True if the passed string is a hyperlink
+*/
+bool isHyperlink( const QString& hyperlink );
+/**
+* Returns the preferred module name for the given type.
+* @param type The type which is used to find the module
+* @return The default module name for the passed type
+*/
+const QString preferredModule( const Type type );
+/**
+* Returns the type of the passed module type
+* @param type The CSwordModuleInfo module typpe
+* @return The ReferenceManager type
+*/
+ReferenceManager::Type typeFromModule( const CSwordModuleInfo::ModuleType type );
+
+
+struct ParseOptions {
+ QString refDestinationModule;
+ QString refBase; /* only valid for verse based destination modules*/
+ QString sourceLanguage; /* only valid for verse based destination modules*/
+ QString destinationLanguage; /* only valid for verse based destination modules*/
+
+ ParseOptions() {
+ destinationLanguage = "en";
+ };
+};
+
+/** Parses the given verse references using the given language and the module.
+* @param moduleName The name of the module to use. Required for the language checking before parsing the key.
+* @param ref The verse reference.
+* @param lang The language of the verse reference
+* @param newLang The language of the reference, which will be returned. For example: If BibleTime using an english environment parses a spanish ref (lang=es) the returned ref should be in english (newLang=en), because his english standard module only understands en.
+*/
+const QString parseVerseReference( const QString& ref, const ParseOptions& options);
+
+};
+
+#endif
+
diff --git a/src/backend/rendering/cbookdisplay.cpp b/src/backend/rendering/cbookdisplay.cpp
index 99990f8..f640628 100644
--- a/src/backend/rendering/cbookdisplay.cpp
+++ b/src/backend/rendering/cbookdisplay.cpp
@@ -7,14 +7,15 @@
*
**********/
-//Backend
-#include "cbookdisplay.h"
-#include "cdisplayrendering.h"
+#include "backend/rendering/cbookdisplay.h"
+
+#include <boost/scoped_ptr.hpp>
+#include <QtAlgorithms>
+
#include "backend/drivers/cswordbookmoduleinfo.h"
#include "backend/keys/cswordtreekey.h"
+#include "backend/rendering/cdisplayrendering.h"
-//Util
-#include <boost/scoped_ptr.hpp>
/** Returns the rendered text using the modules in the list and using the key parameter. The displayoptions and filter options are used, too. */
const QString Rendering::CBookDisplay::text( const QList<CSwordModuleInfo*>& modules, const QString& keyName, const CSwordBackend::DisplayOptions displayOptions, const CSwordBackend::FilterOptions filterOptions ) {
@@ -46,6 +47,8 @@ const QString Rendering::CBookDisplay::text( const QList<CSwordModuleInfo*>& mod
const QString renderedText = render.renderKeyTree(tree);
key->setOffset( offset );
+
+ qDeleteAll(tree); // Dispose of the heap allocated objects pointed to in tree.
return renderedText;
};
@@ -75,6 +78,7 @@ const QString Rendering::CBookDisplay::text( const QList<CSwordModuleInfo*>& mod
const QString renderedText = render.renderKeyTree(tree);
key->setOffset( offset );
+ qDeleteAll(tree); // Dispose of the heap allocated objects pointed to in tree.
return renderedText;
};
@@ -91,6 +95,7 @@ const QString Rendering::CBookDisplay::text( const QList<CSwordModuleInfo*>& mod
const QString renderedText = render.renderKeyTree(tree);
key->setOffset( offset );
+ qDeleteAll(tree); // Dispose of the heap allocated objects pointed to in tree.
return renderedText;
};
};
@@ -109,6 +114,7 @@ const QString Rendering::CBookDisplay::text( const QList<CSwordModuleInfo*>& mod
key->setOffset( offset ); //restore key
+ qDeleteAll(tree); // Dispose of the heap allocated objects pointed to in tree.
return renderedText;
}
diff --git a/src/backend/rendering/cbookdisplay.h b/src/backend/rendering/cbookdisplay.h
index 35d7221..832249f 100644
--- a/src/backend/rendering/cbookdisplay.h
+++ b/src/backend/rendering/cbookdisplay.h
@@ -10,10 +10,10 @@
#ifndef RENDERINGCBOOKDISPLAY_H
#define RENDERINGCBOOKDISPLAY_H
-#include "centrydisplay.h"
-#include "ctextrendering.h"
-//TODO: It would be sufficient to forward declare CTextRendering and CTextRendering::KeyTree
-//but I don't know how :(
+#include "backend/rendering/centrydisplay.h"
+
+#include "backend/rendering/ctextrendering.h"
+
class CSwordTreeKey;
diff --git a/src/backend/rendering/cchapterdisplay.cpp b/src/backend/rendering/cchapterdisplay.cpp
index f96bada..74063cf 100644
--- a/src/backend/rendering/cchapterdisplay.cpp
+++ b/src/backend/rendering/cchapterdisplay.cpp
@@ -7,11 +7,12 @@
*
**********/
-//Backend
-#include "cchapterdisplay.h"
-#include "cdisplayrendering.h"
-#include "backend/keys/cswordversekey.h"
+#include "backend/rendering/cchapterdisplay.h"
+
#include "backend/drivers/cswordbiblemoduleinfo.h"
+#include "backend/keys/cswordversekey.h"
+#include "backend/rendering/cdisplayrendering.h"
+
const QString Rendering::CChapterDisplay::text( const QList<CSwordModuleInfo*>& modules, const QString& keyName, const CSwordBackend::DisplayOptions displayOptions, const CSwordBackend::FilterOptions filterOptions ) {
Q_ASSERT( modules.count() >= 1 );
diff --git a/src/backend/rendering/cchapterdisplay.h b/src/backend/rendering/cchapterdisplay.h
index 916f257..3b3d363 100644
--- a/src/backend/rendering/cchapterdisplay.h
+++ b/src/backend/rendering/cchapterdisplay.h
@@ -10,7 +10,8 @@
#ifndef RENDERINGCCHAPTERDISPLAY_H
#define RENDERINGCCHAPTERDISPLAY_H
-#include "centrydisplay.h"
+#include "backend/rendering/centrydisplay.h"
+
namespace Rendering {
diff --git a/src/backend/rendering/cdisplayrendering.cpp b/src/backend/rendering/cdisplayrendering.cpp
index e648303..cc3f7c9 100644
--- a/src/backend/rendering/cdisplayrendering.cpp
+++ b/src/backend/rendering/cdisplayrendering.cpp
@@ -7,19 +7,17 @@
*
**********/
-#include "cdisplayrendering.h"
+#include "backend/rendering/cdisplayrendering.h"
-#include "backend/managers/cdisplaytemplatemgr.h"
-#include "backend/managers/creferencemanager.h"
+#include <QString>
+#include <QRegExp>
+#include <QDebug>
#include "backend/keys/cswordkey.h"
#include "backend/keys/cswordversekey.h"
-
+#include "backend/managers/cdisplaytemplatemgr.h"
+#include "backend/managers/referencemanager.h"
#include "util/cpointers.h"
-//Qt
-#include <QString>
-#include <QRegExp>
-#include <QDebug>
namespace Rendering {
@@ -88,8 +86,8 @@ const QString CDisplayRendering::entryLink( const KeyTreeItem& item, CSwordModul
else {
return QString("<a name=\"").append(keyToHTMLAnchor(item.key())).append("\" ")
.append("href=\"")
- .append(CReferenceManager::encodeHyperlink(
- module->name(), item.key(), CReferenceManager::typeFromModule(module->type()))
+ .append(ReferenceManager::encodeHyperlink(
+ module->name(), item.key(), ReferenceManager::typeFromModule(module->type()))
)
.append("\">").append(linkText).append("</a>\n");
}
@@ -108,7 +106,7 @@ const QString CDisplayRendering::keyToHTMLAnchor(const QString& key) {
const QString CDisplayRendering::finishText( const QString& oldText, KeyTree& tree ) {
QList<CSwordModuleInfo*> modules = collectModules(&tree);
- qDebug("CDisplayRendering::finishText");
+ qDebug() << "CDisplayRendering::finishText";
//marking words is very slow, we have to find a better solution
@@ -123,12 +121,12 @@ const QString CDisplayRendering::finishText( const QString& oldText, KeyTree& tr
while (pos != -1) { //word begin found
//qWarning("found word at %i in %i", pos, text.length());
int endPos = pos + 1;
- if (!CToolClass::inHTMLTag(pos+1, text)) { //the re has a positive look ahead which matches one char before the word start
+ if (!util::tool::inHTMLTag(pos+1, text)) { //the re has a positive look ahead which matches one char before the word start
//qWarning("matched %s", text.mid(pos+1, 4).latin1());
//find end of word and put a marker around it
endPos = text.find(QRegExp("\\b|[,.:]"), pos+1);
- if ((endPos != -1) && !CToolClass::inHTMLTag(endPos, text) && (endPos - pos >= 3)) { //reuire wordslonger than 3 chars
+ if ((endPos != -1) && !util::tool::inHTMLTag(endPos, text) && (endPos - pos >= 3)) { //reuire wordslonger than 3 chars
text.insert(endPos, "</span>");
text.insert(pos, "<span class=\"word\">");
diff --git a/src/backend/rendering/cdisplayrendering.h b/src/backend/rendering/cdisplayrendering.h
index d52d6b7..f66e556 100644
--- a/src/backend/rendering/cdisplayrendering.h
+++ b/src/backend/rendering/cdisplayrendering.h
@@ -10,7 +10,8 @@
#ifndef RENDERINGCDISPLAYRENDERING_H
#define RENDERINGCDISPLAYRENDERING_H
-#include "chtmlexportrendering.h"
+#include "backend/rendering/chtmlexportrendering.h"
+
namespace Rendering {
diff --git a/src/backend/rendering/centrydisplay.cpp b/src/backend/rendering/centrydisplay.cpp
index 89743e2..d3a6aac 100644
--- a/src/backend/rendering/centrydisplay.cpp
+++ b/src/backend/rendering/centrydisplay.cpp
@@ -7,22 +7,20 @@
*
**********/
-//BibleTime includes
-#include "centrydisplay.h"
+#include "backend/rendering/centrydisplay.h"
+#include <QApplication>
+#include <QRegExp>
+
+#include "backend/config/cbtconfig.h"
+#include "backend/drivers/cswordbookmoduleinfo.h"
#include "backend/keys/cswordkey.h"
#include "backend/keys/cswordversekey.h"
-#include "backend/drivers/cswordbookmoduleinfo.h"
-#include "backend/managers/creferencemanager.h"
#include "backend/managers/cdisplaytemplatemgr.h"
-#include "cdisplayrendering.h"
+#include "backend/managers/referencemanager.h"
+#include "backend/rendering/cdisplayrendering.h"
+#include "backend/rendering/ctextrendering.h"
-#include "backend/config/cbtconfig.h"
-#include <boost/scoped_ptr.hpp>
-
-//Qt includes
-#include <QApplication>
-#include <QRegExp>
using namespace Rendering;
@@ -35,7 +33,8 @@ const QString CEntryDisplay::text( const QList<CSwordModuleInfo*>& modules, cons
//no highlighted key and no extra key link in the text
CTextRendering::KeyTreeItem::Settings normal_settings(false, CTextRendering::KeyTreeItem::Settings::CompleteShort);
CSwordModuleInfo* module = modules.first();
- QString result;
+
+ Rendering::CTextRendering::KeyTree tree;
//in Bibles and Commentaries we need to check if 0:0 and X:0 contain something
if (module->type() == CSwordModuleInfo::Bible || module->type() == CSwordModuleInfo::Commentary) {
@@ -52,12 +51,19 @@ const QString CEntryDisplay::text( const QList<CSwordModuleInfo*>& modules, cons
if (k1.Chapter() == 1) { //1:1, also prepend 0:0 before that
k1.Chapter(0);
k1.Verse(0);
- if ( k1.rawText().length() > 0 ) result.append( render.renderSingleKey(k1.key(), modules, preverse_settings ) );
+ if ( k1.rawText().length() > 0 ) {
+ tree.append( new Rendering::CTextRendering::KeyTreeItem(k1.key(), modules, preverse_settings) );
+ }
k1.Chapter(1);
}
k1.Verse(0);
- if ( k1.rawText().length() > 0 ) result.append( render.renderSingleKey(k1.key(), modules, preverse_settings ) );
+ if ( k1.rawText().length() > 0 ) {
+ tree.append( new Rendering::CTextRendering::KeyTreeItem(k1.key(), modules, preverse_settings) );
+ }
}
}
- return result.append( render.renderSingleKey(keyName, modules, normal_settings) );
+ tree.append( new Rendering::CTextRendering::KeyTreeItem(keyName, modules, normal_settings) );
+ QString result(render.renderKeyTree(tree));
+ qDeleteAll(tree);
+ return result;
}
diff --git a/src/backend/rendering/centrydisplay.h b/src/backend/rendering/centrydisplay.h
index 0c451b4..5f410a5 100644
--- a/src/backend/rendering/centrydisplay.h
+++ b/src/backend/rendering/centrydisplay.h
@@ -10,18 +10,14 @@
#ifndef CENTRYDISPLAY_H
#define CENTRYDISPLAY_H
-//BibleTime
-//#include "ctextrendering.h"
-class CSwordModuleInfo;
-#include "backend/managers/cswordbackend.h"
-
#include "util/cpointers.h"
-//Sword
+#include <QString>
+#include "backend/managers/cswordbackend.h"
+
+// Sword includes:
#include <swdisp.h>
-//Qt
-#include <QString>
class CSwordModuleInfo;
diff --git a/src/backend/rendering/chtmlexportrendering.cpp b/src/backend/rendering/chtmlexportrendering.cpp
index 7a0833a..e6d0ff6 100644
--- a/src/backend/rendering/chtmlexportrendering.cpp
+++ b/src/backend/rendering/chtmlexportrendering.cpp
@@ -7,18 +7,17 @@
*
**********/
-#include "chtmlexportrendering.h"
+#include "backend/rendering/chtmlexportrendering.h"
-#include "backend/managers/cdisplaytemplatemgr.h"
-#include "backend/managers/clanguagemgr.h"
+#include <boost/scoped_ptr.hpp>
+#include <iostream>
+#include "backend/drivers/cswordmoduleinfo.h"
#include "backend/keys/cswordkey.h"
#include "backend/keys/cswordversekey.h"
-#include "backend/drivers/cswordmoduleinfo.h"
-
+#include "backend/managers/cdisplaytemplatemgr.h"
+#include "backend/managers/clanguagemgr.h"
#include "util/cpointers.h"
-#include <boost/scoped_ptr.hpp>
-#include <iostream>
namespace {
@@ -141,7 +140,7 @@ const QString CHTMLExportRendering::renderEntry( const KeyTreeItem& i, CSwordKey
for (; it != end; ++it) {
preverseHeading = QString::fromUtf8(it->second.c_str());
- //TODO: Take care of the heading type!
+ /// \todo Take care of the heading type!
if (!preverseHeading.isEmpty()) {
entry.append("<div ")
.append(langAttr)
diff --git a/src/backend/rendering/chtmlexportrendering.h b/src/backend/rendering/chtmlexportrendering.h
index 2240cda..065bb85 100644
--- a/src/backend/rendering/chtmlexportrendering.h
+++ b/src/backend/rendering/chtmlexportrendering.h
@@ -10,10 +10,11 @@
#ifndef RENDERINGCHTMLEXPORTRENDERING_H
#define RENDERINGCHTMLEXPORTRENDERING_H
-#include "backend/managers/cswordbackend.h"
-#include "ctextrendering.h"
+#include "backend/rendering/ctextrendering.h"
#include "backend/config/cbtconfig.h"
+#include "backend/managers/cswordbackend.h"
+
namespace Rendering {
diff --git a/src/backend/rendering/cplaintextexportrendering.cpp b/src/backend/rendering/cplaintextexportrendering.cpp
index dbcbff6..fdbf78d 100644
--- a/src/backend/rendering/cplaintextexportrendering.cpp
+++ b/src/backend/rendering/cplaintextexportrendering.cpp
@@ -7,12 +7,11 @@
*
**********/
-//Backend includes
-#include "cplaintextexportrendering.h"
-#include "backend/keys/cswordkey.h"
+#include "backend/rendering/cplaintextexportrendering.h"
-//Util
#include <boost/scoped_ptr.hpp>
+#include "backend/keys/cswordkey.h"
+
namespace Rendering {
@@ -38,7 +37,7 @@ const QString CPlainTextExportRendering::renderEntry( const KeyTreeItem& i, CSwo
key->module(*it);
key->key( i.key() );
- //ToDo: Check this code
+ /// \todo Check this code
entry.append(key->strippedText()).append("\n");
renderedText.append( entry );
}
diff --git a/src/backend/rendering/cplaintextexportrendering.h b/src/backend/rendering/cplaintextexportrendering.h
index acd6054..5ebbb24 100644
--- a/src/backend/rendering/cplaintextexportrendering.h
+++ b/src/backend/rendering/cplaintextexportrendering.h
@@ -10,7 +10,8 @@
#ifndef RENDERINGCPLAINTEXTEXPORTRENDERING_H
#define RENDERINGCPLAINTEXTEXPORTRENDERING_H
-#include "chtmlexportrendering.h"
+#include "backend/rendering/chtmlexportrendering.h"
+
namespace Rendering {
diff --git a/src/backend/rendering/ctextrendering.cpp b/src/backend/rendering/ctextrendering.cpp
index 5fce14b..645b5d6 100644
--- a/src/backend/rendering/ctextrendering.cpp
+++ b/src/backend/rendering/ctextrendering.cpp
@@ -7,24 +7,22 @@
*
**********/
-#include "ctextrendering.h"
+#include "backend/rendering/ctextrendering.h"
-//BibleTime
+#include <boost/scoped_ptr.hpp>
+
+#include <QRegExp>
+#include <QtAlgorithms>
+
+#include "backend/drivers/cswordmoduleinfo.h"
#include "backend/keys/cswordkey.h"
#include "backend/keys/cswordversekey.h"
-#include "backend/drivers/cswordmoduleinfo.h"
#include "backend/managers/cdisplaytemplatemgr.h"
-#include "backend/managers/creferencemanager.h"
+#include "backend/managers/referencemanager.h"
-#include <boost/scoped_ptr.hpp>
-#include "util/ctoolclass.h"
-
-//Sword
+// Sword includes:
#include <swkey.h>
-//Qt
-#include <QRegExp>
-
using namespace Rendering;
@@ -229,8 +227,11 @@ const QString CTextRendering::renderKeyRange( const QString& start, const QStrin
//make sure the key given by highlightKey gets marked as current key
settings.highlight = (!highlightKey.isEmpty() ? (vk_start->key() == highlightKey) : false);
- /*TODO: We need to take care of linked verses if we render one or (esp) more modules
- If the verses 2,3,4,5 are linked to 1, it should be displayed as one entry with the caption 1-5 */
+ /**
+ \todo We need to take care of linked verses if we render one or
+ (esp) more modules. If the verses 2,3,4,5 are linked to 1,
+ it should be displayed as one entry with the caption 1-5.
+ */
if (vk_start->Chapter() == 0) { //range was 0:0-1:x, render 0:0 first and jump to 1:0
vk_start->Verse(0);
@@ -238,12 +239,12 @@ const QString CTextRendering::renderKeyRange( const QString& start, const QStrin
vk_start->Chapter(1);
vk_start->Verse(0);
}
- /// \bug Valgrind reports memory leak with allocation:
tree.append( new KeyTreeItem(vk_start->key(), modules, settings) );
ok = vk_start->next(CSwordVerseKey::UseVerse);
}
-
- return renderKeyTree(tree);
+ const QString renderedText = renderKeyTree(tree);
+ qDeleteAll(tree);
+ return renderedText;
}
return QString::null;
@@ -253,7 +254,9 @@ const QString CTextRendering::renderSingleKey( const QString& key, const QList<C
KeyTree tree;
tree.append( new KeyTreeItem(key, moduleList, settings) );
- return renderKeyTree(tree);
+ const QString renderedText = renderKeyTree(tree);
+ qDeleteAll(tree);
+ return renderedText;
}
diff --git a/src/backend/rendering/ctextrendering.h b/src/backend/rendering/ctextrendering.h
index 5d0531b..b6dd5e1 100644
--- a/src/backend/rendering/ctextrendering.h
+++ b/src/backend/rendering/ctextrendering.h
@@ -10,15 +10,12 @@
#ifndef CTEXTRENDERING_H
#define CTEXTRENDERING_H
-//BT includes
-class CSwordModuleInfo;
-//#include "util/autoptrvector.h"
-
-//QT includes
-#include <QString>
#include <QList>
+#include <QString>
+
class CSwordKey;
+class CSwordModuleInfo;
/**
* CTextRendering is BibleTime's place where the actual rendering takes place.