summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/backend/bookshelfmodel/btbookshelffiltermodel.cpp202
-rw-r--r--src/backend/bookshelfmodel/btbookshelffiltermodel.h127
-rw-r--r--src/backend/bookshelfmodel/btbookshelfmodel.cpp49
-rw-r--r--src/backend/bookshelfmodel/btbookshelfmodel.h7
-rw-r--r--src/backend/bookshelfmodel/btbookshelftreemodel.cpp196
-rw-r--r--src/backend/bookshelfmodel/btbookshelftreemodel.h26
-rw-r--r--src/backend/bookshelfmodel/btcheckstatefilterproxymodel.cpp70
-rw-r--r--src/backend/bookshelfmodel/btcheckstatefilterproxymodel.h53
-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.cpp46
-rw-r--r--src/backend/bookshelfmodel/btmodulenamefilterproxymodel.h37
-rw-r--r--src/backend/bookshelfmodel/categoryitem.cpp11
-rw-r--r--src/backend/bookshelfmodel/categoryitem.h8
-rw-r--r--src/backend/bookshelfmodel/distributionitem.cpp23
-rw-r--r--src/backend/bookshelfmodel/indexingitem.cpp37
-rw-r--r--src/backend/bookshelfmodel/indexingitem.h (renamed from src/backend/bookshelfmodel/distributionitem.h)25
-rw-r--r--src/backend/bookshelfmodel/item.cpp32
-rw-r--r--src/backend/bookshelfmodel/item.h43
-rw-r--r--src/backend/bookshelfmodel/languageitem.cpp11
-rw-r--r--src/backend/bookshelfmodel/languageitem.h12
-rw-r--r--src/backend/bookshelfmodel/moduleitem.cpp12
-rw-r--r--src/backend/bookshelfmodel/moduleitem.h19
-rw-r--r--src/backend/config/cbtconfig.cpp22
-rw-r--r--src/backend/config/cbtconfig.h8
-rw-r--r--src/backend/drivers/cswordlexiconmoduleinfo.cpp184
-rw-r--r--src/backend/drivers/cswordmoduleinfo.cpp42
-rw-r--r--src/backend/drivers/cswordmoduleinfo.h16
-rw-r--r--src/backend/filters/bt_teihtml.cpp108
-rw-r--r--src/backend/keys/cswordversekey.cpp6
-rw-r--r--src/backend/managers/cswordbackend.cpp41
-rw-r--r--src/backend/managers/cswordbackend.h8
-rw-r--r--src/backend/managers/referencemanager.h32
-rw-r--r--src/backend/rendering/cbookdisplay.cpp2
-rw-r--r--src/backend/rendering/centrydisplay.cpp6
-rw-r--r--src/backend/rendering/chtmlexportrendering.cpp7
-rw-r--r--src/bibletime.cpp92
-rw-r--r--src/bibletime.h56
-rw-r--r--src/bibletime_dbus.cpp3
-rw-r--r--src/bibletime_dbus_adaptor.cpp4
-rw-r--r--src/bibletime_dbus_adaptor.h4
-rw-r--r--src/bibletime_init.cpp119
-rw-r--r--src/bibletime_slots.cpp191
-rw-r--r--src/display-templates/Christmastide.tmpl151
-rw-r--r--src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.cpp9
-rw-r--r--src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.h4
-rw-r--r--src/frontend/bookshelfmanager/indexpage/btindexpage.cpp2
-rw-r--r--src/frontend/bookshelfmanager/indexpage/btindexpage.h1
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallpage.cpp2
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallpathdialog.cpp41
-rw-r--r--src/frontend/bookshelfmanager/installpage/btsourcewidget.cpp6
-rw-r--r--src/frontend/bookshelfmanager/instbackend.cpp22
-rw-r--r--src/frontend/bookshelfmanager/removepage/btremovepage.cpp141
-rw-r--r--src/frontend/bookshelfmanager/removepage/btremovepage.h44
-rw-r--r--src/frontend/bookshelfmanager/removepage/btremovepagetreemodel.cpp59
-rw-r--r--src/frontend/bookshelfmanager/removepage/btremovepagetreemodel.h30
-rw-r--r--src/frontend/btbookshelfdockwidget.cpp27
-rw-r--r--src/frontend/btbookshelfdockwidget.h12
-rw-r--r--src/frontend/btmenuview.cpp161
-rw-r--r--src/frontend/btmenuview.h55
-rw-r--r--src/frontend/cinfodisplay.cpp2
-rw-r--r--src/frontend/cmdiarea.cpp186
-rw-r--r--src/frontend/cmdiarea.h39
-rw-r--r--src/frontend/display/bthtmlreaddisplay.cpp16
-rw-r--r--src/frontend/display/bthtmlreaddisplay.h5
-rw-r--r--src/frontend/display/cdisplay.cpp4
-rw-r--r--src/frontend/display/cdisplay.h13
-rw-r--r--src/frontend/display/creaddisplay.cpp4
-rw-r--r--src/frontend/display/creaddisplay.h3
-rw-r--r--src/frontend/displaywindow/btdisplaysettingsbutton.cpp232
-rw-r--r--src/frontend/displaywindow/btdisplaysettingsbutton.h71
-rw-r--r--src/frontend/displaywindow/btmodulechooserbar.cpp134
-rw-r--r--src/frontend/displaywindow/btmodulechooserbar.h62
-rw-r--r--src/frontend/displaywindow/btmodulechooserbutton.cpp166
-rw-r--r--src/frontend/displaywindow/btmodulechooserbutton.h104
-rw-r--r--src/frontend/displaywindow/bttextwindowheader.cpp132
-rw-r--r--src/frontend/displaywindow/bttextwindowheader.h67
-rw-r--r--src/frontend/displaywindow/bttextwindowheaderwidget.cpp197
-rw-r--r--src/frontend/displaywindow/bttextwindowheaderwidget.h106
-rw-r--r--src/frontend/displaywindow/btwindowmodulechooser.h61
-rw-r--r--src/frontend/displaywindow/cbiblereadwindow.cpp72
-rw-r--r--src/frontend/displaywindow/cbookreadwindow.cpp11
-rw-r--r--src/frontend/displaywindow/cbuttons.cpp185
-rw-r--r--src/frontend/displaywindow/cbuttons.h75
-rw-r--r--src/frontend/displaywindow/cdisplaywindow.cpp205
-rw-r--r--src/frontend/displaywindow/cdisplaywindow.h206
-rw-r--r--src/frontend/displaywindow/clexiconreadwindow.cpp22
-rw-r--r--src/frontend/displaywindow/cmodulechooserbar.cpp126
-rw-r--r--src/frontend/displaywindow/cmodulechooserbar.h75
-rw-r--r--src/frontend/displaywindow/cmodulechooserbutton.cpp208
-rw-r--r--src/frontend/displaywindow/cmodulechooserbutton.h85
-rw-r--r--src/frontend/displaywindow/creadwindow.cpp32
-rw-r--r--src/frontend/displaywindow/creadwindow.h6
-rw-r--r--src/frontend/htmldialogs/btaboutdialog.cpp29
-rw-r--r--src/frontend/htmldialogs/bttabhtmldialog.cpp4
-rw-r--r--src/frontend/keychooser/clexiconkeychooser.cpp7
-rw-r--r--src/frontend/keychooser/versekeychooser/cbiblekeychooser.cpp14
-rw-r--r--src/frontend/keychooser/versekeychooser/ckeyreferencewidget.cpp12
-rw-r--r--src/frontend/keychooser/versekeychooser/ckeyreferencewidget.h4
-rw-r--r--src/frontend/mainindex/bookmarks/cbookmarkindex.cpp64
-rw-r--r--src/frontend/mainindex/bookmarks/cbookmarkindex.h29
-rw-r--r--src/frontend/profile/cprofile.cpp18
-rw-r--r--src/frontend/searchdialog/btsearchresultarea.cpp8
-rw-r--r--src/frontend/searchdialog/cmoduleresultview.cpp8
-rw-r--r--src/frontend/searchdialog/csearchdialog.cpp17
-rw-r--r--src/frontend/searchdialog/csearchdialog.h2
-rw-r--r--src/frontend/settingsdialogs/btshortcutseditor.cpp10
-rw-r--r--src/frontend/settingsdialogs/cacceleratorsettings.cpp2
-rw-r--r--src/main.cpp87
-rw-r--r--src/util/cresmgr.cpp13
-rw-r--r--src/util/cresmgr.h13
-rw-r--r--src/util/directory.cpp23
-rw-r--r--src/util/directory.h4
-rw-r--r--src/util/tool.h96
116 files changed, 3880 insertions, 2489 deletions
diff --git a/src/backend/bookshelfmodel/btbookshelffiltermodel.cpp b/src/backend/bookshelfmodel/btbookshelffiltermodel.cpp
new file mode 100644
index 0000000..b896556
--- /dev/null
+++ b/src/backend/bookshelfmodel/btbookshelffiltermodel.cpp
@@ -0,0 +1,202 @@
+/*********
+*
+* 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/btbookshelffiltermodel.h"
+
+#include "backend/bookshelfmodel/btbookshelfmodel.h"
+
+
+BtBookshelfFilterModel::BtBookshelfFilterModel(QObject *parent)
+ : QSortFilterProxyModel(parent), m_enabled(true),
+ m_nameFilterRole(BtBookshelfModel::ModuleNameRole), m_nameFilterColumn(0),
+ m_nameFilterCase(Qt::CaseInsensitive),
+ m_hiddenFilterRole(BtBookshelfModel::ModuleHiddenRole),
+ m_hiddenFilterColumn(0), m_showHidden(false), m_showShown(true),
+ m_categoryFilter(CSwordModuleInfo::AllCategories),
+ m_categoryFilterRole(BtBookshelfModel::ModuleCategoryRole),
+ m_categoryFilterColumn(0)
+{
+ // Intentionally empty
+}
+
+BtBookshelfFilterModel::~BtBookshelfFilterModel() {
+ // Intentionally empty
+}
+
+void BtBookshelfFilterModel::setEnabled(bool enable) {
+ if (enable == m_enabled) return;
+ m_enabled = enable;
+ invalidateFilter();
+}
+
+// Name filter:
+
+void BtBookshelfFilterModel::setNameFilterRole(int role) {
+ if (m_nameFilterRole == role) return;
+ m_nameFilterRole = role;
+ invalidateFilter();
+}
+
+void BtBookshelfFilterModel::setNameFilterKeyColumn(int column) {
+ if (m_nameFilterColumn == column) return;
+ m_nameFilterColumn = column;
+ invalidateFilter();
+}
+
+void BtBookshelfFilterModel::setNameFilterFixedString(const QString &filter) {
+ if (m_nameFilter == filter) return;
+ m_nameFilter = filter;
+ invalidateFilter();
+}
+
+void BtBookshelfFilterModel::setNameFilterCase(Qt::CaseSensitivity value) {
+ if (m_nameFilterCase == value) return;
+ m_nameFilterCase = value;
+ invalidateFilter();
+}
+
+// Hidden filter:
+
+void BtBookshelfFilterModel::setHiddenFilterRole(int role) {
+ if (m_hiddenFilterRole == role) return;
+ m_hiddenFilterRole = role;
+ invalidateFilter();
+}
+
+void BtBookshelfFilterModel::setHiddenFilterKeyColumn(int column) {
+ if (m_hiddenFilterColumn == column) return;
+ m_hiddenFilterColumn = column;
+ invalidateFilter();
+}
+
+void BtBookshelfFilterModel::setShowHidden(bool show) {
+ if (m_showHidden == show) return;
+ m_showHidden = show;
+ invalidateFilter();
+}
+
+void BtBookshelfFilterModel::setShowShown(bool show) {
+ if (m_showShown == show) return;
+ m_showShown = show;
+ invalidateFilter();
+}
+
+// Category filter:
+
+void BtBookshelfFilterModel::setCategoryFilterRole(int role) {
+ if (m_categoryFilterRole == role) return;
+ m_categoryFilterRole = role;
+ invalidateFilter();
+}
+
+void BtBookshelfFilterModel::setCategoryFilterKeyColumn(int column) {
+ if (m_categoryFilterColumn == column) return;
+ m_categoryFilterColumn = column;
+ invalidateFilter();
+}
+
+void BtBookshelfFilterModel::setShownCategories(
+ const CSwordModuleInfo::Categories &categories)
+{
+ if (m_categoryFilter == categories) return;
+ m_categoryFilter = categories;
+ invalidateFilter();
+}
+
+// Filtering:
+
+bool BtBookshelfFilterModel::filterAcceptsRow(int row,
+ const QModelIndex &parent) const
+{
+ if (!m_enabled) return true;
+
+ if (!hiddenFilterAcceptsRow(row, parent)) return false;
+ if (!nameFilterAcceptsRow(row, parent)) return false;
+ if (!categoryFilterAcceptsRow(row, parent)) return false;
+ return true;
+}
+
+bool BtBookshelfFilterModel::nameFilterAcceptsRow(int row, const QModelIndex &p)
+ const
+{
+ if (!m_enabled) return true;
+ if (m_nameFilter.isEmpty()) return true;
+
+ const QAbstractItemModel *m(sourceModel());
+ Q_ASSERT(m != 0);
+
+ QModelIndex itemIndex(m->index(row, m_nameFilterColumn, p));
+ int numChildren(m->rowCount(itemIndex));
+ if (numChildren == 0) {
+ QVariant data(m->data(itemIndex, m_nameFilterRole));
+ return data.toString().contains(m_nameFilter, m_nameFilterCase);
+ }
+ else {
+ for (int i(0); i < numChildren; i++) {
+ if (filterAcceptsRow(i, itemIndex)) return true;
+ }
+ return false;
+ }
+}
+
+bool BtBookshelfFilterModel::hiddenFilterAcceptsRow(int row,
+ const QModelIndex &parent) const
+{
+ if (m_showHidden && m_showShown) return true;
+
+ typedef Qt::CheckState CS;
+
+ QAbstractItemModel *m(sourceModel());
+
+ QModelIndex itemIndex(m->index(row, m_hiddenFilterColumn, parent));
+ int numChildren(m->rowCount(itemIndex));
+ if (numChildren == 0) {
+ if ((CS) m->data(itemIndex, m_hiddenFilterRole).toBool()) {
+ return m_showHidden;
+ }
+ else {
+ return m_showShown;
+ }
+ }
+ else {
+ for (int i(0); i < numChildren; i++) {
+ if (filterAcceptsRow(i, itemIndex)) return true;
+ }
+ return false;
+ }
+}
+
+bool BtBookshelfFilterModel::categoryFilterAcceptsRow(int row,
+ const QModelIndex &parent) const
+{
+ if (m_categoryFilter == CSwordModuleInfo::AllCategories) return true;
+
+ QAbstractItemModel *m(sourceModel());
+
+ QModelIndex itemIndex(m->index(row, m_categoryFilterColumn, parent));
+ int numChildren(m->rowCount(itemIndex));
+ if (numChildren == 0) {
+ int cat = m->data(itemIndex, m_categoryFilterRole).toInt();
+ if (m_categoryFilter.testFlag((CSwordModuleInfo::Category) cat)) {
+ return true;
+ }
+ else {
+ return false;
+ }
+ }
+ else {
+ for (int i(0); i < numChildren; i++) {
+ if (filterAcceptsRow(i, itemIndex)) return true;
+ }
+ return false;
+ }
+}
diff --git a/src/backend/bookshelfmodel/btbookshelffiltermodel.h b/src/backend/bookshelfmodel/btbookshelffiltermodel.h
new file mode 100644
index 0000000..e440c69
--- /dev/null
+++ b/src/backend/bookshelfmodel/btbookshelffiltermodel.h
@@ -0,0 +1,127 @@
+/*********
+*
+* 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 BTBOOKSHELFFILTERMODEL_H
+#define BTBOOKSHELFFILTERMODEL_H
+
+#include <QSortFilterProxyModel>
+
+#include "backend/drivers/cswordmoduleinfo.h"
+
+
+class BtBookshelfFilterModel: public QSortFilterProxyModel {
+ Q_OBJECT
+ public:
+ BtBookshelfFilterModel(QObject *parent = 0);
+ virtual ~BtBookshelfFilterModel();
+
+ // Common methods:
+ inline bool enabled() const {
+ return m_enabled;
+ }
+
+ virtual bool filterAcceptsRow(int row, const QModelIndex &parent) const;
+
+ // Name filter:
+ inline int nameFilterRole() const {
+ return m_nameFilterRole;
+ }
+
+ inline int nameFilterKeyColumn() const {
+ return m_nameFilterColumn;
+ }
+
+ inline const QString &nameFilter() const {
+ return m_nameFilter;
+ }
+
+ inline const Qt::CaseSensitivity nameFilterCase() const {
+ return m_nameFilterCase;
+ }
+
+ // Hidden filter:
+ int hiddenFilterRole() const {
+ return m_hiddenFilterRole;
+ }
+
+ int hiddenFilterKeyColumn() const {
+ return m_hiddenFilterColumn;
+ }
+
+ inline bool showHidden() const {
+ return m_showHidden;
+ }
+
+ inline bool showShown() const {
+ return m_showShown;
+ }
+
+ // Category filter:
+ int categoryFilterRole() const {
+ return m_categoryFilterRole;
+ }
+
+ int categoryFilterKeyColumn() const {
+ return m_categoryFilterColumn;
+ }
+
+ inline CSwordModuleInfo::Categories shownCategories() const {
+ return m_categoryFilter;
+ }
+
+ public slots:
+ void setEnabled(bool enable);
+
+ // Name filter:
+ void setNameFilterRole(int role);
+ void setNameFilterKeyColumn(int column);
+ void setNameFilterFixedString(const QString &nameFilter);
+ void setNameFilterCase(Qt::CaseSensitivity value);
+
+ // Hidden filter:
+ void setHiddenFilterRole(int role);
+ void setHiddenFilterKeyColumn(int column);
+ void setShowHidden(bool show);
+ void setShowShown(bool show);
+
+ // Category filter:
+ void setCategoryFilterRole(int role);
+ void setCategoryFilterKeyColumn(int column);
+ void setShownCategories(const CSwordModuleInfo::Categories &categories);
+
+ protected:
+ bool nameFilterAcceptsRow(int row, const QModelIndex &parent) const;
+ bool hiddenFilterAcceptsRow(int row, const QModelIndex &parent) const;
+ bool categoryFilterAcceptsRow(int row, const QModelIndex &parent) const;
+
+ protected:
+ bool m_enabled;
+
+ // Name filter:
+ QString m_nameFilter;
+ int m_nameFilterRole;
+ int m_nameFilterColumn;
+ Qt::CaseSensitivity m_nameFilterCase;
+
+ // Hidden filter:
+ int m_hiddenFilterRole;
+ int m_hiddenFilterColumn;
+ bool m_showHidden;
+ bool m_showShown;
+
+ // Categories filter:
+ CSwordModuleInfo::Categories m_categoryFilter;
+ int m_categoryFilterRole;
+ int m_categoryFilterColumn;
+};
+
+#endif // BTBOOKSHELFFILTERMODEL_H
diff --git a/src/backend/bookshelfmodel/btbookshelfmodel.cpp b/src/backend/bookshelfmodel/btbookshelfmodel.cpp
index 6882b90..ccbb5a5 100644
--- a/src/backend/bookshelfmodel/btbookshelfmodel.cpp
+++ b/src/backend/bookshelfmodel/btbookshelfmodel.cpp
@@ -27,6 +27,8 @@ BtBookshelfModel::~BtBookshelfModel() {
}
int BtBookshelfModel::rowCount(const QModelIndex &parent) const {
+ if (parent.isValid()) return 0;
+
return m_data.size();
}
@@ -44,6 +46,12 @@ QVariant BtBookshelfModel::data(CSwordModuleInfo *module, int role) const {
return QVariant(); /// \todo Unimplemented
case ModuleHiddenRole:
return module->isHidden();
+ case ModuleInstallPathRole:
+ return module->config(CSwordModuleInfo::AbsoluteDataPath);
+ case ModuleHasIndexRole:
+ return module->hasIndex();
+ case ModuleIndexSizeRole:
+ return (qulonglong) module->indexSize();
default:
return QVariant();
}
@@ -73,8 +81,7 @@ 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)
- {
+ && 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
@@ -97,25 +104,29 @@ QIcon BtBookshelfModel::moduleIcon(const CSwordModuleInfo *m) {
case CSwordModuleInfo::Bibles:
if (module->isLocked()) {
return DU::getIcon(CResMgr::modules::bible::icon_locked);
- } else {
+ }
+ else {
return DU::getIcon(CResMgr::modules::bible::icon_unlocked);
}
case CSwordModuleInfo::Commentaries:
if (module->isLocked()) {
return DU::getIcon(CResMgr::modules::commentary::icon_locked);
- } else {
+ }
+ else {
return DU::getIcon(CResMgr::modules::commentary::icon_unlocked);
}
case CSwordModuleInfo::Lexicons:
if (module->isLocked()) {
return DU::getIcon(CResMgr::modules::lexicon::icon_locked);
- } else {
+ }
+ else {
return DU::getIcon(CResMgr::modules::lexicon::icon_unlocked);
}
case CSwordModuleInfo::Books:
if (module->isLocked()) {
return DU::getIcon(CResMgr::modules::book::icon_locked);
- } else {
+ }
+ else {
return DU::getIcon(CResMgr::modules::book::icon_unlocked);
}
case CSwordModuleInfo::Cult:
@@ -204,6 +215,8 @@ void BtBookshelfModel::addModule(CSwordModuleInfo * const module) {
m_data.append(module);
connect(module, SIGNAL(hiddenChanged(bool)),
this, SLOT(moduleHidden(bool)));
+ connect(module, SIGNAL(hasIndexChanged(bool)),
+ this, SLOT(moduleIndexed(bool)));
endInsertRows();
}
@@ -227,33 +240,34 @@ void BtBookshelfModel::addModules(const QSet<CSwordModuleInfo *> &modules) {
m_data.append(module);
connect(module, SIGNAL(hiddenChanged(bool)),
this, SLOT(moduleHidden(bool)));
+ connect(module, SIGNAL(hasIndexChanged(bool)),
+ this, SLOT(moduleIndexed(bool)));
}
endInsertRows();
}
void BtBookshelfModel::removeModule(CSwordModuleInfo * const module,
- bool destroy)
-{
+ bool destroy) {
const int index(m_data.indexOf(module));
if (index == -1) return;
beginRemoveRows(QModelIndex(), index, index);
disconnect(module, SIGNAL(hiddenChanged(bool)),
this, SLOT(moduleHidden(bool)));
+ disconnect(module, SIGNAL(hasIndexChanged(bool)),
+ this, SLOT(moduleIndexed(bool)));
m_data.removeAt(index);
endRemoveRows();
if (destroy) delete module;
}
void BtBookshelfModel::removeModules(const QList<CSwordModuleInfo *> &modules,
- bool destroy)
-{
+ bool destroy) {
removeModules(modules.toSet(), destroy);
}
void BtBookshelfModel::removeModules(const QSet<CSwordModuleInfo *> &modules,
- bool destroy)
-{
+ bool destroy) {
// This is inefficient, since signals are emitted for each removed module:
Q_FOREACH(CSwordModuleInfo *module, modules) {
removeModule(module, destroy);
@@ -270,7 +284,16 @@ CSwordModuleInfo* BtBookshelfModel::getModule(const QString &name) const {
void BtBookshelfModel::moduleHidden(bool) {
Q_ASSERT(qobject_cast<CSwordModuleInfo*>(sender()) != 0);
- CSwordModuleInfo *module(static_cast<CSwordModuleInfo*>(sender()));
+ moduleDataChanged(static_cast<CSwordModuleInfo*>(sender()));
+}
+
+void BtBookshelfModel::moduleIndexed(bool) {
+ Q_ASSERT(qobject_cast<CSwordModuleInfo*>(sender()) != 0);
+
+ moduleDataChanged(static_cast<CSwordModuleInfo*>(sender()));
+}
+
+void BtBookshelfModel::moduleDataChanged(CSwordModuleInfo *module) {
Q_ASSERT(m_data.count(module) == 1);
QModelIndex i(index(m_data.indexOf(module), 0));
diff --git a/src/backend/bookshelfmodel/btbookshelfmodel.h b/src/backend/bookshelfmodel/btbookshelfmodel.h
index 16fdb13..735c655 100644
--- a/src/backend/bookshelfmodel/btbookshelfmodel.h
+++ b/src/backend/bookshelfmodel/btbookshelfmodel.h
@@ -28,6 +28,9 @@ class BtBookshelfModel: public QAbstractListModel {
ModuleCategoryRole = Qt::UserRole + 1,
ModuleLanguageRole = Qt::UserRole + 2,
ModuleHiddenRole = Qt::UserRole + 3,
+ ModuleInstallPathRole = Qt::UserRole + 4,
+ ModuleHasIndexRole = Qt::UserRole + 5,
+ ModuleIndexSizeRole = Qt::UserRole + 6,
UserRole = Qt::UserRole + 100
};
@@ -71,6 +74,10 @@ class BtBookshelfModel: public QAbstractListModel {
protected slots:
void moduleHidden(bool hidden);
+ void moduleIndexed(bool indexed);
+
+ protected:
+ void moduleDataChanged(CSwordModuleInfo *module);
protected:
QList<CSwordModuleInfo *> m_data;
diff --git a/src/backend/bookshelfmodel/btbookshelftreemodel.cpp b/src/backend/bookshelfmodel/btbookshelftreemodel.cpp
index 5be1aec..a2a988c 100644
--- a/src/backend/bookshelfmodel/btbookshelftreemodel.cpp
+++ b/src/backend/bookshelfmodel/btbookshelftreemodel.cpp
@@ -14,7 +14,7 @@
#include <QSet>
#include "backend/bookshelfmodel/categoryitem.h"
-#include "backend/bookshelfmodel/distributionitem.h"
+#include "backend/bookshelfmodel/indexingitem.h"
#include "backend/bookshelfmodel/languageitem.h"
#include "backend/bookshelfmodel/moduleitem.h"
@@ -30,8 +30,7 @@ BtBookshelfTreeModel::BtBookshelfTreeModel(QObject *parent)
BtBookshelfTreeModel::BtBookshelfTreeModel(const Grouping &g, QObject *parent)
: QAbstractItemModel(parent), m_sourceModel(0), m_rootItem(new RootItem),
- m_groupingOrder(g), m_defaultChecked(MODULE_HIDDEN), m_checkable(false)
-{
+ m_groupingOrder(g), m_defaultChecked(MODULE_HIDDEN), m_checkable(false) {
// Intentionally empty
}
@@ -44,6 +43,8 @@ int BtBookshelfTreeModel::rowCount(const QModelIndex &parent) const {
}
int BtBookshelfTreeModel::columnCount(const QModelIndex &parent) const {
+ Q_UNUSED(parent);
+
return 1;
}
@@ -56,7 +57,7 @@ QModelIndex BtBookshelfTreeModel::index(int row, int column,
if (!hasIndex(row, column, parent)) return QModelIndex();
Item *parentItem(getItem(parent));
- Item *childItem(parentItem->childAt(row));
+ Item *childItem(parentItem->children().at(row));
if (childItem != 0) {
return createIndex(row, column, childItem);
}
@@ -87,55 +88,56 @@ QVariant BtBookshelfTreeModel::data(const QModelIndex &index, int role) const {
Item *i(static_cast<Item*>(index.internalPointer()));
Q_ASSERT(i != 0);
switch (role) {
- case Qt::DisplayRole:
- 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:
- if (i->type() == Item::ITEM_MODULE) {
- return parentData(static_cast<ModuleItem *>(i), role);
- } else {
- return i->icon();
- }
case BtBookshelfModel::ModulePointerRole:
+ /* This case is just an optimization. */
if (i->type() == Item::ITEM_MODULE) {
ModuleItem *mi(static_cast<ModuleItem *>(i));
return qVariantFromValue((void*) mi->moduleInfo());
}
return 0;
+ case Qt::DisplayRole:
+ case Qt::DecorationRole:
case BtBookshelfModel::ModuleHiddenRole:
- return i->isHidden();
default:
if (i->type() == Item::ITEM_MODULE) {
- return parentData(static_cast<ModuleItem *>(i), role);
+ ModuleItem *item(static_cast<ModuleItem *>(i));
+ CSwordModuleInfo* m(item->moduleInfo());
+ return data(m, role);
+ }
+ else {
+ return i->data(role);
}
- break;
}
return QVariant();
}
+QVariant BtBookshelfTreeModel::data(CSwordModuleInfo *module, int role) const {
+ Q_ASSERT(m_sourceIndexMap.contains(module));
+ return m_sourceModel->data(m_sourceIndexMap.value(module), role);
+}
+
bool BtBookshelfTreeModel::setData(const QModelIndex &itemIndex,
const QVariant &value,
int role) {
typedef QPair<Item *, QModelIndex> IP;
Qt::CheckState newState;
- if (role == BtBookshelfModel::ModuleHiddenRole) {
- newState = value.toBool() ? Qt::Checked : Qt::Unchecked;
- } else if (role == Qt::CheckStateRole) {
+ if (role == Qt::CheckStateRole) {
bool ok;
newState = (Qt::CheckState) value.toInt(&ok);
- if (!ok || newState == Qt::PartiallyChecked) return false;
- } else {
+ if (!ok) return false;
+ }
+ else {
return false;
}
+ // Handle partially checked as checked here in setData():
+ if (newState == Qt::PartiallyChecked) newState = Qt::Checked;
+
Item *item(static_cast<Item*>(itemIndex.internalPointer()));
Q_ASSERT(item != 0);
if (item->checkState() == newState) return false;
@@ -148,9 +150,18 @@ bool BtBookshelfTreeModel::setData(const QModelIndex &itemIndex,
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 {
+ ModuleItem *mItem(static_cast<ModuleItem*>(item));
+ CSwordModuleInfo *mInfo(mItem->moduleInfo());
+ if (newState == Qt::Checked) {
+ m_checkedModulesCache.insert(mInfo);
+ emit moduleChecked(mInfo, true);
+ }
+ else {
+ m_checkedModulesCache.remove(mInfo);
+ emit moduleChecked(mInfo, false);
+ }
+ }
+ 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)));
@@ -207,6 +218,7 @@ void BtBookshelfTreeModel::setSourceModel(QAbstractItemModel *sourceModel) {
delete m_rootItem;
m_modules.clear();
m_sourceIndexMap.clear();
+ m_checkedModulesCache.clear();
m_rootItem = new RootItem;
endRemoveRows();
}
@@ -225,6 +237,8 @@ void BtBookshelfTreeModel::setSourceModel(QAbstractItemModel *sourceModel) {
typedef BtBookshelfModel::ModuleRole MRole;
static const MRole HR(BtBookshelfModel::ModuleHiddenRole);
static const MRole PR(BtBookshelfModel::ModulePointerRole);
+ static const MRole IR(BtBookshelfModel::ModuleHasIndexRole);
+
QModelIndex moduleIndex(sourceModel->index(i, 0));
CSwordModuleInfo *module(
static_cast<CSwordModuleInfo *>(
@@ -235,7 +249,11 @@ void BtBookshelfTreeModel::setSourceModel(QAbstractItemModel *sourceModel) {
bool checked;
if (m_defaultChecked == MODULE_HIDDEN) {
checked = !sourceModel->data(moduleIndex, HR).toBool();
- } else {
+ }
+ else if (m_defaultChecked == MODULE_INDEXED) {
+ checked = !sourceModel->data(moduleIndex, IR).toBool();
+ }
+ else {
checked = (m_defaultChecked == CHECKED);
}
m_sourceIndexMap[module] = moduleIndex;
@@ -249,32 +267,28 @@ void BtBookshelfTreeModel::setGroupingOrder(const Grouping &groupingOrder) {
m_groupingOrder = groupingOrder;
if (m_sourceModel != 0) {
- QSet<CSwordModuleInfo*> checked(checkedModules().toSet());
+ QSet<CSwordModuleInfo*> checked(m_checkedModulesCache);
+ m_checkedModulesCache.clear();
+
beginRemoveRows(QModelIndex(), 0, m_rootItem->children().size() - 1);
delete m_rootItem;
m_modules.clear();
m_rootItem = new RootItem;
endRemoveRows();
- BtBookshelfModel *m(dynamic_cast<BtBookshelfModel*>(m_sourceModel));
- if (m != 0) {
- Q_FOREACH(CSwordModuleInfo *module, m->modules()) {
- addModule(module, checked.contains(module));
- }
- }
- else {
- for (int i(0); i < m_sourceModel->rowCount(); i++) {
- CSwordModuleInfo *module(
- static_cast<CSwordModuleInfo *>(
- m_sourceModel->data(
- m_sourceModel->index(i, 0),
- BtBookshelfModel::ModulePointerRole
- ).value<void*>()
- )
- );
- Q_ASSERT(module != 0);
- addModule(module, checked.contains(module));
- }
+ for (int i(0); i < m_sourceModel->rowCount(); i++) {
+ QModelIndex sourceIndex(m_sourceModel->index(i, 0));
+ CSwordModuleInfo *module(
+ static_cast<CSwordModuleInfo *>(
+ m_sourceModel->data(
+ sourceIndex,
+ BtBookshelfModel::ModulePointerRole
+ ).value<void*>()
+ )
+ );
+ Q_ASSERT(module != 0);
+ m_sourceIndexMap[module] = sourceIndex;
+ addModule(module, checked.contains(module));
}
}
}
@@ -282,43 +296,24 @@ void BtBookshelfTreeModel::setGroupingOrder(const Grouping &groupingOrder) {
void BtBookshelfTreeModel::setCheckable(bool checkable) {
if (m_checkable == checkable) return;
m_checkable = checkable;
- if (m_sourceModel != 0) {
- QModelIndexList queue;
- queue.append(QModelIndex());
- do {
- QModelIndex parent(queue.takeFirst());
- int numChildren(rowCount(parent));
- emit dataChanged(index(0, 0, parent),
- index(numChildren - 1, 0, parent));
- for (int i(0); i < numChildren; i++) {
- QModelIndex childIndex(index(i, 0, parent));
- if (rowCount(childIndex) > 0) {
- queue.append(childIndex);
- }
+ if (m_sourceModel == 0) return;
+
+ // Notify views that flags changed for all items:
+ QModelIndexList queue;
+ queue.append(QModelIndex());
+ do {
+ QModelIndex parent(queue.takeFirst());
+ int numChildren(rowCount(parent));
+ emit dataChanged(index(0, 0, parent),
+ index(numChildren - 1, 0, parent));
+ for (int i(0); i < numChildren; i++) {
+ QModelIndex childIndex(index(i, 0, parent));
+ if (rowCount(childIndex) > 0) {
+ queue.append(childIndex);
}
}
- while (!queue.isEmpty());
- }
-}
-
-QList<CSwordModuleInfo*> BtBookshelfTreeModel::checkedModules() const {
- typedef ModuleItemMap::const_iterator MMCI;
-
- QList<CSwordModuleInfo*> modules;
- for (MMCI it(m_modules.constBegin()); it != m_modules.constEnd(); it++) {
- if (it.value()->checkState() == Qt::Checked) {
- modules.append(it.key());
- }
}
- 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);
+ while (!queue.isEmpty());
}
void BtBookshelfTreeModel::addModule(CSwordModuleInfo *module, bool checked) {
@@ -344,28 +339,36 @@ void BtBookshelfTreeModel::addModule(CSwordModuleInfo *module,
if (!intermediateGrouping.empty()) {
QModelIndex newIndex;
switch (intermediateGrouping.front()) {
- case GROUP_DISTRIBUTION:
- newIndex = getGroup<DistributionItem>(module, parentIndex);
- break;
case GROUP_CATEGORY:
newIndex = getGroup<CategoryItem>(module, parentIndex);
break;
case GROUP_LANGUAGE:
newIndex = getGroup<LanguageItem>(module, parentIndex);
break;
+ case GROUP_INDEXING:
+ newIndex = getGroup<IndexingItem>(module, parentIndex);
+ break;
}
intermediateGrouping.pop_front();
addModule(module, newIndex, intermediateGrouping, checked);
}
else {
Item *parentItem(getItem(parentIndex));
- ModuleItem *newItem(new ModuleItem(module));
+ ModuleItem *newItem(new ModuleItem(module, this));
newItem->setCheckState(checked ? Qt::Checked : Qt::Unchecked);
const int newIndex(parentItem->indexFor(newItem));
+
+ // Actually do the insertion:
beginInsertRows(parentIndex, newIndex, newIndex);
parentItem->insertChild(newIndex, newItem);
m_modules.insert(module, newItem);
+ if (checked) {
+ // Add to checked modules cache
+ m_checkedModulesCache.insert(module);
+ }
endInsertRows();
+
+ // Reset parent item check states, if needed:
resetParentCheckStates(parentIndex);
}
}
@@ -383,13 +386,18 @@ void BtBookshelfTreeModel::removeModule(CSwordModuleInfo *module) {
Q_ASSERT(i != 0);
Q_ASSERT(i->parent() != 0);
- // Remove item:
+ // Calculate item indexes:
int index(i->childIndex());
QModelIndex parentIndex(getIndex(i->parent()));
+
+ // Actually remove the item:
beginRemoveRows(parentIndex, index, index);
- i->parent()->deleteChildAt(index);
+ delete i->parent()->children().takeAt(index);
m_modules.remove(module);
+ m_checkedModulesCache.remove(module);
endRemoveRows();
+
+ // Reset parent item check states, if needed:
resetParentCheckStates(parentIndex);
}
@@ -431,7 +439,7 @@ void BtBookshelfTreeModel::resetParentCheckStates(QModelIndex parentIndex) {
bool haveCheckedChildren(false);
bool haveUncheckedChildren(false);
for (int i(0); i < parentItem->children().size(); i++) {
- Qt::CheckState state(parentItem->childAt(i)->checkState());
+ Qt::CheckState state(parentItem->children().at(i)->checkState());
if (state == Qt::PartiallyChecked) {
haveCheckedChildren = true;
haveUncheckedChildren = true;
@@ -491,7 +499,8 @@ void BtBookshelfTreeModel::moduleDataChanged(const QModelIndex &topLeft,
do {
itemIndex = itemIndex.parent();
emit dataChanged(itemIndex, itemIndex);
- } while (itemIndex.isValid());
+ }
+ while (itemIndex.isValid());
}
}
@@ -500,6 +509,7 @@ void BtBookshelfTreeModel::moduleInserted(const QModelIndex &parent, int start,
typedef BtBookshelfModel BM;
static const BM::ModuleRole PR(BM::ModulePointerRole);
static const BM::ModuleRole HR(BM::ModuleHiddenRole);
+ static const BM::ModuleRole IR(BM::ModuleHasIndexRole);
for (int i(start); i <= end; i++) {
QModelIndex moduleIndex(m_sourceModel->index(i, 0, parent));
@@ -509,7 +519,11 @@ void BtBookshelfTreeModel::moduleInserted(const QModelIndex &parent, int start,
bool checked;
if (m_defaultChecked == MODULE_HIDDEN) {
checked = !m_sourceModel->data(moduleIndex, HR).toBool();
- } else {
+ }
+ else if (m_defaultChecked == MODULE_INDEXED) {
+ checked = !m_sourceModel->data(moduleIndex, IR).toBool();
+ }
+ else {
checked = (m_defaultChecked == CHECKED);
}
m_sourceIndexMap[module] = moduleIndex;
diff --git a/src/backend/bookshelfmodel/btbookshelftreemodel.h b/src/backend/bookshelfmodel/btbookshelftreemodel.h
index e73b154..47ce672 100644
--- a/src/backend/bookshelfmodel/btbookshelftreemodel.h
+++ b/src/backend/bookshelfmodel/btbookshelftreemodel.h
@@ -15,8 +15,10 @@
#include <QAbstractItemModel>
+#include <QList>
#include <QMap>
#include <QPersistentModelIndex>
+#include <QSet>
#include "backend/bookshelfmodel/btbookshelfmodel.h"
#include "backend/bookshelfmodel/item.h"
@@ -39,8 +41,17 @@ class BtBookshelfTreeModel: public QAbstractItemModel {
CheckStateRole = BtBookshelfModel::UserRole,
UserRole = BtBookshelfModel::UserRole + 100
};
- enum Group { GROUP_CATEGORY = 0, GROUP_LANGUAGE, GROUP_DISTRIBUTION };
- enum CheckedBehavior { CHECKED, UNCHECKED, MODULE_HIDDEN };
+ enum Group {
+ GROUP_CATEGORY = 0,
+ GROUP_LANGUAGE = 1,
+ GROUP_INDEXING
+ };
+ enum CheckedBehavior {
+ CHECKED, /**< Check all added modules by default. */
+ UNCHECKED, /**< Uncheck all added modules by default. */
+ MODULE_HIDDEN, /**< By default, check only added modules that are not hidden. */
+ MODULE_INDEXED /**< By default, check only added modules that are indexed. */
+ };
typedef QList<Group> Grouping;
BtBookshelfTreeModel(QObject *parent = 0);
@@ -56,7 +67,8 @@ class BtBookshelfTreeModel: public QAbstractItemModel {
const QModelIndex &parent = QModelIndex())
const;
virtual QModelIndex parent(const QModelIndex &index) const;
- virtual QVariant data(const QModelIndex &index, int role) const;
+ virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
+ QVariant data(CSwordModuleInfo *module, int role = Qt::DisplayRole) const;
virtual Qt::ItemFlags flags(const QModelIndex &index) const;
virtual QVariant headerData(int section, Qt::Orientation orientation,
int role = Qt::DisplayRole) const;
@@ -82,7 +94,9 @@ class BtBookshelfTreeModel: public QAbstractItemModel {
return m_defaultChecked;
}
- QList<CSwordModuleInfo*> checkedModules() const;
+ inline const QSet<CSwordModuleInfo*> &checkedModules() const {
+ return m_checkedModulesCache;
+ }
protected:
QVariant parentData(BookshelfModel::ModuleItem *item, int role) const;
@@ -100,7 +114,7 @@ class BtBookshelfTreeModel: public QAbstractItemModel {
QModelIndex parentIndex) {
BookshelfModel::Item *parentItem(getItem(parentIndex));
int groupIndex;
- T *groupItem(parentItem->getGroupItem<T>(module, &groupIndex));
+ T *groupItem(parentItem->getGroupItem<T>(module, groupIndex));
if (groupItem == 0) {
groupItem = new T(module);
@@ -129,6 +143,8 @@ class BtBookshelfTreeModel: public QAbstractItemModel {
Grouping m_groupingOrder;
CheckedBehavior m_defaultChecked;
bool m_checkable;
+
+ QSet<CSwordModuleInfo*> m_checkedModulesCache;
};
QDataStream &operator<<(QDataStream &os, const BtBookshelfTreeModel::Grouping &o);
diff --git a/src/backend/bookshelfmodel/btcheckstatefilterproxymodel.cpp b/src/backend/bookshelfmodel/btcheckstatefilterproxymodel.cpp
deleted file mode 100644
index 184bd39..0000000
--- a/src/backend/bookshelfmodel/btcheckstatefilterproxymodel.cpp
+++ /dev/null
@@ -1,70 +0,0 @@
-/*********
-*
-* 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/btcheckstatefilterproxymodel.h"
-
-BtCheckStateFilterProxyModel::BtCheckStateFilterProxyModel(QObject *parent)
- : QSortFilterProxyModel(parent), m_enabled(true), m_showChecked(true),
- m_showUnchecked(false), m_showPartiallyChecked(true) {
- setFilterRole(Qt::CheckStateRole);
-}
-
-BtCheckStateFilterProxyModel::~BtCheckStateFilterProxyModel() {
- // Intentionally empty
-}
-
-void BtCheckStateFilterProxyModel::setEnabled(bool enable) {
- if (enable == m_enabled) return;
- m_enabled = enable;
- invalidateFilter();
-}
-
-void BtCheckStateFilterProxyModel::setShowChecked(bool show) {
- if (m_showChecked == show) return;
- m_showChecked = show;
- invalidateFilter();
-}
-
-void BtCheckStateFilterProxyModel::setShowUnchecked(bool show) {
- if (m_showUnchecked == show) return;
- m_showUnchecked = show;
- invalidateFilter();
-}
-
-void BtCheckStateFilterProxyModel::setShowPartiallyChecked(bool show) {
- if (m_showPartiallyChecked == show) return;
- m_showPartiallyChecked = show;
- invalidateFilter();
-}
-
-bool BtCheckStateFilterProxyModel::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));
- CS state((CS) m->data(i, filterRole()).toInt());
- Q_ASSERT(state == Qt::Checked || state == Qt::Unchecked ||
- state == Qt::PartiallyChecked);
- if (state == Qt::Unchecked) {
- return m_showUnchecked;
- }
- else if (state == Qt::Checked) {
- return m_showChecked;
- }
- else {
- return m_showPartiallyChecked;
- }
-}
diff --git a/src/backend/bookshelfmodel/btcheckstatefilterproxymodel.h b/src/backend/bookshelfmodel/btcheckstatefilterproxymodel.h
deleted file mode 100644
index 78d324d..0000000
--- a/src/backend/bookshelfmodel/btcheckstatefilterproxymodel.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*********
-*
-* 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 BTCHECKSTATEFILTERPROXYMODEL_H
-#define BTCHECKSTATEFILTERPROXYMODEL_H
-
-#include <QSortFilterProxyModel>
-
-class BtCheckStateFilterProxyModel: public QSortFilterProxyModel {
- Q_OBJECT
- public:
- BtCheckStateFilterProxyModel(QObject *parent = 0);
- virtual ~BtCheckStateFilterProxyModel();
-
- inline bool enabled() const {
- return m_enabled;
- }
- void setEnabled(bool enable);
-
- inline bool showChecked() const {
- return m_showChecked;
- }
- void setShowChecked(bool show);
-
- inline bool showUnchecked() const {
- return m_showUnchecked;
- }
- void setShowUnchecked(bool show);
-
- inline bool showPartiallyChecked() const {
- return m_showPartiallyChecked;
- }
- void setShowPartiallyChecked(bool show);
-
- virtual bool filterAcceptsRow(int row, const QModelIndex &parent) const;
-
- protected:
- bool m_enabled;
- bool m_showChecked;
- bool m_showUnchecked;
- bool m_showPartiallyChecked;
-};
-
-#endif // BTSELECTEDMODULESBOOKSHELFPROXYMODEL_H
diff --git a/src/backend/bookshelfmodel/btmodulecategoryfilterproxymodel.cpp b/src/backend/bookshelfmodel/btmodulecategoryfilterproxymodel.cpp
deleted file mode 100644
index a969218..0000000
--- a/src/backend/bookshelfmodel/btmodulecategoryfilterproxymodel.cpp
+++ /dev/null
@@ -1,71 +0,0 @@
-/*********
-*
-* 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
deleted file mode 100644
index 7517986..0000000
--- a/src/backend/bookshelfmodel/btmodulecategoryfilterproxymodel.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*********
-*
-* 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
deleted file mode 100644
index 3a50300..0000000
--- a/src/backend/bookshelfmodel/btmodulehiddenfilterproxymodel.cpp
+++ /dev/null
@@ -1,61 +0,0 @@
-/*********
-*
-* 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
deleted file mode 100644
index 8871930..0000000
--- a/src/backend/bookshelfmodel/btmodulehiddenfilterproxymodel.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*********
-*
-* 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
deleted file mode 100644
index 1d20cdb..0000000
--- a/src/backend/bookshelfmodel/btmodulenamefilterproxymodel.cpp
+++ /dev/null
@@ -1,46 +0,0 @@
-/*********
-*
-* 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/btmodulenamefilterproxymodel.h"
-
-#include "backend/bookshelfmodel/btbookshelfmodel.h"
-
-
-BtModuleNameFilterProxyModel::BtModuleNameFilterProxyModel(QObject *parent)
- : QSortFilterProxyModel(parent), m_enabled(true) {
- setFilterRole(BtBookshelfModel::ModuleNameRole);
- setFilterCaseSensitivity(Qt::CaseInsensitive);
-}
-
-BtModuleNameFilterProxyModel::~BtModuleNameFilterProxyModel() {
- // Intentionally empty
-}
-
-bool BtModuleNameFilterProxyModel::filterAcceptsRow(int row,
- const QModelIndex &p) const {
- if (!m_enabled) return true;
-
- const QAbstractItemModel *m(sourceModel());
- Q_ASSERT(m != 0);
-
- QModelIndex itemIndex(m->index(row, filterKeyColumn(), p));
- int numChildren(m->rowCount(itemIndex));
- if (numChildren == 0) {
- return QSortFilterProxyModel::filterAcceptsRow(row, p);
- }
- else {
- for (int i(0); i < numChildren; i++) {
- if (filterAcceptsRow(i, itemIndex)) return true;
- }
- return false;
- }
-}
diff --git a/src/backend/bookshelfmodel/btmodulenamefilterproxymodel.h b/src/backend/bookshelfmodel/btmodulenamefilterproxymodel.h
deleted file mode 100644
index 9b24dd6..0000000
--- a/src/backend/bookshelfmodel/btmodulenamefilterproxymodel.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/*********
-*
-* 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 BTMODULENAMEFILTERPROXYMODEL_H
-#define BTMODULENAMEFILTERPROXYMODEL_H
-
-#include <QSortFilterProxyModel>
-
-
-class BtModuleNameFilterProxyModel: public QSortFilterProxyModel {
- Q_OBJECT
- public:
- BtModuleNameFilterProxyModel(QObject *parent = 0);
- virtual ~BtModuleNameFilterProxyModel();
-
- inline bool enabled() const {
- return m_enabled;
- }
- void setEnabled(bool enable);
-
- virtual bool filterAcceptsRow(int row, const QModelIndex &parent) const;
-
- protected:
- QString m_filter;
- bool m_enabled;
-};
-
-#endif // BTMODULENAMEFILTERPROXYMODEL_H
diff --git a/src/backend/bookshelfmodel/categoryitem.cpp b/src/backend/bookshelfmodel/categoryitem.cpp
index 1788dfc..46905d7 100644
--- a/src/backend/bookshelfmodel/categoryitem.cpp
+++ b/src/backend/bookshelfmodel/categoryitem.cpp
@@ -20,6 +20,17 @@ CategoryItem::CategoryItem(CSwordModuleInfo *module)
// Intentionally empty
}
+QVariant CategoryItem::data(int role) const {
+ switch (role) {
+ case Qt::DisplayRole:
+ return BtBookshelfModel::categoryName(m_category);
+ case Qt::DecorationRole:
+ return BtBookshelfModel::categoryIcon(m_category);
+ default:
+ return Item::data(role);
+ }
+}
+
bool CategoryItem::operator<(const Item &other) const {
if (other.type() != ITEM_CATEGORY) {
return ITEM_CATEGORY < other.type();
diff --git a/src/backend/bookshelfmodel/categoryitem.h b/src/backend/bookshelfmodel/categoryitem.h
index fcff12b..879895f 100644
--- a/src/backend/bookshelfmodel/categoryitem.h
+++ b/src/backend/bookshelfmodel/categoryitem.h
@@ -34,13 +34,7 @@ class CategoryItem: public Item {
return m_category;
}
- inline QString name() const {
- return BtBookshelfModel::categoryName(m_category);
- }
-
- inline QIcon icon() const {
- return BtBookshelfModel::categoryIcon(m_category);
- }
+ QVariant data(int role = Qt::DisplayRole) const;
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
deleted file mode 100644
index fee9c19..0000000
--- a/src/backend/bookshelfmodel/distributionitem.cpp
+++ /dev/null
@@ -1,23 +0,0 @@
-/*********
-*
-* 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/distributionitem.h"
-
-
-namespace BookshelfModel {
-
-DistributionItem::DistributionItem(CSwordModuleInfo *module)
- : Item(ITEM_DISTRIBUTION) {
- m_distribution = module->config(CSwordModuleInfo::DistributionSource);
-}
-
-} // namespace BookshelfModel
diff --git a/src/backend/bookshelfmodel/indexingitem.cpp b/src/backend/bookshelfmodel/indexingitem.cpp
new file mode 100644
index 0000000..898096f
--- /dev/null
+++ b/src/backend/bookshelfmodel/indexingitem.cpp
@@ -0,0 +1,37 @@
+/*********
+*
+* 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 "indexingitem.h"
+
+
+namespace BookshelfModel {
+
+IndexingItem::IndexingItem(CSwordModuleInfo *module)
+ : Item(Item::ITEM_INDEXING), m_indexed(module->hasIndex()) {
+ // Intentionally empty
+}
+
+QVariant IndexingItem::data(int role) const {
+ switch (role) {
+ case Qt::DisplayRole:
+ if (m_indexed) {
+ return QObject::tr("Indexed works");
+ }
+ else {
+ return QObject::tr("Unindexed works");
+ }
+ default:
+ return Item::data(role);
+ }
+}
+
+} // namespace BookshelfModel
diff --git a/src/backend/bookshelfmodel/distributionitem.h b/src/backend/bookshelfmodel/indexingitem.h
index 4ae1197..f30fb2d 100644
--- a/src/backend/bookshelfmodel/distributionitem.h
+++ b/src/backend/bookshelfmodel/indexingitem.h
@@ -10,8 +10,8 @@
*
**********/
-#ifndef DISTRIBUTIONITEM_H
-#define DISTRIBUTIONITEM_H
+#ifndef INDEXINGITEM_H
+#define INDEXINGITEM_H
#include "backend/bookshelfmodel/item.h"
@@ -20,29 +20,22 @@
namespace BookshelfModel {
-class DistributionItem: public Item {
+class IndexingItem: public Item {
public:
- static const Item::Type GROUP_TYPE = Item::ITEM_DISTRIBUTION;
+ static const Item::Type GROUP_TYPE = Item::ITEM_INDEXING;
- DistributionItem(CSwordModuleInfo *module);
+ IndexingItem(CSwordModuleInfo *module);
- inline QString distribution() const {
- return m_distribution;
- }
-
- inline QString name() const {
- return m_distribution;
- }
+ QVariant data(int role = Qt::DisplayRole) const;
inline bool fitFor(CSwordModuleInfo *module) const {
- return module->config(CSwordModuleInfo::DistributionSource)
- == m_distribution;
+ return module->hasIndex() == m_indexed;
}
protected:
- QString m_distribution;
+ bool m_indexed;
};
} // namespace BookshelfModel
-#endif // DISTRIBUTIONITEM_H
+#endif // INDEXINGITEM_H
diff --git a/src/backend/bookshelfmodel/item.cpp b/src/backend/bookshelfmodel/item.cpp
index ec2dcab..809021b 100644
--- a/src/backend/bookshelfmodel/item.cpp
+++ b/src/backend/bookshelfmodel/item.cpp
@@ -12,9 +12,7 @@
#include "backend/bookshelfmodel/item.h"
-#include "backend/bookshelfmodel/categoryitem.h"
-#include "backend/bookshelfmodel/distributionitem.h"
-#include "backend/bookshelfmodel/languageitem.h"
+#include "backend/bookshelfmodel/btbookshelfmodel.h"
namespace BookshelfModel {
@@ -47,19 +45,29 @@ int Item::indexFor(Item *newItem) {
}
}
-bool Item::operator<(const Item &other) const {
- if (m_type != other.type()) {
- return m_type < other.type();
+QVariant Item::data(int role) const {
+ switch (role) {
+ case Qt::CheckStateRole:
+ return m_checkState;
+ case BtBookshelfModel::ModuleHiddenRole:
+ if (m_children.empty()) return true;
+
+ foreach (Item *child, m_children) {
+ if (!child->data(role).toBool()) return false;
+ }
+ return true;
+ default:
+ return QVariant();
}
- 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;
+bool Item::operator<(const Item &other) const {
+ if (m_type != other.type()) {
+ return m_type < other.type();
}
- return true;
+ QString first(data(Qt::DisplayRole).toString().toLower());
+ QString second(other.data(Qt::DisplayRole).toString().toLower());
+ return first.localeAwareCompare(second) < 0;
}
} // namespace BookshelfModel
diff --git a/src/backend/bookshelfmodel/item.h b/src/backend/bookshelfmodel/item.h
index 665343f..f10da04 100644
--- a/src/backend/bookshelfmodel/item.h
+++ b/src/backend/bookshelfmodel/item.h
@@ -17,6 +17,7 @@
#include <QList>
#include <QString>
#include <QtGlobal>
+#include <QVariant>
class CSwordModuleInfo;
@@ -30,7 +31,7 @@ class Item {
ITEM_CATEGORY = 1,
ITEM_LANGUAGE = 2,
ITEM_MODULE = 3,
- ITEM_DISTRIBUTION = 4
+ ITEM_INDEXING = 4
};
Item(Type type);
@@ -54,21 +55,11 @@ class Item {
/**
\brief Returns the list of child items of this node.
*/
- inline const QList<Item*> &children() const {
+ inline QList<Item*> &children() {
return m_children;
}
/**
- \brief Returns a pointer to the child item at the given index.
- \pre The given index is valid
- \param[in] index Index of child item to return.
- */
- Item *childAt(int index) const {
- Q_ASSERT(index >= 0 && index < m_children.size());
- return m_children.at(index);
- }
-
- /**
\brief Returns the index of this item under its parent.
\retval -1 if this item has no parent.
*/
@@ -97,18 +88,13 @@ class Item {
newItem->setParent(this);
}
- inline void deleteChildAt(int index) {
- Q_ASSERT(index >= 0 && index <= m_children.size());
- delete m_children.takeAt(index);
- }
-
template <class T>
- T *getGroupItem(CSwordModuleInfo *module, int *index) {
+ T *getGroupItem(CSwordModuleInfo *module, int &outIndex) {
for (int i(0); i < m_children.size(); i++) {
Q_ASSERT(m_children.at(i)->type() == T::GROUP_TYPE);
T *item(static_cast<T*>(m_children.at(i)));
if (item->fitFor(module)) {
- if (index != 0) *index = i;
+ outIndex = i;
return item;
}
}
@@ -116,23 +102,14 @@ class Item {
}
/**
- \brief Returns the visible name of the item.
+ \brief Returns data for this item.
*/
- inline virtual QString name() const {
- return QString::null;
- }
-
- /**
- \brief Returns the visible icon of the item.
- */
- inline virtual QIcon icon() const {
- return QIcon();
- }
+ virtual QVariant data(int role = Qt::DisplayRole) const;
/**
\brief Returns the check state of this item.
*/
- inline const Qt::CheckState checkState() const {
+ inline Qt::CheckState checkState() const {
return m_checkState;
}
@@ -148,7 +125,7 @@ class Item {
\brief Returns whether this item is fit to contain the given module.
\param[in] module The module to check with.
\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.
+ \retval false This item is not a group or is a wrong group.
*/
inline virtual bool fitFor(CSwordModuleInfo *module) const {
Q_UNUSED(module);
@@ -160,8 +137,6 @@ 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 8d37891..547c953 100644
--- a/src/backend/bookshelfmodel/languageitem.cpp
+++ b/src/backend/bookshelfmodel/languageitem.cpp
@@ -20,4 +20,15 @@ LanguageItem::LanguageItem(CSwordModuleInfo *module)
// Intentionally empty
}
+QVariant LanguageItem::data(int role) const {
+ switch (role) {
+ case Qt::DisplayRole:
+ return BtBookshelfModel::languageName(m_language);
+ case Qt::DecorationRole:
+ return util::directory::getIcon("flag.svg");
+ default:
+ return Item::data(role);
+ }
+}
+
} // namespace BookshelfModel
diff --git a/src/backend/bookshelfmodel/languageitem.h b/src/backend/bookshelfmodel/languageitem.h
index b5696d9..c6e4417 100644
--- a/src/backend/bookshelfmodel/languageitem.h
+++ b/src/backend/bookshelfmodel/languageitem.h
@@ -28,17 +28,7 @@ class LanguageItem: public Item {
LanguageItem(CSwordModuleInfo *module);
- inline const CLanguageMgr::Language *language() const {
- return m_language;
- }
-
- inline QString name() const {
- return BtBookshelfModel::languageName(m_language);
- }
-
- inline QIcon icon() const {
- return util::directory::getIcon("flag.svg");
- }
+ QVariant data(int role = Qt::DisplayRole) const;
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 95e6f62..e7aff92 100644
--- a/src/backend/bookshelfmodel/moduleitem.cpp
+++ b/src/backend/bookshelfmodel/moduleitem.cpp
@@ -12,14 +12,22 @@
#include "backend/bookshelfmodel/moduleitem.h"
+#include "backend/bookshelfmodel/btbookshelftreemodel.h"
#include "util/cresmgr.h"
namespace BookshelfModel {
-ModuleItem::ModuleItem(CSwordModuleInfo *module)
- : Item(ITEM_MODULE), m_moduleInfo(module) {
+ModuleItem::ModuleItem(CSwordModuleInfo *module,
+ BtBookshelfTreeModel *parentModel)
+ : Item(ITEM_MODULE), m_moduleInfo(module), m_parentModel(parentModel) {
Q_ASSERT(module != 0);
+ Q_ASSERT(parentModel != 0);
+}
+
+QVariant ModuleItem::data(int role) const {
+ // Dispatch request to tree model:
+ return m_parentModel->data(m_moduleInfo, role);
}
} // namespace BookshelfModel
diff --git a/src/backend/bookshelfmodel/moduleitem.h b/src/backend/bookshelfmodel/moduleitem.h
index 9657423..006ae97 100644
--- a/src/backend/bookshelfmodel/moduleitem.h
+++ b/src/backend/bookshelfmodel/moduleitem.h
@@ -19,22 +19,27 @@
#include "backend/drivers/cswordmoduleinfo.h"
+class BtBookshelfTreeModel;
+
namespace BookshelfModel {
class ModuleItem: public Item {
public:
- ModuleItem(CSwordModuleInfo *module);
+ ModuleItem(CSwordModuleInfo *module, BtBookshelfTreeModel *parentModel);
- CSwordModuleInfo *moduleInfo() const {
- return m_moduleInfo;
- }
+ /**
+ Reimplementation of \ref Item::data which dispatches all requests to
+ the \ref BtBookshelfTreeModel parent model.
+ */
+ QVariant data(int role = Qt::DisplayRole) const;
- inline bool isHidden() const {
- return m_moduleInfo->isHidden();
+ inline CSwordModuleInfo *moduleInfo() const {
+ return m_moduleInfo;
}
protected:
- CSwordModuleInfo *m_moduleInfo;
+ CSwordModuleInfo *m_moduleInfo;
+ BtBookshelfTreeModel *m_parentModel;
};
} // namespace BookshelfModel
diff --git a/src/backend/config/cbtconfig.cpp b/src/backend/config/cbtconfig.cpp
index 98a2967..39c3e0c 100644
--- a/src/backend/config/cbtconfig.cpp
+++ b/src/backend/config/cbtconfig.cpp
@@ -89,6 +89,8 @@ QString getKey(const bools ID) {
return "autoTileVertical";
case autoTileHorizontal:
return "autoTileHorizontal";
+ case autoTile:
+ return "autoTile";
case autoCascade:
return "autoCascade";
@@ -110,6 +112,15 @@ QString getKey(const bools ID) {
return "bookshelfShowHidden";
case allowNetworkConnection:
return "allowNetworkConnection";
+
+ case showTextWindowHeaders:
+ return "showTextWindowHeaders";
+ case showTextWindowNavigator:
+ return "showTextWindowNavigator";
+ case showTextWindowModuleSelectorButtons:
+ return "showTextWindowModuleSelectorButtons";
+ case showTextWindowToolButtons:
+ return "showTextWindowToolButtons";
}
Q_ASSERT(false);
return false;
@@ -305,6 +316,8 @@ bool getDefault(const bools ID) {
return true;
case autoTileHorizontal:
return false;
+ case autoTile:
+ return false;
case autoCascade:
return false;
@@ -325,6 +338,15 @@ bool getDefault(const bools ID) {
return false;
case allowNetworkConnection:
return false;
+
+ case showTextWindowHeaders:
+ return true;
+ case showTextWindowNavigator:
+ return true;
+ case showTextWindowModuleSelectorButtons:
+ return true;
+ case showTextWindowToolButtons:
+ return true;
}
return false;
}
diff --git a/src/backend/config/cbtconfig.h b/src/backend/config/cbtconfig.h
index d4d075b..9f3a850 100644
--- a/src/backend/config/cbtconfig.h
+++ b/src/backend/config/cbtconfig.h
@@ -55,6 +55,7 @@ enum bools {
autoTileVertical,
autoTileHorizontal,
+ autoTile,
autoCascade,
lineBreaks,
@@ -67,7 +68,12 @@ enum bools {
bookshelfShowHidden,
- allowNetworkConnection
+ allowNetworkConnection,
+
+ showTextWindowHeaders,
+ showTextWindowNavigator,
+ showTextWindowToolButtons,
+ showTextWindowModuleSelectorButtons
};
enum ints {
footnotes,
diff --git a/src/backend/drivers/cswordlexiconmoduleinfo.cpp b/src/backend/drivers/cswordlexiconmoduleinfo.cpp
index 776be9c..c4a04de 100644
--- a/src/backend/drivers/cswordlexiconmoduleinfo.cpp
+++ b/src/backend/drivers/cswordlexiconmoduleinfo.cpp
@@ -13,6 +13,8 @@
#include <QFile>
#include <QDataStream>
#include <QTextCodec>
+#include <QDebug>
+
#include "util/directory.h"
// Sword includes:
@@ -20,7 +22,7 @@
//Change it once the format changed to make all systems rebuild their caches
-#define CACHE_FORMAT "2"
+#define CACHE_FORMAT "3"
CSwordLexiconModuleInfo::CSwordLexiconModuleInfo( sword::SWModule* module, CSwordBackend* const backend ) : CSwordModuleInfo(module, backend) {
m_entryList = 0;
@@ -49,111 +51,103 @@ QStringList* CSwordLexiconModuleInfo::entries() {
return 0;
}
- sword::SWModule* my_module = module();
- bool is_unicode = isUnicode();
+ if (m_entryList) return m_entryList;
- if (!m_entryList) {
- m_entryList = new QStringList();
- bool read = false;
+ m_entryList = new QStringList();
+
+ //Check for buggy modules! They will not be loaded any more.
+ if ( name() == QString("ZhEnglish")) {
+ qWarning() << "Module ZhEnglish is buggy and will not be loaded.";
+ return m_entryList;
+ }
+ if ( name() == QString("EReo_en")) {
+ qWarning() << "Module EReo_en is buggy and will not be loaded.";
+ return m_entryList;
+ }
- //Check for buggy modules! They will not be loaded any more.
+ QString dir(DU::getUserCacheDir().absolutePath());
+ QFile f1( QString(dir).append("/").append(name()));
+
+ /*
+ * Try the module's cache
+ */
+ if ( f1.open( QIODevice::ReadOnly ) ) {
+ QDataStream s( &f1 );
+ QString ModuleVersion, CacheVersion, QDataStreamVersion;
+ s >> ModuleVersion;
+ s >> CacheVersion;
+ s >> QDataStreamVersion;
+
+ qDebug() << "Lexicon cache metadata"
+ << "Name" << name()
+ << "ModuleVersion" << ModuleVersion
+ << "CacheVersion" << CacheVersion
+ << "QDataStreamVersion" << QDataStreamVersion;
+
+ // Check if cache is valid
+ if (ModuleVersion == config(CSwordModuleInfo::ModuleVersion)
+ && CacheVersion == CACHE_FORMAT
+ && QDataStreamVersion == QString::number(s.version())) {
+ s >> *m_entryList;
- if ( name() == QString("ZhEnglish")) {
- qWarning("Module ZhEnglish is buggy and will not be loaded.");
+ f1.close();
+ qDebug() << "Read" << m_entryList->count() << "entries from lexicon cache for module" << name();
return m_entryList;
}
- if ( name() == QString("EReo_en")) {
- qWarning("Module EReo_en is buggy and will not be loaded.");
- return m_entryList;
+ f1.close();
+ }
+
+ /*
+ * Ok, no cache or invalid.
+ */
+ qDebug() << "Read all entries of lexicon" << name();
+
+ sword::SWModule* my_module = module();
+ my_module->setSkipConsecutiveLinks(true);
+ (*my_module) = sword::TOP;
+ snap(); //snap to top entry
+
+ do {
+ if ( isUnicode() ) {
+ m_entryList->append(QString::fromUtf8(my_module->KeyText()));
+ }
+ else {
+ //for latin1 modules use fromLatin1 because of speed
+ QTextCodec* codec = QTextCodec::codecForName("Windows-1252");
+ m_entryList->append(codec->toUnicode(my_module->KeyText()));
}
- QString dir(DU::getUserCacheDir().absolutePath());
- QFile f1(
- QString(dir)
- .append("/")
- .append(name())
- );
-
- if ( f1.open( QIODevice::ReadOnly ) ) {
- QDataStream s( &f1 );
- QString mod_ver, prog_ver;
- s >> mod_ver;
- s >> prog_ver;
-
- if ((mod_ver == config(ModuleVersion)) && (prog_ver == CACHE_FORMAT)) {
- s >> *m_entryList;
- read = true;
- }
+ (*my_module)++;
+ }
+ while ( !my_module->Error() );
- f1.close();
- // qWarning("read entries %d",m_entryList->count());
+ (*my_module) = sword::TOP; //back to the first entry
+
+ my_module->setSkipConsecutiveLinks(false);
+
+ if (m_entryList->count()) {
+ m_entryList->first().simplified();
+
+ if (m_entryList->first().trimmed().isEmpty()) {
+ m_entryList->erase( m_entryList->begin() );
}
+ }
- // Q_ASSERT(read);
- // Q_ASSERT(m_entryList->count());
- if (!read || !m_entryList->count()) {
- my_module->setSkipConsecutiveLinks(true);
- (*my_module) = sword::TOP;
- snap(); //snap to top entry
-
- // qWarning("Reading in module" );
- int i = 0;
-
- do {
- if ( is_unicode ) {
- m_entryList->append(QString::fromUtf8(my_module->KeyText()));
- // qWarning("Entry: %s", my_module->KeyText() );
- }
- else { //for latin1 modules use fromLatin1 because of speed
- // m_entryList->append(QString::fromLatin1(my_module->KeyText()));
- QTextCodec* codec = QTextCodec::codecForName("Windows-1252");
- m_entryList->append(codec->toUnicode(my_module->KeyText()));
- }
-
- (*my_module)++;
- i++;
- }
- while ( !my_module->Error() );
-
- // qWarning("Reading finished. Module has %d entries.", i );
-
- (*my_module) = sword::TOP; //back to the first entry
-
- my_module->setSkipConsecutiveLinks(false);
-
- if (m_entryList->count()) {
- m_entryList->first().simplified();
-
- if (m_entryList->first().trimmed().isEmpty()) {
- m_entryList->erase( m_entryList->begin() );
- }
-
- //now sort the list, this is necesssary because Sword doesn't do Unicode ordering
- // qWarning("sorting");
- // QStringList::iterator start(m_entryList->begin());
- // QStringList::iterator end(m_entryList->end());
- // std::sort( start, end, myLocaleAwareCompare() ); //stl sort
- // m_entryList->sort(); //make sure the module is sorted by utf-8
- }
-
- qWarning("Writing cache file.");
-
- if (m_entryList->count()) {
- //create cache
- QString dir(DU::getUserCacheDir().absolutePath());
- //QFile f2( QString::fromLatin1("%1/%2").arg(dir).arg( name() ) );
- QFile f2( QString(dir).append("/").append(name()) );
-
-
- if (f2.open( QIODevice::WriteOnly )) {
- QDataStream s( &f2 );
- s << config(CSwordModuleInfo::ModuleVersion); //store module version
- s << QString(CACHE_FORMAT); //store BT version -- format may change
- s << *m_entryList;
- f2.close();
- }
- }
+ qDebug() << "Writing cache file for lexicon module" << name();
+
+ if (m_entryList->count()) {
+ //create cache
+ QString dir(DU::getUserCacheDir().absolutePath());
+ QFile f2( QString(dir).append("/").append(name()) );
+
+ if (f2.open( QIODevice::WriteOnly )) {
+ QDataStream s( &f2 );
+ s << config(CSwordModuleInfo::ModuleVersion) //store module version
+ << QString(CACHE_FORMAT) //store BT version -- format may change
+ << QString::number(s.version()) //store QDataStream version -- format may change
+ << *m_entryList;
+ f2.close();
}
}
diff --git a/src/backend/drivers/cswordmoduleinfo.cpp b/src/backend/drivers/cswordmoduleinfo.cpp
index bafe098..6096af2 100644
--- a/src/backend/drivers/cswordmoduleinfo.cpp
+++ b/src/backend/drivers/cswordmoduleinfo.cpp
@@ -109,13 +109,7 @@ bool CSwordModuleInfo::isLocked() {
//still works, but the cipherkey is stored in CBTConfig.
//Works because it is set in sword on program startup.
- if (isEncrypted()) {
- if (unlockKeyIsValid()) {
- return false;
- }
- return true;
- }
- return false;
+ return isEncrypted() && !unlockKeyIsValid();
}
/** This functions returns true if this module is encrypted (locked or unlocked). */
@@ -129,11 +123,7 @@ bool CSwordModuleInfo::isEncrypted() const {
sword::ConfigEntMap config = backend()->getConfig()->Sections.find(name().toUtf8().constData())->second;
sword::ConfigEntMap::iterator it = config.find("CipherKey");
- if (it != config.end()) {
- return true;
- }
-
- return false;
+ return it != config.end();
}
/** This function makes an estimate if a module was properly unlocked.
@@ -194,12 +184,13 @@ bool CSwordModuleInfo::hasIndex() {
//first check if the index version and module version are ok
QSettings module_config(getModuleBaseIndexLocation() + QString("/bibletime-index.conf"), QSettings::IniFormat);
- if (hasVersion()) {
- if (module_config.value("module-version") != QString(config(CSwordModuleInfo::ModuleVersion)) ) {
- return false;
- }
+ if (hasVersion() &&
+ module_config.value("module-version").toString() != config(CSwordModuleInfo::ModuleVersion))
+ {
+ return false;
}
- if (module_config.value("index-version") != QString::number( INDEX_VERSION )) {
+
+ if (module_config.value("index-version").toUInt() != INDEX_VERSION) {
qDebug("%s: INDEX_VERSION is not compatible with this version of BibleTime.", name().toUtf8().constData());
return false;
}
@@ -397,24 +388,30 @@ void CSwordModuleInfo::buildIndex() {
writer->close();
if (m_cancelIndexing) {
- deleteIndexForModule(name());
+ deleteIndex();
m_cancelIndexing = false;
}
else {
QSettings module_config(getModuleBaseIndexLocation() + QString("/bibletime-index.conf"), QSettings::IniFormat);
if (hasVersion()) module_config.setValue("module-version", config(CSwordModuleInfo::ModuleVersion) );
- module_config.setValue("index-version", INDEX_VERSION );
+ module_config.setValue("index-version", INDEX_VERSION);
+ emit hasIndexChanged(true);
}
}
catch (...) {
qWarning("CLucene exception occurred while indexing");
util::showWarning(0, QCoreApplication::tr("Indexing aborted"), QCoreApplication::tr("An internal error occurred while building the index."));
- deleteIndexForModule(name());
+ deleteIndex();
m_cancelIndexing = false;
}
}
-void CSwordModuleInfo::deleteIndexForModule( QString name ) {
+void CSwordModuleInfo::deleteIndex() {
+ deleteIndexForModule(name());
+ emit hasIndexChanged(false);
+}
+
+void CSwordModuleInfo::deleteIndexForModule(const QString &name) {
util::directory::removeRecursive( getGlobalBaseIndexLocation() + "/" + name );
}
@@ -927,7 +924,8 @@ bool CSwordModuleInfo::setHidden(bool hide) {
if (hide) {
Q_ASSERT(!hiddenModules.contains(name()));
hiddenModules.append(name());
- } else {
+ }
+ else {
Q_ASSERT(hiddenModules.contains(name()));
hiddenModules.removeOne(name());
}
diff --git a/src/backend/drivers/cswordmoduleinfo.h b/src/backend/drivers/cswordmoduleinfo.h
index 9f32b12..a767c41 100644
--- a/src/backend/drivers/cswordmoduleinfo.h
+++ b/src/backend/drivers/cswordmoduleinfo.h
@@ -144,10 +144,17 @@ class CSwordModuleInfo: public QObject {
* Returns the base directory for search indices
*/
static QString getGlobalBaseIndexLocation();
+
/**
- * Removes search index for this module, even if the module is not there any more
+ Removes the search index for this module (rm -rf).
*/
- static void deleteIndexForModule( QString name );
+ void deleteIndex();
+
+ /**
+ Removes search index for a module, even if the module is not there any more.
+ \param[in] name name of the module.
+ */
+ static void deleteIndexForModule(const QString &name);
/**
@@ -289,7 +296,9 @@ class CSwordModuleInfo: public QObject {
/**
* Returns true if this module is hidden (not to be shown with other modules in certain views).
*/
- inline bool isHidden() const { return m_hidden; }
+ inline bool isHidden() const {
+ return m_hidden;
+ }
/**
Shows or hides the module.
@@ -336,6 +345,7 @@ class CSwordModuleInfo: public QObject {
QString getFormattedConfigEntry(const QString& name) const;
signals:
+ void hasIndexChanged(bool);
void hiddenChanged(bool);
void indexingFinished();
void indexingProgress(int);
diff --git a/src/backend/filters/bt_teihtml.cpp b/src/backend/filters/bt_teihtml.cpp
index 340e8af..b242f46 100644
--- a/src/backend/filters/bt_teihtml.cpp
+++ b/src/backend/filters/bt_teihtml.cpp
@@ -24,7 +24,7 @@
Filters::BT_TEIHTML::BT_TEIHTML() : sword::TEIHTMLHREF() {
- setPassThruUnknownEscapeString(true); //the HTML widget will render the HTML escape codes
+ 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) {
@@ -32,59 +32,59 @@ bool Filters::BT_TEIHTML::handleToken(sword::SWBuf &buf, const char *token, swor
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>");
- }
- }
+ 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);
}
diff --git a/src/backend/keys/cswordversekey.cpp b/src/backend/keys/cswordversekey.cpp
index 84c0b29..a7e16c5 100644
--- a/src/backend/keys/cswordversekey.cpp
+++ b/src/backend/keys/cswordversekey.cpp
@@ -32,7 +32,7 @@ CSwordVerseKey::CSwordVerseKey( CSwordModuleInfo* const module ) :
}
CSwordVerseKey::CSwordVerseKey( const CSwordVerseKey& k ) : CSwordKey(k), VerseKey(k) {
- this->VerseKey::setAutoNormalize(true);
+ this->VerseKey::setAutoNormalize(true);
}
CSwordVerseKey::CSwordVerseKey( const VerseKey* const k, CSwordModuleInfo* const module ) : CSwordKey(module), VerseKey(*k) {}
@@ -163,7 +163,7 @@ bool CSwordVerseKey::next( const JumpType type ) {
m_module->module()->setSkipConsecutiveLinks(true);
//disable headings for next verse
- const bool useHeaders = (Verse() == 0);
+ const bool useHeaders = 1; //(Verse() == 0);
const bool oldHeadingsStatus = ((VerseKey*)(m_module->module()->getKey()))->Headings( useHeaders );
//don't use setKey(), that would create a new key without Headings set
m_module->module()->getKey()->setText( key().toUtf8().constData() );
@@ -243,7 +243,7 @@ bool CSwordVerseKey::previous( const JumpType type ) {
case UseVerse: {
if (m_module && m_module->module()) {
- const bool useHeaders = (Verse() == 0);
+ const bool useHeaders = 1; //(Verse() == 0);
const bool oldHeadingsStatus = ((VerseKey*)(m_module->module()->getKey()))->Headings( useHeaders );
m_module->module()->getKey()->setText( key().toUtf8().constData() );
diff --git a/src/backend/managers/cswordbackend.cpp b/src/backend/managers/cswordbackend.cpp
index ee74e4a..4596a61 100644
--- a/src/backend/managers/cswordbackend.cpp
+++ b/src/backend/managers/cswordbackend.cpp
@@ -47,8 +47,7 @@ using namespace Rendering;
CSwordBackend::CSwordBackend()
: sword::SWMgr(0, 0, false, new sword::EncodingFilterMgr( sword::ENC_UTF8 ), true),
- m_dataModel(this)
-{
+ m_dataModel(this) {
m_filters.gbf = new BT_GBFHTML();
m_filters.plain = new BT_PLAINHTML();
m_filters.thml = new BT_ThMLHTML();
@@ -126,6 +125,18 @@ QList<CSwordModuleInfo*> CSwordBackend::takeModulesFromList(QStringList names) {
return list;
}
+QList<CSwordModuleInfo*> CSwordBackend::getPointerList(QStringList names) {
+ QList<CSwordModuleInfo*> list;
+ foreach(QString name, names) {
+ CSwordModuleInfo* mInfo = findModuleByName(name);
+ if (mInfo) {
+ list.append(mInfo);
+ }
+ }
+ return list;
+}
+
+
/** Initializes the Sword modules. */
CSwordBackend::LoadError CSwordBackend::initModules(SetupChangedReason reason) {
// qWarning("globalSwordConfigPath is %s", globalConfPath);
@@ -513,29 +524,26 @@ void CSwordBackend::reloadModules(SetupChangedReason reason) {
}
// Get one or more shared sword config (sword.conf) files
-QStringList CSwordBackend::getSharedSwordConfigFiles() const
-{
- QStringList configPath;
+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");
+ // %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
+ // /etc/sword.conf, /usr/local/etc/sword.conf
configPath = QString(globalConfPath).split(":");
#endif
- return configPath;
+ return configPath;
}
// Get the private sword directory
-QString CSwordBackend::getPrivateSwordConfigPath() const
-{
+QString CSwordBackend::getPrivateSwordConfigPath() const {
return util::directory::getUserHomeSwordDir().absolutePath();
}
-QString CSwordBackend::getPrivateSwordConfigFile() const
-{
+QString CSwordBackend::getPrivateSwordConfigFile() const {
QString file(getPrivateSwordConfigPath() + "/sword.conf");
return util::directory::convertDirSeparators(file);
}
@@ -553,7 +561,8 @@ QStringList CSwordBackend::swordDirList() const {
if (QFile(getPrivateSwordConfigFile()).exists()) {
// Use the private sword.conf file:
configs << getPrivateSwordConfigFile();
- } else {
+ }
+ 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
diff --git a/src/backend/managers/cswordbackend.h b/src/backend/managers/cswordbackend.h
index 3120694..c8b4f77 100644
--- a/src/backend/managers/cswordbackend.h
+++ b/src/backend/managers/cswordbackend.h
@@ -211,6 +211,11 @@ class CSwordBackend : public QObject, public sword::SWMgr {
*/
QList<CSwordModuleInfo*> takeModulesFromList(QStringList names);
+ /**
+ * Returns a list of pointers to modules, created from a list of module names.
+ */
+ QList<CSwordModuleInfo*> getPointerList(QStringList names);
+
/** Sword prefix list.
* @return A list of all known Sword prefix dirs
*/
@@ -254,6 +259,9 @@ class CSwordBackend : public QObject, public sword::SWMgr {
QMap<QString, QString> m_moduleDescriptionMap;
};
+Q_DECLARE_METATYPE(CSwordBackend::FilterOptions)
+Q_DECLARE_METATYPE(CSwordBackend::DisplayOptions)
+
/**Returns The list of modules managed by this backend*/
inline const QList<CSwordModuleInfo*> &CSwordBackend::moduleList() const {
return m_dataModel.modules();
diff --git a/src/backend/managers/referencemanager.h b/src/backend/managers/referencemanager.h
index a038130..fdef8b2 100644
--- a/src/backend/managers/referencemanager.h
+++ b/src/backend/managers/referencemanager.h
@@ -19,15 +19,15 @@
*/
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 */
+ 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.
@@ -82,14 +82,14 @@ 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*/
+ 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";
- };
+ ParseOptions() {
+ destinationLanguage = "en";
+ };
};
/** Parses the given verse references using the given language and the module.
diff --git a/src/backend/rendering/cbookdisplay.cpp b/src/backend/rendering/cbookdisplay.cpp
index f640628..9da57f2 100644
--- a/src/backend/rendering/cbookdisplay.cpp
+++ b/src/backend/rendering/cbookdisplay.cpp
@@ -95,7 +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.
+ qDeleteAll(tree); // Dispose of the heap allocated objects pointed to in tree.
return renderedText;
};
};
diff --git a/src/backend/rendering/centrydisplay.cpp b/src/backend/rendering/centrydisplay.cpp
index d3a6aac..b6c7a27 100644
--- a/src/backend/rendering/centrydisplay.cpp
+++ b/src/backend/rendering/centrydisplay.cpp
@@ -58,12 +58,12 @@ const QString CEntryDisplay::text( const QList<CSwordModuleInfo*>& modules, cons
}
k1.Verse(0);
if ( k1.rawText().length() > 0 ) {
- tree.append( new Rendering::CTextRendering::KeyTreeItem(k1.key(), modules, preverse_settings) );
+ tree.append( new Rendering::CTextRendering::KeyTreeItem(k1.key(), modules, preverse_settings) );
}
}
}
- tree.append( new Rendering::CTextRendering::KeyTreeItem(keyName, modules, normal_settings) );
+ tree.append( new Rendering::CTextRendering::KeyTreeItem(keyName, modules, normal_settings) );
QString result(render.renderKeyTree(tree));
qDeleteAll(tree);
- return result;
+ return result;
}
diff --git a/src/backend/rendering/chtmlexportrendering.cpp b/src/backend/rendering/chtmlexportrendering.cpp
index e6d0ff6..6a571c6 100644
--- a/src/backend/rendering/chtmlexportrendering.cpp
+++ b/src/backend/rendering/chtmlexportrendering.cpp
@@ -11,6 +11,8 @@
#include <boost/scoped_ptr.hpp>
#include <iostream>
+#include <QDebug>
+
#include "backend/drivers/cswordmoduleinfo.h"
#include "backend/keys/cswordkey.h"
#include "backend/keys/cswordversekey.h"
@@ -132,7 +134,10 @@ const QString CHTMLExportRendering::renderEntry( const KeyTreeItem& i, CSwordKey
key_renderedText = key->renderedText();
if (m_filterOptions.headings) {
- (*mod_Itr)->module()->RenderText();
+
+ // only process EntryAttributes, do not render, this might destroy the EntryAttributes again
+ (*mod_Itr)->module()->RenderText(0, -1, 0);
+
sword::AttributeValue::const_iterator it =
(*mod_Itr)->module()->getEntryAttributes()["Heading"]["Preverse"].begin();
const sword::AttributeValue::const_iterator end =
diff --git a/src/bibletime.cpp b/src/bibletime.cpp
index 687ec23..f2478d9 100644
--- a/src/bibletime.cpp
+++ b/src/bibletime.cpp
@@ -10,10 +10,12 @@
#include "bibletime.h"
#include <cstdlib>
+#include <iostream>
#include <ctime>
#include <QAction>
#include <QApplication>
#include <QCloseEvent>
+#include <QDate>
#include <QDebug>
#include <QInputDialog>
#include <QMdiSubWindow>
@@ -43,27 +45,55 @@
using namespace Profile;
-BibleTime::BibleTime() {
+BibleTime::BibleTime()
+ : m_WindowWasMaximizedBeforeFullScreen(false) {
namespace DU = util::directory;
- QPixmap pm;
- if (!pm.load(DU::getPicsDir().canonicalPath().append( "/startuplogo.png"))) {
- qWarning("Can't load startuplogo! Check your installation.");
- }
- QSplashScreen splash(pm);
- QString splashHtml("<div style='background:transparent;color:white;font-weight:bold'>%1</div>");
- if (CBTConfig::get(CBTConfig::logo)) {
+ QSplashScreen splash;
+ bool showSplash = CBTConfig::get(CBTConfig::logo);
+ QString splashHtml;
+
+ if (showSplash) {
+ splashHtml = "<div style='background:transparent;color:white;font-weight:bold'>%1"
+ "</div>";
+ const QDate date(QDate::currentDate());
+ const int day = date.day();
+ const int month = date.month();
+ QString splashImage(DU::getPicsDir().canonicalPath().append("/"));
+
+ if ((month >= 12 && day >= 24) || (month <= 1 && day < 6)) {
+ splashImage.append("startuplogo_christmas.png");
+ } else {
+ splashImage.append("startuplogo.png");
+ }
+
+ QPixmap pm;
+ if (!pm.load(splashImage)) {
+ qWarning("Can't load startuplogo! Check your installation.");
+ }
+ splash.setPixmap(pm);
splash.show();
+
+ splash.showMessage(splashHtml.arg(tr("Initializing the SWORD engine...")),
+ Qt::AlignCenter);
}
- splash.showMessage(splashHtml.arg(tr("Initializing the SWORD engine...")), Qt::AlignCenter);
initBackends();
- splash.showMessage(splashHtml.arg(tr("Creating BibleTime's user interface...")), Qt::AlignCenter);
+
+ if (showSplash) {
+ splash.showMessage(splashHtml.arg(tr("Creating BibleTime's user interface...")),
+ Qt::AlignCenter);
+ }
initView();
- splash.showMessage(splashHtml.arg(tr("Initializing menu- and toolbars...")), Qt::AlignCenter);
+
+ if (showSplash) {
+ splash.showMessage(splashHtml.arg(tr("Initializing menu- and toolbars...")),
+ Qt::AlignCenter);
+ }
initActions();
initConnections();
readSettings();
- setPlainCaption(QString());
+
+ setWindowTitle("BibleTime " BT_VERSION);
setWindowIcon(DU::getIcon(CResMgr::mainWindow::icon));
}
@@ -86,6 +116,7 @@ void BibleTime::saveSettings() {
*/
CBTConfig::set(CBTConfig::autoTileVertical, m_windowAutoTileVertical_action->isChecked());
CBTConfig::set(CBTConfig::autoTileHorizontal, m_windowAutoTileHorizontal_action->isChecked());
+ CBTConfig::set(CBTConfig::autoTile, m_windowAutoTile_action->isChecked());
CBTConfig::set(CBTConfig::autoCascade, m_windowAutoCascade_action->isChecked());
CProfile* p = m_profileMgr.startupProfile();
@@ -113,6 +144,11 @@ void BibleTime::readSettings() {
m_windowManualMode_action->setChecked(false);
slotAutoTileHorizontal();
}
+ else if ( CBTConfig::get(CBTConfig::autoTile) ) {
+ m_windowAutoTile_action->setChecked(true);
+ m_windowManualMode_action->setChecked(false);
+ slotAutoTile();
+ }
else if ( CBTConfig::get(CBTConfig::autoCascade) ) {
m_windowAutoCascade_action->setChecked(true);
m_windowManualMode_action->setChecked(false);
@@ -264,21 +300,19 @@ void BibleTime::restoreWorkspace() {
}
}
-/** Sets the plain caption of the main window */
-void BibleTime::setPlainCaption(const QString& title) {
- QString suffix;
- //Watch out, subtitles must be appended with the form " - [%s]", otherwise
- //QMdiSubWindow will mess up when it is maximized
- if (!title.isEmpty()) {
- suffix = QString(" - [").append(title).append("]");
- }
- QMainWindow::setWindowTitle( QString("BibleTime ").append(BT_VERSION) + suffix );
-}
-
/** Processes the commandline options given to BibleTime. */
void BibleTime::processCommandline() {
QStringList args = qApp->QCoreApplication::arguments();
+ if (args.contains("--help") || args.contains("-h") || args.contains("/h") || args.contains("/?")) {
+ std::cout << "BibleTime" << std::endl << "--help (-h, /h, /?): Show this help message and exit"
+ << std::endl << "--ignore-session: open a clean session" << std:: endl << "--open-default-bible <ref>: "
+ << "Open the default Bible with the reference <ref>" << std::endl;
+ std::cout << "Some Qt arguments:" << std::endl << "-reverse: reverse the UI layout direction"
+ << std::endl;
+ exit(0);
+ //printHelpAndExit();
+ }
if ( !CBTConfig::get(CBTConfig::crashedTwoTimes) &&
!args.contains("--ignore-session") ) {
restoreWorkspace();
@@ -310,7 +344,13 @@ void BibleTime::processCommandline() {
}
bool BibleTime::event(QEvent* event) {
- if (event->type() == QEvent::Close)
- Search::CSearchDialog::closeDialog();
- return QMainWindow::event(event);
+ if (event->type() == QEvent::Close)
+ Search::CSearchDialog::closeDialog();
+ return QMainWindow::event(event);
+}
+
+QAction* BibleTime::getAction(const QString& actionName)
+{
+ return m_actionCollection->action(actionName);
}
+
diff --git a/src/bibletime.h b/src/bibletime.h
index 42cf04f..89d0473 100644
--- a/src/bibletime.h
+++ b/src/bibletime.h
@@ -156,6 +156,10 @@ class BibleTime : public QMainWindow {
* Save the configuration dialog settings, don't open dialog
*/
void saveConfigSettings();
+ /**
+ * Get QAction from actionCollection
+ */
+ QAction* getAction(const QString& actionName);
public slots:
/**
@@ -175,10 +179,6 @@ class BibleTime : public QMainWindow {
*/
void openOnlineHelp_Howto();
/**
- * Sets the plain caption of the main window
- */
- void setPlainCaption( const QString& );
- /**
* Processes the commandline options given to BibleTime.
*/
void processCommandline();
@@ -191,11 +191,11 @@ class BibleTime : public QMainWindow {
/**
* Catch QMainWindow events
*/
- bool event(QEvent* event);
+ bool event(QEvent* event);
/**
* Initializes the sword.conf in the $HOME\Sword directory
*/
- void initSwordConfigFile();
+ void initSwordConfigFile();
/**
* Initializes the view of this widget
*/
@@ -246,7 +246,7 @@ class BibleTime : public QMainWindow {
void searchInModule(CSwordModuleInfo *module);
void moduleUnlock(CSwordModuleInfo *module);
void moduleAbout(CSwordModuleInfo *module);
- void quit();
+ void quit();
/**
* Is called when the window menu is about to show ;-)
@@ -267,23 +267,35 @@ class BibleTime : public QMainWindow {
/**
* This slot is connected with the windowAutoCascade_action object
*/
+ void slotAutoTile();
+ /**
+ * This slot is connected with the windowAutoTile_action object
+ */
void slotAutoCascade();
void slotUpdateWindowArrangementActions( QAction* );
void slotCascade();
+ void slotTile();
void slotTileVertical();
void slotTileHorizontal();
void slotManualArrangementMode();
/**
- * Is called when a client was selected in the window menu
- */
- void slotWindowMenuActivated();
- /**
* Shows/hides the toolbar
*/
void slotToggleToolbar();
+
+ /**
+ * Shows/hides the text window text area headers and sets
+ * configuration that newly opened windows don't user headers.
+ */
+ void slotToggleTextWindowHeader();
+
+ void slotToggleTextWindowToolButtons();
+ void slotToggleTextWindowNavigator();
+ void slotToggleTextWindowModuleChooser();
+
/**
* Used to set the active menu
*/
@@ -317,11 +329,7 @@ class BibleTime : public QMainWindow {
* changed (ok or apply)
*/
void slotSettingsChanged();
- /**
- * Is called when settings in the sword setup dialog have been
- * changed (ok or apply)
- */
- void slotSwordSetupChanged();
+
/**
* Called when search button is pressed
**/
@@ -347,7 +355,16 @@ class BibleTime : public QMainWindow {
*/
void slotOpenAboutDialog();
+ signals:
+ void toggledTextWindowHeader(bool newState);
+ void toggledTextWindowNavigator(bool newState);
+ void toggledTextWindowToolButtons(bool newState);
+ void toggledTextWindowModuleChooser(bool newState);
+
private:
+ // True if window was maximized before last toggle to full screen.
+ bool m_WindowWasMaximizedBeforeFullScreen;
+
// Docking widgets and their respective content widgets:
BtBookshelfDockWidget* m_bookshelfDock;
QDockWidget* m_bookmarksDock;
@@ -362,10 +379,12 @@ class BibleTime : public QMainWindow {
QMenu* m_openWindowsMenu;
/** WINDOW menu actions */
QAction* m_windowCascade_action;
+ QAction* m_windowTile_action;
QAction* m_windowTileHorizontal_action;
QAction* m_windowTileVertical_action;
QAction* m_windowManualMode_action;
QAction* m_windowAutoCascade_action;
+ QAction* m_windowAutoTile_action;
QAction* m_windowAutoTileVertical_action;
QAction* m_windowAutoTileHorizontal_action;
QAction* m_windowClose_action;
@@ -389,6 +408,7 @@ class BibleTime : public QMainWindow {
Profile::CProfileMgr m_profileMgr;
+
protected: //DBUS interface implementation
void closeAllModuleWindows();
void syncAllBibles(const QString& key);
@@ -402,8 +422,8 @@ class BibleTime : public QMainWindow {
QStringList searchInOpenModules(const QString& searchText);
QStringList searchInDefaultBible(const QString& searchText);
QStringList getModulesOfType(const QString& type);
- void reloadModules();
- //helper function
+
+ // Helper function
void syncAllModulesByType(const CSwordModuleInfo::ModuleType type, const QString& key);
};
diff --git a/src/bibletime_dbus.cpp b/src/bibletime_dbus.cpp
index 44225bb..6adf71c 100644
--- a/src/bibletime_dbus.cpp
+++ b/src/bibletime_dbus.cpp
@@ -199,6 +199,3 @@ QStringList BibleTime::getModulesOfType(const QString& type) {
return ret;
}
-void BibleTime::reloadModules() {
- slotSwordSetupChanged();
-}
diff --git a/src/bibletime_dbus_adaptor.cpp b/src/bibletime_dbus_adaptor.cpp
index c841e18..30619ec 100644
--- a/src/bibletime_dbus_adaptor.cpp
+++ b/src/bibletime_dbus_adaptor.cpp
@@ -32,10 +32,6 @@ void BibleTimeDBusAdaptor::syncAllVerseBasedModules(const QString& key) {
m_bibletime->syncAllVerseBasedModules(key);
}
-void BibleTimeDBusAdaptor::reloadModules() {
- m_bibletime->reloadModules();
-}
-
void BibleTimeDBusAdaptor::openWindow(const QString& moduleName, const QString& key) {
m_bibletime->openWindow(moduleName, key);
}
diff --git a/src/bibletime_dbus_adaptor.h b/src/bibletime_dbus_adaptor.h
index 9bfcae3..ea4ec69 100644
--- a/src/bibletime_dbus_adaptor.h
+++ b/src/bibletime_dbus_adaptor.h
@@ -48,9 +48,7 @@ class BibleTimeDBusAdaptor : QDBusAbstractAdaptor {
* @param key The key which is set to all Bible and Commentary windows.
*/
void syncAllVerseBasedModules(const QString& key);
- /** Reload all modules
- */
- void reloadModules();
+
/** Open a new read window for the module moduleName using the given key
* @param moduleName The name of the module which is opened in a new module window.
* @param key The key to set to the newly opened window.
diff --git a/src/bibletime_init.cpp b/src/bibletime_init.cpp
index 98db7d9..cbff79f 100644
--- a/src/bibletime_init.cpp
+++ b/src/bibletime_init.cpp
@@ -151,6 +151,13 @@ void BibleTime::insertKeyboardActions( BtActionCollection* const a ) {
a->addAction("autoHorizontal", action);
action = new QAction(a);
+ action->setText(tr("Auto-&tile"));
+ action->setIcon(DU::getIcon(CResMgr::mainMenu::window::arrangementMode::autoTile::icon));
+ action->setShortcut(QKeySequence(CResMgr::mainMenu::window::arrangementMode::autoTile::accel));
+ action->setToolTip(tr("Automatically tile the open windows"));
+ a->addAction("autoTile", action);
+
+ action = new QAction(a);
action->setText(tr("Auto-&cascade"));
action->setIcon(DU::getIcon(CResMgr::mainMenu::window::arrangementMode::autoCascade::icon));
action->setShortcut(QKeySequence(CResMgr::mainMenu::window::arrangementMode::autoCascade::accel));
@@ -165,6 +172,13 @@ void BibleTime::insertKeyboardActions( BtActionCollection* const a ) {
a->addAction("cascade", action);
action = new QAction(a);
+ action->setText(tr("&Tile"));
+ action->setIcon(DU::getIcon(CResMgr::mainMenu::window::tile::icon));
+ action->setShortcut(QKeySequence(CResMgr::mainMenu::window::tile::accel));
+ action->setToolTip(tr("Tile the open windows"));
+ a->addAction("tile", action);
+
+ action = new QAction(a);
action->setText(tr("Tile &vertically"));
action->setIcon(DU::getIcon(CResMgr::mainMenu::window::tileVertical::icon));
action->setShortcut(QKeySequence(CResMgr::mainMenu::window::tileVertical::accel));
@@ -254,10 +268,11 @@ void BibleTime::initActions() {
QAction* tmp = m_actionCollection->action("quit");
fileMenu->addAction(tmp);
- m_mainToolBar->addAction(tmp);
- m_mainToolBar->addSeparator();
connect(tmp, SIGNAL(triggered()), this, SLOT(quit()) );
+
+ // ********** View menu *********************
+
m_windowFullscreen_action = m_actionCollection->action("toggleFullscreen");
m_windowFullscreen_action->setCheckable(true);
viewMenu->addAction(m_windowFullscreen_action);
@@ -282,6 +297,35 @@ void BibleTime::initActions() {
action->setText(tr("Show Mag"));
viewMenu->addAction(action);
+ viewMenu->addSeparator();
+ QMenu* textWindowsMenu = new QMenu(tr("Text windows"));
+ viewMenu->addMenu(textWindowsMenu);
+
+ action = new QAction(tr("Show text area headers"), this);
+ action->setCheckable(true);
+ action->setChecked(CBTConfig::get(CBTConfig::showTextWindowHeaders));
+ connect(action, SIGNAL(toggled(bool)), SLOT(slotToggleTextWindowHeader()));
+ textWindowsMenu->addAction(action);
+
+ action = new QAction(tr("Show navigation"), this);
+ action->setCheckable(true);
+ action->setChecked(CBTConfig::get(CBTConfig::showTextWindowNavigator));
+ connect(action, SIGNAL(toggled(bool)), SLOT(slotToggleTextWindowNavigator()));
+ textWindowsMenu->addAction(action);
+
+ action = new QAction(tr("Show work chooser buttons"), this);
+ action->setCheckable(true);
+ action->setChecked(CBTConfig::get(CBTConfig::showTextWindowModuleSelectorButtons));
+ connect(action, SIGNAL(toggled(bool)), SLOT(slotToggleTextWindowModuleChooser()));
+ textWindowsMenu->addAction(action);
+
+ action = new QAction(tr("Show tools"), this);
+ action->setCheckable(true);
+ action->setChecked(CBTConfig::get(CBTConfig::showTextWindowToolButtons));
+ connect(action, SIGNAL(toggled(bool)), SLOT(slotToggleTextWindowToolButtons()));
+ textWindowsMenu->addAction(action);
+
+ // *************************************
m_mainToolBar->addSeparator();
tmp = m_actionCollection->action("searchOpenWorks");
@@ -316,6 +360,10 @@ void BibleTime::initActions() {
m_windowMenu->addAction(m_windowCascade_action);
connect(m_windowCascade_action, SIGNAL(triggered()), this, SLOT(slotCascade()) );
+ m_windowTile_action = m_actionCollection->action("tile");
+ m_windowMenu->addAction(m_windowTile_action);
+ connect(m_windowTile_action, SIGNAL(triggered()), this, SLOT(slotTile()) );
+
m_windowTileVertical_action = m_actionCollection->action("tileVertically");
m_windowMenu->addAction(m_windowTileVertical_action);
connect(m_windowTileVertical_action, SIGNAL(triggered()), this, SLOT(slotTileVertical()) );
@@ -344,6 +392,11 @@ void BibleTime::initActions() {
arrangementMenu->addAction(m_windowAutoTileHorizontal_action);
connect(m_windowAutoTileHorizontal_action, SIGNAL(triggered()), this, SLOT(slotAutoTileHorizontal()) );
+ m_windowAutoTile_action = m_actionCollection->action("autoTile");
+ m_windowAutoTile_action->setCheckable(true);
+ arrangementMenu->addAction(m_windowAutoTile_action);
+ connect(m_windowAutoTile_action, SIGNAL(triggered()), this, SLOT(slotAutoTile()) );
+
m_windowAutoCascade_action = m_actionCollection->action("autoCascade");
m_windowAutoCascade_action->setCheckable(true);
arrangementMenu->addAction(m_windowAutoCascade_action);
@@ -398,11 +451,6 @@ void BibleTime::initActions() {
/** Initializes the SIGNAL / SLOT connections */
void BibleTime::initConnections() {
- QObject::connect(m_mdi, SIGNAL(sigSetToplevelCaption(const QString&)),
- this, SLOT(setPlainCaption(const QString&)));
- QObject::connect(m_mdi, SIGNAL(createReadDisplayWindow(QList<CSwordModuleInfo*>, const QString&)),
- this, SLOT(createReadDisplayWindow(QList<CSwordModuleInfo*>, const QString&)));
-
if (m_windowMenu) {
QObject::connect(m_windowMenu, SIGNAL(aboutToShow()), this, SLOT(slotWindowMenuAboutToShow()));
}
@@ -411,15 +459,18 @@ void BibleTime::initConnections() {
}
if (m_openWindowsMenu) {
- QObject::connect(m_openWindowsMenu, SIGNAL(aboutToShow()), this, SLOT(slotOpenWindowsMenuAboutToShow()));
+ QObject::connect(m_openWindowsMenu, SIGNAL(aboutToShow()),
+ this, SLOT(slotOpenWindowsMenuAboutToShow()));
}
else {
qWarning() << "Main window: can't find open windows menu";
}
bool ok;
- ok = connect(m_bookmarksPage, SIGNAL(createReadDisplayWindow(QList<CSwordModuleInfo*>, const QString&)),
- this, SLOT(createReadDisplayWindow(QList<CSwordModuleInfo*>, const QString&)));
+ ok = connect(m_bookmarksPage,
+ SIGNAL(createReadDisplayWindow(QList<CSwordModuleInfo*>, const QString&)),
+ this,
+ SLOT(createReadDisplayWindow(QList<CSwordModuleInfo*>, const QString&)));
Q_ASSERT(ok);
connect(m_bookshelfDock, SIGNAL(moduleOpenTriggered(CSwordModuleInfo*)),
this, SLOT(createReadDisplayWindow(CSwordModuleInfo*)));
@@ -444,21 +495,21 @@ void BibleTime::initSwordConfigFile() {
// If this is not done here, the sword locales.d won't be found
#ifdef Q_WS_WIN
namespace DU = util::directory;
- QString configFile = util::directory::getUserHomeSwordDir().filePath("sword.conf");
- QFile file(configFile);
- if (file.exists()) {
- return;
- }
- if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
- return;
- }
- QTextStream out(&file);
- out << "\n";
- out << "[Install]\n";
- out << "DataPath=" << DU::convertDirSeparators( DU::getSharedSwordDir().absolutePath()) << "\n";
- out << "LocalePath=" << DU::convertDirSeparators(DU::getApplicationSwordDir().absolutePath()) << "\n";
- out << "\n";
- file.close();
+ QString configFile = util::directory::getUserHomeSwordDir().filePath("sword.conf");
+ QFile file(configFile);
+ if (file.exists()) {
+ return;
+ }
+ if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
+ return;
+ }
+ QTextStream out(&file);
+ out << "\n";
+ out << "[Install]\n";
+ out << "DataPath=" << DU::convertDirSeparators( DU::getSharedSwordDir().absolutePath()) << "\n";
+ out << "LocalePath=" << DU::convertDirSeparators(DU::getApplicationSwordDir().absolutePath()) << "\n";
+ out << "\n";
+ file.close();
#endif
}
@@ -466,7 +517,7 @@ void BibleTime::initSwordConfigFile() {
void BibleTime::initBackends() {
qDebug() << "BibleTime::initBackends";
- initSwordConfigFile();
+ initSwordConfigFile();
sword::StringMgr::setSystemStringMgr( new BTStringMgr() );
sword::SWLog::getSystemLog()->setLogLevel(1);
@@ -479,7 +530,7 @@ void BibleTime::initBackends() {
if (errorCode != CSwordBackend::NoError) {
//show error message that initBackend failed
- /// \todo
+ /// \todo
// switch (errorCode) {
// case CSwordBackend::NoSwordConfig: //mods.d or mods.conf missing
// {
@@ -528,8 +579,8 @@ void BibleTime::applyProfileSettings( CProfile* p ) {
//first Main Window state
restoreState(p->getMainwindowState());
- restoreGeometry(p->getMainwindowGeometry());
- m_windowFullscreen_action->setChecked(isFullScreen());
+ restoreGeometry(p->getMainwindowGeometry());
+ m_windowFullscreen_action->setChecked(isFullScreen());
const CMDIArea::MDIArrangementMode newArrangementMode = p->getMDIArrangementMode();
//make sure actions are updated by calling the slot functions
@@ -544,9 +595,15 @@ void BibleTime::applyProfileSettings( CProfile* p ) {
case CMDIArea::ArrangementModeCascade:
slotAutoCascade();
break;
- default:
+ case CMDIArea::ArrangementModeTile:
+ slotAutoTile();
+ break;
+ case CMDIArea::ArrangementModeManual:
slotManualArrangementMode();
break;
+ default:
+ slotAutoTileVertical();
+ break;
}
}
@@ -555,7 +612,7 @@ void BibleTime::storeProfileSettings( CProfile* p ) {
if (!p || !m_windowFullscreen_action) return;
p->setMainwindowState(saveState());
- p->setMainwindowGeometry(saveGeometry());
+ p->setMainwindowGeometry(saveGeometry());
p->setMDIArrangementMode(m_mdi->getMDIArrangementMode());
}
diff --git a/src/bibletime_slots.cpp b/src/bibletime_slots.cpp
index 973b8e6..b1ee3b3 100644
--- a/src/bibletime_slots.cpp
+++ b/src/bibletime_slots.cpp
@@ -39,28 +39,6 @@
using namespace Profile;
-// /* An action which stores a user defined pointer to a widget.
-// * @author Joachim Ansorg
-// */
-// class KUserDataAction : public KToggleAction {
-// public:
-// KUserDataAction( QString caption, const KShortcut& shortcut, const QObject* receiver, const char* slot, KActionCollection* actionCollection)
-// : KToggleAction(caption, actionCollection), m_userData(0)
-// {
-// setShortcut(shortcut);
-// QObject::connect(this, SIGNAL(triggered()), receiver, slot);
-// };
-//
-// void setUserData(QWidget* const data) {
-// m_userData = data;
-// };
-// QWidget* const getUserData() const {
-// return m_userData;
-// };
-//
-// private:
-// QWidget* m_userData;
-// };
/** Opens the optionsdialog of BibleTime. */
void BibleTime::slotSettingsOptions() {
@@ -102,12 +80,7 @@ void BibleTime::slotSettingsChanged() {
/** Opens the sword setup dialog of BibleTime. */
void BibleTime::slotSwordSetupDialog() {
- /// \todo nonmodal dialog, memory management (one instance only!
- //BtModuleManagerDialog *dlg = new BtModuleManagerDialog(this);
- BtModuleManagerDialog* dlg = BtModuleManagerDialog::getInstance(this);
- //disconnect first because it may be connected already
- //QObject::disconnect(dlg, SIGNAL(swordSetupChanged()), this, SLOT(slotSwordSetupChanged()) );
- //connect(dlg, SIGNAL(swordSetupChanged()), SLOT(slotSwordSetupChanged()) );
+ BtModuleManagerDialog *dlg = BtModuleManagerDialog::getInstance(this);
dlg->showNormal();
dlg->show();
@@ -115,37 +88,9 @@ void BibleTime::slotSwordSetupDialog() {
dlg->activateWindow();
}
-/** Is called when settings in the sword setup dialog were changed (ok or apply) */
-void BibleTime::slotSwordSetupChanged() {
- /*
- Refresh everything here what might have changed
- these are the mainindex, the searchdialog, the displaywindows
- But at first we have to reset the Sword backend to reload the modules
-
- \todo should bookshelf manager be updated?
- Should there be different signals/slots for visual changes,
- i.e. grouping/hiding?
-
- */
-
-
- //CPointers::deleteBackend();
- //m_backend = new CSwordBackend();
- //CPointers::setBackend(new CSwordBackend());
- //CPointers::backend()->reloadModules();
-
- //m_mainIndex->reloadSword();
-
- // refresh display windows
- //refreshDisplayWindows();
-}
-
/** Is called just before the window menu is ahown. */
void BibleTime::slotWindowMenuAboutToShow() {
Q_ASSERT(m_windowMenu);
- if (!m_windowMenu) {
- return;
- }
if ( m_mdi->subWindowList().isEmpty() ) {
m_windowCascade_action->setEnabled(false);
@@ -170,47 +115,12 @@ void BibleTime::slotWindowMenuAboutToShow() {
m_windowCloseAll_action->setEnabled(true);
m_openWindowsMenu->setEnabled(true);
}
-
- // QList<QAction*>::iterator end = m_windowOpenWindowsList.end();
- // for (QList<QAction*>::iterator it = m_windowOpenWindowsList.begin(); it != end; ++it )
- // {
- //(*it)->unplugAll(); //see kde porting doc
- // foreach (QWidget *w, (*it)->associatedWidgets() )
- // {
- // w->removeAction(*it);
- // }
- // }
-
- //m_windowOpenWindowsList.setAutoDelete(true);
- // qDeleteAll(m_windowOpenWindowsList);
- // m_windowOpenWindowsList.clear();
-
-// if (!m_windowActionCollection) {
-// m_windowActionCollection = new KActionCollection(this, KComponentData());
-// }
-
-// QList<QWidget*> windows = m_mdi->windowList();
-// const int count = windows.count();
-// for ( int i = 0; i < count; ++i ) {
-// QWidget* w = windows.at(i);
-// Q_ASSERT(w);
-//
-// KUserDataAction* action = new KUserDataAction(w->windowTitle(), KShortcut(), this, SLOT(slotWindowMenuActivated()), m_windowActionCollection);
-// Q_ASSERT(action);
-// action->setUserData(w);
-//
-// m_windowOpenWindowsList.append(action);
-// action->setChecked( w == m_mdi->activeWindow() );
-// m_windowMenu->addAction(action);
-// }
}
/** Is called just before the open windows menu is ahown. */
void BibleTime::slotOpenWindowsMenuAboutToShow() {
Q_ASSERT(m_openWindowsMenu);
- if (!m_openWindowsMenu) {
- return;
- }
+
QList<QMdiSubWindow*> windows = m_mdi->usableWindowList();
m_openWindowsMenu->clear();
foreach (QMdiSubWindow *window, windows) {
@@ -230,6 +140,7 @@ void BibleTime::slotUpdateWindowArrangementActions( QAction* clickedAction ) {
m_windowTileVertical_action->setEnabled( m_windowManualMode_action->isChecked() );
m_windowTileHorizontal_action->setEnabled( m_windowManualMode_action->isChecked() );
m_windowCascade_action->setEnabled( m_windowManualMode_action->isChecked() );
+ m_windowTile_action->setEnabled( m_windowManualMode_action->isChecked() );
if (clickedAction) {
m_windowManualMode_action->setEnabled(
@@ -237,40 +148,58 @@ void BibleTime::slotUpdateWindowArrangementActions( QAction* clickedAction ) {
&& m_windowTileHorizontal_action != clickedAction
&& m_windowTileVertical_action != clickedAction
&& m_windowCascade_action != clickedAction
+ && m_windowTile_action != clickedAction
);
m_windowAutoTileVertical_action->setEnabled( m_windowAutoTileVertical_action != clickedAction );
m_windowAutoTileHorizontal_action->setEnabled( m_windowAutoTileHorizontal_action != clickedAction );
m_windowAutoCascade_action->setEnabled( m_windowAutoCascade_action != clickedAction );
+ m_windowAutoTile_action->setEnabled( m_windowAutoTile_action != clickedAction );
}
if (clickedAction == m_windowManualMode_action) {
m_windowAutoTileVertical_action->setChecked(false);
m_windowAutoTileHorizontal_action->setChecked(false);
m_windowAutoCascade_action->setChecked(false);
-
+ m_windowAutoTile_action->setChecked(false);
+ m_mdi->enableWindowMinMaxFlags(true);
m_mdi->setMDIArrangementMode( CMDIArea::ArrangementModeManual );
}
else if (clickedAction == m_windowAutoTileVertical_action) {
m_windowManualMode_action->setChecked(false);
m_windowAutoTileHorizontal_action->setChecked(false);
m_windowAutoCascade_action->setChecked(false);
-
+ m_windowAutoTile_action->setChecked(false);
+ m_mdi->enableWindowMinMaxFlags(false);
m_mdi->setMDIArrangementMode( CMDIArea::ArrangementModeTileVertical );
}
else if (clickedAction == m_windowAutoTileHorizontal_action) {
m_windowManualMode_action->setChecked(false);
m_windowAutoTileVertical_action->setChecked(false);
m_windowAutoCascade_action->setChecked(false);
-
+ m_windowAutoTile_action->setChecked(false);
+ m_mdi->enableWindowMinMaxFlags(false);
m_mdi->setMDIArrangementMode( CMDIArea::ArrangementModeTileHorizontal );
}
+ else if (clickedAction == m_windowAutoTile_action) {
+ m_windowManualMode_action->setChecked(false);
+ m_windowAutoTileHorizontal_action->setChecked(false);
+ m_windowAutoTileVertical_action->setChecked(false);
+ m_windowAutoCascade_action->setChecked(false);
+ m_mdi->enableWindowMinMaxFlags(false);
+ m_mdi->setMDIArrangementMode( CMDIArea::ArrangementModeTile );
+ }
else if (clickedAction == m_windowAutoCascade_action) {
m_windowManualMode_action->setChecked(false);
m_windowAutoTileHorizontal_action->setChecked(false);
m_windowAutoTileVertical_action->setChecked(false);
-
+ m_windowAutoTile_action->setChecked(false);
+ m_mdi->enableWindowMinMaxFlags(false);
m_mdi->setMDIArrangementMode( CMDIArea::ArrangementModeCascade );
}
+ else if (clickedAction == m_windowTile_action) {
+ m_mdi->setMDIArrangementMode( CMDIArea::ArrangementModeManual );
+ m_mdi->myTile();
+ }
else if (clickedAction == m_windowCascade_action) {
m_mdi->setMDIArrangementMode( CMDIArea::ArrangementModeManual );
m_mdi->myCascade();
@@ -299,6 +228,15 @@ void BibleTime::slotAutoTileVertical() {
slotUpdateWindowArrangementActions( m_windowAutoTileVertical_action );
}
+/** This slot is connected with the windowAutoTile_action object */
+void BibleTime::slotAutoTile() {
+ slotUpdateWindowArrangementActions( m_windowAutoTile_action );
+}
+
+void BibleTime::slotTile() {
+ slotUpdateWindowArrangementActions( m_windowTile_action );
+}
+
void BibleTime::slotCascade() {
slotUpdateWindowArrangementActions( m_windowCascade_action );
}
@@ -316,22 +254,6 @@ void BibleTime::slotAutoCascade() {
slotUpdateWindowArrangementActions( m_windowAutoCascade_action );
}
-void BibleTime::slotWindowMenuActivated() {
- if (!m_windowMenu) {
- return;
- }
-
- /* const KUserDataAction* action = dynamic_cast<const KUserDataAction*>(sender());
- Q_ASSERT(action);
- if (action) {
- QWidget* const window = action->getUserData();
- Q_ASSERT(window);
- if ( window ) {
- window->setFocus();
- }
- }*/
-}
-
/** Shows/hides the toolbar */
void BibleTime::slotToggleToolbar() {
Q_ASSERT(m_mainToolBar);
@@ -343,6 +265,30 @@ void BibleTime::slotToggleToolbar() {
}
}
+void BibleTime::slotToggleTextWindowHeader() {
+ bool currentState = CBTConfig::get(CBTConfig::showTextWindowHeaders);
+ CBTConfig::set(CBTConfig::showTextWindowHeaders, !currentState);
+ emit toggledTextWindowHeader(!currentState);
+}
+
+void BibleTime::slotToggleTextWindowNavigator() {
+ bool currentState = CBTConfig::get(CBTConfig::showTextWindowNavigator);
+ CBTConfig::set(CBTConfig::showTextWindowNavigator, !currentState);
+ emit toggledTextWindowNavigator(!currentState);
+}
+
+void BibleTime::slotToggleTextWindowToolButtons() {
+ bool currentState = CBTConfig::get(CBTConfig::showTextWindowToolButtons);
+ CBTConfig::set(CBTConfig::showTextWindowToolButtons, !currentState);
+ emit toggledTextWindowToolButtons(!currentState);
+}
+
+void BibleTime::slotToggleTextWindowModuleChooser() {
+ bool currentState = CBTConfig::get(CBTConfig::showTextWindowModuleSelectorButtons);
+ CBTConfig::set(CBTConfig::showTextWindowModuleSelectorButtons, !currentState);
+ emit toggledTextWindowModuleChooser(!currentState);
+}
+
/** Sets the active window. */
void BibleTime::slotSetActiveSubWindow(QWidget* window) {
if (!window)
@@ -411,7 +357,7 @@ void BibleTime::saveProfile(CProfile* profile) {
storeProfileSettings(profile);
QList<CProfileWindow*> profileWindows;
- foreach (QMdiSubWindow* w, m_mdi->subWindowList()) {
+ foreach (QMdiSubWindow* w, m_mdi->subWindowList(QMdiArea::StackingOrder)) {
CDisplayWindow* displayWindow = dynamic_cast<CDisplayWindow*>(w->widget());
if (!displayWindow) {
continue;
@@ -503,7 +449,20 @@ void BibleTime::deleteProfile(QAction* action) {
}
void BibleTime::toggleFullscreen() {
- m_windowFullscreen_action->isChecked() ? showFullScreen() : showNormal();
+ if (m_windowFullscreen_action->isChecked()) {
+ // set full screen mode
+ m_WindowWasMaximizedBeforeFullScreen = isMaximized();
+ showFullScreen();
+ }
+ else {
+ // restore previous non-full screen mode
+ if (m_WindowWasMaximizedBeforeFullScreen) {
+ showMaximized();
+ }
+ else {
+ showNormal();
+ }
+ }
m_mdi->triggerWindowUpdate();
}
@@ -543,6 +502,6 @@ void BibleTime::refreshProfileMenus() {
// Quit from BibleTime
void BibleTime::quit() {
- Search::CSearchDialog::closeDialog();
- close();
+ Search::CSearchDialog::closeDialog();
+ close();
}
diff --git a/src/display-templates/Christmastide.tmpl b/src/display-templates/Christmastide.tmpl
new file mode 100644
index 0000000..6c4c9ea
--- /dev/null
+++ b/src/display-templates/Christmastide.tmpl
@@ -0,0 +1,151 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <title>Christmastide</title>
+ <meta name="GENERATOR" content="BibleTime " VERSION "0.1" />
+ <meta name="AUTHOR" content="BibleTime " VERSION "tabthorpe@FreeBSD.org" />
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+
+ <style type="text/css">
+/* <![CDATA[ */
+body {
+ background-color: #FDF5E6; /* OldeLaceWhite */
+ color: #006400; /* # DarkGreen */
+}
+
+#content {
+ margin: 5px;
+}
+
+#content table {
+ margin:0;
+ padding:0;
+ border-spacing:10px;
+ border-collapse: collapse;
+ vertical-align: top;
+}
+
+#content table th {
+ padding: 0 0 2px 0;
+ text-align: center;
+ font-weight: bold;
+ font-size: 115%;
+}
+
+a {
+ text-decoration:none;
+ font-weight:normal;
+ color: #4A766E; /* # DarkGreenCopper */
+ padding:2px;
+}
+
+td.entry, div.entry {
+ padding: 5px;
+ vertical-align: top;
+}
+
+div.entry {
+ padding: 5px;
+}
+
+td.currententry, div.currententry {
+ padding: 5px;
+ vertical-align: top;
+ font-weight:bold;
+}
+
+td.entry + td.entry {
+ margin-left: 5px;
+}
+
+div.currententry {
+ font-weight:bold;
+ padding: 5px;
+}
+
+.footnote {
+ color: #2E8B57; /* #SeaGreen */
+}
+
+.strongnumber {
+ vertical-align: top;
+ font-size: 60%;
+ color: #20B2AA; /* #LightSeaGreen */
+}
+
+.morphcode {
+ vertical-align: top;
+ font-size: 60%;
+ color: #20B2AA; /* #LightSeaGreen */
+}
+
+.lemma {
+}
+
+.sectiontitle {
+ font-weight: bold;
+ font-size: 120%;
+}
+
+.entry + .sectiontitle {
+ margin-top:35px;
+ padding-top:35px;
+}
+
+.booktitle {
+ font-weight: bold;
+ font-size: 140%;
+}
+
+.foreign {
+}
+
+.jesuswords {
+ color: red;
+ font-size: 0.9em;
+}
+
+.name > .divine {
+ font-variant: small-caps;
+}
+
+.quotation {
+}
+
+.poetry {
+}
+
+.sup {
+ vertical-align: super;
+}
+
+.sub {
+ vertical-align: sub;
+}
+
+.right {
+ text-align: right;
+}
+
+.center {
+ text-align: center;
+}
+
+.bold {
+ font-weight: bold;
+}
+
+.italic {
+ font-style: italic;
+}
+
+#LANG_CSS#
+/* ]]> */
+ </style>
+</head>
+
+<body>
+ <div id="content" lang="#LANG_ABBREV#" xml:lang="#LANG_ABBREV#" dir="#PAGE_DIRECTION#">#CONTENT#</div>
+</body>
+</html>
diff --git a/src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.cpp b/src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.cpp
index 47e274c..e326641 100644
--- a/src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.cpp
+++ b/src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.cpp
@@ -81,7 +81,7 @@ CSwordSetupInstallSourcesDialog::CSwordSetupInstallSourcesDialog(/*QWidget *pare
mainLayout->addSpacing( 10 );
- QDialogButtonBox* buttonBox = new QDialogButtonBox(QDialogButtonBox::Cancel|QDialogButtonBox::Save, Qt::Horizontal, this);
+ QDialogButtonBox* buttonBox = new QDialogButtonBox(QDialogButtonBox::Cancel | QDialogButtonBox::Save, Qt::Horizontal, this);
util::prepareDialogBox(buttonBox);
QPushButton* getListButton = new QPushButton(tr("Get list..."), this);
getListButton->setToolTip(tr("Download a list of sources from CrossWire server and add sources"));
@@ -105,7 +105,8 @@ void CSwordSetupInstallSourcesDialog::slotOk() {
sword::InstallSource is = instbackend::source(m_captionEdit->text());
if ( (QString)is.caption.c_str() == m_captionEdit->text() ) { //source already exists
util::showInformation( this, tr( "Error" ),
- tr("A source with this caption already exists.<br/>Please provide a different caption."));
+ /** \bug Double space in the following string: */
+ tr("A source with this caption already exists. Please provide a different caption."));
return;
}
@@ -153,7 +154,7 @@ void CSwordSetupInstallSourcesDialog::slotProtocolChanged() {
void CSwordSetupInstallSourcesDialog::slotGetListClicked() {
QString message(tr("List of sources will be downloaded from a remote server. Sources will be added to the current list. New source will replace an old one if it has the same label. You can later remove the sources you don't want to keep.\n\nDo you want to continue?"));
- QMessageBox::StandardButton answer = util::showQuestion(this, tr("Get source list from remote server?"), message, QMessageBox::Yes|QMessageBox::No, QMessageBox::Yes);
+ QMessageBox::StandardButton answer = util::showQuestion(this, tr("Get source list from remote server?"), message, QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
if (answer == QMessageBox::No) {
return;
}
@@ -181,7 +182,7 @@ void CSwordSetupInstallSourcesDialog::slotGetListClicked() {
qDebug() << "download succeeded";
success = true;
m_progressDialog->setValue(100); //make sure the dialog closes
- m_remoteListAdded = true;
+ m_remoteListAdded = true;
accept();
}
else {
diff --git a/src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.h b/src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.h
index 64c7f21..12df221 100644
--- a/src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.h
+++ b/src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.h
@@ -28,7 +28,9 @@ class CSwordSetupInstallSourcesDialog : public QDialog {
public:
sword::InstallSource getSource();
- bool wasRemoteListAdded() {return m_remoteListAdded;}
+ bool wasRemoteListAdded() {
+ return m_remoteListAdded;
+ }
CSwordSetupInstallSourcesDialog();
protected slots:
diff --git a/src/frontend/bookshelfmanager/indexpage/btindexpage.cpp b/src/frontend/bookshelfmanager/indexpage/btindexpage.cpp
index df388dd..984700c 100644
--- a/src/frontend/bookshelfmanager/indexpage/btindexpage.cpp
+++ b/src/frontend/bookshelfmanager/indexpage/btindexpage.cpp
@@ -165,7 +165,7 @@ void BtIndexPage::deleteIndices() {
if (m_modsWithIndices->child(i)->checkState(0) == Qt::Checked) {
CSwordModuleInfo* module = CPointers::backend()->findModuleByName(m_modsWithIndices->child(i)->text(0).toUtf8());
if (module) {
- CSwordModuleInfo::deleteIndexForModule( module->name() );
+ module->deleteIndex();
indicesDeleted = true;
}
}
diff --git a/src/frontend/bookshelfmanager/indexpage/btindexpage.h b/src/frontend/bookshelfmanager/indexpage/btindexpage.h
index aa13eb0..795cc0b 100644
--- a/src/frontend/bookshelfmanager/indexpage/btindexpage.h
+++ b/src/frontend/bookshelfmanager/indexpage/btindexpage.h
@@ -11,7 +11,6 @@
#define BTINDEXPAGE_H
#include "frontend/bookshelfmanager/btconfigdialog.h"
-#include "backend/btmoduletreeitem.h"
class QCheckBox;
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallpage.cpp b/src/frontend/bookshelfmanager/installpage/btinstallpage.cpp
index ecdf7e3..b71599a 100644
--- a/src/frontend/bookshelfmanager/installpage/btinstallpage.cpp
+++ b/src/frontend/bookshelfmanager/installpage/btinstallpage.cpp
@@ -145,7 +145,7 @@ void BtInstallPage::initPathCombo() {
if (!dir.isReadable()) continue;
QFileInfo fi( dir.canonicalPath());
if (!fi.isWritable()) continue;
- m_pathCombo->addItem(util::directory::convertDirSeparators(*it));
+ m_pathCombo->addItem(util::directory::convertDirSeparators(*it));
}
// choose the current value from config but check whether we have so many items
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallpathdialog.cpp b/src/frontend/bookshelfmanager/installpage/btinstallpathdialog.cpp
index c6175d5..9efb9f0 100644
--- a/src/frontend/bookshelfmanager/installpage/btinstallpathdialog.cpp
+++ b/src/frontend/bookshelfmanager/installpage/btinstallpathdialog.cpp
@@ -125,19 +125,22 @@ void BtInstallPathDialog::updateTopLevelItems() {
if (m_writableItem->childCount()) {
m_writableItem->setHidden(false);
m_swordPathListBox->expandItem(m_writableItem);
- } else {
+ }
+ else {
m_writableItem->setHidden(true);
}
if (m_readableItem->childCount()) {
m_readableItem->setHidden(false);
m_swordPathListBox->expandItem(m_readableItem);
- } else {
+ }
+ else {
m_readableItem->setHidden(true);
}
if (m_nonexistingItem->childCount()) {
m_nonexistingItem->setHidden(false);
m_swordPathListBox->expandItem(m_nonexistingItem);
- } else {
+ }
+ else {
m_nonexistingItem->setHidden(true);
}
}
@@ -145,22 +148,24 @@ void BtInstallPathDialog::updateTopLevelItems() {
void BtInstallPathDialog::addPathToList(QString pathname) {
if (pathname.isEmpty()) return;
- QTreeWidgetItem* i = 0;
- QDir dir(pathname);
- if (!dir.exists()) {
- i = new QTreeWidgetItem(m_nonexistingItem, QStringList(pathname) );
- } else if (dir.isReadable()) {
- const QFileInfo fi( dir.canonicalPath() );
- if (fi.isWritable()) {
- i = new QTreeWidgetItem(m_writableItem, QStringList(pathname) );
- } else {
- i = new QTreeWidgetItem(m_readableItem, QStringList(pathname) );
- }
+ QTreeWidgetItem* i = 0;
+ QDir dir(pathname);
+ if (!dir.exists()) {
+ i = new QTreeWidgetItem(m_nonexistingItem, QStringList(pathname) );
+ }
+ else if (dir.isReadable()) {
+ const QFileInfo fi( dir.canonicalPath() );
+ if (fi.isWritable()) {
+ i = new QTreeWidgetItem(m_writableItem, QStringList(pathname) );
}
- if (i && QDir(pathname) == instbackend::swordDir()) {
- i->setFlags(Qt::NoItemFlags);
- i->setToolTip(0, tr("This default folder in your home directory can't be removed"));
+ else {
+ i = new QTreeWidgetItem(m_readableItem, QStringList(pathname) );
}
+ }
+ if (i && QDir(pathname) == instbackend::swordDir()) {
+ i->setFlags(Qt::NoItemFlags);
+ i->setToolTip(0, tr("This default folder in your home directory can't be removed"));
+ }
}
void BtInstallPathDialog::slotEditClicked() {
@@ -218,7 +223,7 @@ void BtInstallPathDialog::slotRemoveClicked() {
void BtInstallPathDialog::writeSwordConfig() {
qDebug() << "BtInstallPathDialog::writeSwordConfig";
QStringList targets;
- QTreeWidgetItemIterator it(m_swordPathListBox, QTreeWidgetItemIterator::NoChildren|QTreeWidgetItemIterator::Enabled|QTreeWidgetItemIterator::NotHidden);
+ QTreeWidgetItemIterator it(m_swordPathListBox, QTreeWidgetItemIterator::NoChildren | QTreeWidgetItemIterator::Enabled | QTreeWidgetItemIterator::NotHidden);
while (*it) {
if (!(*it)->text(0).isEmpty()) {
targets << (*it)->text(0);
diff --git a/src/frontend/bookshelfmanager/installpage/btsourcewidget.cpp b/src/frontend/bookshelfmanager/installpage/btsourcewidget.cpp
index 8c43837..81e84fb 100644
--- a/src/frontend/bookshelfmanager/installpage/btsourcewidget.cpp
+++ b/src/frontend/bookshelfmanager/installpage/btsourcewidget.cpp
@@ -192,12 +192,12 @@ void BtSourceWidget::initSources() {
//first clear all sources
//int i = count();
- for (int i = count()-1; i >= 0; i--) {
+ for (int i = count() - 1; i >= 0; i--) {
BtSourceArea* a = dynamic_cast<BtSourceArea*>(widget(i));
a->prepareRemove();
}
- for (int i = count()-1; i >= 0; i--) {
- qDebug() << "remove tab"<<tabText(i);
+ for (int i = count() - 1; i >= 0; i--) {
+ qDebug() << "remove tab" << tabText(i);
QWidget* w = widget(i);
removeTab(i);
delete w;
diff --git a/src/frontend/bookshelfmanager/instbackend.cpp b/src/frontend/bookshelfmanager/instbackend.cpp
index d671430..463a6e5 100644
--- a/src/frontend/bookshelfmanager/instbackend.cpp
+++ b/src/frontend/bookshelfmanager/instbackend.cpp
@@ -120,7 +120,7 @@ bool deleteSource(QString name) {
sce = l.join("|").append("|");
it = range.first;
while (it != range.second) {
- qDebug() << it->second;
+ qDebug() << it->second;
if (it->second == sce) {
config["Sources"].erase(it);
break;
@@ -150,8 +150,8 @@ bool isRemote(const sword::InstallSource& source) {
}
const QString configPath() {
- QString confPath = util::directory::getUserHomeSwordDir().absolutePath();
- confPath.append("/InstallMgr");
+ QString confPath = util::directory::getUserHomeSwordDir().absolutePath();
+ confPath.append("/InstallMgr");
return confPath;
}
@@ -196,23 +196,23 @@ bool setTargetList( const QStringList& targets ) {
return false;
}
- filename = util::directory::convertDirSeparators(filename);
+ filename = util::directory::convertDirSeparators(filename);
SWConfig conf(filename.toLocal8Bit());
conf.Sections.clear();
#ifdef Q_WS_WIN
- // On Windows, add the sword directory to the config file.
- QString swordPath = DU::convertDirSeparators( DU::getApplicationSwordDir().absolutePath());
- conf["Install"].insert(
- std::make_pair( SWBuf("LocalePath"), swordPath.toLocal8Bit().data() )
- );
+ // On Windows, add the sword directory to the config file.
+ QString swordPath = DU::convertDirSeparators( DU::getApplicationSwordDir().absolutePath());
+ conf["Install"].insert(
+ std::make_pair( SWBuf("LocalePath"), swordPath.toLocal8Bit().data() )
+ );
#endif
bool setDataPath = false;
for (QStringList::const_iterator it = targets.begin(); it != targets.end(); ++it) {
- QString t = DU::convertDirSeparators(*it);
+ QString t = DU::convertDirSeparators(*it);
#ifdef Q_WS_WIN
- if (t.contains(DU::convertDirSeparators(DU::getUserHomeDir().canonicalPath().append("\\Sword")))) {
+ if (t.contains(DU::convertDirSeparators(DU::getUserHomeDir().canonicalPath().append("\\Sword")))) {
#else
if (t.contains(DU::getUserHomeDir().canonicalPath().append("/.sword"))) {
#endif
diff --git a/src/frontend/bookshelfmanager/removepage/btremovepage.cpp b/src/frontend/bookshelfmanager/removepage/btremovepage.cpp
index 1cc6398..3f602e0 100644
--- a/src/frontend/bookshelfmanager/removepage/btremovepage.cpp
+++ b/src/frontend/bookshelfmanager/removepage/btremovepage.cpp
@@ -1,31 +1,28 @@
/*********
*
+* 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-2008 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+* Copyright 1999-2009 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License
+* version 2.0.
*
**********/
#include "frontend/bookshelfmanager/removepage/btremovepage.h"
-#include <QDebug>
#include <QGridLayout>
-#include <QLabel>
+#include <QHeaderView>
#include <QList>
-#include <QMultiMap>
#include <QPushButton>
-#include <QString>
-#include <QTreeWidget>
-#include <QTreeWidgetItem>
-#include "backend/btmoduletreeitem.h"
-#include "backend/config/cbtconfig.h"
+#include <QTreeView>
#include "backend/drivers/cswordmoduleinfo.h"
+#include "backend/managers/cswordbackend.h"
#include "util/directory.h"
#include "util/dialogutil.h"
#include "util/cpointers.h"
#include "util/cresmgr.h"
-#include "util/tool.h"
// Sword includes:
#include <swmgr.h>
@@ -43,11 +40,14 @@ BtRemovePage::BtRemovePage()
layout->setColumnStretch(1, 1);
layout->setRowStretch(2, 1);
- m_view = new QTreeWidget(this);
- m_view->setHeaderLabels(QStringList() << tr("Work") << tr("Install path"));
- m_view->setColumnWidth(0, util::tool::mWidth(m_view, 20));
+ m_model = new BtRemovePageTreeModel(this);
+ m_model->setSourceModel(CPointers::backend()->model());
+
+ m_view = new QTreeView(this);
+ m_view->header()->setResizeMode(QHeaderView::ResizeToContents);
+ m_view->setModel(m_model);
- layout->addWidget( m_view, 2, 0, 1, 2);
+ layout->addWidget(m_view, 2, 0, 1, 2);
m_removeButton = new QPushButton(tr("Remove..."), this);
m_removeButton->setToolTip(tr("Remove the selected works"));
@@ -55,80 +55,36 @@ BtRemovePage::BtRemovePage()
m_removeButton->setEnabled(false);
layout->addWidget(m_removeButton, 3, 1, Qt::AlignRight);
- connect(m_view, SIGNAL(itemDoubleClicked(QTreeWidgetItem*, int)), SLOT(slotItemDoubleClicked(QTreeWidgetItem*, int)));
- connect(m_removeButton, SIGNAL(clicked()), this, SLOT(slotRemoveModules()));
- connect(CPointers::backend(), SIGNAL(sigSwordSetupChanged(CSwordBackend::SetupChangedReason)), SLOT(slotSwordSetupChanged()));
- populateModuleList();
+ connect(m_removeButton, SIGNAL(clicked()),
+ this, SLOT(slotRemoveModules()));
+ connect(m_model, SIGNAL(moduleChecked(CSwordModuleInfo*, bool)),
+ this, SLOT(resetRemoveButton()));
+ connect(m_model, SIGNAL(rowsRemoved(const QModelIndex &, int, int)),
+ this, SLOT(resetRemoveButton()));
}
QString BtRemovePage::label() {
return tr("Remove installed works. Select the works and click Remove button.");
}
+
QString BtRemovePage::iconName() {
return CResMgr::bookshelfmgr::removepage::icon;
}
+
QString BtRemovePage::header() {
return tr("Remove");
}
-
-void BtRemovePage::populateModuleList() {
-
- m_view->clear();
- m_selectedModules.clear();
-
- // disconnect the signal so that we don't have to run functions for every module
- disconnect(m_view, SIGNAL(itemChanged(QTreeWidgetItem*, int)), this, SLOT(slotSelectionChanged(QTreeWidgetItem*, int)) );
-
- QList<BTModuleTreeItem::Filter*> empty;
- BTModuleTreeItem rootItem(empty, (BTModuleTreeItem::Grouping)CBTConfig::get(CBTConfig::bookshelfGrouping));
- addToTree(&rootItem, m_view->invisibleRootItem());
-
- // receive signal when user checks modules
- connect(m_view, SIGNAL(itemChanged(QTreeWidgetItem*, int)), this, SLOT(slotSelectionChanged(QTreeWidgetItem*, int)) );
- qDebug() << "BtSourceArea::createModuleTree end";
+void BtRemovePage::resetRemoveButton() {
+ m_removeButton->setEnabled(!m_model->checkedModules().empty());
}
-void BtRemovePage::addToTree(BTModuleTreeItem* item, QTreeWidgetItem* widgetItem) {
- //qDebug()<<"BtRemovePage::addToTree "<<item->text();
- //qDebug() << "BTMTItem type: " << item->type();
-
- foreach (BTModuleTreeItem* i, item->children()) {
- addToTree(i, new QTreeWidgetItem(widgetItem));
- }
- if (item->type() != BTModuleTreeItem::Root) {
- CSwordModuleInfo* mInfo = item->moduleInfo();
- widgetItem->setText(0, item->text());
- if (item->type() == BTModuleTreeItem::Category || item->type() == BTModuleTreeItem::Language) {
- //qDebug() << "item"<<item->text()<< "was cat or lang";
- widgetItem->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsTristate);
- }
- if (item->type() == BTModuleTreeItem::Module) {
- //qDebug() << "item"<<item->text()<< "was a module";
- widgetItem->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
- widgetItem->setCheckState(0, Qt::Unchecked);
-
- /// \todo add the relevant information in to item or tooltip
- // (install path, is still available from some source)
-
- QString descr(mInfo->config(CSwordModuleInfo::AbsoluteDataPath));
- QString toolTipText = util::tool::moduleToolTip(mInfo);
- widgetItem->setText(1, descr);
- widgetItem->setToolTip(0, toolTipText);
- widgetItem->setToolTip(1, descr);
- }
- }
-}
-
-
-
void BtRemovePage::slotRemoveModules() {
- if ( m_selectedModules.empty() ) {
- return; //no message, just do nothing
- }
+ // Do nothing when this signal fires without anything selected to remove:
+ if (m_model->checkedModules().empty()) return;
QStringList moduleNames;
- foreach (CSwordModuleInfo* m, m_selectedModules) {
+ foreach (CSwordModuleInfo *m, m_model->checkedModules()) {
moduleNames.append(m->name());
}
const QString message = tr("You selected the following work(s): ")
@@ -175,44 +131,3 @@ void BtRemovePage::slotRemoveModules() {
mgrDict.clear();
}
}
-
-
-void BtRemovePage::slotSelectionChanged(QTreeWidgetItem* item, int column) {
- //qDebug() << "BtRemovePage::slotSelectionChanged";
- // modify the internal list of checked modules
- // if() leaves groups away
- if (!item->childCount() && column == 0) {
- CSwordModuleInfo* mInfo = 0;
- //qDebug() << "BtRemovePage::slotSelectionChanged";
- foreach (CSwordModuleInfo* module, CPointers::backend()->moduleList()) {
- if (module->name() == item->text(0) && module->config(CSwordModuleInfo::AbsoluteDataPath) == item->text(1)) {
- mInfo = module;
- break;
- }
- }
- Q_ASSERT(mInfo); // this should have been found
- if (item->checkState(0) == Qt::Checked) {
- //qDebug() << item->text(0) << "in" << item->text(1) << "was checked";
- m_selectedModules.append(mInfo);
- }
- else {
- //qDebug() << mInfo->name() << "was unchecked";
- m_selectedModules.removeAll(mInfo); // there is only one, it's a pointer
- }
-
- if (m_selectedModules.count() > 0) {
- m_removeButton->setEnabled(true);
- }
- else {
- m_removeButton->setEnabled(false);
- }
- }
-}
-
-void BtRemovePage::slotItemDoubleClicked(QTreeWidgetItem* /*item*/, int /*column*/) {
- // \todo Open the About dialog.
-}
-
-void BtRemovePage::slotSwordSetupChanged() {
- populateModuleList();
-}
diff --git a/src/frontend/bookshelfmanager/removepage/btremovepage.h b/src/frontend/bookshelfmanager/removepage/btremovepage.h
index 920b1ee..2950619 100644
--- a/src/frontend/bookshelfmanager/removepage/btremovepage.h
+++ b/src/frontend/bookshelfmanager/removepage/btremovepage.h
@@ -1,9 +1,12 @@
/*********
*
+* 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-2008 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+* Copyright 1999-2009 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License
+* version 2.0.
*
**********/
@@ -15,49 +18,32 @@
#include <QMultiMap>
#include <QString>
#include "backend/btmoduletreeitem.h"
+#include "frontend/bookshelfmanager/removepage/btremovepagetreemodel.h"
-class QTreeWidget;
-class QTreeWidgetItem;
class QPushButton;
+class QTreeView;
-class BtRemovePage : public BtConfigPage {
+class BtRemovePage: public BtConfigPage {
Q_OBJECT
public:
BtRemovePage();
- ~BtRemovePage() {}
-
- // BtConfigPage methods
+ // BtConfigPage methods:
QString header();
QString iconName();
QString label();
- void populateModuleList();
-
-//signals:
- //void swordSetupChanged();
-
- public slots:
- void slotSwordSetupChanged();
-
- private slots:
-
+ protected slots:
void slotRemoveModules();
- /** Handles activating the Remove button. */
- void slotSelectionChanged(QTreeWidgetItem* item, int column);
- void slotItemDoubleClicked(QTreeWidgetItem* item, int column);
-
- private: // methods
- void addToTree(BTModuleTreeItem* item, QTreeWidgetItem* widgetItem);
+ void resetRemoveButton();
- private: // data
- QTreeWidget* m_view;
- QPushButton* m_removeButton;
- /** Map of module name and install path (absolute path from the moduleinfo config entry).*/
- QList<CSwordModuleInfo*> m_selectedModules;
+ protected:
+ BtRemovePageTreeModel *m_model;
+ QTreeView *m_view;
+ QPushButton *m_removeButton;
};
#endif
diff --git a/src/frontend/bookshelfmanager/removepage/btremovepagetreemodel.cpp b/src/frontend/bookshelfmanager/removepage/btremovepagetreemodel.cpp
new file mode 100644
index 0000000..fe566d1
--- /dev/null
+++ b/src/frontend/bookshelfmanager/removepage/btremovepagetreemodel.cpp
@@ -0,0 +1,59 @@
+/*********
+*
+* 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 "frontend/bookshelfmanager/removepage/btremovepagetreemodel.h"
+
+
+BtRemovePageTreeModel::BtRemovePageTreeModel(QObject *parent)
+ : BtBookshelfTreeModel(parent) {
+ setCheckable(true);
+ setDefaultChecked(BtBookshelfTreeModel::UNCHECKED);
+}
+
+int BtRemovePageTreeModel::columnCount(const QModelIndex &parent) const {
+ Q_UNUSED(parent);
+
+ return 2;
+}
+
+QVariant BtRemovePageTreeModel::data(const QModelIndex &i, int role) const {
+ if (i.column() == 1) {
+ QModelIndex realIndex(index(i.row(), 0, i.parent()));
+ switch (role) {
+ case Qt::DisplayRole:
+ case Qt::ToolTipRole:
+ return BtBookshelfTreeModel::data(realIndex, BtBookshelfModel::ModuleInstallPathRole);
+ default:
+ break;
+ }
+ }
+ else {
+ return BtBookshelfTreeModel::data(i, role);
+ }
+
+ return QVariant();
+}
+
+QVariant BtRemovePageTreeModel::headerData(int section,
+ Qt::Orientation orientation,
+ int role) const {
+ if (role == Qt::DisplayRole && orientation == Qt::Horizontal) {
+ if (section == 0) {
+ return tr("Work");
+ }
+ else if (section == 1) {
+ return tr("Install path");
+ }
+ }
+
+ return QVariant();
+}
diff --git a/src/frontend/bookshelfmanager/removepage/btremovepagetreemodel.h b/src/frontend/bookshelfmanager/removepage/btremovepagetreemodel.h
new file mode 100644
index 0000000..619a1ff
--- /dev/null
+++ b/src/frontend/bookshelfmanager/removepage/btremovepagetreemodel.h
@@ -0,0 +1,30 @@
+/*********
+*
+* 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 BTREMOVEPAGETREEMODEL_H
+#define BTREMOVEPAGETREEMODEL_H
+
+#include "backend/bookshelfmodel/btbookshelftreemodel.h"
+
+class BtRemovePageTreeModel: public BtBookshelfTreeModel {
+ Q_OBJECT
+
+ public:
+ BtRemovePageTreeModel(QObject *parent = 0);
+
+ int columnCount(const QModelIndex &parent = QModelIndex()) const;
+ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
+ QVariant headerData(int section, Qt::Orientation orientation,
+ int role = Qt::DisplayRole) const;
+};
+
+#endif // BTREMOVEPAGETREEMODEL_H
diff --git a/src/frontend/btbookshelfdockwidget.cpp b/src/frontend/btbookshelfdockwidget.cpp
index bedebcb..880c939 100644
--- a/src/frontend/btbookshelfdockwidget.cpp
+++ b/src/frontend/btbookshelfdockwidget.cpp
@@ -26,8 +26,7 @@
#include <QVBoxLayout>
#include "backend/bookshelfmodel/btbookshelfmodel.h"
#include "backend/bookshelfmodel/btbookshelftreemodel.h"
-#include "backend/bookshelfmodel/btmodulehiddenfilterproxymodel.h"
-#include "backend/bookshelfmodel/btmodulenamefilterproxymodel.h"
+#include "backend/bookshelfmodel/btbookshelffiltermodel.h"
#include "backend/config/cbtconfig.h"
#include "backend/drivers/cswordmoduleinfo.h"
#include "backend/managers/cswordbackend.h"
@@ -59,10 +58,8 @@ BtBookshelfDockWidget::BtBookshelfDockWidget(QWidget *parent, Qt::WindowFlags f)
m_bookshelfTreeModel->setDefaultChecked(BtBookshelfTreeModel::MODULE_HIDDEN);
m_bookshelfTreeModel->setSourceModel(CPointers::backend()->model());
- m_filterProxyModel = new BtModuleHiddenFilterProxyModel(this);
+ m_filterProxyModel = new BtBookshelfFilterModel(this);
m_filterProxyModel->setSourceModel(m_bookshelfTreeModel);
- m_nameFilterProxyModel = new BtModuleNameFilterProxyModel(this);
- m_nameFilterProxyModel->setSourceModel(m_filterProxyModel);
// Setup actions and menus:
initMenus();
@@ -73,7 +70,7 @@ BtBookshelfDockWidget::BtBookshelfDockWidget(QWidget *parent, Qt::WindowFlags f)
layout->setContentsMargins(0, 0, 0, 0);
QHBoxLayout *toolBar(new QHBoxLayout);
// Add a small margin between the edge of the window and the label (looks better)
- toolBar->setContentsMargins(3,0,0,0);
+ toolBar->setContentsMargins(3, 0, 0, 0);
m_nameFilterLabel = new QLabel(this);
toolBar->addWidget(m_nameFilterLabel);
@@ -96,13 +93,13 @@ BtBookshelfDockWidget::BtBookshelfDockWidget(QWidget *parent, Qt::WindowFlags f)
layout->addLayout(toolBar);
m_view = new BtBookshelfView(this);
- m_view->setModel(m_nameFilterProxyModel);
+ m_view->setModel(m_filterProxyModel);
layout->addWidget(m_view);
m_widget->setLayout(layout);
setWidget(m_widget);
connect(m_nameFilterEdit, SIGNAL(textEdited(QString)),
- m_nameFilterProxyModel, SLOT(setFilterFixedString(QString)));
+ m_filterProxyModel, SLOT(setNameFilterFixedString(QString)));
connect(m_view, SIGNAL(contextMenuActivated(QPoint)),
this, SLOT(showContextMenu(QPoint)));
connect(m_view,
@@ -110,10 +107,10 @@ BtBookshelfDockWidget::BtBookshelfDockWidget(QWidget *parent, Qt::WindowFlags f)
this, SLOT(showItemContextMenu(CSwordModuleInfo*, QPoint)));
connect(m_view, SIGNAL(moduleActivated(CSwordModuleInfo*)),
this, SIGNAL(moduleOpenTriggered(CSwordModuleInfo*)));
- connect(m_bookshelfTreeModel, SIGNAL(moduleChecked(CSwordModuleInfo*,bool)),
- this, SLOT(moduleChecked(CSwordModuleInfo*,bool)));
+ connect(m_bookshelfTreeModel, SIGNAL(moduleChecked(CSwordModuleInfo*, bool)),
+ this, SLOT(moduleChecked(CSwordModuleInfo*, bool)));
- retranslateInterface();
+ retranslateUi();
}
bool BtBookshelfDockWidget::eventFilter(QObject *object, QEvent *event) {
@@ -173,7 +170,7 @@ void BtBookshelfDockWidget::initMenus() {
m_groupingMenu->addAction(m_groupingNoneAction);
m_showHideAction = new QAction(this);
- m_showHideAction->setIcon(DU::getIcon(RM::search::icon));
+ m_showHideAction->setIcon(DU::getIcon("layer-visible-on.svg"));
m_showHideAction->setCheckable(true);
connect(m_showHideAction, SIGNAL(toggled(bool)),
this, SLOT(showHideEnabled(bool)));
@@ -217,7 +214,7 @@ void BtBookshelfDockWidget::initMenus() {
m_itemContextMenu->addAction(m_itemAboutAction);
}
-void BtBookshelfDockWidget::retranslateInterface() {
+void BtBookshelfDockWidget::retranslateUi() {
setWindowTitle(tr("Bookshelf"));
m_nameFilterLabel->setText(tr("Fi&lter:"));
@@ -276,10 +273,10 @@ void BtBookshelfDockWidget::groupingActionTriggered(QAction *action) {
void BtBookshelfDockWidget::showHideEnabled(bool enable) {
if (enable) {
m_bookshelfTreeModel->setCheckable(true);
- m_filterProxyModel->setEnabled(false);
+ m_filterProxyModel->setShowHidden(true);
}
else {
- m_filterProxyModel->setEnabled(true);
+ m_filterProxyModel->setShowHidden(false);
m_bookshelfTreeModel->setCheckable(false);
}
}
diff --git a/src/frontend/btbookshelfdockwidget.h b/src/frontend/btbookshelfdockwidget.h
index 165ebae..cfa20e6 100644
--- a/src/frontend/btbookshelfdockwidget.h
+++ b/src/frontend/btbookshelfdockwidget.h
@@ -19,8 +19,7 @@
class CSwordModuleInfo;
class BtBookshelfView;
class BtBookshelfTreeModel;
-class BtModuleHiddenFilterProxyModel;
-class BtModuleNameFilterProxyModel;
+class BtBookshelfFilterModel;
class QAction;
class QActionGroup;
class QLabel;
@@ -45,7 +44,7 @@ class BtBookshelfDockWidget: public QDockWidget {
protected:
bool eventFilter(QObject *object, QEvent *event);
void initMenus();
- void retranslateInterface();
+ void retranslateUi();
protected slots:
void moduleChecked(CSwordModuleInfo *module, bool checked);
@@ -57,12 +56,11 @@ class BtBookshelfDockWidget: public QDockWidget {
protected:
// Models:
- BtBookshelfTreeModel *m_bookshelfTreeModel;
- BtModuleHiddenFilterProxyModel *m_filterProxyModel;
- BtModuleNameFilterProxyModel *m_nameFilterProxyModel;
+ BtBookshelfTreeModel *m_bookshelfTreeModel;
+ BtBookshelfFilterModel *m_filterProxyModel;
// Widgets:
- QWidget *m_widget;
+ QWidget *m_widget;
BtBookshelfView *m_view;
QLabel *m_nameFilterLabel;
QLineEdit *m_nameFilterEdit;
diff --git a/src/frontend/btmenuview.cpp b/src/frontend/btmenuview.cpp
new file mode 100644
index 0000000..ab9fdd1
--- /dev/null
+++ b/src/frontend/btmenuview.cpp
@@ -0,0 +1,161 @@
+/*********
+*
+* 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 "frontend/btmenuview.h"
+
+#include <QActionGroup>
+
+
+BtMenuView::BtMenuView(QWidget *parent)
+ : QMenu(parent), m_model(0), m_actions(0)
+{
+ connect(this, SIGNAL(aboutToShow()),
+ this, SLOT(slotAboutToShow()));
+ connect(this, SIGNAL(aboutToHide()),
+ this, SLOT(slotAboutToHide()));
+}
+
+BtMenuView::~BtMenuView() {
+ if (m_actions != 0) {
+ delete m_actions;
+ }
+}
+
+void BtMenuView::setModel(QAbstractItemModel *model) {
+ m_model = model;
+}
+
+void BtMenuView::buildMenu(QMenu *parentMenu, const QModelIndex &parent) {
+ Q_ASSERT(m_model != 0);
+
+ int children = m_model->rowCount(parent);
+ for (int i = 0; i < children; i++) {
+ QModelIndex child(m_model->index(i, 0, parent));
+ QVariant displayData(m_model->data(child, Qt::DisplayRole));
+ QVariant iconData(m_model->data(child, Qt::DecorationRole));
+ QVariant toolTipData(m_model->data(child, Qt::ToolTipRole));
+ QVariant statusTipData(m_model->data(child, Qt::StatusTipRole));
+ QVariant whatsThisData(m_model->data(child, Qt::WhatsThisRole));
+
+ if (m_model->rowCount(child) > 0) {
+ QMenu *childMenu = new QMenu(parentMenu);
+
+ // Set text:
+ if (qVariantCanConvert<QString>(displayData)) {
+ childMenu->setTitle(displayData.toString());
+ }
+
+ // Set icon:
+ if (qVariantCanConvert<QIcon>(iconData)) {
+ childMenu->setIcon(iconData.value<QIcon>());
+ }
+
+ // Set tooltip:
+ if (qVariantCanConvert<QString>(toolTipData)) {
+ childMenu->setToolTip(toolTipData.toString());
+ }
+
+ // Set status tip:
+ if (qVariantCanConvert<QString>(statusTipData)) {
+ childMenu->setStatusTip(statusTipData.toString());
+ }
+
+ // Set whatsthis:
+ if (qVariantCanConvert<QString>(whatsThisData)) {
+ childMenu->setWhatsThis(whatsThisData.toString());
+ }
+
+ parentMenu->addMenu(childMenu);
+ buildMenu(childMenu, child);
+ } else {
+ QAction *childAction = new QAction(m_actions);
+
+ // Set text:
+ if (qVariantCanConvert<QString>(displayData)) {
+ childAction->setText(displayData.toString());
+ }
+
+ // Set icon:
+ if (qVariantCanConvert<QIcon>(iconData)) {
+ childAction->setIcon(iconData.value<QIcon>());
+ }
+
+ // Set tooltip:
+ if (qVariantCanConvert<QString>(toolTipData)) {
+ childAction->setToolTip(toolTipData.toString());
+ }
+
+ // Set status tip:
+ if (qVariantCanConvert<QString>(statusTipData)) {
+ childAction->setStatusTip(statusTipData.toString());
+ }
+
+ // Set whatsthis:
+ if (qVariantCanConvert<QString>(whatsThisData)) {
+ childAction->setWhatsThis(whatsThisData.toString());
+ }
+
+ // Set checkable:
+ if (m_model->flags(child).testFlag(Qt::ItemIsUserCheckable)) {
+ childAction->setCheckable(true);
+ }
+
+ // Set checked:
+ QVariant checkData(m_model->data(child, Qt::CheckStateRole));
+ bool ok;
+ Qt::CheckState state = (Qt::CheckState) checkData.toInt(&ok);
+ if (ok) {
+ childAction->setChecked(state == Qt::Checked);
+ }
+
+
+ // Map index
+ m_indexMap[childAction] = QPersistentModelIndex(child);
+
+ // Add action to action group:
+ m_actions->addAction(childAction);
+
+ // Add action to menu:
+ parentMenu->addAction(childAction);
+ }
+ }
+}
+
+void BtMenuView::slotAboutToShow() {
+ if (m_actions != 0) {
+ delete m_actions;
+ m_actions = 0;
+ }
+ m_indexMap.clear();
+
+ if (m_model == 0) return;
+
+ m_actions = new QActionGroup(this);
+ connect(m_actions, SIGNAL(triggered(QAction*)),
+ this, SLOT(slotActionTriggered(QAction*)));
+
+ QModelIndex parentIndex;
+ buildMenu(this, parentIndex);
+}
+
+void BtMenuView::slotAboutToHide() {
+ clear();
+}
+
+void BtMenuView::slotActionTriggered(QAction *action) {
+ Q_ASSERT(m_indexMap.contains(action));
+ QPersistentModelIndex itemIndex(m_indexMap.value(action));
+ if (itemIndex.isValid()) {
+ emit triggered(itemIndex);
+ }
+}
+
diff --git a/src/frontend/btmenuview.h b/src/frontend/btmenuview.h
new file mode 100644
index 0000000..dc913e4
--- /dev/null
+++ b/src/frontend/btmenuview.h
@@ -0,0 +1,55 @@
+/*********
+*
+* 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 BTMENUVIEW_H
+#define BTMENUVIEW_H
+
+#include <QMenu>
+
+#include <QMap>
+#include <QPersistentModelIndex>
+
+class QAbstractItemModel;
+class QActionGroup;
+
+/**
+ \warning This menu does not properly handle changes in the source model while
+ being shown, so beware to check whether the index emitted by
+ triggered() is valid.
+*/
+class BtMenuView: public QMenu {
+ Q_OBJECT
+ public:
+ BtMenuView(QWidget *parent = 0);
+ ~BtMenuView();
+
+ void setModel(QAbstractItemModel *model);
+ inline QAbstractItemModel *model() const { return m_model; }
+
+ signals:
+ void triggered(QModelIndex index);
+
+ protected:
+ void buildMenu(QMenu *parentMenu, const QModelIndex &parent);
+
+ protected slots:
+ void slotActionTriggered(QAction *action);
+ void slotAboutToShow();
+ void slotAboutToHide();
+
+ protected:
+ QAbstractItemModel *m_model;
+ QActionGroup *m_actions;
+ QMap<QAction *, QPersistentModelIndex> m_indexMap;
+};
+
+#endif // BTMENUVIEW_H
diff --git a/src/frontend/cinfodisplay.cpp b/src/frontend/cinfodisplay.cpp
index 59aa452..474eacd 100644
--- a/src/frontend/cinfodisplay.cpp
+++ b/src/frontend/cinfodisplay.cpp
@@ -296,7 +296,7 @@ const QString CInfoDisplay::decodeCrossReference( const QString& data ) {
.arg(lang)
.arg(tr("Cross references"))
.arg(module ? ((module->textDirection() == CSwordModuleInfo::LeftToRight) ? "ltr" : "rtl") : "")
- .arg(RenderedText);
+ .arg(RenderedText);
}
/*!
diff --git a/src/frontend/cmdiarea.cpp b/src/frontend/cmdiarea.cpp
index 3745993..c499962 100644
--- a/src/frontend/cmdiarea.cpp
+++ b/src/frontend/cmdiarea.cpp
@@ -14,11 +14,11 @@
#include <QMdiSubWindow>
#include <QTimer>
#include <QWindowStateChangeEvent>
+#include <QMenu>
CMDIArea::CMDIArea(BibleTime *parent)
- : QMdiArea(parent), m_mdiArrangementMode(ArrangementModeManual)
-{
+ : QMdiArea(parent), m_mdiArrangementMode(ArrangementModeManual) {
Q_ASSERT(parent != 0);
setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
@@ -28,20 +28,55 @@ CMDIArea::CMDIArea(BibleTime *parent)
this, SLOT(slotSubWindowActivated(QMdiSubWindow*)));
}
+static const int moveSize = 30;
+
QMdiSubWindow* CMDIArea::addSubWindow(QWidget * widget, Qt::WindowFlags windowFlags) {
QMdiSubWindow* subWindow = QMdiArea::addSubWindow(widget, windowFlags);
subWindow->installEventFilter(this);
- //If we do have a maximized Window, set it to normal so that the new window can be seen
- if (activeSubWindow() && activeSubWindow()->isMaximized()) {
- activeSubWindow()->showNormal();
+ // Change Qt QMdiSubWindow Close action to have no shortcut
+ // This makes our closeWindow actions with Ctrl-W work correctly
+ QList<QAction*> actions = subWindow->systemMenu()->actions();
+ for (int i=0; i<actions.count(); i++) {
+ QAction* action = actions.at(i);
+ QString text = action->text();
+ if (text.contains("Close")) {
+ action->setShortcut(QKeySequence());
+ break;
+ }
}
+ // Manual arrangement mode
+ enableWindowMinMaxFlags(true);
if (m_mdiArrangementMode == ArrangementModeManual) {
- subWindow->resize(400, 400); //set the window to be big enough
+ // Note that the window size/maximization may be changed later by a session restore.
+ // If we already have an active window, make the new one simular to it
+ if (activeSubWindow()) {
+ if (activeSubWindow()->isMaximized()) {
+ // Maximize the new window
+ subWindow->showMaximized();
+ }
+ else {
+ // Make new window the same size as the active window and move it slightly.
+ subWindow->resize(activeSubWindow()->size());
+ QRect subWinGeom = activeSubWindow()->geometry();
+ subWinGeom.translate(moveSize, moveSize);
+ // If it goes off screen, move it almost to the top left
+ if ( ! frameRect().contains(subWinGeom)) {
+ subWinGeom.moveTo(moveSize, moveSize);
+ }
+ subWindow->setGeometry(subWinGeom);
+ }
+ }
+ else {
+ //set the window to be big enough
+ subWindow->resize(400, 400);
+ }
subWindow->raise();
}
else {
+ // Automatic arrangement modes
+ enableWindowMinMaxFlags(false);
triggerWindowUpdate();
}
return subWindow;
@@ -58,34 +93,24 @@ void CMDIArea::myTileVertical() {
}
QList<QMdiSubWindow*> windows = usableWindowList();
- if (activeSubWindow() && activeSubWindow()->isMaximized()) {
- if (activeSubWindow()->size() != this->size()) {
- activeSubWindow()->resize(this->size());
- }
- }
- else if (windows.count() == 1) {
- windows.at(0)->showMaximized();
- }
- else {
- setUpdatesEnabled(false);
- QMdiSubWindow* active = activeSubWindow();
+ setUpdatesEnabled(false);
+ QMdiSubWindow* active = activeSubWindow();
- const int widthForEach = width() / windows.count();
- unsigned int x = 0;
- foreach (QMdiSubWindow *window, windows) {
- window->showNormal();
+ const int widthForEach = width() / windows.count();
+ unsigned int x = 0;
+ foreach (QMdiSubWindow *window, windows) {
+ window->showNormal();
- const int preferredWidth = window->minimumWidth() + window->baseSize().width();
- const int actWidth = qMax(widthForEach, preferredWidth);
+ const int preferredWidth = window->minimumWidth() + window->baseSize().width();
+ const int actWidth = qMax(widthForEach, preferredWidth);
- window->setGeometry(x, 0, actWidth, height());
- x += actWidth;
- }
-
- if (active) active->setFocus();
- setUpdatesEnabled(true);
+ window->setGeometry(x, 0, actWidth, height());
+ x += actWidth;
}
- emitWindowCaptionChanged();
+
+ if (active) active->setFocus();
+ setUpdatesEnabled(true);
+emitWindowCaptionChanged();
}
void CMDIArea::myTileHorizontal() {
@@ -94,33 +119,30 @@ void CMDIArea::myTileHorizontal() {
}
QList<QMdiSubWindow*> windows = usableWindowList();
+ setUpdatesEnabled(false);
+ QMdiSubWindow* active = activeSubWindow();
- if (activeSubWindow() && activeSubWindow()->isMaximized()) {
- if (activeSubWindow()->size() != this->size()) {
- activeSubWindow()->resize(this->size());
- }
- }
- else if (windows.count() == 1) {
- windows.at(0)->showMaximized();
- }
- else {
- setUpdatesEnabled(false);
- QMdiSubWindow* active = activeSubWindow();
+ const int heightForEach = height() / windows.count();
+ unsigned int y = 0;
+ foreach (QMdiSubWindow *window, windows) {
+ window->showNormal();
- const int heightForEach = height() / windows.count();
- unsigned int y = 0;
- foreach (QMdiSubWindow *window, windows) {
- window->showNormal();
+ const int preferredHeight = window->minimumHeight() + window->baseSize().height();
+ const int actHeight = qMax(heightForEach, preferredHeight);
- const int preferredHeight = window->minimumHeight() + window->baseSize().height();
- const int actHeight = qMax(heightForEach, preferredHeight);
+ window->setGeometry( 0, y, width(), actHeight );
+ y += actHeight;
+ }
+ if (active) active->setFocus();
+ setUpdatesEnabled(true);
+ emitWindowCaptionChanged();
+}
- window->setGeometry( 0, y, width(), actHeight );
- y += actHeight;
- }
- if (active) active->setFocus();
- setUpdatesEnabled(true);
+void CMDIArea::myTile() {
+ if (!updatesEnabled() || !usableWindowList().count() ) {
+ return;
}
+ tileSubWindows();
emitWindowCaptionChanged();
}
@@ -131,12 +153,7 @@ void CMDIArea::myCascade() {
QList<QMdiSubWindow*> windows = usableWindowList();
- if (activeSubWindow() && activeSubWindow()->isMaximized()) {
- if (activeSubWindow()->size() != this->size()) {
- activeSubWindow()->resize(this->size());
- }
- }
- else if (windows.count() == 1) {
+ if (windows.count() == 1) {
windows.at(0)->showMaximized();
}
else {
@@ -155,11 +172,13 @@ void CMDIArea::myCascade() {
if (window == active) { //leave out the active window which should be the top window
continue;
}
+ window->showNormal();
window->raise(); //make it the on-top-of-window-stack window to make sure they're in the right order
window->setGeometry(x, y, windowWidth, windowHeight);
x += offsetX;
y += offsetY;
}
+ active->showNormal();
active->setGeometry(x, y, windowWidth, windowHeight);
active->raise();
active->activateWindow();
@@ -172,7 +191,8 @@ void CMDIArea::myCascade() {
void CMDIArea::emitWindowCaptionChanged() {
if (activeSubWindow()) {
emit sigSetToplevelCaption(activeSubWindow()->windowTitle());
- } else {
+ }
+ else {
emit sigSetToplevelCaption(QString());
}
}
@@ -182,7 +202,7 @@ QList<QMdiSubWindow*> CMDIArea::usableWindowList() {
//in subWindowList() when their ChildAdded-Event is triggered
QList<QMdiSubWindow*> ret;
foreach(QMdiSubWindow* w, subWindowList()) {
- if (w->isMinimized() || w->isHidden()) { //not usable for us
+ if (w->isHidden()) { //not usable for us
continue;
}
ret.append( w );
@@ -197,13 +217,18 @@ void CMDIArea::slotSubWindowActivated(QMdiSubWindow* client) {
emit sigSetToplevelCaption( client->windowTitle().trimmed() );
}
-//resize event of the MDI area itself, update layout if necessary
void CMDIArea::resizeEvent(QResizeEvent* e) {
- // Do not call QMdiArea::resizeEvent(e), this would mess up our layout
- // unless we are in manual mode
- if (updatesEnabled()) triggerWindowUpdate();
- if (m_mdiArrangementMode == ArrangementModeManual)
- QMdiArea::resizeEvent(e);
+ /*
+ Do not call QMdiArea::resizeEvent(e) unless we are in manual arrangement
+ mode, since this would mess up our layout. The manual arrangement mode
+ should be handled exactly as in QMdiArea.
+ */
+ if (m_mdiArrangementMode == ArrangementModeManual) {
+ QMdiArea::resizeEvent(e);
+ }
+ else if (updatesEnabled()) {
+ triggerWindowUpdate();
+ }
}
//handle events of the client windows to update layout if necessary
@@ -214,8 +239,7 @@ bool CMDIArea::eventFilter(QObject *o, QEvent *e) {
if (w == 0) return QMdiArea::eventFilter(o, e);
switch (e->type()) {
- case QEvent::WindowStateChange:
- {
+ case QEvent::WindowStateChange: {
Qt::WindowStates newState(w->windowState());
Qt::WindowStates oldState(((QWindowStateChangeEvent*)e)->oldState());
@@ -241,7 +265,9 @@ bool CMDIArea::eventFilter(QObject *o, QEvent *e) {
triggerWindowUpdate();
break;
case QEvent::WindowTitleChange:
- emitWindowCaptionChanged();
+ if (o == activeSubWindow()) {
+ emit sigSetToplevelCaption(w->windowTitle());
+ }
break;
default:
break;
@@ -262,8 +288,30 @@ void CMDIArea::triggerWindowUpdate() {
case ArrangementModeCascade:
QTimer::singleShot(0, this, SLOT(myCascade()));
break;
+ case ArrangementModeTile:
+ QTimer::singleShot(0, this, SLOT(myTile()));
+ break;
default:
break;
}
}
}
+
+void CMDIArea::enableWindowMinMaxFlags(bool enable)
+{
+ foreach(QMdiSubWindow* subWindow, subWindowList()) {
+ Qt::WindowFlags flags = subWindow->windowFlags();
+ if (enable) {
+ flags |= Qt::WindowMinimizeButtonHint;
+ flags |= Qt::WindowMaximizeButtonHint;
+ }
+ else {
+ flags &= ~Qt::WindowMinimizeButtonHint;
+ flags &= ~Qt::WindowMaximizeButtonHint;
+ }
+ subWindow->setWindowFlags(flags);
+ subWindow->hide();
+ subWindow->show();
+ }
+}
+
diff --git a/src/frontend/cmdiarea.h b/src/frontend/cmdiarea.h
index 1fb1c7f..858d0d4 100644
--- a/src/frontend/cmdiarea.h
+++ b/src/frontend/cmdiarea.h
@@ -32,7 +32,8 @@ class CMDIArea: public QMdiArea {
ArrangementModeTileVertical = 1,
ArrangementModeTileHorizontal = 2,
ArrangementModeCascade = 3,
- ArrangementModeManual = 4
+ ArrangementModeManual = 4,
+ ArrangementModeTile = 5
};
/**
@@ -68,22 +69,43 @@ class CMDIArea: public QMdiArea {
*/
QList<QMdiSubWindow*> usableWindowList();
+ /**
+ Show or hide the sub-window min/max buttons.
+ */
+ void enableWindowMinMaxFlags(bool enable);
+
public slots:
/**
- Our own cascade version which, if only one window is left, shows this
- maximized. Also necessary for autoCascade feature.
+ Uses Qt's tileSubWindows function.
+ \note This not set an automatic arrangement mode, it just arranges the
+ subwindows once. However, this method is also used when
+ arranging the subwindows into a tile automatically.
+ */
+ void myTile();
+ /**
+ Our own cascade version which, if only one subwindow is left, shows it
+ maximized.
+ \note This not set an automatic arrangement mode, it just arranges the
+ subwindows once. However, this method is also used when
+ arranging the subwindows into a cascade automatically.
*/
void myCascade();
/**
- Our own cascade version which, if only one window is left, shows this
- maximized. Also necessary for autoTile feature.
+ Our own vertical tile version which, if only one subwindow is left,
+ shows it maximized.
+ \note This not set an automatic arrangement mode, it just arranges the
+ subwindows once. However, this method is also used when
+ arranging the subwindows into a vertical tiling automatically.
*/
void myTileVertical();
/**
- Horizontal tile function. This function was taken from Qt's MDI
- example.
+ Our own horizontal tile version which, if only one subwindow is left,
+ shows it maximized.
+ \note This not set an automatic arrangement mode, it just arranges the
+ subwindows once. However, this method is also used when
+ arranging the subwindows into a horizontal tiling automatically.
*/
void myTileHorizontal();
@@ -95,7 +117,8 @@ class CMDIArea: public QMdiArea {
protected:
/**
- * Reimplementation of QWidget::resizeEvent().
+ Reimplementation of QWidget::resizeEvent() to handle our automatic
+ tiling properly.
*/
void resizeEvent(QResizeEvent *e);
diff --git a/src/frontend/display/bthtmlreaddisplay.cpp b/src/frontend/display/bthtmlreaddisplay.cpp
index 3d97fba..dd2132f 100644
--- a/src/frontend/display/bthtmlreaddisplay.cpp
+++ b/src/frontend/display/bthtmlreaddisplay.cpp
@@ -28,12 +28,8 @@ using namespace InfoDisplay;
void showBtHtmlFindText(CMDIArea*);
-static const QString body = "</body>";
-static const QString jsBegin = "<script type=\"text/javascript\">";
-static const QString jsEnd = "</script>";
static QString javascript; // Initialized from file bthtml.js
-
BtHtmlReadDisplay::BtHtmlReadDisplay(CReadWindow* readWindow, QWidget* parentWidget)
: QWebPage(parentWidget), CReadDisplay(readWindow), m_magTimerId(0), m_view(0), m_jsObject(0)
@@ -198,9 +194,13 @@ const QString BtHtmlReadDisplay::text( const CDisplay::TextType format, const CD
// Puts html text and javascript into QWebView
void BtHtmlReadDisplay::setText( const QString& newText ) {
+
QString jsText = newText;
- jsText.replace(body, jsBegin + javascript + jsEnd + body);
+ jsText.replace(
+ QString("</body>"),
+ QString("<script type=\"text/javascript\">").append(javascript).append("</script></body>")
+ );
// Disconnect any previous connect and connect to slot that loads the javascript object
QWebFrame* frame = mainFrame();
@@ -210,6 +210,12 @@ void BtHtmlReadDisplay::setText( const QString& newText ) {
// Send text to the html viewer
m_view->setHtml(jsText);
+
+ this->currentSource = jsText;
+}
+
+QString BtHtmlReadDisplay::getCurrentSource( ) {
+ return this->currentSource;
}
// See if any text is selected
diff --git a/src/frontend/display/bthtmlreaddisplay.h b/src/frontend/display/bthtmlreaddisplay.h
index 7c2d91f..e4011d0 100644
--- a/src/frontend/display/bthtmlreaddisplay.h
+++ b/src/frontend/display/bthtmlreaddisplay.h
@@ -45,6 +45,9 @@ class BtHtmlReadDisplay : public QWebPage, public CReadDisplay {
// Sets the new text for this display widget.
virtual void setText( const QString& newText );
+ // Get the current source
+ virtual QString getCurrentSource();
+
virtual bool hasSelection();
// Reimplementation.
@@ -81,6 +84,8 @@ class BtHtmlReadDisplay : public QWebPage, public CReadDisplay {
}
m_dndData;
+ QString currentSource;
+
QMap<NodeInfoType, QString> m_nodeInfo;
int m_magTimerId;
diff --git a/src/frontend/display/cdisplay.cpp b/src/frontend/display/cdisplay.cpp
index a63b55b..8135d03 100644
--- a/src/frontend/display/cdisplay.cpp
+++ b/src/frontend/display/cdisplay.cpp
@@ -22,8 +22,6 @@
#include "util/tool.h"
-typedef BtHtmlReadDisplay HTMLREADDISPLAY;
-
CDisplayConnections::CDisplayConnections( CDisplay* display ) : m_display(display) {}
void CDisplayConnections::selectAll() {
@@ -109,7 +107,7 @@ void CDisplayConnections::openFindTextDialog() {
/*----------------------*/
CReadDisplay* CDisplay::createReadInstance( CReadWindow* readWindow, QWidget* parent ) {
- return new HTMLREADDISPLAY(readWindow, parent);
+ return new BtHtmlReadDisplay(readWindow, parent);
}
CWriteDisplay* CDisplay::createWriteInstance( CWriteWindow* writeWindow, const CWriteDisplay::WriteDisplayType& type, QWidget* parent ) {
diff --git a/src/frontend/display/cdisplay.h b/src/frontend/display/cdisplay.h
index b84c26e..a7d6a03 100644
--- a/src/frontend/display/cdisplay.h
+++ b/src/frontend/display/cdisplay.h
@@ -35,7 +35,9 @@ class CDisplay : public CPointers {
};
static CReadDisplay* createReadInstance(CReadWindow* readWindow, QWidget* parent = 0);
- static CWriteDisplay* createWriteInstance( CWriteWindow* writeWindow, const WriteDisplayType& type = PlainTextDisplay, QWidget* parent = 0 );
+ static CWriteDisplay* createWriteInstance( CWriteWindow* writeWindow,
+ const WriteDisplayType& type = PlainTextDisplay,
+ QWidget* parent = 0 );
enum TextType {
HTMLText, /* Used for HTML markup */
@@ -63,7 +65,8 @@ class CDisplay : public CPointers {
/** Returns the text in the given format.
*
*/
- virtual const QString text( const CDisplay::TextType format = CDisplay::HTMLText, const CDisplay::TextPart part = CDisplay::Document ) = 0;
+ virtual const QString text( const CDisplay::TextType format = CDisplay::HTMLText,
+ const CDisplay::TextPart part = CDisplay::Document ) = 0;
/**
* Sets the new text for this display widget.
*/
@@ -88,7 +91,8 @@ class CDisplay : public CPointers {
* Returns the parent window used for this display widget.
*/
CDisplayWindow* parentWindow() const;
- virtual void print( const CDisplay::TextPart, CSwordBackend::DisplayOptions displayOptions, CSwordBackend::FilterOptions filterOptions) = 0;
+ virtual void print( const CDisplay::TextPart, CSwordBackend::DisplayOptions displayOptions,
+ CSwordBackend::FilterOptions filterOptions) = 0;
/**
* Installs the popup which should be opened when the right mouse button was pressed.
*/
@@ -148,7 +152,8 @@ class CDisplayConnections : public QObject {
void saveAnchorWithText();
void printAll(CSwordBackend::DisplayOptions displayOptions, CSwordBackend::FilterOptions filterOptions);
- void printAnchorWithText(CSwordBackend::DisplayOptions displayOptions, CSwordBackend::FilterOptions filterOptions);
+ void printAnchorWithText(CSwordBackend::DisplayOptions displayOptions,
+ CSwordBackend::FilterOptions filterOptions);
void copySelection();
void copyAll();
diff --git a/src/frontend/display/creaddisplay.cpp b/src/frontend/display/creaddisplay.cpp
index de0680b..90175d4 100644
--- a/src/frontend/display/creaddisplay.cpp
+++ b/src/frontend/display/creaddisplay.cpp
@@ -51,8 +51,8 @@ void CReadDisplay::print(const CDisplay::TextPart type, CSwordBackend::DisplayOp
CSwordKey* const key = window->key();
CSwordModuleInfo* module = key->module();
-
- CExportManager mgr(QObject::tr("Print keys"), false, QString::null, parentWindow()->filterOptions(), parentWindow()->displayOptions());
+ const CDisplayWindow *displayWindow = parentWindow();
+ CExportManager mgr(QObject::tr("Print keys"), false, QString::null, displayWindow->filterOptions(), displayWindow->displayOptions());
switch (type) {
case Document: {
diff --git a/src/frontend/display/creaddisplay.h b/src/frontend/display/creaddisplay.h
index 57524b5..b766f5b 100644
--- a/src/frontend/display/creaddisplay.h
+++ b/src/frontend/display/creaddisplay.h
@@ -33,7 +33,8 @@ class CReadDisplay : public CDisplay {
* Moves the widget to the given anchor.
*/
virtual void moveToAnchor( const QString& ) = 0;
- virtual void print(const CDisplay::TextPart, CSwordBackend::DisplayOptions displayOptions, CSwordBackend::FilterOptions filterOptions);
+ virtual void print(const CDisplay::TextPart, CSwordBackend::DisplayOptions displayOptions,
+ CSwordBackend::FilterOptions filterOptions);
void setMouseTracking(const bool trackingEnabled) {
m_useMouseTracking = trackingEnabled;
diff --git a/src/frontend/displaywindow/btdisplaysettingsbutton.cpp b/src/frontend/displaywindow/btdisplaysettingsbutton.cpp
new file mode 100644
index 0000000..e809efc
--- /dev/null
+++ b/src/frontend/displaywindow/btdisplaysettingsbutton.cpp
@@ -0,0 +1,232 @@
+/*********
+*
+* 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 "frontend/displaywindow/btdisplaysettingsbutton.h"
+
+#include <QHash>
+#include <QMenu>
+#include <QString>
+#include <QToolTip>
+#include <QToolButton>
+#include "util/directory.h"
+#include "util/cpointers.h"
+#include "util/cresmgr.h"
+
+
+BtDisplaySettingsButton::BtDisplaySettingsButton(QWidget *parent)
+ : QToolButton(parent) {
+ namespace DU = util::directory;
+
+ initMenu();
+
+ setIcon(DU::getIcon(CResMgr::displaywindows::displaySettings::icon));
+ setPopupMode(QToolButton::InstantPopup);
+ setEnabled(false);
+
+ initMenu();
+ retranslateUi();
+
+ connect(m_popup, SIGNAL(triggered(QAction*)),
+ this, SLOT(slotOptionToggled(QAction*)));
+}
+
+void BtDisplaySettingsButton::setDisplayOptions(
+ const CSwordBackend::DisplayOptions &displaySettings, bool repopulate)
+{
+ m_displayOptions = displaySettings;
+ if (repopulate) {
+ repopulateMenu();
+ }
+}
+
+void BtDisplaySettingsButton::setFilterOptions(
+ const CSwordBackend::FilterOptions &moduleSettings,
+ bool repopulate)
+{
+ m_filterOptions = moduleSettings;
+ if (repopulate) {
+ repopulateMenu();
+ }
+}
+
+void BtDisplaySettingsButton::setModules(const QList<CSwordModuleInfo*> &modules) {
+ m_modules = modules;
+ repopulateMenu();
+}
+
+void BtDisplaySettingsButton::initMenu() {
+ m_popup = new QMenu(this);
+ setMenu(m_popup);
+
+ m_lineBreakAction = new QAction(this);
+ m_lineBreakAction->setCheckable(true);
+
+ m_verseNumbersAction = new QAction(this);
+ m_verseNumbersAction->setCheckable(true);
+
+ m_headingsAction = new QAction(this);
+ m_headingsAction->setCheckable(true);
+
+ m_redWordsAction = new QAction(this);
+ m_redWordsAction->setCheckable(true);
+
+ m_hebrewPointsAction = new QAction(this);
+ m_hebrewPointsAction->setCheckable(true);
+
+ m_hebrewCantillationAction = new QAction(this);
+ m_hebrewCantillationAction->setCheckable(true);
+
+ m_greekAccentsAction = new QAction(this);
+ m_greekAccentsAction->setCheckable(true);
+
+ m_variantAction = new QAction(this);
+ m_variantAction->setCheckable(true);
+
+ m_scriptureReferencesAction = new QAction(this);
+ m_scriptureReferencesAction->setCheckable(true);
+
+ m_morphSegmentationAction = new QAction(this);
+ m_morphSegmentationAction->setCheckable(true);
+}
+
+void BtDisplaySettingsButton::retranslateUi() {
+ m_lineBreakAction->setText(tr("Use linebreaks after each verse"));
+ m_verseNumbersAction->setText(tr("Show verse numbers"));
+ m_headingsAction->setText(tr("Show headings"));
+ m_redWordsAction->setText(tr("Highlight words of Jesus"));
+ m_hebrewPointsAction->setText(tr("Show Hebrew vowel points"));
+ m_hebrewCantillationAction->setText(tr("Show Hebrew cantillation marks"));
+ m_greekAccentsAction->setText(tr("Show Greek accents"));
+ m_variantAction->setText(tr("Use alternative textual variant"));
+ m_scriptureReferencesAction->setText(tr("Show scripture cross-references"));
+ m_morphSegmentationAction->setText(tr("Show morph segmentation"));
+
+ retranslateToolTip();
+}
+
+void BtDisplaySettingsButton::retranslateToolTip() {
+ if (isEnabled()) {
+ setToolTip(tr("Display settings"));
+ }
+ else {
+ setToolTip(tr("Display settings: No options available"));
+ }
+}
+
+void BtDisplaySettingsButton::slotOptionToggled(QAction *action) {
+ bool checked = action->isChecked();
+
+ if (action == m_lineBreakAction) {
+ m_displayOptions.lineBreaks = checked;
+ emit sigDisplayOptionsChanged(m_displayOptions);
+ } else if (action == m_verseNumbersAction) {
+ m_displayOptions.verseNumbers = checked;
+ emit sigDisplayOptionsChanged(m_displayOptions);
+ } else if (action == m_variantAction) {
+ m_filterOptions.textualVariants = checked;
+ emit sigFilterOptionsChanged(m_filterOptions);
+ } else if (action == m_hebrewPointsAction) {
+ m_filterOptions.hebrewPoints = checked;
+ emit sigFilterOptionsChanged(m_filterOptions);
+ } else if (action == m_greekAccentsAction) {
+ m_filterOptions.greekAccents = checked;
+ emit sigFilterOptionsChanged(m_filterOptions);
+ } else if (action == m_hebrewCantillationAction) {
+ m_filterOptions.hebrewCantillation = checked;
+ emit sigFilterOptionsChanged(m_filterOptions);
+ } else if (action == m_headingsAction) {
+ m_filterOptions.headings = checked;
+ emit sigFilterOptionsChanged(m_filterOptions);
+ } else if (action == m_morphSegmentationAction) {
+ m_filterOptions.morphSegmentation = checked;
+ emit sigFilterOptionsChanged(m_filterOptions);
+ } else if (action == m_scriptureReferencesAction) {
+ m_filterOptions.scriptureReferences = checked;
+ emit sigFilterOptionsChanged(m_filterOptions);
+ } else if (action == m_redWordsAction) {
+ m_filterOptions.redLetterWords = checked;
+ emit sigFilterOptionsChanged(m_filterOptions);
+ } else {
+ Q_ASSERT(false);
+ return;
+ }
+
+ emit sigChanged();
+}
+
+/** No descriptions */
+void BtDisplaySettingsButton::repopulateMenu() {
+ bool enable = false;
+
+ m_popup->clear();
+ if (!m_modules.isEmpty()) {
+ if (m_modules.first()->type() == CSwordModuleInfo::Bible) {
+ addMenuEntry(m_lineBreakAction, m_displayOptions.lineBreaks);
+ addMenuEntry(m_verseNumbersAction, m_displayOptions.verseNumbers);
+ enable = true;
+ }
+
+ if (isOptionAvailable(CSwordModuleInfo::headings)) {
+ addMenuEntry(m_headingsAction, m_filterOptions.headings);
+ enable = true;
+ }
+
+ if (isOptionAvailable(CSwordModuleInfo::redLetterWords)) {
+ addMenuEntry(m_redWordsAction, m_filterOptions.redLetterWords);
+ enable = true;
+ }
+
+ if (isOptionAvailable(CSwordModuleInfo::hebrewPoints)) {
+ addMenuEntry(m_hebrewPointsAction, m_filterOptions.hebrewPoints);
+ enable = true;
+ }
+
+ if (isOptionAvailable(CSwordModuleInfo::hebrewCantillation)) {
+ addMenuEntry(m_hebrewCantillationAction, m_filterOptions.hebrewCantillation);
+ enable = true;
+ }
+
+ if (isOptionAvailable(CSwordModuleInfo::greekAccents)) {
+ addMenuEntry(m_greekAccentsAction, m_filterOptions.greekAccents);
+ enable = true;
+ }
+
+ if (isOptionAvailable(CSwordModuleInfo::textualVariants)) {
+ addMenuEntry(m_variantAction, m_filterOptions.textualVariants);
+ enable = true;
+ }
+
+ if (isOptionAvailable(CSwordModuleInfo::scriptureReferences)) {
+ addMenuEntry(m_scriptureReferencesAction, m_filterOptions.scriptureReferences);
+ enable = true;
+ }
+
+ if (isOptionAvailable(CSwordModuleInfo::morphSegmentation)) {
+ addMenuEntry(m_morphSegmentationAction, m_filterOptions.morphSegmentation);
+ enable = true;
+ }
+ }
+
+ // Disable the settings button if no options are available:
+ setEnabled(enable);
+ retranslateToolTip();
+}
+
+/** Adds an entry to m_popup. */
+void BtDisplaySettingsButton::addMenuEntry(QAction *action, bool checked) {
+ action->setChecked(checked);
+ m_popup->addAction(action);
+}
+
+bool BtDisplaySettingsButton::isOptionAvailable(const CSwordModuleInfo::FilterTypes option) {
+ foreach (CSwordModuleInfo *module, m_modules) {
+ if (module->has(option)) return true;
+ }
+ return false;
+}
diff --git a/src/frontend/displaywindow/btdisplaysettingsbutton.h b/src/frontend/displaywindow/btdisplaysettingsbutton.h
new file mode 100644
index 0000000..e947e83
--- /dev/null
+++ b/src/frontend/displaywindow/btdisplaysettingsbutton.h
@@ -0,0 +1,71 @@
+/*********
+*
+* 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 BTDISPLAYSETTINGSBUTTON_H
+#define BTDISPLAYSETTINGSBUTTON_H
+
+#include <QToolButton>
+
+#include "backend/managers/cswordbackend.h"
+
+
+class CSwordModuleInfo;
+class QMenu;
+
+/** This class manages the display options of the selected modules.
+ * @author The BibleTime team
+ */
+class BtDisplaySettingsButton: public QToolButton {
+ Q_OBJECT
+
+ public:
+ BtDisplaySettingsButton(QWidget *parent = 0);
+
+ void setDisplayOptions(const CSwordBackend::DisplayOptions &displaySettings,
+ bool repopulate = true);
+ void setFilterOptions(const CSwordBackend::FilterOptions &moduleSettings,
+ bool repopulate = true);
+ void setModules(const QList<CSwordModuleInfo*> &modules);
+
+ signals:
+ void sigFilterOptionsChanged(CSwordBackend::FilterOptions filterOptions);
+ void sigDisplayOptionsChanged(CSwordBackend::DisplayOptions displayOptions);
+ void sigChanged(void);
+
+ protected slots:
+ void slotOptionToggled(QAction *action);
+
+ protected:
+ void initMenu();
+ void retranslateUi();
+ void retranslateToolTip();
+ void repopulateMenu();
+
+ bool isOptionAvailable(const CSwordModuleInfo::FilterTypes option);
+ void addMenuEntry(QAction *action, bool checked);
+
+ private:
+ CSwordBackend::FilterOptions m_filterOptions;
+ CSwordBackend::DisplayOptions m_displayOptions;
+ QList<CSwordModuleInfo*> m_modules;
+
+ QMenu *m_popup;
+ QAction *m_lineBreakAction;
+ QAction *m_verseNumbersAction;
+ QAction *m_headingsAction;
+ QAction *m_redWordsAction;
+ QAction *m_hebrewPointsAction;
+ QAction *m_hebrewCantillationAction;
+ QAction *m_greekAccentsAction;
+ QAction *m_variantAction;
+ QAction *m_scriptureReferencesAction;
+ QAction *m_morphSegmentationAction;
+};
+
+#endif
diff --git a/src/frontend/displaywindow/btmodulechooserbar.cpp b/src/frontend/displaywindow/btmodulechooserbar.cpp
new file mode 100644
index 0000000..e07e739
--- /dev/null
+++ b/src/frontend/displaywindow/btmodulechooserbar.cpp
@@ -0,0 +1,134 @@
+/*********
+*
+* 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 "frontend/displaywindow/btmodulechooserbar.h"
+#include "frontend/displaywindow/btmodulechooserbutton.h"
+#include "creadwindow.h"
+
+#include <QAction>
+#include <QDebug>
+#include <QList>
+#include <QToolBar>
+
+
+BtModuleChooserBar::BtModuleChooserBar(QStringList useModules, CSwordModuleInfo::ModuleType type, CReadWindow *parent)
+ : QToolBar(parent),
+ BtWindowModuleChooser(parent, type),
+ m_idCounter(0) {
+
+ qDebug() << "BtModuleChooserBar::BtModuleChooserBar";
+ setAllowedAreas(Qt::TopToolBarArea);
+ setFloatable(false);
+ setModules(useModules);
+ connect(parent, SIGNAL(sigModuleListSet(QStringList)), SLOT(slotBackendModulesChanged()));
+ connect(parent, SIGNAL(sigModuleListChanged()), SLOT(slotWindowModulesChanged()));
+}
+
+void BtModuleChooserBar::slotBackendModulesChanged() {
+ backendModulesChanged();
+}
+
+void BtModuleChooserBar::backendModulesChanged() {
+ m_modules = m_window->getModuleList();
+
+ adjustButtonCount();
+
+ //recreate all menus from scratch
+ for (int i = 0; i < m_buttonList.count(); i++) {
+ BtModuleChooserButton* button = m_buttonList.at(i);
+ QString moduleName = (i >= m_modules.count()) ? QString::null : m_modules.at(i);
+ qDebug() << "refresh button's menu:" << moduleName << i;
+ button->recreateMenu(m_modules, moduleName, i);
+ }
+}
+
+void BtModuleChooserBar::slotWindowModulesChanged() {
+ windowModulesChanged();
+}
+
+void BtModuleChooserBar::adjustButtonCount(bool adjustToZero) {
+ //qDebug() << "BtModuleChooserBar::ajustButtonCount";
+ int buttonCountDifference = 0;
+ if (adjustToZero) {
+ buttonCountDifference = m_buttonList.count();
+ }
+ else {
+ buttonCountDifference = m_buttonList.count() - (m_modules.count() + 1);
+ }
+ if (m_moduleType == CSwordModuleInfo::GenericBook && !adjustToZero) {
+ buttonCountDifference = (1 - m_buttonList.count()) * -1;
+ }
+ //if there are more buttons than modules, delete buttons
+ if (buttonCountDifference > 0) {
+ for (int j = 0; j < buttonCountDifference; j++) {
+ //qDebug() << "delete first button, " << j;
+ // it should be safe to delete the button later
+ BtModuleChooserButton* b = m_buttonList.takeFirst();
+ b->setParent(0);
+ b->deleteLater();
+ }
+ }
+ // if there are more modules than buttons, add buttons
+ if (buttonCountDifference < 0) {
+ for (int i = (buttonCountDifference * (-1)); i > 0; i--) {
+ addButton();
+ }
+ }
+}
+
+void BtModuleChooserBar::windowModulesChanged() {
+ //qDebug() << "BtModuleChooserBar::windowModulesChanged";
+ m_modules = m_window->getModuleList();
+ adjustButtonCount();
+ updateButtonMenus();
+}
+
+BtModuleChooserButton* BtModuleChooserBar::addButton() {
+ //qDebug() << "BtModuleChooserBar::addButton";
+ BtModuleChooserButton* b = new BtModuleChooserButton(this, m_moduleType);
+ QAction* a = addWidget(b);
+ m_buttonList.append(b);
+
+ // the button sends signals directly to the window which then signals back when the module
+ // list has changed
+ connect(b, SIGNAL(sigModuleAdd(int, QString)), m_window, SLOT(slotAddModule(int, QString)));
+ connect(b, SIGNAL(sigModuleReplace(int, QString)), m_window, SLOT(slotReplaceModule(int, QString)));
+ connect(b, SIGNAL(sigModuleRemove(int)), m_window, SLOT(slotRemoveModule(int)));
+
+ a->setVisible(true);
+ return b;
+}
+
+/** Sets the modules which are chosen in this module chooser bar. */
+void BtModuleChooserBar::setModules( QStringList useModules ) {
+ qDebug() << "BtModuleChooserBar::setModules";
+ m_modules = useModules;
+ adjustButtonCount(true);
+
+ //if (!useModules.count()) return;
+ for (int i = 0; i < useModules.count(); i++) {
+ addButton();
+ }
+ if (!(m_moduleType == CSwordModuleInfo::GenericBook)) {
+ addButton(); // for ADD button
+ }
+ updateButtonMenus();
+ qDebug() << "BtModuleChooserBar::setModules end";
+}
+
+void BtModuleChooserBar::updateButtonMenus() {
+ //qDebug() << "BtModuleChooserBar::updateMenuItems";
+
+ for (int i = 0; i < m_buttonList.count(); i++) {
+ BtModuleChooserButton* button = m_buttonList.at(i);
+ QString moduleName = (i >= m_modules.count()) ? QString::null : m_modules.at(i);
+ //qDebug() << "refresh button's menu:" << moduleName << i;
+ button->updateMenu(m_modules, moduleName, i);
+ }
+}
diff --git a/src/frontend/displaywindow/btmodulechooserbar.h b/src/frontend/displaywindow/btmodulechooserbar.h
new file mode 100644
index 0000000..7ae903c
--- /dev/null
+++ b/src/frontend/displaywindow/btmodulechooserbar.h
@@ -0,0 +1,62 @@
+/*********
+*
+* 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_MODULECHOOSERBAR
+#define BT_MODULECHOOSERBAR
+
+#include "btwindowmodulechooser.h"
+#include "backend/drivers/cswordmoduleinfo.h"
+#include <QToolBar>
+#include <QStringList>
+
+class CReadWindow;
+class BtModuleChooserButton;
+
+class BtModuleChooserBar: public QToolBar, public BtWindowModuleChooser {
+ Q_OBJECT
+ public:
+ BtModuleChooserBar(QStringList useModules, CSwordModuleInfo::ModuleType type, CReadWindow* parent);
+
+ public slots:
+ /** The backend module list was updated, module list and widgets must be updated*/
+ void slotBackendModulesChanged();
+ void slotWindowModulesChanged();
+
+ protected:
+ /**
+ * The backend module list was updated, module list and widgets must be updated.
+ * The signal comes from the window, not from the backend. The new list can
+ * be shorter but not longer than the old list.
+ */
+ virtual void backendModulesChanged();
+ /**
+ * The window module list was changed, i.e. 1 module added, removed or replaced.
+ */
+ virtual void windowModulesChanged();
+
+ private:
+ /** Adds an empty button to the toolbar.*/
+ BtModuleChooserButton* addButton();
+ /** Initialize with module list.*/
+ void setModules( QStringList useModules );
+
+ /** Updates every button's menu without recreating it.*/
+ void updateButtonMenus();
+ /**
+ * Removes or adds buttons so that the count matches the limit.
+ * If given limit is -1 the module count is the limit.
+ */
+ void adjustButtonCount(bool adjustToZero = false);
+
+ private:
+ int m_idCounter;
+ QList<BtModuleChooserButton*> m_buttonList;
+};
+
+#endif
diff --git a/src/frontend/displaywindow/btmodulechooserbutton.cpp b/src/frontend/displaywindow/btmodulechooserbutton.cpp
new file mode 100644
index 0000000..549123f
--- /dev/null
+++ b/src/frontend/displaywindow/btmodulechooserbutton.cpp
@@ -0,0 +1,166 @@
+/*********
+*
+* 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 "frontend/displaywindow/btmodulechooserbutton.h"
+
+#include <QDebug>
+#include <QHash>
+#include <QMenu>
+#include <QString>
+#include <QToolButton>
+#include <QToolTip>
+#include "backend/config/cbtconfig.h"
+#include "backend/managers/cswordbackend.h"
+#include "frontend/displaywindow/btmodulechooserbar.h"
+#include "util/cresmgr.h"
+#include "util/directory.h"
+#include "util/cpointers.h"
+
+
+BtModuleChooserButton::BtModuleChooserButton(BtModuleChooserBar *parent, CSwordModuleInfo::ModuleType mtype)
+ : QToolButton(parent),
+ m_moduleType(mtype),
+ m_popup(0) {
+ //qDebug()<<"BtModuleChooserButton::BtModuleChooserButton";
+ setPopupMode(QToolButton::InstantPopup);
+}
+
+BtModuleChooserButton::~BtModuleChooserButton() {}
+
+void BtModuleChooserButton::recreateMenu(QStringList newModulesToUse, QString thisModule, int newIndex) {
+ populateMenu();
+ updateMenu(newModulesToUse, thisModule, newIndex);
+}
+
+const QString BtModuleChooserButton::iconName() {
+ qDebug() << "BtModuleChooserButton::iconName, has module:" << m_hasModule;
+ switch (m_moduleType) {
+ case CSwordModuleInfo::Bible:
+ return (m_hasModule) ? CResMgr::modules::bible::icon_unlocked : CResMgr::modules::bible::icon_add;
+ case CSwordModuleInfo::Commentary:
+ return (m_hasModule) ? CResMgr::modules::commentary::icon_unlocked : CResMgr::modules::commentary::icon_add;
+ case CSwordModuleInfo::Lexicon:
+ return m_hasModule ? CResMgr::modules::lexicon::icon_unlocked : CResMgr::modules::lexicon::icon_add;
+ case CSwordModuleInfo::GenericBook:
+ return m_hasModule ? CResMgr::modules::book::icon_unlocked : CResMgr::modules::book::icon_add;
+ default: //return as default the bible icon
+ return CResMgr::modules::bible::icon_unlocked;
+ }
+}
+
+void BtModuleChooserButton::updateMenu(QStringList newModulesToUse, QString thisModule, int newIndex) {
+ //qDebug() << "BtModuleChooserButton::updateMenu" << newModulesToUse << thisModule << newIndex << this;
+ // create the menu if it doesn't exist
+ if (!m_popup) populateMenu();
+
+ m_id = newIndex;
+ m_module = thisModule;
+ m_hasModule = thisModule.isEmpty() ? false : true;
+ namespace DU = util::directory;
+
+ //All items are iterated and the state is changed properly
+ QListIterator<QMenu*> it(m_submenus);
+ while (it.hasNext()) {
+ QMenu* popup = it.next();
+ foreach (QAction* a, popup->actions()) {
+ a->setChecked( (a->text() == thisModule) ? true : false );
+ a->setDisabled( newModulesToUse.contains(a->text()) ? true : false );
+ }
+ }
+ m_noneAction->setChecked(m_hasModule ? false : true);
+ setIcon(DU::getIcon(iconName()));
+
+ if (m_hasModule) {
+ setToolTip( QString(tr("Select a work [%1]")).arg(m_module) );
+ }
+ else {
+ setToolTip( tr("Select an additional work") );
+ }
+ m_noneAction->setDisabled((newModulesToUse.count() == 1) ? true : false);
+ //qDebug()<<"BtModuleChooserButton::modulesChanged end";
+}
+
+/** Is called after a module was selected in the popup */
+void BtModuleChooserButton::moduleChosen( QAction* action ) {
+ //qDebug() << "BtModuleChooserButton::moduleChosen";
+
+ if (action->text() == tr("NONE")) { // note: this is for m_popup, the toplevel!
+ if (m_hasModule) {
+ qDebug() << "remove module" << m_id;
+ emit sigModuleRemove(m_id);
+ return;
+ }
+ else {
+ // nothing else is done but the item must be set to checked
+ // lest it change to unchecked
+ action->setChecked(true);
+ }
+ }
+ else {
+ if (!m_hasModule) {
+ emit sigModuleAdd(m_id + 1, action->text());
+ return;
+ }
+ emit sigModuleReplace(m_id, action->text());
+ }
+}
+
+
+void BtModuleChooserButton::populateMenu() {
+ //qDebug()<<"BtModuleChooserButton::populateMenu";
+ qDeleteAll(m_submenus);
+ m_submenus.clear();
+ delete m_popup;
+ m_popup = new QMenu(this);
+
+ m_noneAction = m_popup->addAction(tr("NONE"));
+ m_noneAction->setCheckable(true);
+ if (m_module.isEmpty()) m_noneAction->setChecked(true);
+
+ m_popup->addSeparator();
+ connect(m_popup, SIGNAL(triggered(QAction*)), this, SLOT(moduleChosen(QAction*)));
+ setMenu(m_popup);
+
+
+ // ******* Add languages and modules ********
+
+ // Filters: add only non-hidden and right type
+ BTModuleTreeItem::HiddenOff hiddenFilter;
+ TypeFilter typeFilter(m_moduleType);
+ QList<BTModuleTreeItem::Filter*> filters;
+ if (!CBTConfig::get(CBTConfig::bookshelfShowHidden)) {
+ filters.append(&hiddenFilter);
+ }
+ filters.append(&typeFilter);
+ BTModuleTreeItem root(filters, BTModuleTreeItem::LangMod);
+ // add all items recursively
+ addItemToMenu(&root, m_popup);
+}
+
+void BtModuleChooserButton::addItemToMenu(BTModuleTreeItem* item, QMenu* menu) {
+ qDebug() << "BtModuleChooserButton::addItemToMenu";
+ foreach (BTModuleTreeItem* i, item->children()) {
+
+ if (i->type() == BTModuleTreeItem::Language) {
+ // argument menu was m_popup, create and add a new lang menu to it
+ QMenu* langMenu = new QMenu(i->text(), this);
+ menu->addMenu(langMenu);
+ m_submenus.append(langMenu);
+ // add the module items to the lang menu
+ addItemToMenu(i, langMenu);
+ }
+ else {
+ // item must be module, create and add it to the lang menu
+ QString name(i->text());
+ QAction* modItem = new QAction(name, menu);
+ modItem->setCheckable(true);
+ menu->addAction(modItem);
+ }
+ }
+}
diff --git a/src/frontend/displaywindow/btmodulechooserbutton.h b/src/frontend/displaywindow/btmodulechooserbutton.h
new file mode 100644
index 0000000..9835eb0
--- /dev/null
+++ b/src/frontend/displaywindow/btmodulechooserbutton.h
@@ -0,0 +1,104 @@
+/*********
+*
+* 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_MODULECHOOSERBUTTON
+#define BT_MODULECHOOSERBUTTON
+
+#include <QToolButton>
+#include "backend/btmoduletreeitem.h"
+#include "backend/drivers/cswordmoduleinfo.h"
+
+class BtModuleChooserBar;
+class QMenu;
+class QAction;
+
+/**
+* A toolbar button for choosing a module in a window. When user selects a module,
+* button sends a signal. This button needs to get a signal back after a window
+* module list has been changed. Only then the button will be updated.
+* See BtModuleChooserBar.
+*/
+class BtModuleChooserButton : public QToolButton {
+ Q_OBJECT
+ public:
+
+ /** Filter out modules of wrong type from buttons module list.
+ * See populateMenu() and BTModuleTreeItem. */
+ struct TypeFilter : public BTModuleTreeItem::Filter {
+ TypeFilter(CSwordModuleInfo::ModuleType t) {
+ m_mType = t;
+ }
+ bool filter(CSwordModuleInfo* mi) {
+ return ((mi->type() == m_mType) && !mi->isLocked());
+ }
+ CSwordModuleInfo::ModuleType m_mType;
+ };
+
+ /**
+ * A new empty button. updateMenu() is needed to update the icon, menu items etc.
+ */
+ BtModuleChooserButton(BtModuleChooserBar *parent, CSwordModuleInfo::ModuleType mtype);
+ /** Does nothing. All resources are freed and children deleted automatically.*/
+ ~BtModuleChooserButton();
+
+ // /** Returns the module name this button represents. Not needed?*/
+ //QString module();
+ // /** Returns the index used for this button.*/
+ //int getIndex() const;
+ // /** Updates existing menu items, setting their states.*/
+ //void updateMenuItems();
+
+ public:
+ /**
+ * Called after the window module list has changed. Updates the existing menu items
+ * but doesn't add or remove them if the menu exists.
+ * If the menu doesn't exist, creates it first and then updates it.
+ * Updates also the icon.
+ */
+ void updateMenu(QStringList newModulesToUse, QString thisModule, int newIndex);
+
+ /** Creates the menu from scratch and updates the items using updateMenu().*/
+ void recreateMenu(QStringList newModulesToUse, QString thisModule, int newIndex);
+
+ signals:
+ /** User selected a module from menu to replace another module*/
+ void sigModuleReplace ( int index, QString newModule );
+ /** User selected a module from menu to add */
+ void sigModuleAdd ( int index, QString module );
+ /** User selected a module from menu to be removed */
+ void sigModuleRemove ( int index );
+
+ private slots:
+ /** Handle the action signal from the menu.*/
+ void moduleChosen(QAction* action );
+
+ private:
+ /** Returns the icon used for the current status.*/
+ const QString iconName();
+
+ /**
+ * Populates the menu with language submenus and module items without setting
+ * their states.
+ */
+ void populateMenu();
+ /** Adds items to the menu recursively. */
+ void addItemToMenu(BTModuleTreeItem* item, QMenu* menu);
+
+ private:
+ bool m_hasModule;
+ int m_id;
+ QAction* m_noneAction;
+ CSwordModuleInfo::ModuleType m_moduleType;
+ QString m_module;
+
+ QMenu* m_popup;
+ QList<QMenu*> m_submenus;
+};
+
+#endif
diff --git a/src/frontend/displaywindow/bttextwindowheader.cpp b/src/frontend/displaywindow/bttextwindowheader.cpp
new file mode 100644
index 0000000..cd5392f
--- /dev/null
+++ b/src/frontend/displaywindow/bttextwindowheader.cpp
@@ -0,0 +1,132 @@
+/*********
+*
+* 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 "bttextwindowheader.h"
+
+#include "bttextwindowheaderwidget.h"
+#include "clexiconreadwindow.h"
+
+#include <QStringList>
+#include <QWidget>
+#include <QHBoxLayout>
+#include <QLabel>
+#include <QSizePolicy>
+#include <QToolButton>
+#include <QFrame>
+#include <QAction>
+#include <QDebug>
+
+BtTextWindowHeader::BtTextWindowHeader ( CDisplayWindow* window, CSwordModuleInfo::ModuleType modtype, QStringList modules )
+ : QWidget ( window ),
+ BtWindowModuleChooser(window, modtype) {
+ QHBoxLayout* layout = new QHBoxLayout ( this );
+ layout->setContentsMargins(0, 0, 0, 0);
+ setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
+ setLayoutDirection(Qt::LeftToRight);
+ setModules(modules);
+ connect(window, SIGNAL(sigModuleListSet(QStringList)), SLOT(slotBackendModulesChanged()));
+ connect(window, SIGNAL(sigModuleListChanged()), SLOT(slotWindowModulesChanged()));
+}
+
+BtTextWindowHeader::~BtTextWindowHeader() {}
+
+void BtTextWindowHeader::slotBackendModulesChanged() {
+ backendModulesChanged();
+}
+
+void BtTextWindowHeader::backendModulesChanged() {
+ m_modules = m_window->getModuleList();
+
+ adjustWidgetCount();
+
+ //recreate all widgets from scratch
+ for (int i = 0; i < m_widgetList.count(); i++) {
+ BtTextWindowHeaderWidget* widgt = m_widgetList.at(i);
+ QString moduleName = m_modules.at(i);
+ qDebug() << "refresh button's menu:" << moduleName << i;
+ widgt->recreateWidget(m_modules, moduleName, i);
+ }
+}
+
+void BtTextWindowHeader::slotWindowModulesChanged() {
+ windowModulesChanged();
+}
+
+void BtTextWindowHeader::windowModulesChanged() {
+ m_modules = m_window->getModuleList();
+ adjustWidgetCount();
+ updateWidgets();
+}
+
+void BtTextWindowHeader::adjustWidgetCount(bool adjustToZero) {
+ //qDebug() << "BtModuleChooserBar::ajustButtonCount";
+ int widgetCountDifference = 0;
+ if (adjustToZero) {
+ widgetCountDifference = m_widgetList.count();
+ }
+ else {
+ widgetCountDifference = m_widgetList.count() - (m_modules.count());
+ }
+ if (m_moduleType == CSwordModuleInfo::GenericBook && !adjustToZero) {
+ widgetCountDifference = (1 - m_widgetList.count()) * -1;
+ }
+ //if there are more buttons than modules, delete buttons
+ if (widgetCountDifference > 0) {
+ while (widgetCountDifference) {
+ // it should be safe to delete the button later
+ BtTextWindowHeaderWidget* w = m_widgetList.takeFirst();
+ w->setParent(0);
+ w->deleteLater();
+ widgetCountDifference--;
+ }
+ }
+ // if there are more modules than buttons, add buttons
+ if (widgetCountDifference < 0) {
+ while (widgetCountDifference) {
+ addWidget();
+ widgetCountDifference++;
+ }
+ }
+}
+
+BtTextWindowHeaderWidget* BtTextWindowHeader::addWidget() {
+ BtTextWindowHeaderWidget* w = new BtTextWindowHeaderWidget(this, m_moduleType);
+ layout()->addWidget(w);
+ m_widgetList.append(w);
+
+ // the button sends signals directly to the window which then signals back when the module
+ // list has changed
+ connect(w, SIGNAL(sigModuleAdd(int, QString)), m_window, SLOT(slotAddModule(int, QString)));
+ connect(w, SIGNAL(sigModuleReplace(int, QString)), m_window, SLOT(slotReplaceModule(int, QString)));
+ connect(w, SIGNAL(sigModuleRemove(int)), m_window, SLOT(slotRemoveModule(int)));
+
+ return w;
+}
+
+void BtTextWindowHeader::setModules( QStringList useModules ) {
+ qDebug() << "BtModuleChooserBar::setModules";
+ m_modules = useModules;
+ adjustWidgetCount(true);
+
+ //if (!useModules.count()) return;
+ for (int i = 0; i < useModules.count(); i++) {
+ addWidget();
+ }
+ updateWidgets();
+ //qDebug() << "BtModuleChooserBar::setModules end";
+}
+
+void BtTextWindowHeader::updateWidgets() {
+ for (int i = 0; i < m_widgetList.count(); i++) {
+ BtTextWindowHeaderWidget* w = m_widgetList.at(i);
+ //QString moduleName = m_modules.at(i);
+ //qDebug() << "refresh button's menu:" << moduleName << i;
+ w->updateWidget(m_modules, m_modules.at(i), i);
+ }
+}
diff --git a/src/frontend/displaywindow/bttextwindowheader.h b/src/frontend/displaywindow/bttextwindowheader.h
new file mode 100644
index 0000000..a3e6b6b
--- /dev/null
+++ b/src/frontend/displaywindow/bttextwindowheader.h
@@ -0,0 +1,67 @@
+/*********
+*
+* 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_TEXTWINDOWHEADER
+#define BT_TEXTWINDOWHEADER
+
+#include "btwindowmodulechooser.h"
+#include <QStringList>
+#include <QWidget>
+
+class QAction;
+class QToolButton;
+class CDisplayWindow;
+class BtTextWindowHeaderWidget;
+
+class BtTextWindowHeader: public QWidget, public BtWindowModuleChooser {
+ Q_OBJECT
+ public:
+ BtTextWindowHeader(CDisplayWindow* window, CSwordModuleInfo::ModuleType modtype, QStringList modules);
+ virtual ~BtTextWindowHeader();
+
+ public slots:
+ void slotBackendModulesChanged();
+ void slotWindowModulesChanged();
+
+
+ protected:
+ /** The backend module list was updated, module list and widgets must be updated from scratch.*/
+ void backendModulesChanged();
+ /** The window module list was updated, module list and widgets must be updated.*/
+ void windowModulesChanged();
+
+ signals:
+ /** User selected a module from menu to replace another module*/
+ void sigModuleReplace ( int index, QString newModule );
+ /** User selected a module from menu to add */
+ void sigModuleAdd ( int index, QString module );
+ /** User selected a module from menu to be removed */
+ void sigModuleRemove ( int index );
+
+ private:
+ /** Called when backend has changed and menus must be created from scratch.*/
+ void initMenus();
+ /** Updates all widgets without recreating them. */
+ void updateWidgets();
+ /**
+ * Removes or adds widgets so that the count matches the limit.
+ * The module count is the limit unless adjustToZero is true
+ * when limit is 0 and list is emptied.
+ */
+ void adjustWidgetCount(bool adjustToZero = false);
+ /** Adds an empty widget to the header.*/
+ BtTextWindowHeaderWidget* addWidget();
+ /** Sets the initial modules.*/
+ void setModules( QStringList useModules );
+
+ private:
+ QList<BtTextWindowHeaderWidget*> m_widgetList;
+};
+
+#endif
diff --git a/src/frontend/displaywindow/bttextwindowheaderwidget.cpp b/src/frontend/displaywindow/bttextwindowheaderwidget.cpp
new file mode 100644
index 0000000..3858efb
--- /dev/null
+++ b/src/frontend/displaywindow/bttextwindowheaderwidget.cpp
@@ -0,0 +1,197 @@
+/*********
+*
+* 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 "frontend/displaywindow/bttextwindowheaderwidget.h"
+
+#include <QDebug>
+//#include <QHash>
+#include <QMenu>
+#include <QString>
+#include <QToolButton>
+#include <QToolTip>
+#include <QHBoxLayout>
+#include <QSizePolicy>
+#include <QLabel>
+
+#include "backend/config/cbtconfig.h"
+#include "backend/managers/cswordbackend.h"
+#include "frontend/displaywindow/bttextwindowheader.h"
+#include "util/cresmgr.h"
+#include "util/directory.h"
+#include "util/cpointers.h"
+
+const char* ActionType = "ActionType";
+
+BtTextWindowHeaderWidget::BtTextWindowHeaderWidget(BtTextWindowHeader *parent, CSwordModuleInfo::ModuleType mtype)
+ : QWidget(parent),
+ m_moduleType(mtype),
+ m_popup(0) {
+ QHBoxLayout* layout = new QHBoxLayout(this);
+ layout->setContentsMargins(0, 0, 0, 0);
+
+ m_label = new QLabel("", this);
+ QSizePolicy sizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed);
+ m_label->setSizePolicy(sizePolicy);
+ m_label->setStyleSheet("QLabel{font-weight:bold}");
+ layout->addWidget(m_label, 0, Qt::AlignRight);
+
+ m_button = new QToolButton( this );
+ m_button->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
+ m_button->setPopupMode( QToolButton::InstantPopup );
+ m_button->setArrowType(Qt::NoArrow);
+ m_button->setStyleSheet("QToolButton{margin:0px;}QToolButton::menu-indicator{subcontrol-position: center center;}");
+ m_button->setToolTip( tr("Add/remove/replace") );
+
+ layout->addWidget(m_button, 0, Qt::AlignLeft);
+
+ m_separator = new QFrame(this);
+ m_separator->setFrameShape(QFrame::VLine);
+ layout->addWidget(m_separator);
+}
+
+BtTextWindowHeaderWidget::~BtTextWindowHeaderWidget() {}
+
+void BtTextWindowHeaderWidget::recreateWidget(QStringList newModulesToUse, QString thisModule, int newIndex) {
+ populateMenu();
+ updateWidget(newModulesToUse, thisModule, newIndex);
+}
+
+// don't remove yet, maybe we'll add icons to buttons...
+// const QString BtTextWindowHeaderWidget::iconName() {
+// qDebug() << "BtTextWindowHeaderWidget::iconName, has module:" << m_hasModule;
+// switch (m_moduleType) {
+// case CSwordModuleInfo::Bible:
+// return (m_hasModule) ? CResMgr::modules::bible::icon_unlocked : CResMgr::modules::bible::icon_add;
+// case CSwordModuleInfo::Commentary:
+// return (m_hasModule) ? CResMgr::modules::commentary::icon_unlocked : CResMgr::modules::commentary::icon_add;
+// case CSwordModuleInfo::Lexicon:
+// return m_hasModule ? CResMgr::modules::lexicon::icon_unlocked : CResMgr::modules::lexicon::icon_add;
+// case CSwordModuleInfo::GenericBook:
+// return m_hasModule ? CResMgr::modules::book::icon_unlocked : CResMgr::modules::book::icon_add;
+// default: //return as default the bible icon
+// return CResMgr::modules::bible::icon_unlocked;
+// }
+// }
+
+void BtTextWindowHeaderWidget::updateWidget(QStringList newModulesToUse, QString thisModule, int newIndex) {
+ //qDebug() << "BtTextWindowHeaderWidget::updateMenu" << newModulesToUse << thisModule << newIndex << this;
+ m_label->setText(thisModule);
+ // create the menu if it doesn't exist
+ if (!m_popup) populateMenu();
+
+ m_id = newIndex;
+ m_module = thisModule;
+ namespace DU = util::directory;
+
+ //All items are iterated and the state is changed properly
+ QListIterator<QMenu*> it(m_submenus);
+ while (it.hasNext()) {
+ QMenu* popup = it.next();
+ foreach (QAction* a, popup->actions()) {
+ a->setChecked( (a->text() == thisModule) ? true : false );
+ a->setDisabled( newModulesToUse.contains(a->text()) ? true : false );
+ }
+ }
+
+ if (m_id == newModulesToUse.count() - 1) {
+ // this is the rightmost module, hide the separator
+ m_separator->hide();
+ }
+ else {
+ m_separator->show();
+ }
+ m_removeAction->setDisabled((newModulesToUse.count() == 1) ? true : false);
+}
+
+/** Is called after a module was selected in the popup */
+void BtTextWindowHeaderWidget::moduleChosen( QAction* action ) {
+ //qDebug() << "BtTextWindowHeaderWidget::moduleChosen";
+
+ if (action->property(ActionType).toInt() == RemoveAction) { // note: this is for m_popup, the toplevel!
+ emit sigModuleRemove(m_id);
+ return;
+ }
+ if (action->property(ActionType).toInt() == AddAction) {
+ emit sigModuleAdd(m_id + 1, action->text());
+ return;
+ }
+ if (action->property(ActionType).toInt() == ReplaceAction) {
+ emit sigModuleReplace(m_id, action->text());
+ }
+}
+
+
+void BtTextWindowHeaderWidget::populateMenu() {
+ //qDebug()<<"BtTextWindowHeaderWidget::populateMenu";
+ delete m_popup;
+ m_popup = new QMenu(m_button);
+
+ connect(m_popup, SIGNAL(triggered(QAction*)), this, SLOT(moduleChosen(QAction*)));
+ m_button->setMenu(m_popup);
+
+ m_removeAction = new QAction(tr("Remove"), m_popup);
+ m_removeAction->setProperty(ActionType, RemoveAction);
+ m_removeAction->setIcon(util::directory::getIcon(CResMgr::displaywindows::general::removemoduleicon));
+ m_popup->addAction(m_removeAction);
+
+ // Add Replace and Add menus, both have all modules in them
+ QMenu* replaceItem = new QMenu(tr("Replace"), m_popup);
+ replaceItem->setIcon(util::directory::getIcon(CResMgr::displaywindows::general::replacemoduleicon));
+ replaceItem->setProperty(ActionType, ReplaceAction);
+ m_popup->addMenu(replaceItem);
+
+ QMenu* addItem = new QMenu(tr("Add"), m_popup);
+ addItem->setProperty(ActionType, AddAction);
+ addItem->setIcon(util::directory::getIcon(CResMgr::displaywindows::general::addmoduleicon));
+ m_popup->addMenu(addItem);
+
+ QList<QMenu*> toplevelMenus;
+ toplevelMenus.append(replaceItem);
+ toplevelMenus.append(addItem);
+
+ foreach(QMenu* menu, toplevelMenus) {
+ // ******* Add languages and modules ********
+ //m_popup->addSeparator();
+
+ // Filters: add only non-hidden, non-locked and correct type
+ BTModuleTreeItem::HiddenOff hiddenFilter;
+ TypeFilter typeFilter(m_moduleType);
+ QList<BTModuleTreeItem::Filter*> filters;
+ if (!CBTConfig::get(CBTConfig::bookshelfShowHidden)) {
+ filters.append(&hiddenFilter);
+ }
+ filters.append(&typeFilter);
+ BTModuleTreeItem root(filters, BTModuleTreeItem::LangMod);
+ // add all items recursively
+ addItemToMenu(&root, menu, (TypeOfAction)menu->property(ActionType).toInt());
+ }
+}
+
+void BtTextWindowHeaderWidget::addItemToMenu(BTModuleTreeItem* item, QMenu* menu, TypeOfAction actionType) {
+ qDebug() << "BtTextWindowHeaderWidget::addItemToMenu";
+ foreach (BTModuleTreeItem* i, item->children()) {
+
+ if (i->type() == BTModuleTreeItem::Language) {
+ // argument menu was m_popup, create and add a new lang menu to it
+ QMenu* langMenu = new QMenu(i->text(), this);
+ menu->addMenu(langMenu);
+ m_submenus.append(langMenu);
+ // add the module items to the lang menu
+ addItemToMenu(i, langMenu, actionType);
+ }
+ else {
+ // item must be module, create and add it to the lang menu
+ QString name(i->text());
+ QAction* modItem = new QAction(name, menu);
+ modItem->setCheckable(true);
+ modItem->setProperty(ActionType, actionType);
+ menu->addAction(modItem);
+ }
+ }
+}
diff --git a/src/frontend/displaywindow/bttextwindowheaderwidget.h b/src/frontend/displaywindow/bttextwindowheaderwidget.h
new file mode 100644
index 0000000..2b5379e
--- /dev/null
+++ b/src/frontend/displaywindow/bttextwindowheaderwidget.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 BT_MODULECHOOSERHEADERWIDGET
+#define BT_MODULECHOOSERHEADERWIDGET
+
+#include <QString>
+#include <QWidget>
+#include <QList>
+
+#include "backend/btmoduletreeitem.h"
+#include "backend/drivers/cswordmoduleinfo.h"
+
+class BtTextWindowHeader;
+class QMenu;
+class QAction;
+class QLabel;
+class QToolButton;
+class QFrame;
+
+/**
+* A widget for choosing a module in a window. Consists of a label and a button.
+* When user selects a module,
+* button sends a signal. This widget needs to get a message back after a window
+* module list has been changed. Only then it will be updated.
+* See BtTextWindowHeader.
+*/
+class BtTextWindowHeaderWidget : public QWidget {
+ Q_OBJECT
+
+ public:
+ /** For internal use to mark the menu items */
+ enum TypeOfAction {RemoveAction, AddAction, ReplaceAction};
+
+ /** Filter out modules of wrong type from buttons module list.
+ * See populateMenu() and BTModuleTreeItem. */
+ struct TypeFilter : public BTModuleTreeItem::Filter {
+ TypeFilter(CSwordModuleInfo::ModuleType t) {
+ m_mType = t;
+ }
+ bool filter(CSwordModuleInfo* mi) {
+ return ((mi->type() == m_mType) && !mi->isLocked());
+ }
+ CSwordModuleInfo::ModuleType m_mType;
+ };
+
+ /**
+ * A new empty widget. updateMenu() is needed to update the label, menu items etc.
+ */
+ BtTextWindowHeaderWidget(BtTextWindowHeader *parent, CSwordModuleInfo::ModuleType mtype);
+ /** Does nothing. All resources are freed and children deleted automatically.*/
+ ~BtTextWindowHeaderWidget();
+
+ public:
+ /**
+ * Called after the window module list has changed. Updates the module name and
+ * the existing menu items but doesn't add or remove them if the menu exists.
+ * If the menu doesn't exist, creates it first and then updates it.
+ */
+ void updateWidget(QStringList newModulesToUse, QString thisModule, int newIndex);
+
+ /** Creates the menu from scratch and updates the items using updateMenu().*/
+ void recreateWidget(QStringList newModulesToUse, QString thisModule, int newIndex);
+
+ signals:
+ /** User selected a module from menu to replace an existing module.*/
+ void sigModuleReplace ( int index, QString newModule );
+ /** User selected a module from menu to add. */
+ void sigModuleAdd ( int index, QString module );
+ /** User selected a module from menu to be removed. */
+ void sigModuleRemove ( int index );
+
+ private slots:
+ /** Handle the action signal from the menu.*/
+ void moduleChosen(QAction* action );
+
+ private:
+
+ /**
+ * Populates the menu with language submenus and module items without setting
+ * their states.
+ */
+ void populateMenu();
+ /** Adds items to the menu recursively. */
+ void addItemToMenu(BTModuleTreeItem* item, QMenu* menu, TypeOfAction actionType);
+
+ private:
+
+ int m_id;
+ QAction* m_removeAction;
+ CSwordModuleInfo::ModuleType m_moduleType;
+ QString m_module;
+ QLabel* m_label;
+ QToolButton* m_button;
+ QFrame* m_separator;
+ QMenu* m_popup;
+ QList<QMenu*> m_submenus;
+};
+
+#endif
diff --git a/src/frontend/displaywindow/btwindowmodulechooser.h b/src/frontend/displaywindow/btwindowmodulechooser.h
new file mode 100644
index 0000000..c30c284
--- /dev/null
+++ b/src/frontend/displaywindow/btwindowmodulechooser.h
@@ -0,0 +1,61 @@
+/*********
+*
+* 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_WINDOWMODULECHOOSER
+#define BT_WINDOWMODULECHOOSER
+
+#include "backend/drivers/cswordmoduleinfo.h"
+#include <QStringList>
+
+class CDisplayWindow;
+
+/**
+* This is an abstract base class for buttonbar and text window header
+* which work as module choosers in a text window.
+*
+* Signals or slots can't be inherited from this class for Qt's
+* technical reasons. Add corresponding slots for the protected
+* modulesChanged methods and delegate the message.
+*
+* Add these signals to the subclass or to some part of it:
+* User selected a module from menu to replace another module:
+* void sigModuleReplace ( int index, QString newModule );
+* User selected a module from menu to add:
+* void sigModuleAdd ( int index, QString module );
+* User selected a module from menu to be removed:
+* void sigModuleRemove ( int index );
+*
+* Connect slots and signals to the window's corresponding signals and slots.
+*/
+class BtWindowModuleChooser {
+ public:
+ BtWindowModuleChooser ( CDisplayWindow* parentWindow, CSwordModuleInfo::ModuleType moduleType )
+ : m_window ( parentWindow ), m_moduleType ( moduleType ) {}
+
+ virtual ~BtWindowModuleChooser() {}
+
+ protected:
+ /**
+ * The backend module list was updated, module list and widgets must be updated.
+ * This expects that the window module list has already been updated, so
+ * the corresponding slot should be connected to the window, not to the backend.
+ */
+ virtual void backendModulesChanged() = 0;
+ /** Modules have been added, replaced or removed in the window without backend changing.*/
+ virtual void windowModulesChanged() = 0;
+
+
+ protected:
+ CDisplayWindow* m_window;
+ CSwordModuleInfo::ModuleType m_moduleType;
+ /** The cache of the window module list. Kept for convenience.*/
+ QStringList m_modules;
+};
+
+#endif
diff --git a/src/frontend/displaywindow/cbiblereadwindow.cpp b/src/frontend/displaywindow/cbiblereadwindow.cpp
index 7b346f7..70dbd35 100644
--- a/src/frontend/displaywindow/cbiblereadwindow.cpp
+++ b/src/frontend/displaywindow/cbiblereadwindow.cpp
@@ -9,7 +9,6 @@
#include "frontend/displaywindow/cbiblereadwindow.h"
-#include <cmath>
#include <QAction>
#include <QApplication>
#include <QEvent>
@@ -27,7 +26,7 @@
#include "frontend/display/creaddisplay.h"
#include "frontend/displaywindow/btactioncollection.h"
#include "frontend/displaywindow/ccommentaryreadwindow.h"
-#include "frontend/displaywindow/cbuttons.h"
+#include "frontend/displaywindow/btdisplaysettingsbutton.h"
#include "frontend/keychooser/ckeychooser.h"
#include "frontend/profile/cprofilewindow.h"
#include "util/directory.h"
@@ -45,34 +44,59 @@ CBibleReadWindow::CBibleReadWindow(QList<CSwordModuleInfo*> moduleList, CMDIArea
CBibleReadWindow::~CBibleReadWindow() {
}
-void CBibleReadWindow::applyProfileSettings( CProfileWindow* const settings ) {
+void CBibleReadWindow::applyProfileSettings(CProfileWindow* const settings) {
+ /**
+ \todo Make \ref CProfileWindow properly handle these things so we wouldn't have to mess
+ around with bits.
+ */
CLexiconReadWindow::applyProfileSettings(settings);
- const int count = displaySettingsButton()->menuItemCount();
int result = settings->windowSettings();
- for (int i = count - 1; i >= 1; i--) {
- if (result - (int)pow((double)2, i - 1) >= 0) { //2^i was added before, so item with index i is set
- result -= (int)pow((double)2, i - 1);
- displaySettingsButton()->setItemStatus(i, true);
- }
- else {
- displaySettingsButton()->setItemStatus(i, false);
- }
- }
- displaySettingsButton()->setChanged();
+
+ filterOptions().footnotes = (result & 0x0001) != 0;
+ filterOptions().strongNumbers = (result & 0x0002) != 0;
+ filterOptions().headings = (result & 0x0004) != 0;
+ filterOptions().morphTags = (result & 0x0008) != 0;
+ filterOptions().lemmas = (result & 0x0010) != 0;
+ filterOptions().hebrewPoints = (result & 0x0020) != 0;
+ filterOptions().hebrewCantillation = (result & 0x0040) != 0;
+ filterOptions().greekAccents = (result & 0x0080) != 0;
+ filterOptions().textualVariants = (result & 0x0100) != 0;
+ filterOptions().redLetterWords = (result & 0x0200) != 0;
+ filterOptions().scriptureReferences = (result & 0x0400) != 0;
+ filterOptions().morphSegmentation = (result & 0x0800) != 0;
+ displayOptions().lineBreaks = (result & 0x1000) != 0;
+ displayOptions().verseNumbers = (result & 0x2000) != 0;
+
+ displaySettingsButton()->setFilterOptions(filterOptions(), false);
+ displaySettingsButton()->setDisplayOptions(displayOptions());
}
-void CBibleReadWindow::storeProfileSettings( CProfileWindow* const settings ) {
- CLexiconReadWindow::storeProfileSettings(settings);
+void CBibleReadWindow::storeProfileSettings( CProfileWindow * const settings) {
+ /**
+ \todo Make \ref CProfileWindow properly handle these things so we wouldn't have to mess
+ around with bits.
+ */
+
+ int result = 0x0000;
+ if (filterOptions().footnotes) result |= 0x0001;
+ if (filterOptions().strongNumbers) result |= 0x0002;
+ if (filterOptions().headings) result |= 0x0004;
+ if (filterOptions().morphTags) result |= 0x0008;
+ if (filterOptions().lemmas) result |= 0x0010;
+ if (filterOptions().hebrewPoints) result |= 0x0020;
+ if (filterOptions().hebrewCantillation) result |= 0x0040;
+ if (filterOptions().greekAccents) result |= 0x0080;
+ if (filterOptions().textualVariants) result |= 0x0100;
+ if (filterOptions().redLetterWords) result |= 0x0200;
+ if (filterOptions().scriptureReferences) result |= 0x0400;
+ if (filterOptions().morphSegmentation) result |= 0x0800;
+ if (displayOptions().lineBreaks) result |= 0x1000;
+ if (displayOptions().verseNumbers) result |= 0x2000;
- const int count = displaySettingsButton()->menuItemCount();
- int result = 0;
- //now check every item
- for (int i = 1; i < count; i++) { //first item is a title
- if (displaySettingsButton()->itemStatus(i)) //item is checked
- result += (int)pow((double)2, i - 1);//add 2^i (the i. digit in binary)
- }
settings->setWindowSettings(result);
+
+ CLexiconReadWindow::storeProfileSettings(settings);
}
@@ -135,7 +159,7 @@ void CBibleReadWindow::insertKeyboardActions( BtActionCollection* const a ) {
qaction = new QAction(tr("Reference with text"), a);
a->addAction("printReferenceWithText", qaction);
- qaction = new QAction(tr("Reference with text"), a);
+ qaction = new QAction(tr("Reference with text"), a);
a->addAction("saveReferenceWithText", qaction);
}
diff --git a/src/frontend/displaywindow/cbookreadwindow.cpp b/src/frontend/displaywindow/cbookreadwindow.cpp
index d852eb3..062d42d 100644
--- a/src/frontend/displaywindow/cbookreadwindow.cpp
+++ b/src/frontend/displaywindow/cbookreadwindow.cpp
@@ -18,8 +18,8 @@
#include "frontend/display/cdisplay.h"
#include "frontend/displaywindow/bttoolbarpopupaction.h"
#include "frontend/displaywindow/btactioncollection.h"
-#include "frontend/displaywindow/cmodulechooserbar.h"
-#include "frontend/displaywindow/cbuttons.h"
+#include "frontend/displaywindow/btmodulechooserbar.h"
+#include "frontend/displaywindow/btdisplaysettingsbutton.h"
#include "frontend/keychooser/cbooktreechooser.h"
#include "frontend/profile/cprofilewindow.h"
#include "util/cresmgr.h"
@@ -103,14 +103,15 @@ void CBookReadWindow::initView() {
setKeyChooser( CKeyChooser::createInstance(modules(), key(), mainToolBar()) );
- setModuleChooserBar( new CModuleChooserBar(modules(), modules().first()->type(), this) );
- moduleChooserBar()->setButtonLimit(1);
+ setModuleChooserBar( new BtModuleChooserBar(getModuleList(), modules().first()->type(), this) );
addToolBar(moduleChooserBar());
setButtonsToolBar( new QToolBar(this) );
buttonsToolBar()->setAllowedAreas(Qt::TopToolBarArea);
buttonsToolBar()->setFloatable(false);
- setDisplaySettingsButton( new CDisplaySettingsButton( &displayOptions(), &filterOptions(), modules(), buttonsToolBar()) );
+
+ setDisplaySettingsButton(new BtDisplaySettingsButton(buttonsToolBar()));
+
addToolBar(buttonsToolBar());
m_treeChooser->hide();
diff --git a/src/frontend/displaywindow/cbuttons.cpp b/src/frontend/displaywindow/cbuttons.cpp
deleted file mode 100644
index 46c262a..0000000
--- a/src/frontend/displaywindow/cbuttons.cpp
+++ /dev/null
@@ -1,185 +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.
-*
-**********/
-
-#include "frontend/displaywindow/cbuttons.h"
-
-#include <QHash>
-#include <QMenu>
-#include <QString>
-#include <QToolTip>
-#include <QToolButton>
-#include "util/directory.h"
-#include "util/cpointers.h"
-#include "util/cresmgr.h"
-
-
-CDisplaySettingsButton::CDisplaySettingsButton(CSwordBackend::DisplayOptions *displaySettings, CSwordBackend::FilterOptions *moduleSettings, const QList<CSwordModuleInfo*>& useModules, QWidget *parent )
- : QToolButton(parent) {
- namespace DU = util::directory;
-
- // qWarning("CDisplaySettingsButton::CDisplaySettingsButton");
- QToolButton::setIcon(DU::getIcon(CResMgr::displaywindows::displaySettings::icon));
-
- m_displaySettings = displaySettings;
- m_moduleSettings = moduleSettings;
- m_modules = useModules;
-
- m_popup = new QMenu(this);
- setMenu(m_popup);
- setPopupMode(QToolButton::InstantPopup);
- setToolTip(tr("Display options"));
-
- connect(m_popup, SIGNAL(triggered(QAction*)), this, SLOT(optionToggled(QAction*)));
- populateMenu();
-}
-
-void CDisplaySettingsButton::reset(const QList<CSwordModuleInfo*>& useModules) {
- m_modules = useModules;
- populateMenu();
- //disable the settings button if no options are available
- if (!populateMenu()) {
- setEnabled(false);
- setToolTip(tr("Display settings: No options available"));
- }
- else {
- setEnabled(true);
- setToolTip(tr("Display settings"));
- }
-}
-
-
-void CDisplaySettingsButton::optionToggled(QAction* /*action*/) {
- //Take each Action and set the corresponding setting.
- //Using QAction (QObject) property and OptionType enum is a dirty way to do this.
- //See populateMenu().
- foreach (QAction* act, m_popup->actions()) {
- int optionType = act->property("OptionType").toInt();
- bool checked = act->isChecked();
- switch (optionType) {
- case Linebreak:
- m_displaySettings->lineBreaks = checked;
- break;
- case Versenum:
- m_displaySettings->verseNumbers = checked;
- break;
- case Variant:
- m_moduleSettings->textualVariants = checked;
- break;
- case Vowel:
- m_moduleSettings->hebrewPoints = checked;
- break;
- case Accents:
- m_moduleSettings->greekAccents = checked;
- break;
- case Cantillation:
- m_moduleSettings->hebrewCantillation = checked;
- break;
- case Headings:
- m_moduleSettings->headings = checked;
- break;
- case Morphseg:
- m_moduleSettings->morphSegmentation = checked;
- break;
- case Xref:
- m_moduleSettings->scriptureReferences = checked;
- break;
- case WordsofJ:
- m_moduleSettings->redLetterWords = checked;
- break;
- }
- }
-
- emit sigChanged();
-}
-
-/** No descriptions */
-int CDisplaySettingsButton::populateMenu() {
- int ret = 0;
-
- m_popup->clear();
-
- // See also optionToggled()
-
- ret += addMenuEntry(tr("Use linebreaks after each verse"), Linebreak, &m_displaySettings->lineBreaks, (m_modules.first()->type() == CSwordModuleInfo::Bible));
-
- //show the verse numbers option only for bible modules
- ret += addMenuEntry(tr("Show verse numbers"), Versenum, &m_displaySettings->verseNumbers, (m_modules.first()->type() == CSwordModuleInfo::Bible));
-
- ret += addMenuEntry(tr("Show headings"), Headings, &m_moduleSettings->headings,
- isOptionAvailable(CSwordModuleInfo::headings));
-
- ret += addMenuEntry(tr("Highlight words of Jesus"), WordsofJ, &m_moduleSettings->redLetterWords,
- isOptionAvailable(CSwordModuleInfo::redLetterWords ));
-
- ret += addMenuEntry(tr("Show Hebrew vowel points"), Vowel, &m_moduleSettings->hebrewPoints,
- isOptionAvailable(CSwordModuleInfo::hebrewPoints ));
-
- ret += addMenuEntry(tr("Show Hebrew cantillation marks"), Cantillation, &m_moduleSettings->hebrewCantillation,
- isOptionAvailable(CSwordModuleInfo::hebrewCantillation ));
-
- ret += addMenuEntry(tr("Show Greek accents"), Accents, &m_moduleSettings->greekAccents,
- isOptionAvailable(CSwordModuleInfo::greekAccents ));
-
- ret += addMenuEntry(tr("Use alternative textual variant"), Variant, &m_moduleSettings->textualVariants,
- isOptionAvailable(CSwordModuleInfo::textualVariants ));
-
- ret += addMenuEntry(tr("Show scripture cross-references"), Xref, &m_moduleSettings->scriptureReferences,
- isOptionAvailable(CSwordModuleInfo::scriptureReferences ));
-
- ret += addMenuEntry(tr("Show morph segmentation"), Morphseg, &m_moduleSettings->morphSegmentation,
- isOptionAvailable(CSwordModuleInfo::morphSegmentation ));
-
- return ret;
-}
-
-/** Adds an entry to m_popup. */
-int CDisplaySettingsButton::addMenuEntry( const QString name, OptionType type, const int* option, const bool available) {
- int ret = 0;
-
- if (available) {
- QAction* a = m_popup->addAction(name);
- //see optionToggled()
- a->setProperty("OptionType", type);
- a->setCheckable(true);
- a->setChecked(*option);
- ret = 1;
- }
-
- return ret;
-}
-
-bool CDisplaySettingsButton::isOptionAvailable( const CSwordModuleInfo::FilterTypes option ) {
- bool ret = false;
- QList<CSwordModuleInfo*>::iterator end_it = m_modules.end();
- for (QList<CSwordModuleInfo*>::iterator it(m_modules.begin()); it != end_it; ++it) {
- ret = ret || (*it)->has(option);
- }
- return ret;
-}
-
-/** Returns the number of usable menu items in the settings menu. */
-int CDisplaySettingsButton::menuItemCount() {
- return m_popup->actions().count();
-}
-
-/** Sets the item at position pos to the state given as 2nd paramter. */
-void CDisplaySettingsButton::setItemStatus( const int index, const bool checked ) {
- QAction* action = m_popup->actions().at(index);
- action->setChecked(checked);
-}
-
-/** Returns the status of the item at position "index" */
-bool CDisplaySettingsButton::itemStatus( const int index ) {
- return m_popup->actions().at(index)->isChecked();
-}
-
-/** Sets the status to changed. The signal changed will be emitted. */
-void CDisplaySettingsButton::setChanged() {
- optionToggled(0);
-}
diff --git a/src/frontend/displaywindow/cbuttons.h b/src/frontend/displaywindow/cbuttons.h
deleted file mode 100644
index 39dbbf9..0000000
--- a/src/frontend/displaywindow/cbuttons.h
+++ /dev/null
@@ -1,75 +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 CBUTTONS_H
-#define CBUTTONS_H
-
-#include <QToolButton>
-
-#include <QHash>
-#include "backend/managers/cswordbackend.h"
-
-
-class CSwordModuleInfo;
-class QMenu;
-
-/** This class manages the display options of the selected modules.
- * @author The BibleTime team
- */
-class CDisplaySettingsButton : public QToolButton {
- Q_OBJECT
- public:
-
- CDisplaySettingsButton(CSwordBackend::DisplayOptions *displaySettings, CSwordBackend::FilterOptions *settings, const QList<CSwordModuleInfo*>& useModules, QWidget *parent = 0);
- void reset(const QList<CSwordModuleInfo*>& useModules);
- /**
- * Sets the item at position pos to the satet given as 2nd paramter.
- */
- void setItemStatus( const int pos, const bool checked );
- /**
- * Returns the number of usable menu items in the setttings menu.
- */
- int menuItemCount();
- /**
- * Returns the status of the item at position "index"
- */
- bool itemStatus( const int index );
- /**
- * Sets the status to changed. The signal changed will be emitted.
- */
- void setChanged();
-
- signals:
- void sigChanged(void);
-
- protected slots:
- void optionToggled(QAction* action);
-
- protected:
-
- /** This enum marks the option types for a display. Used internally.*/
- enum OptionType {Linebreak, Versenum, Headings, WordsofJ, Vowel, Cantillation, Accents,
- Variant, Xref, Morphseg
- };
-
- CSwordBackend::FilterOptions* m_moduleSettings;
- CSwordBackend::DisplayOptions* m_displaySettings;
- CSwordBackend::FilterOptions m_available;
- QList<CSwordModuleInfo*> m_modules;
-
- QHash<QString, int> m_dict;
-
- QMenu* m_popup;
-
- int populateMenu();
- bool isOptionAvailable( const CSwordModuleInfo::FilterTypes option);
- int addMenuEntry( const QString name, OptionType type, const int* option, const bool available);
-};
-
-#endif
diff --git a/src/frontend/displaywindow/cdisplaywindow.cpp b/src/frontend/displaywindow/cdisplaywindow.cpp
index 4ba567a..3900a92 100644
--- a/src/frontend/displaywindow/cdisplaywindow.cpp
+++ b/src/frontend/displaywindow/cdisplaywindow.cpp
@@ -21,8 +21,8 @@
#include "frontend/display/cdisplay.h"
#include "frontend/displaywindow/bttoolbarpopupaction.h"
#include "frontend/displaywindow/btactioncollection.h"
-#include "frontend/displaywindow/cmodulechooserbar.h"
-#include "frontend/displaywindow/cbuttons.h"
+#include "frontend/displaywindow/btmodulechooserbar.h"
+#include "frontend/displaywindow/btdisplaysettingsbutton.h"
#include "frontend/keychooser/ckeychooser.h"
#include "frontend/keychooser/bthistory.h"
#include "frontend/profile/cprofilewindow.h"
@@ -36,8 +36,6 @@ using namespace Profile;
CDisplayWindow::CDisplayWindow(QList<CSwordModuleInfo*> modules, CMDIArea *parent)
: QMainWindow(parent),
m_mdi(parent),
- m_filterOptions(),
- m_displayOptions(),
m_displaySettingsButton(0),
m_keyChooser(0),
m_swordKey(0),
@@ -53,7 +51,14 @@ CDisplayWindow::CDisplayWindow(QList<CSwordModuleInfo*> modules, CMDIArea *paren
setModules(modules);
// Connect this to the backend module list changes
- connect(CPointers::backend(), SIGNAL(sigSwordSetupChanged(CSwordBackend::SetupChangedReason)), SLOT(reload(CSwordBackend::SetupChangedReason)));
+ connect(CPointers::backend(),
+ SIGNAL(sigSwordSetupChanged(CSwordBackend::SetupChangedReason)),
+ SLOT(reload(CSwordBackend::SetupChangedReason)));
+ BibleTime* mainwindow = dynamic_cast<BibleTime*>(m_mdi->parent());
+ connect(mainwindow, SIGNAL(toggledTextWindowHeader(bool)), SLOT(slotShowHeader(bool)) );
+ connect(mainwindow, SIGNAL(toggledTextWindowNavigator(bool)), SLOT(slotShowNavigator(bool)) );
+ connect(mainwindow, SIGNAL(toggledTextWindowToolButtons(bool)), SLOT(slotShowToolButtons(bool)) );
+ connect(mainwindow, SIGNAL(toggledTextWindowModuleChooser(bool)), SLOT(slotShowModuleChooser(bool)) );
}
CDisplayWindow::~CDisplayWindow() {
@@ -61,10 +66,6 @@ CDisplayWindow::~CDisplayWindow() {
m_swordKey = 0;
}
-CMDIArea* CDisplayWindow::mdi() const {
- return m_mdi;
-}
-
/** Returns the right window caption. */
const QString CDisplayWindow::windowCaption() {
if (!m_modules.count()) {
@@ -74,18 +75,11 @@ const QString CDisplayWindow::windowCaption() {
return QString(key()->key()).append(" (").append(m_modules.join(" | ")).append(")");
}
-/** Returns the used modules as a QPtrList */
+/** Returns the used modules as a pointer list */
QList<CSwordModuleInfo*> CDisplayWindow::modules() {
- QList<CSwordModuleInfo*> mods;
+ //qDebug() << "CDisplayWindow::modules";
- for (QStringList::iterator it = m_modules.begin(); it != m_modules.end(); ++it) {
- Q_ASSERT(backend()->findModuleByName(*it));
- if (CSwordModuleInfo* m = backend()->findModuleByName(*it)) {
- mods.append(m);
- }
- }
-
- return mods;
+ return CPointers::backend()->getPointerList(m_modules);
}
void CDisplayWindow::insertKeyboardActions( BtActionCollection* a ) {
@@ -101,10 +95,6 @@ void CDisplayWindow::insertKeyboardActions( BtActionCollection* a ) {
actn->setShortcut(QKeySequence::ZoomOut);
a->addAction("zoomOut", actn);
- actn = new QAction(QIcon(), tr("Close"), a);
- actn->setShortcut(QKeySequence::Close);
- a->addAction("closeWindow", actn);
-
actn = new QAction(QIcon(), tr("Select all"), a);
actn->setShortcut(QKeySequence::SelectAll);
a->addAction("selectAll", actn);
@@ -167,10 +157,6 @@ void CDisplayWindow::initActions() {
QObject::connect(actn, SIGNAL(triggered()), conn, SLOT(zoomOut()));
addAction(actn);
- actn = ac->action("closeWindow");
- QObject::connect(actn, SIGNAL(triggered()), this, SLOT(close()));
- addAction(actn);
-
actn = ac->action("selectAll");
QObject::connect(actn, SIGNAL(triggered()), conn, SLOT(selectAll()));
addAction(actn);
@@ -198,6 +184,7 @@ void CDisplayWindow::initActions() {
/** Refresh the settings of this window. */
void CDisplayWindow::reload(CSwordBackend::SetupChangedReason) {
+ qDebug() << "CDisplayWindow::reload";
//first make sure all used Sword modules are still present
QMutableStringListIterator it(m_modules);
while (it.hasNext()) {
@@ -213,43 +200,51 @@ void CDisplayWindow::reload(CSwordBackend::SetupChangedReason) {
if (keyChooser()) keyChooser()->setModules( modules(), false );
- if (m_moduleChooserBar) { //necessary for edit windows which have now chooser bar
- m_moduleChooserBar->setModules(modules());
- }
- modulesChanged();
lookup();
CBTConfig::setupAccelSettings(CBTConfig::allWindows, actionCollection());
CBTConfig::setupAccelSettings(CBTConfig::readWindow, actionCollection());
+ qDebug() << "CDisplayWindow::reload emits sigModuleListSet...";
+ emit sigModuleListSet(m_modules);
+}
+
+void CDisplayWindow::slotAddModule(int index, QString module) {
+ qDebug() << "CDisplayWindow::slotAddModule";
+ m_modules.insert(index, module);
+ lookup();
+ modulesChanged();
+ emit sigModuleListChanged();
}
-/** Returns the filter options used by this window. */
-CSwordBackend::FilterOptions& CDisplayWindow::filterOptions() {
- return m_filterOptions;
+void CDisplayWindow::slotReplaceModule(int index, QString newModule) {
+ qDebug() << "CDisplayWindow::slotReplaceModule" << m_modules.at(index) << "with" << newModule;
+ m_modules.replace(index, newModule);
+ qDebug() << "window's new module list:" << m_modules;
+ lookup();
+ modulesChanged();
+ emit sigModuleListChanged();
}
-/** Returns the display options used by this display window. */
-CSwordBackend::DisplayOptions& CDisplayWindow::displayOptions() {
- return m_displayOptions;
+void CDisplayWindow::slotRemoveModule(int index) {
+ qDebug() << "CDisplayWindow::slotRemoveModule";
+ m_modules.removeAt(index);
+ lookup();
+ modulesChanged();
+ emit sigModuleListChanged();
}
/** Sets the new display options for this window. */
-void CDisplayWindow::setDisplayOptions( const CSwordBackend::DisplayOptions& displayOptions ) {
+void CDisplayWindow::setDisplayOptions(const CSwordBackend::DisplayOptions &displayOptions) {
m_displayOptions = displayOptions;
}
/** Sets the new filter options of this window. */
-void CDisplayWindow::setFilterOptions( CSwordBackend::FilterOptions& filterOptions ) {
+void CDisplayWindow::setFilterOptions(const CSwordBackend::FilterOptions &filterOptions) {
m_filterOptions = filterOptions;
}
-/** Returns true if the widget is ready for use. */
-bool CDisplayWindow::isReady() const {
- return m_isReady;
-}
-
/** Set the ready status */
-void CDisplayWindow::setReady( const bool& ready ) {
+void CDisplayWindow::setReady(bool ready) {
m_isReady = ready;
}
@@ -258,22 +253,11 @@ bool CDisplayWindow::queryClose() {
return true;
}
-/** Returns the keychooser widget of this display window. */
-CKeyChooser* CDisplayWindow::keyChooser() const {
- return m_keyChooser;
-}
-
/** Sets the keychooser widget for this display window. */
void CDisplayWindow::setKeyChooser( CKeyChooser* ck ) {
m_keyChooser = ck;
}
-/** Returns the key of this display window. */
-CSwordKey* CDisplayWindow::key() const {
- Q_ASSERT( m_swordKey );
- return m_swordKey;
-}
-
/** Sets the new sword key. */
void CDisplayWindow::setKey( CSwordKey* key ) {
Q_ASSERT( key );
@@ -281,16 +265,16 @@ void CDisplayWindow::setKey( CSwordKey* key ) {
}
void CDisplayWindow::modulesChanged() {
- if (moduleChooserBar()) { //necessary for write windows
- setModules( m_moduleChooserBar->getModuleList() );
- }
-
- if (!modules().count()) {
+ // this would only set the stringlist again
+ //if (moduleChooserBar()) { //necessary for write windows
+ //setModules( m_moduleChooserBar->getModuleList() );
+ //}
+ if (modules().isEmpty()) {
close();
}
else {
if (displaySettingsButton()) {
- displaySettingsButton()->reset(modules());
+ displaySettingsButton()->setModules(modules());
}
key()->module(modules().first());
@@ -298,24 +282,30 @@ void CDisplayWindow::modulesChanged() {
}
}
-/** Returns the module chooser bar. */
-CModuleChooserBar* CDisplayWindow::moduleChooserBar() const {
- return m_moduleChooserBar;
-}
-
/** Sets the module chooser bar. */
-void CDisplayWindow::setModuleChooserBar( CModuleChooserBar* bar ) {
+void CDisplayWindow::setModuleChooserBar( BtModuleChooserBar* bar ) {
+ qDebug() << "CDisplayWindow::setModuleChooserBar";
if (m_moduleChooserBar) {
- disconnect(m_moduleChooserBar, SIGNAL(sigChanged()), this, SLOT(modulesChanged()));
+ m_moduleChooserBar->deleteLater();
}
//if a new bar should be set!
if (bar) {
m_moduleChooserBar = bar;
- connect(bar, SIGNAL(sigChanged()), SLOT(modulesChanged()));
+ bar->setWindowTitle(tr("Work chooser buttons"));
+ bar->setLayoutDirection(Qt::LeftToRight);
+ bar->setVisible(CBTConfig::get(CBTConfig::showTextWindowModuleSelectorButtons));
}
}
+/** Sets the module header of text area. */
+void CDisplayWindow::setHeaderBar( QToolBar* header ) {
+ m_headerBar = header;
+ header->setMovable(false);
+ header->setWindowTitle(tr("Text area header"));
+ header->setVisible(CBTConfig::get(CBTConfig::showTextWindowHeaders));
+}
+
/** Sets the modules. */
void CDisplayWindow::setModules( const QList<CSwordModuleInfo*>& newModules ) {
qDebug() << "CDisplayWindow::setModules";
@@ -344,45 +334,67 @@ bool CDisplayWindow::init() {
m_filterOptions = CBTConfig::getFilterOptionDefaults();
m_displayOptions = CBTConfig::getDisplayOptionDefaults();
if (displaySettingsButton()) {
- displaySettingsButton()->reset(modules());
+ displaySettingsButton()->setFilterOptions(m_filterOptions, false);
+ displaySettingsButton()->setDisplayOptions(m_displayOptions, false);
+ displaySettingsButton()->setModules(modules());
}
setReady(true);
return true;
}
-/** Returns the main toolbar. */
-QToolBar* CDisplayWindow::mainToolBar() const {
- return m_mainToolBar;
-}
-
-/** Returns the main toolbar. */
-QToolBar* CDisplayWindow::buttonsToolBar() const {
- return m_buttonsToolBar;
-}
-
/** Sets the main toolbar. */
void CDisplayWindow::setMainToolBar( QToolBar* bar ) {
m_mainToolBar = bar;
+ bar->setAllowedAreas(Qt::TopToolBarArea);
+ bar->setFloatable(false);
+ bar->setWindowTitle(tr("Navigation"));
+ bar->setVisible(CBTConfig::get(CBTConfig::showTextWindowNavigator));
}
/** Sets the main toolbar. */
void CDisplayWindow::setButtonsToolBar( QToolBar* bar ) {
m_buttonsToolBar = bar;
-}
-
-/** Returns the display settings button */
-CDisplaySettingsButton* CDisplayWindow::displaySettingsButton() const {
- return m_displaySettingsButton;
+ bar->setAllowedAreas(Qt::TopToolBarArea);
+ bar->setFloatable(false);
+ bar->setWindowTitle(tr("Tools"));
+ bar->setVisible( CBTConfig::get(CBTConfig::showTextWindowToolButtons) );
}
/** Sets the display settings button. */
-void CDisplayWindow::setDisplaySettingsButton( CDisplaySettingsButton* button ) {
- if (m_displaySettingsButton)
- disconnect(m_displaySettingsButton, SIGNAL( sigChanged() ), this, SLOT(lookup() ));
+void CDisplayWindow::setDisplaySettingsButton( BtDisplaySettingsButton* button ) {
+ if (m_displaySettingsButton) {
+ m_displaySettingsButton->disconnect(this);
+ }
m_displaySettingsButton = button;
- connect(m_displaySettingsButton, SIGNAL(sigChanged()), this, SLOT(lookup()));
+
+ button->setDisplayOptions(displayOptions(), false);
+ button->setFilterOptions(filterOptions(), false);
+ button->setModules(modules());
+
+ connect(button, SIGNAL(sigFilterOptionsChanged(CSwordBackend::FilterOptions)),
+ this, SLOT(setFilterOptions(CSwordBackend::FilterOptions)));
+ connect(button, SIGNAL(sigDisplayOptionsChanged(CSwordBackend::DisplayOptions)),
+ this, SLOT(setDisplayOptions(CSwordBackend::DisplayOptions)));
+ connect(button, SIGNAL(sigChanged()),
+ this, SLOT(lookup()));
+}
+
+void CDisplayWindow::slotShowHeader(bool show) {
+ headerBar()->setVisible(show);
+}
+
+void CDisplayWindow::slotShowNavigator(bool show) {
+ mainToolBar()->setVisible(show);
+}
+
+void CDisplayWindow::slotShowToolButtons(bool show) {
+ buttonsToolBar()->setVisible(show);
+}
+
+void CDisplayWindow::slotShowModuleChooser(bool show) {
+ moduleChooserBar()->setVisible(show);
}
/** Lookup the current key. Used to refresh the display. */
@@ -423,12 +435,13 @@ void CDisplayWindow::lookupKey( const QString& keyName ) {
*/
Q_ASSERT(modules().first());
- //qDebug("CDisplayWindow::lookup: %s", keyName.latin1());
+ qDebug() << "CDisplayWindow::lookupKey: " << keyName;
lookupModKey(modules().first()->name(), keyName);
}
/** Update the status of the popup menu entries. */
void CDisplayWindow::updatePopupMenu() {
+ /// \todo Verify this should be empty and comment.
}
@@ -448,12 +461,6 @@ QMenu* CDisplayWindow::popup() {
return m_popupMenu;
}
-/** Returns the display widget used by this implementation of CDisplayWindow. */
-CDisplay* CDisplayWindow::displayWidget() const {
- Q_ASSERT(m_displayWidget);
- return m_displayWidget;
-}
-
/** Sets the display widget used by this display window. */
void CDisplayWindow::setDisplayWidget( CDisplay* newDisplay ) {
m_displayWidget = newDisplay;
@@ -480,10 +487,6 @@ void CDisplayWindow::printAnchorWithText() {
m_displayWidget->connectionsProxy()->printAnchorWithText( m_displayOptions, m_filterOptions);
}
-BtActionCollection* CDisplayWindow::actionCollection() {
- return m_actionCollection;
-}
-
void CDisplayWindow::setFocusKeyChooser() {
keyChooser()->setFocus();
}
diff --git a/src/frontend/displaywindow/cdisplaywindow.h b/src/frontend/displaywindow/cdisplaywindow.h
index 6164e94..b23d856 100644
--- a/src/frontend/displaywindow/cdisplaywindow.h
+++ b/src/frontend/displaywindow/cdisplaywindow.h
@@ -20,10 +20,11 @@
class BtActionCollection;
class CDisplay;
-class CDisplaySettingsButton;
+class BtDisplaySettingsButton;
class CKeyChooser;
class CMDIArea;
-class CModuleChooserBar;
+//class CModuleChooserBar;
+class BtModuleChooserBar;
class CReadWindow;
class CSwordModuleInfo;
class CWriteWindow;
@@ -42,105 +43,153 @@ class CDisplayWindow : public QMainWindow, public CPointers {
PlainTextWindow = 2
};
- // Insert the keyboard accelerators of this window into the given KAccel object.
+ /** Insert the keyboard accelerators of this window into the given actioncollection.*/
static void insertKeyboardActions( BtActionCollection* const a );
- CMDIArea* mdi() const;
+ inline CMDIArea *mdi() const {
+ return m_mdi;
+ }
- // Returns the right window caption.
+ /** Returns the correct window caption.*/
const QString windowCaption();
- // Returns the used modules as a QPtrList
+ /** Returns the used modules as a pointer list.*/
QList<CSwordModuleInfo*> modules();
- // Store the settings of this window in the given CProfileWindow object.
+ /** Returns the used modules as a string list. */
+ inline const QStringList &getModuleList() const {
+ return m_modules;
+ }
+
+ /** Store the settings of this window in the given CProfileWindow object.*/
virtual void storeProfileSettings( Profile::CProfileWindow* profileWindow ) = 0;
- // Store the settings of this window in the given profile window.
+ /** Store the settings of this window in the given profile window.*/
virtual void applyProfileSettings( Profile::CProfileWindow* profileWindow ) = 0;
- // Sets the new filter options of this window.
- void setFilterOptions( CSwordBackend::FilterOptions& filterOptions );
-
- // Sets the new display options for this window.
- void setDisplayOptions( const CSwordBackend::DisplayOptions& displayOptions );
-
- // Returns the display options used by this display window.
- CSwordBackend::DisplayOptions& displayOptions();
+ /** Returns the display options used by this display window. */
+ inline const CSwordBackend::DisplayOptions &displayOptions() const {
+ return m_displayOptions;
+ }
- // Returns the filter options used by this window.
- CSwordBackend::FilterOptions& filterOptions();
+ /** Returns the filter options used by this window. */
+ inline const CSwordBackend::FilterOptions &filterOptions() const {
+ return m_filterOptions;
+ }
- // Set the ready status
- void setReady( const bool& ready );
+ /** Set the ready status. */
+ void setReady(bool ready);
- // Returns true if the widget is ready for use.
- bool isReady() const;
+ /** Returns true if the widget is ready for use. */
+ inline bool isReady() const {
+ return m_isReady;
+ }
- // Returns true if the window may be closed.
+ /** Returns true if the window may be closed.*/
virtual bool queryClose();
- // Returns the keychooser widget of this display window.
- CKeyChooser* keyChooser() const;
+ /** Returns the keychooser widget of this display window. */
+ inline CKeyChooser *keyChooser() const {
+ return m_keyChooser;
+ }
- // Sets the new sword key.
+ /** Sets the new sword key.*/
void setKey( CSwordKey* key );
- // Returns the key of this display window.
- CSwordKey* key() const;
+ /** Returns the key of this display window. */
+ inline CSwordKey *key() const {
+ Q_ASSERT(m_swordKey != 0);
+ return m_swordKey;
+ }
- // Initialize the window. Call this method from the outside, because calling this in the constructor is not possible!
+ /**
+ * Initialize the window. Call this method from the outside,
+ * because calling this in the constructor is not possible!
+ */
virtual bool init();
- // Sets the main toolbar.
+ /** Sets and inits the properties of the main navigation toolbar.*/
void setMainToolBar( QToolBar* bar );
- // Sets the buttons toolbar.
+ /** Sets and inits the properties of the tool buttons toolbar.*/
void setButtonsToolBar( QToolBar* bar );
- // Returns the main toolbar.
- QToolBar* mainToolBar() const;
+ /** Returns the main navigation toolbar. */
+ inline QToolBar *mainToolBar() const {
+ return m_mainToolBar;
+ }
- // Returns the buttons toolbar.
- QToolBar* buttonsToolBar() const;
+ /** Returns the tool buttons toolbar. */
+ inline QToolBar *buttonsToolBar() const {
+ return m_buttonsToolBar;
+ }
- // Initialize the toolbars
+ /** Initialize the toolbars.*/
virtual void initToolbars() = 0;
- // Returns the display settings button
- CDisplaySettingsButton* displaySettingsButton() const;
+ /** Returns the display settings button. */
+ inline BtDisplaySettingsButton *displaySettingsButton() const {
+ return m_displaySettingsButton;
+ }
- // Sets the display settings button.
- void setDisplaySettingsButton( CDisplaySettingsButton* button );
+ /** Sets the display settings button.*/
+ void setDisplaySettingsButton( BtDisplaySettingsButton* button );
virtual void setupPopupMenu() = 0;
- // Returns the display widget used by this implementation of CDisplayWindow.
- virtual CDisplay* displayWidget() const;
+ /** Returns the display widget used by this implementation of CDisplayWindow. */
+ virtual inline CDisplay *displayWidget() const {
+ Q_ASSERT(m_displayWidget != 0);
+ return m_displayWidget;
+ }
- // Sets the display widget used by this display window.
+ /** Sets the display widget used by this display window.*/
virtual void setDisplayWidget( CDisplay* newDisplay );
- // Returns whether syncs to the active window are allowed at this time for this display window
- // @return boolean value whether sync is allowed
+ /**
+ * Returns whether syncs to the active window are allowed at this time for this display window
+ * @return boolean value whether sync is allowed
+ */
virtual bool syncAllowed() const {
return false;
};
- BtActionCollection* actionCollection();
-
+ inline BtActionCollection *actionCollection() const {
+ return m_actionCollection;
+ }
+
+ signals:
+ /** The module list was set because backend was reloaded.*/
+ void sigModuleListSet(QStringList modules);
+ /** A module was added to this window.*/
+ void sigModuleAdded(int index, QString module);
+ void sigModuleReplaced(int index, QString newModule);
+ void sigModuleRemoved(int index);
+ /** The module list of window changed but backend list didn't.*/
+ void sigModuleListChanged();
public slots:
-
- // Lookup the specified key in the given module. If the module is not chosen withing
- // this display window create a new displaywindow with the right module in it.
+ /** Receives a signal telling that a module should be added.*/
+ void slotAddModule(int index, QString module);
+ void slotReplaceModule(int index, QString newModule);
+ void slotRemoveModule(int index);
+
+ /**
+ * Lookup the specified key in the given module. If the module is not chosen withing
+ * this display window create a new displaywindow with the right module in it.
+ */
virtual void lookupModKey( const QString& module, const QString& key );
- // Lookup the key in the chosen modules.
+ /** Lookup the key in the chosen modules.*/
virtual void lookupKey( const QString& key );
- // Refresh the settings of this window.
+ /** Refresh the settings of this window.*/
virtual void reload(CSwordBackend::SetupChangedReason reason);
+ void slotShowNavigator(bool show);
+ void slotShowToolButtons(bool show);
+ void slotShowModuleChooser(bool show);
+ void slotShowHeader(bool show);
+
protected:
friend class CMDIArea;
friend class CBibleReadWindow;
@@ -148,39 +197,63 @@ class CDisplayWindow : public QMainWindow, public CPointers {
CDisplayWindow(QList<CSwordModuleInfo*> modules, CMDIArea* parent);
virtual ~CDisplayWindow();
- // Initializes the intern keyboard actions.
+ /** Returns the display options used by this display window. */
+ inline CSwordBackend::DisplayOptions &displayOptions() {
+ return m_displayOptions;
+ }
+
+ /** Returns the filter options used by this window. */
+ inline CSwordBackend::FilterOptions &filterOptions() {
+ return m_filterOptions;
+ }
+
+ /** Initializes the internel keyboard actions.*/
virtual void initActions();
- // Sets the keychooser widget for this display window.
+ /** Sets the keychooser widget for this display window.*/
void setKeyChooser( CKeyChooser* ck );
- // Returns the module chooser bar.
- CModuleChooserBar* moduleChooserBar() const;
+ /** Returns the module chooser bar. */
+ inline BtModuleChooserBar *moduleChooserBar() const {
+ return m_moduleChooserBar;
+ }
- // Lookup the given key.
+ /** Lookup the given key.*/
virtual void lookupSwordKey( CSwordKey* ) = 0;
- // Sets the module chooser bar.
- void setModuleChooserBar( CModuleChooserBar* bar );
+ /** Sets the module chooser bar.*/
+ void setModuleChooserBar( BtModuleChooserBar* bar );
+
+ void setHeaderBar(QToolBar* header);
- // Sets the modules.
+ inline QToolBar *headerBar() const {
+ return m_headerBar;
+ }
+
+ /** Sets the modules. */
void setModules( const QList<CSwordModuleInfo*>& modules );
- // Initializes the signal / slot connections of this display window.
+ /** Initializes the signal / slot connections of this display window.*/
virtual void initConnections() = 0;
- // Initialize the view of this display window.
+ /** Initialize the view of this display window.*/
virtual void initView() = 0;
- // Returns the installed popup menu.
+ /** Returns the installed RMB popup menu.*/
QMenu* popup();
virtual void closeEvent(QCloseEvent* e);
protected slots:
+ /** Sets the new filter options of this window.*/
+ void setFilterOptions(const CSwordBackend::FilterOptions &filterOptions);
+
+ /** Sets the new display options for this window.*/
+ void setDisplayOptions(const CSwordBackend::DisplayOptions &displayOptions);
+
virtual void modulesChanged();
- // Lookup the current key. Used to refresh the display.
+ /** Lookup the current key. Used to refresh the display.*/
void lookup();
virtual void updatePopupMenu();
@@ -203,13 +276,14 @@ class CDisplayWindow : public QMainWindow, public CPointers {
CSwordBackend::FilterOptions m_filterOptions;
CSwordBackend::DisplayOptions m_displayOptions;
- CDisplaySettingsButton* m_displaySettingsButton;
+ BtDisplaySettingsButton* m_displaySettingsButton;
CKeyChooser* m_keyChooser;
CSwordKey* m_swordKey;
bool m_isReady;
- CModuleChooserBar* m_moduleChooserBar;
+ BtModuleChooserBar* m_moduleChooserBar;
QToolBar* m_mainToolBar;
QToolBar* m_buttonsToolBar;
+ QToolBar* m_headerBar;
QMenu* m_popupMenu;
CDisplay* m_displayWidget;
};
diff --git a/src/frontend/displaywindow/clexiconreadwindow.cpp b/src/frontend/displaywindow/clexiconreadwindow.cpp
index 2a5fb40..894c787 100644
--- a/src/frontend/displaywindow/clexiconreadwindow.cpp
+++ b/src/frontend/displaywindow/clexiconreadwindow.cpp
@@ -25,8 +25,9 @@
#include "frontend/display/creaddisplay.h"
#include "frontend/displaywindow/btactioncollection.h"
#include "frontend/displaywindow/bttoolbarpopupaction.h"
-#include "frontend/displaywindow/cbuttons.h"
-#include "frontend/displaywindow/cmodulechooserbar.h"
+#include "frontend/displaywindow/btdisplaysettingsbutton.h"
+#include "frontend/displaywindow/bttextwindowheader.h"
+#include "frontend/displaywindow/btmodulechooserbar.h"
#include "frontend/keychooser/bthistory.h"
#include "frontend/keychooser/ckeychooser.h"
#include "util/directory.h"
@@ -183,18 +184,18 @@ void CLexiconReadWindow::initView() {
qDebug() << "CLexiconReadWindow::initView";
setDisplayWidget( CDisplay::createReadInstance(this) );
setMainToolBar( new QToolBar(this) );
- mainToolBar()->setAllowedAreas(Qt::TopToolBarArea);
- mainToolBar()->setFloatable(false);
addToolBar(mainToolBar());
setKeyChooser( CKeyChooser::createInstance(modules(), key(), mainToolBar()) );
mainToolBar()->addWidget(keyChooser());
- setModuleChooserBar( new CModuleChooserBar(modules(), modules().first()->type(), this) );
- moduleChooserBar()->adjustSize();
+ setModuleChooserBar( new BtModuleChooserBar(getModuleList(), modules().first()->type(), this) );
addToolBar(moduleChooserBar());
setButtonsToolBar( new QToolBar(this) );
- buttonsToolBar()->setAllowedAreas(Qt::TopToolBarArea);
- buttonsToolBar()->setFloatable(false);
addToolBar(buttonsToolBar());
+ addToolBarBreak();
+ setHeaderBar(new QToolBar(this));
+ addToolBar(headerBar());
+ BtTextWindowHeader* h = new BtTextWindowHeader(this, modules().first()->type(), getModuleList());
+ headerBar()->addWidget(h);
setWindowIcon(util::tool::getIconForModule(modules().first()));
setCentralWidget( displayWidget()->view() );
}
@@ -212,7 +213,8 @@ void CLexiconReadWindow::initToolbars() {
if (action) {
buttonsToolBar()->addAction(action);
}
- setDisplaySettingsButton( new CDisplaySettingsButton( &displayOptions(), &filterOptions(), modules(), buttonsToolBar()) );
+
+ setDisplaySettingsButton(new BtDisplaySettingsButton(buttonsToolBar()));
/// \todo find the right place for the button
buttonsToolBar()->addWidget(displaySettingsButton());
@@ -310,7 +312,7 @@ void CLexiconReadWindow::saveRawHTML() {
qDebug() << "could not open file";
return;
}
- QString source = disp->text();
+ QString source = disp->getCurrentSource();
file.write(source.toUtf8());
//qDebug() << "wrote" << bytes << "bytes";
file.close();
diff --git a/src/frontend/displaywindow/cmodulechooserbar.cpp b/src/frontend/displaywindow/cmodulechooserbar.cpp
deleted file mode 100644
index 0e6131a..0000000
--- a/src/frontend/displaywindow/cmodulechooserbar.cpp
+++ /dev/null
@@ -1,126 +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.
-*
-**********/
-
-#include "frontend/displaywindow/cmodulechooserbar.h"
-
-#include <QAction>
-#include <QDebug>
-#include <QList>
-#include <QToolBar>
-#include "frontend/displaywindow/cmodulechooserbutton.h"
-
-
-CModuleChooserBar::CModuleChooserBar(QList<CSwordModuleInfo*> useModules, CSwordModuleInfo::ModuleType type, QWidget *parent)
- : QToolBar(parent),
- m_moduleType(type),
- m_idCounter(0),
- m_buttonLimit(-1) { //-1 means no limit
- setAllowedAreas(Qt::TopToolBarArea);
- setFloatable(false);
- //insert buttons if useModules != 0
- QList<CSwordModuleInfo*>::iterator end_it = useModules.end();
- for (QList<CSwordModuleInfo*>::iterator it(useModules.begin()); it != end_it; ++it) {
- if ((m_buttonLimit != -1) && ( m_buttonLimit <= (int)m_buttonList.count()) ) { //we reached the button limit
- break;
- }
- addButton( *it );
- }
-
- // We can add a button to choose an additional module
- if ( (m_buttonLimit == -1) || (m_buttonLimit > (int)m_buttonList.count()) ) {
- addButton(0); //add a button without module set
- }
-}
-
-CModuleChooserButton* CModuleChooserBar::addButton( CSwordModuleInfo* const module ) {
- CModuleChooserButton* b = new CModuleChooserButton(module, m_moduleType, ++m_idCounter, this);
- QAction* a = addWidget(b);
- m_buttonList.append(b);
- connect( b, SIGNAL(sigAddButton()), this, SLOT(addButton()) );
- connect( b, SIGNAL(sigRemoveButton(const int)), this, SLOT(removeButton(const int)) );
- connect( b, SIGNAL(sigChanged()), SIGNAL(sigChanged()) );
- connect( b, SIGNAL(sigChanged()), SLOT(updateMenuItems()) );
- a->setVisible(true);
- updateMenuItems(); //make sure the items are up to date with the newest module list
- return b;
-}
-
-void CModuleChooserBar::addButton( ) {
- addButton(0);
-}
-
-//change current with next and remove
-/** Removes a button from the toolbar */
-void CModuleChooserBar::removeButton( const int ID ) {
- QMutableListIterator<CModuleChooserButton*> it(m_buttonList);
- while (it.hasNext()) {
- CModuleChooserButton* b = it.next();
- if (b->getId() == ID) { //found the right button to remove
- it.remove();
- b->deleteLater();
- break;
- }
- }
- emit sigChanged();
- updateMenuItems(); //make sure the items are up to date with the newest module list
-}
-
-/** Returns a list of selected modules. */
-QList<CSwordModuleInfo*> CModuleChooserBar::getModuleList() {
- QList<CSwordModuleInfo*> list;
- foreach (CModuleChooserButton* b, m_buttonList) {
- if (b->module()) list.append( b->module() );
- }
- return list;
-}
-
-//change current with remove
-/** Sets the number of the maximum count of buttons. */
-void CModuleChooserBar::setButtonLimit(const int limit) {
- m_buttonLimit = limit;
- if (limit == -1) //no need to delete buttons
- return;
-
- const int tooMuch = m_buttonList.size() - limit;
- for (int i = 0; i < tooMuch; ++i) {
- CModuleChooserButton* b = m_buttonList.takeLast();
- b->deleteLater();
- }
-
- updateMenuItems();
-}
-
-/** Sets the modules which are chosen in this module chooser bar. */
-void CModuleChooserBar::setModules( QList<CSwordModuleInfo*> useModules ) {
- setButtonLimit(0);
- setButtonLimit(-1); //these two lines clear the bar
-
- if (!useModules.count()) return;
-
- QList<CSwordModuleInfo*>::iterator end_it = useModules.end();
- for (QList<CSwordModuleInfo*>::iterator it(useModules.begin()); it != end_it; ++it) {
- if ( (m_buttonLimit != -1) && (m_buttonLimit <= (int)m_buttonList.count()) ) {
- break;
- }
- addButton( *it );
- }
-
- if ( (m_buttonLimit == -1) || (m_buttonLimit > (int)m_buttonList.count()) ) {
- addButton(0);//add button without module set
- }
-
- updateMenuItems();
-}
-
-void CModuleChooserBar::updateMenuItems() {
- resize(sizeHint());
- update(); //seems to be neccessary to enforce display of the layout changes when a button was removed or added
- foreach (CModuleChooserButton* b, m_buttonList)
- b->updateMenuItems();
-}
diff --git a/src/frontend/displaywindow/cmodulechooserbar.h b/src/frontend/displaywindow/cmodulechooserbar.h
deleted file mode 100644
index fbdd737..0000000
--- a/src/frontend/displaywindow/cmodulechooserbar.h
+++ /dev/null
@@ -1,75 +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 CMODULECHOOSERBAR_H
-#define CMODULECHOOSERBAR_H
-
-#include <QToolBar>
-
-#include <QList>
-#include "backend/drivers/cswordmoduleinfo.h"
-#include "util/cpointers.h"
-
-
-class CModuleChooserButton;
-class QWidget;
-
-/**
- * @author The BibleTime team
- */
-class CModuleChooserBar : public QToolBar {
- Q_OBJECT
- public:
- /**
- * Default constructor
- */
- CModuleChooserBar(QList<CSwordModuleInfo*> useModules, CSwordModuleInfo::ModuleType type, QWidget *parent = 0);
- /**
- * Returns a list of selected modules.
- */
- QList<CSwordModuleInfo*> getModuleList();
- /**
- * Sets the number of the maximum count of buttons.
- */
- void setButtonLimit( const int limit);
- /**
- * Sets the modules which are chosen in this module chooser bar.
- */
- void setModules( QList<CSwordModuleInfo*> modules );
-
- signals:
- void sigChanged();
-
- protected:
- /**
- * Adds a button to the toolbar
- */
- CModuleChooserButton* addButton( CSwordModuleInfo* const module );
-
- protected slots: // Protected slots
- /*
- * This slot calls the addButton function above to add a button.
- */
- void addButton();
- /**
- * Removes a button from the toolbar
- */
- void removeButton( const int ID );
- /** */
- void updateMenuItems();
-
- private:
- CSwordModuleInfo::ModuleType m_moduleType;
- int m_idCounter;
- int m_buttonLimit;
- QList<CModuleChooserButton*> m_buttonList;
-
-};
-
-#endif
diff --git a/src/frontend/displaywindow/cmodulechooserbutton.cpp b/src/frontend/displaywindow/cmodulechooserbutton.cpp
deleted file mode 100644
index 0444cf6..0000000
--- a/src/frontend/displaywindow/cmodulechooserbutton.cpp
+++ /dev/null
@@ -1,208 +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.
-*
-**********/
-
-#include "frontend/displaywindow/cmodulechooserbutton.h"
-
-#include <QDebug>
-#include <QHash>
-#include <QMenu>
-#include <QString>
-#include <QToolButton>
-#include <QToolTip>
-#include "backend/config/cbtconfig.h"
-#include "backend/managers/cswordbackend.h"
-#include "frontend/displaywindow/cmodulechooserbar.h"
-#include "util/cresmgr.h"
-#include "util/directory.h"
-
-
-CModuleChooserButton::CModuleChooserButton(CSwordModuleInfo* useModule, CSwordModuleInfo::ModuleType type, const int id, CModuleChooserBar *parent)
- : QToolButton(parent),
- m_id(id), m_popup(0), m_moduleChooserBar(parent) {
- namespace DU = util::directory;
-
- m_moduleType = type;
- m_module = useModule;
- m_hasModule = (m_module) ? true : false;
-
- setIcon(DU::getIcon(iconName()));
- setPopupMode(QToolButton::InstantPopup);
-
- populateMenu();
-}
-
-CModuleChooserButton::~CModuleChooserButton() {
- qDeleteAll(m_submenus);
- m_submenus.clear();
- delete m_popup; //not necessary, because has "this" as parent?
-}
-
-/** Returns the icon used for the current status. */
-const QString CModuleChooserButton::iconName() {
- switch (m_moduleType) {
- case CSwordModuleInfo::Bible:
- return (m_hasModule) ? CResMgr::modules::bible::icon_unlocked : CResMgr::modules::bible::icon_add;
- case CSwordModuleInfo::Commentary:
- return (m_hasModule) ? CResMgr::modules::commentary::icon_unlocked : CResMgr::modules::commentary::icon_add;
- case CSwordModuleInfo::Lexicon:
- return m_hasModule ? CResMgr::modules::lexicon::icon_unlocked : CResMgr::modules::lexicon::icon_add;
- case CSwordModuleInfo::GenericBook:
- return m_hasModule ? CResMgr::modules::book::icon_unlocked : CResMgr::modules::book::icon_add;
- default: //return as default the bible icon
- return CResMgr::modules::bible::icon_unlocked;
- }
-}
-
-CSwordModuleInfo* CModuleChooserButton::module() {
- foreach (QMenu* popup, m_submenus) {
- foreach (QAction* action, popup->actions()) {
- if ( action->isChecked() ) { //idAt -> , isItemChecked -> QAction::isChecked
- QString mod = action->text(); //popup->text(popup->idAt(i)); //text ->
- mod.remove(QChar('&')); //remove hotkey indicators
- return backend()->findModuleByName( mod.left(mod.indexOf(" ")) );
- }
- }
- }
- return 0; //"none" selected
-}
-
-/** Returns the id used for this button. */
-int CModuleChooserButton::getId() const {
- return m_id;
-}
-
-/** Is called after a module was selected in the popup */
-void CModuleChooserButton::moduleChosen( QAction* action ) {
- namespace DU = util::directory;
-
- QListIterator<QMenu*> it(m_submenus);
- while (it.hasNext()) {
- QMenu* popup = it.next();
- foreach (QAction* a, popup->actions()) {
- a->setChecked(false);
- }
- action->setChecked(true);
- }
-
- m_noneAction->setChecked(false); //uncheck the "none" item
- if (action->text().remove(QChar('&')) == tr("NONE")) { // note: this is for m_popup, the toplevel!
- if (m_hasModule) {
- emit sigRemoveButton(m_id);
- return;
- }
- }
- else {
- if (!m_hasModule) {
- emit sigAddButton();
- }
-
- m_hasModule = true;
- m_module = module();
-
- setIcon(DU::getIcon(iconName()));
- emit sigChanged();
-
- if (m_module) {
- setToolTip( tr("Select a work") + " [" + m_module->name() + "]" );
- }
- else {
- setToolTip( tr("Select an additional work") );
- }
- }
-}
-
-/** No descriptions */
-void CModuleChooserButton::populateMenu() {
- qDeleteAll(m_submenus);
- m_submenus.clear();
- delete m_popup;
- m_popup = new QMenu(this);
-
- if (m_module) {
- this->setToolTip( tr("Select a work") + " [" + m_module->name() + "]" );
- }
- else {
- this->setToolTip( tr("Select an additional work") );
- }
-
- m_noneAction = m_popup->addAction(tr("NONE"));
- m_noneAction->setCheckable(true);
- if (!m_module) m_noneAction->setChecked(true);
-
- m_popup->addSeparator();
- connect(m_popup, SIGNAL(triggered(QAction*)), this, SLOT(moduleChosen(QAction*)));
- setMenu(m_popup);
-
-
- // ******* Add languages and modules ********
-
- // Filters: add only non-hidden and right type
- BTModuleTreeItem::HiddenOff hiddenFilter;
- TypeFilter typeFilter(m_moduleType);
- QList<BTModuleTreeItem::Filter*> filters;
- if (!CBTConfig::get(CBTConfig::bookshelfShowHidden)) {
- filters.append(&hiddenFilter);
- }
- filters.append(&typeFilter);
- BTModuleTreeItem root(filters, BTModuleTreeItem::LangMod);
- // add all items recursively
- addItemToMenu(&root, m_popup);
-
-}
-
-void CModuleChooserButton::addItemToMenu(BTModuleTreeItem* item, QMenu* menu) {
- foreach (BTModuleTreeItem* i, item->children()) {
-
- if (i->type() == BTModuleTreeItem::Language) {
- // argument menu was m_popup, create and add a new lang menu to it
- QMenu* langMenu = new QMenu(i->text(), this);
- menu->addMenu(langMenu);
- m_submenus.append(langMenu);
- connect(langMenu, SIGNAL(triggered(QAction*)), this, SLOT(moduleChosen(QAction*)));
- // add the module items to the lang menu
- addItemToMenu(i, langMenu);
- }
- else {
- // item must be module, create and add it to the lang menu
- QString name(i->text());
- name.append(" ").append(i->moduleInfo()->isLocked() ? tr("[locked]") : QString::null);
- QAction* modItem = new QAction(name, menu);
- modItem->setCheckable(true);
- if ( m_module && i->text() == m_module->name()) modItem->setChecked(true);
- menu->addAction(modItem);
- }
- }
-}
-
-void CModuleChooserButton::updateMenuItems() {
- QString moduleName;
- CSwordModuleInfo* module = 0;
- QList<CSwordModuleInfo*> chosenModules = m_moduleChooserBar->getModuleList();
-
- //for ( QMenu* popup = m_submenus.first(); popup; popup = m_submenus.next() ) {
- QListIterator<QMenu*> it(m_submenus);
- while (it.hasNext()) {
- QMenu* popup = it.next();
- foreach (QAction* action, popup->actions()) {
- moduleName = action->text();
- moduleName.remove(QChar('&')); //remove Hotkey indicator
- module = backend()->findModuleByName( moduleName.left(moduleName.lastIndexOf(" ")) );
-
- //Q_ASSERT(module);
- if (!module) qWarning("Can't find module with name %s", moduleName.toLatin1().data());
-
- bool alreadyChosen = chosenModules.contains( module );
- if (m_module) {
- alreadyChosen = alreadyChosen && (m_module->name() != moduleName);
- }
- //grey it out, it was chosen already
- action->setEnabled(!alreadyChosen);
- }
- }
-}
diff --git a/src/frontend/displaywindow/cmodulechooserbutton.h b/src/frontend/displaywindow/cmodulechooserbutton.h
deleted file mode 100644
index 4d62b67..0000000
--- a/src/frontend/displaywindow/cmodulechooserbutton.h
+++ /dev/null
@@ -1,85 +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 CMODULECHOOSERBUTTON_H
-#define CMODULECHOOSERBUTTON_H
-
-#include <QToolButton>
-#include "util/cpointers.h"
-
-#include <QList>
-#include "backend/btmoduletreeitem.h"
-
-
-class QMenu;
-class CModuleChooserBar;
-class CSwordModuleInfo;
-
-/** The CModuleChooserButton displays a list of submenus sorted by language which contain the possible modules
- * which can be displayed together with the first one.
- * @author The BibleTime team
- */
-class CModuleChooserButton : public QToolButton, public CPointers {
- Q_OBJECT
- public:
-
- /** Filter out modules of wrong type. See populateMenu() and BTModuleTreeItem. */
- struct TypeFilter : public BTModuleTreeItem::Filter {
- TypeFilter(CSwordModuleInfo::ModuleType t) {
- m_mType = t;
- }
- bool filter(CSwordModuleInfo* mi) {
- return (mi->type() == m_mType);
- }
- CSwordModuleInfo::ModuleType m_mType;
- };
-
- CModuleChooserButton(CSwordModuleInfo* useModule, CSwordModuleInfo::ModuleType type, const int id, CModuleChooserBar *parent);
- ~CModuleChooserButton();
-
- CSwordModuleInfo* module();
- /**
- * Returns the id used for this button.
- */
- int getId() const;
- void updateMenuItems();
-
- protected:
- /** Populates the menu with language submenus and module items. */
- void populateMenu();
- /** Adds items to the menu recursively. */
- void addItemToMenu(BTModuleTreeItem* item, QMenu* menu);
-
- private:
- /**
- * Returns the icon used for the current status.
- */
- const QString iconName();
-
- bool m_hasModule;
- int m_id;
- QAction* m_noneAction;
- CSwordModuleInfo::ModuleType m_moduleType;
- CSwordModuleInfo* m_module;
-
- QMenu* m_popup;
- QList<QMenu*> m_submenus;
-
- CModuleChooserBar* m_moduleChooserBar;
-
-
- private slots:
- void moduleChosen(QAction* action );
-
- signals:
- void sigRemoveButton(const int ID);
- void sigAddButton();
- void sigChanged();
-};
-#endif
diff --git a/src/frontend/displaywindow/creadwindow.cpp b/src/frontend/displaywindow/creadwindow.cpp
index b65cf8c..07c0abb 100644
--- a/src/frontend/displaywindow/creadwindow.cpp
+++ b/src/frontend/displaywindow/creadwindow.cpp
@@ -26,11 +26,9 @@
using namespace Profile;
-typedef BtHtmlReadDisplay HTMLREADDISPLAY;
-
CReadWindow::CReadWindow(QList<CSwordModuleInfo*> modules, CMDIArea* parent)
: CDisplayWindow(modules, parent),
- m_displayWidget(0) {
+ m_readDisplayWidget(0) {
qDebug() << "CReadWindow::CReadWindow";
// installEventFilter(this);
}
@@ -41,34 +39,38 @@ CReadWindow::~CReadWindow() {
/** Sets the display widget of this display window. */
void CReadWindow::setDisplayWidget( CDisplay* newDisplay ) {
- Q_ASSERT(dynamic_cast<CReadDisplay*>(newDisplay));
+ // Lets be orwellianly paranoid here:
+ Q_ASSERT(dynamic_cast<CReadDisplay*>(newDisplay) != 0);
+
CDisplayWindow::setDisplayWidget(newDisplay);
- if (m_displayWidget) {
- disconnect(m_displayWidget->connectionsProxy(), SIGNAL(referenceClicked(const QString&, const QString&)), this, SLOT(lookupModKey(const QString&, const QString&)));
- disconnect(m_displayWidget->connectionsProxy(), SIGNAL(referenceDropped(const QString&)), this, SLOT(lookupKey(const QString&)));
+ if (m_readDisplayWidget) {
+ disconnect(m_readDisplayWidget->connectionsProxy(), SIGNAL(referenceClicked(const QString&, const QString&)),
+ this, SLOT(lookupModKey(const QString&, const QString&)));
+ disconnect(m_readDisplayWidget->connectionsProxy(), SIGNAL(referenceDropped(const QString&)),
+ this, SLOT(lookupKey(const QString&)));
- HTMLREADDISPLAY* v = dynamic_cast<HTMLREADDISPLAY*>(m_displayWidget);
+ BtHtmlReadDisplay* v = dynamic_cast<BtHtmlReadDisplay*>(m_readDisplayWidget);
if (v) {
QObject::disconnect(v, SIGNAL(completed()), this, SLOT(slotMoveToAnchor()) );
}
}
- m_displayWidget = (CReadDisplay*)newDisplay;
+ m_readDisplayWidget = static_cast<CReadDisplay*>(newDisplay);
connect(
- m_displayWidget->connectionsProxy(),
+ m_readDisplayWidget->connectionsProxy(),
SIGNAL(referenceClicked(const QString&, const QString&)),
this,
SLOT(lookupModKey(const QString&, const QString&))
);
connect(
- m_displayWidget->connectionsProxy(),
+ m_readDisplayWidget->connectionsProxy(),
SIGNAL(referenceDropped(const QString&)),
this,
SLOT(lookupKey(const QString&))
);
- HTMLREADDISPLAY* v = dynamic_cast<HTMLREADDISPLAY*>(m_displayWidget);
+ BtHtmlReadDisplay* v = dynamic_cast<BtHtmlReadDisplay*>(m_readDisplayWidget);
if (v) {
QObject::connect(v, SIGNAL(completed()), this, SLOT(slotMoveToAnchor()) );
}
@@ -193,9 +195,9 @@ void CReadWindow::openSearchStrongsDialog() {
QString searchText = QString::null;
if (displayWidget()->getCurrentNodeInfo()[CDisplay::Lemma] != QString::null) {
- Q_FOREACH(QString strongNumber, displayWidget()->getCurrentNodeInfo()[CDisplay::Lemma].split("|")) {
- searchText.append("strong:").append( strongNumber ).append(" ");
- }
+ Q_FOREACH(QString strongNumber, displayWidget()->getCurrentNodeInfo()[CDisplay::Lemma].split("|")) {
+ searchText.append("strong:").append( strongNumber ).append(" ");
+ }
}
Search::CSearchDialog::openDialog( modules(), searchText, 0 );
diff --git a/src/frontend/displaywindow/creadwindow.h b/src/frontend/displaywindow/creadwindow.h
index 1debe9f..7a529b8 100644
--- a/src/frontend/displaywindow/creadwindow.h
+++ b/src/frontend/displaywindow/creadwindow.h
@@ -25,7 +25,7 @@ class QResizeEvent;
class CReadWindow : public CDisplayWindow {
Q_OBJECT
public:
- // static void insertKeyboardActions( KAccel* const a );
+
static void insertKeyboardActions( BtActionCollection* const a );
CReadWindow(QList<CSwordModuleInfo*> modules, CMDIArea* parent);
@@ -39,7 +39,7 @@ class CReadWindow : public CDisplayWindow {
*/
virtual void applyProfileSettings(Profile::CProfileWindow * const settings);
- protected: // Protected methods
+ protected:
/**
* Sets the display widget of this display window.
*/
@@ -68,7 +68,7 @@ class CReadWindow : public CDisplayWindow {
void openSearchStrongsDialog();
private:
- CReadDisplay* m_displayWidget;
+ CReadDisplay* m_readDisplayWidget;
};
#endif
diff --git a/src/frontend/htmldialogs/btaboutdialog.cpp b/src/frontend/htmldialogs/btaboutdialog.cpp
index f8e6666..528d9d5 100644
--- a/src/frontend/htmldialogs/btaboutdialog.cpp
+++ b/src/frontend/htmldialogs/btaboutdialog.cpp
@@ -24,7 +24,6 @@ static QString make_head(const QString& content);
static QString make_html(const QString& content);
static QString make_file_icon(const QString& icon);
static QString make_link(const QString& link, const QString& text);
-static QString make_version();
// Implements the Help > About dialog box
@@ -48,7 +47,7 @@ void BtAboutDialog::init_bt_tab() {
QString content;
content = make_file_icon("bibletime");
content += "&nbsp;&nbsp;";
- content += make_bold("BibleTime " + make_version());
+ content += make_bold("BibleTime " BT_VERSION);
content = make_center(content) + make_br();
content += tr("BibleTime is an easy to use but powerful Bible study tool.");
content += make_br() + make_br();
@@ -68,7 +67,10 @@ void BtAboutDialog::init_contributors_tab() {
setTabText(tr("Contributors"));
QString content;
content += make_bold(tr("The following people contributed to BibleTime:")) + make_br();
- // sorted alphabetically (last name)
+
+ /****************************************************************************************
+ *** NB!!! Credits are sorted alphabetically by last name! ***
+ ****************************************************************************************/
content += "<ul>";
content += "<li>Thomas Abthorpe (" + tr("documentation and translation manager") + ")</li>";
content += "<li>Joachim Ansorg (" + tr("project founder, developer") + ")</li>";
@@ -89,18 +91,26 @@ void BtAboutDialog::init_contributors_tab() {
content += "<li>Mark Lybarger (" + tr("developer") + ")</li>";
content += "<li>Luke Mauldin (" + tr("developer") + ")</li>";
content += "<li>James Ots (" + tr("designer") + ")</li>";
+ /** \todo BibleTime 2.6: Add tr("artist"): */
+ content += "<li>Andrus Raag</li>";
+ content += "<li>Jaak Ristioja (" + tr("developer") + ")</li>";
content += "<li>Fred Saalbach (" + tr("documentation") + ")</li>";
content += "<li>Gary Sims (" + tr("developer") + ")</li>";
content += "<li>Wolfgang Stradner (" + tr("tester, usability expert") + ")</li>";
+ content += "<li>Kang Sun (" + tr("developer") + ")</li>";
content += "<li>Thorsten Uhlmann (" + tr("developer") + ")</li>";
content += "<li>David White (" + tr("developer") + ")</li>";
content += "<li>Mark Zealey (" + tr("developer") + ")</li>";
content += "</ul>";
content += make_bold(tr("The following people translated BibleTime into their language:")) + make_br();
- // sorted alphabetically (last name)
+
+ /****************************************************************************************
+ *** NB!!! Credits are sorted alphabetically by last name! ***
+ ****************************************************************************************/
content += "<ul>";
content += "<li>Horatiu Alexe</li>";
+ content += "<li>Luis Barron</li>";
content += "<li>Jan B&#x11B;lohoubek</li>";
content += "<li>Chun-shek Chan</li>";
content += "<li>Nouhoun Y. Diarra</li>";
@@ -230,15 +240,10 @@ static QString make_link(const QString& link, const QString& text) {
return "<a href=\"" + link + "\">" + text + "</a>";
}
-static QString make_version() {
-// return "";
- return BT_VERSION;
-}
-
static QString make_file_icon(const QString& icon) {
namespace DU = util::directory;
-
- QString dir("<img src=file://" + DU::getIconDir().path());
- return dir + "/" + icon + ".png >";
+ QUrl url = QUrl::fromLocalFile( DU::getIconDir().path() + "/" + icon + ".svg");
+ QString html = "<img src=\"" + url.toString() + "\">";
+ return html;
}
diff --git a/src/frontend/htmldialogs/bttabhtmldialog.cpp b/src/frontend/htmldialogs/bttabhtmldialog.cpp
index 74a2b20..bd52464 100644
--- a/src/frontend/htmldialogs/bttabhtmldialog.cpp
+++ b/src/frontend/htmldialogs/bttabhtmldialog.cpp
@@ -93,11 +93,9 @@ QWebView* BtTabHtmlDialog::webView() {
void BtTabHtmlDialog::setHtml(const QString& html, const QUrl& baseUrl) {
namespace DU = util::directory;
-
QUrl url = baseUrl;
if (url == QUrl()) {
- QString dir("file://" + DU::getIconDir().path());
- url.setUrl(dir);
+ QUrl url = QUrl::fromLocalFile(DU::getIconDir().path());
}
webView()->setHtml(html, url);
}
diff --git a/src/frontend/keychooser/clexiconkeychooser.cpp b/src/frontend/keychooser/clexiconkeychooser.cpp
index 45fa0e2..eca19d4 100644
--- a/src/frontend/keychooser/clexiconkeychooser.cpp
+++ b/src/frontend/keychooser/clexiconkeychooser.cpp
@@ -117,8 +117,11 @@ void CLexiconKeyChooser::refreshContent() {
QStringList refEntries = *(it->second); //copy the items for the first time
QStringList* cmpEntries = ( ++it )->second; //list for comparision, starts with the second module in the map
- while (it != entryMap.end()) {
- std::set_intersection(
+ // Testing for refEntries being empty is not needed for the set union
+ // of all keys, but is a good idea since it is being updated in the
+ // loop. It is necessary for set intersection and prevents a crash.
+ while (it != entryMap.end() && (refEntries.begin() != refEntries.end())) {
+ std::set_union(
refEntries.begin(), --(refEntries.end()), //--end() is the last valid entry
cmpEntries->begin(), --(cmpEntries->end()),
std::back_inserter(goodEntries), //append valid entries to the end of goodEntries
diff --git a/src/frontend/keychooser/versekeychooser/cbiblekeychooser.cpp b/src/frontend/keychooser/versekeychooser/cbiblekeychooser.cpp
index 7bcfbe1..2488668 100644
--- a/src/frontend/keychooser/versekeychooser/cbiblekeychooser.cpp
+++ b/src/frontend/keychooser/versekeychooser/cbiblekeychooser.cpp
@@ -62,13 +62,15 @@ void CBibleKeyChooser::setKey(CSwordKey* key) {
}
void CBibleKeyChooser::beforeRefChange(CSwordVerseKey* key) {
+ Q_UNUSED(key); /// \todo Is this correct?
+
Q_ASSERT(m_key);
- if (!updatesEnabled())
- return;
+ if (!updatesEnabled())
+ return;
- if (m_key)
- emit beforeKeyChange(m_key->key());
+ if (m_key)
+ emit beforeKeyChange(m_key->key());
}
@@ -76,8 +78,8 @@ void CBibleKeyChooser::refChanged(CSwordVerseKey* key) {
Q_ASSERT(m_key);
Q_ASSERT(key);
- if (!updatesEnabled())
- return;
+ if (!updatesEnabled())
+ return;
setUpdatesEnabled(false);
m_key = key;
diff --git a/src/frontend/keychooser/versekeychooser/ckeyreferencewidget.cpp b/src/frontend/keychooser/versekeychooser/ckeyreferencewidget.cpp
index 067b4db..e5cf4ff 100644
--- a/src/frontend/keychooser/versekeychooser/ckeyreferencewidget.cpp
+++ b/src/frontend/keychooser/versekeychooser/ckeyreferencewidget.cpp
@@ -239,7 +239,7 @@ void CKeyReferenceWidget::slotUpdateUnlock() {
}
void CKeyReferenceWidget::slotStepBook(int n) {
- emit beforeChange(m_key);
+ emit beforeChange(m_key);
n > 0 ? m_key->next( CSwordVerseKey::UseBook ) : m_key->previous( CSwordVerseKey::UseBook );
if (!updatelock)
emit changed(m_key);
@@ -247,7 +247,7 @@ void CKeyReferenceWidget::slotStepBook(int n) {
}
void CKeyReferenceWidget::slotStepChapter(int n) {
- emit beforeChange(m_key);
+ emit beforeChange(m_key);
n > 0 ? m_key->next( CSwordVerseKey::UseChapter ) : m_key->previous( CSwordVerseKey::UseChapter );
if (!updatelock)
emit changed(m_key);
@@ -255,7 +255,7 @@ void CKeyReferenceWidget::slotStepChapter(int n) {
}
void CKeyReferenceWidget::slotStepVerse(int n) {
- emit beforeChange(m_key);
+ emit beforeChange(m_key);
n > 0 ? m_key->next( CSwordVerseKey::UseVerse ) : m_key->previous( CSwordVerseKey::UseVerse );
if (!updatelock)
emit changed(m_key);
@@ -265,7 +265,7 @@ void CKeyReferenceWidget::slotStepVerse(int n) {
void CKeyReferenceWidget::slotChangeVerse(int n) {
if (m_key->Verse() != n) {
- emit beforeChange(m_key);
+ emit beforeChange(m_key);
m_key->Verse( n );
setKey( m_key );
}
@@ -275,7 +275,7 @@ void CKeyReferenceWidget::slotChangeVerse(int n) {
void CKeyReferenceWidget::slotChangeChapter(int n) {
if (m_key->Chapter() != n) {
- emit beforeChange(m_key);
+ emit beforeChange(m_key);
m_key->Chapter( n );
setKey( m_key );
}
@@ -286,7 +286,7 @@ void CKeyReferenceWidget::slotChangeChapter(int n) {
void CKeyReferenceWidget::slotChangeBook(QString bookname) {
if (m_key->book() != bookname) {
- emit beforeChange(m_key);
+ emit beforeChange(m_key);
m_key->book( bookname );
setKey( m_key );
}
diff --git a/src/frontend/keychooser/versekeychooser/ckeyreferencewidget.h b/src/frontend/keychooser/versekeychooser/ckeyreferencewidget.h
index 637530a..df2c9d2 100644
--- a/src/frontend/keychooser/versekeychooser/ckeyreferencewidget.h
+++ b/src/frontend/keychooser/versekeychooser/ckeyreferencewidget.h
@@ -35,8 +35,8 @@ class CKeyReferenceWidget : public QWidget {
void setModule(CSwordBibleModuleInfo *m = 0);
bool eventFilter(QObject *o, QEvent *e);
-signals:
- void beforeChange(CSwordVerseKey* key);
+ signals:
+ void beforeChange(CSwordVerseKey* key);
void changed(CSwordVerseKey* key);
protected:
diff --git a/src/frontend/mainindex/bookmarks/cbookmarkindex.cpp b/src/frontend/mainindex/bookmarks/cbookmarkindex.cpp
index dda763b..1f88125 100644
--- a/src/frontend/mainindex/bookmarks/cbookmarkindex.cpp
+++ b/src/frontend/mainindex/bookmarks/cbookmarkindex.cpp
@@ -115,6 +115,7 @@ void CBookmarkIndex::initView() {
m_popup->addAction(separator);
m_popup->addAction(m_actions.deleteEntries);
+ m_bookmarksModified = false;
//qDebug() << "CBookmarkIndex::initView end";
}
@@ -142,6 +143,14 @@ void CBookmarkIndex::initConnections() {
Q_ASSERT(ok);
ok = connect(this, SIGNAL(itemEntered(QTreeWidgetItem*, int)), this, SLOT(slotItemEntered(QTreeWidgetItem*, int)) );
Q_ASSERT(ok);
+
+ // Connection to detect changes in the items themselves (e.g. renames,
+ // description changes) so that we can consider saving the bookmarks.
+ connect(this, SIGNAL(itemChanged(QTreeWidgetItem*, int)), this, SLOT(needToSaveBookmarks(QTreeWidgetItem*)) );
+
+ // Connect the bookmark saving timer.
+ bookmarkSaveTimer.setSingleShot(true);
+ connect(&bookmarkSaveTimer, SIGNAL(timeout()), this, SLOT(considerSavingBookmarks()) );
}
@@ -407,6 +416,9 @@ void CBookmarkIndex::dropEvent( QDropEvent* event ) {
if (dropAction == copy) {
qDebug() << "copy";
parentItem->insertChildren(indexUnderParent, newItems);
+ // Need this here because the "move" case goes through
+ // "deleteEntries" which has a save call.
+ needToSaveBookmarks();
}
else {
if (dropAction == move) {
@@ -415,11 +427,11 @@ void CBookmarkIndex::dropEvent( QDropEvent* event ) {
deleteEntries(false);
}
else {
- QObject::disconnect(this, SIGNAL(itemCollapsed(QTreeWidgetItem*)), this, SLOT(expandAutoCollapsedItem(QTreeWidgetItem*)));
+ QObject::disconnect(this, SIGNAL(itemCollapsed(QTreeWidgetItem*)),
+ this, SLOT(expandAutoCollapsedItem(QTreeWidgetItem*)));
return; // user canceled
}
}
-
}
else {
qDebug() << "the source was outside this";
@@ -442,7 +454,11 @@ void CBookmarkIndex::createBookmarkFromDrop(QDropEvent* event, QTreeWidgetItem*
CSwordModuleInfo* minfo = CPointers::backend()->findModuleByName(moduleName);
QTreeWidgetItem* newItem = new BtBookmarkItem(minfo, keyText, description);
+ // connect(newItem, SIGNAL(bookmarkModified()), this, SLOT(needToSaveBookmarks()) );
parentItem->insertChild(indexInParent, newItem);
+
+ qDebug() << "Saving in...CBookmarkIndex::createBookmarkFromDrop";
+ needToSaveBookmarks();
}
}
@@ -582,6 +598,7 @@ void CBookmarkIndex::createNewFolder() {
newFolder->update();
newFolder->rename();
}
+ needToSaveBookmarks();
}
/** Opens a dialog to change the current folder. */
@@ -621,6 +638,7 @@ void CBookmarkIndex::importBookmarks() {
if (i) {
i->importBookmarks();
}
+ needToSaveBookmarks();
}
/** Prints the selected bookmarks. */
@@ -672,7 +690,10 @@ void CBookmarkIndex::deleteEntries(bool confirm) {
}
}
- if (util::showQuestion(this, tr("Delete Items"), tr("Do you really want to delete the selected items and child-items?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No ) != QMessageBox::Yes) {
+ if (util::showQuestion(this, tr("Delete Items"),
+ tr("Do you really want to delete the selected items and child-items?"),
+ QMessageBox::Yes | QMessageBox::No, QMessageBox::No )
+ != QMessageBox::Yes) {
return;
}
}
@@ -680,7 +701,11 @@ void CBookmarkIndex::deleteEntries(bool confirm) {
while (selectedItems().size() > 0) {
delete selectedItems().at(0); // deleting all does not work because it may cause double deletion
}
-
+ // Save the bookmarks. One way would be to signal that the bookmarks have
+ // changed emit a signal so that a number of changes may be saved at once.
+ // Another way is to simply save the bookmarks after each change, which can
+ // be inefficient.
+ needToSaveBookmarks();
}
@@ -737,7 +762,6 @@ void CBookmarkIndex::saveBookmarks() {
qDebug() << "CBookmarkIndex::saveBookmarks()";
BtBookmarkLoader loader;
loader.saveTreeFromRootItem(invisibleRootItem());
- //qDebug() << "CBookmarkIndex::saveBookmarks end";
}
void CBookmarkIndex::mouseMoveEvent(QMouseEvent* event) {
@@ -839,3 +863,33 @@ QList<QTreeWidgetItem*> CBookmarkIndex::addItemsToDropTree(
return newList;
}
+/// Bookmark saving code. To avoid many saves during a short period of time,
+/// bookmark modification is first noted. Then, after a wait (1.5s), if no more
+/// modifications are made, the bookmarks are saved. The timer is reset when a
+/// new modification is made. The timer bookmarkSaveTimer is set to be oneshot.
+void CBookmarkIndex::needToSaveBookmarks() {
+ qDebug() << "Got signal to save bookmarks!";
+ m_bookmarksModified = true;
+ bookmarkSaveTimer.start(1500); // Only save after 1.5s.
+}
+void CBookmarkIndex::needToSaveBookmarks(QTreeWidgetItem* treeItem) {
+ // Need to test whether the item that changed is not just a display item,
+ // but actually a folder or bookmark.
+ BtBookmarkItemBase* bookmark = dynamic_cast<BtBookmarkItemBase*>(treeItem);
+ if (bookmark) {
+ qDebug() << "Got signal to save bookmarks!";
+ m_bookmarksModified = true;
+ bookmarkSaveTimer.start(1500); // Only save after 1.5s.
+ }
+}
+
+/// Considers saving bookmarks only if they have been modified. This procedure
+/// should be called by the qtimer bookmarkTimer.
+void CBookmarkIndex::considerSavingBookmarks() {
+ qDebug() << "Considering to save bookmarks!";
+ if (m_bookmarksModified) {
+ saveBookmarks();
+ m_bookmarksModified = false;
+ }
+}
+
diff --git a/src/frontend/mainindex/bookmarks/cbookmarkindex.h b/src/frontend/mainindex/bookmarks/cbookmarkindex.h
index 9da12a6..90f9ab2 100644
--- a/src/frontend/mainindex/bookmarks/cbookmarkindex.h
+++ b/src/frontend/mainindex/bookmarks/cbookmarkindex.h
@@ -56,6 +56,19 @@ class CBookmarkIndex : public QTreeWidget {
*/
void createReadDisplayWindow( QList<CSwordModuleInfo*>, const QString& );
+ public slots:
+
+ /**
+ * Indicates a need to save the bookmarks.
+ * This is needed to provide a way for a bookmarkitem stored in the
+ * treeWidget to inform us that it has been modified, namely its
+ * description text. It only sets a dirty-bit so we don't execute many
+ * consecutive saves.
+ */
+ void needToSaveBookmarks();
+ void needToSaveBookmarks(QTreeWidgetItem* treeItem);
+
+
protected: // Protected methods
/** A hack to get the modifiers. */
@@ -173,6 +186,22 @@ class CBookmarkIndex : public QTreeWidget {
QPoint m_dragMovementPosition;
QPoint m_dragStartPosition;
QTreeWidgetItem* m_extraItem;
+
+ // The following is for managing saving bookmarks. It uses a QTimer to
+ // determine whether the bookmarks should be saved. This may seem like
+ // a hassle, but it is to prevent many saves from being executed at a
+ // time.
+
+ /** Flag indicating that bookmarks have been modified. */
+ bool m_bookmarksModified;
+ QTimer bookmarkSaveTimer;
+
+ private slots:
+ /**
+ * Saves the bookmarks.
+ * It checks m_bookmarksModified and resets it at the end. It should be
+ * connected to a timer that periodically calls this. */
+ void considerSavingBookmarks();
};
#endif
diff --git a/src/frontend/profile/cprofile.cpp b/src/frontend/profile/cprofile.cpp
index 9d97b5c..34f397b 100644
--- a/src/frontend/profile/cprofile.cpp
+++ b/src/frontend/profile/cprofile.cpp
@@ -97,9 +97,9 @@ QList<CProfileWindow*> CProfile::load() {
if (mdi_element.hasAttribute("ArrangementMode")) {
this->setMDIArrangementMode((CMDIArea::MDIArrangementMode)mdi_element.attribute("ArrangementMode").toInt());
}
- }
- }
- }
+ }
+ }
+ }
m_profileWindows.clear();
QDomElement elem = document.firstChild().toElement();
@@ -181,6 +181,18 @@ QList<CProfileWindow*> CProfile::load() {
}
elem = elem.nextSibling().toElement();
}
+
+ // Are any windows maximized?
+ bool maximized = false;
+ for (int i = 0; i < m_profileWindows.count(); i++) {
+ if (m_profileWindows.at(i)->maximized())
+ maximized = true;
+ }
+ // Set all windows the same for maximized
+ for (int i = 0; i < m_profileWindows.count(); i++) {
+ m_profileWindows.at(i)->setMaximized(maximized);
+ }
+
return m_profileWindows;
}
diff --git a/src/frontend/searchdialog/btsearchresultarea.cpp b/src/frontend/searchdialog/btsearchresultarea.cpp
index f56c1b1..4b33f80 100644
--- a/src/frontend/searchdialog/btsearchresultarea.cpp
+++ b/src/frontend/searchdialog/btsearchresultarea.cpp
@@ -206,7 +206,7 @@ QStringList BtSearchResultArea::QueryParser(const QString& queryString) {
token = token + queryString[cnt];
cnt++;
}
- else if ((queryString[cnt]).isLetterOrNumber() || (queryString[cnt] == '?')) {
+ else if ((queryString[cnt]).isLetterOrNumber() || (queryString[cnt] == '?')) {
token = token + queryString[cnt];
cnt++;
}
@@ -437,7 +437,7 @@ QString BtSearchResultArea::highlightSearchedText(const QString& content, const
// made a simple parser.
//===========================================================
QStringList words = QueryParser(newSearchText);
- qDebug() << "btsearchresultarea.cpp: " << __LINE__ << ": " << words << '\n';
+ qDebug() << "btsearchresultarea.cpp: " << __LINE__ << ": " << words << '\n';
foreach (QString word, words) { //search for every word in the list
QRegExp findExp;
if (word.contains("*")) {
@@ -446,7 +446,7 @@ QString BtSearchResultArea::highlightSearchedText(const QString& content, const
findExp = QRegExp(word);
findExp.setMinimal(TRUE);
}
- else if (word.contains("?")) {
+ else if (word.contains("?")) {
length = word.length() - 1;
word.replace('?', "\\S?"); //match within a word
findExp = QRegExp(word);
@@ -472,7 +472,7 @@ QString BtSearchResultArea::highlightSearchedText(const QString& content, const
index += length;
}
}
- qDebug() << "btsearchresultarea.cpp: " << __LINE__ << ": " << words << '\n';
+ qDebug() << "btsearchresultarea.cpp: " << __LINE__ << ": " << words << '\n';
//qWarning("\n\n\n%s", ret.latin1());
return ret;
}
diff --git a/src/frontend/searchdialog/cmoduleresultview.cpp b/src/frontend/searchdialog/cmoduleresultview.cpp
index 0228ad2..ef23756 100644
--- a/src/frontend/searchdialog/cmoduleresultview.cpp
+++ b/src/frontend/searchdialog/cmoduleresultview.cpp
@@ -38,8 +38,8 @@ CModuleResultView::CModuleResultView(QWidget* parent)
}
CModuleResultView::~CModuleResultView() {
- qDeleteAll(strongsResults);
- strongsResults.clear();
+ qDeleteAll(strongsResults);
+ strongsResults.clear();
}
@@ -109,7 +109,7 @@ void CModuleResultView::setupTree( QList<CSwordModuleInfo*> modules, const QStri
sword::ListKey result;
- qDeleteAll(strongsResults);
+ qDeleteAll(strongsResults);
strongsResults.clear();
bool strongsAvailable = false;
@@ -187,7 +187,7 @@ void CModuleResultView::executed( QTreeWidgetItem* i, QTreeWidgetItem*) {
return;
}
- StrongsResultClass* strongsResult = strongsResults[activeModule()];
+ StrongsResultClass* strongsResult = strongsResults[activeModule()];
if (!strongsResult) {
return;
diff --git a/src/frontend/searchdialog/csearchdialog.cpp b/src/frontend/searchdialog/csearchdialog.cpp
index 8442c61..6f8214c 100644
--- a/src/frontend/searchdialog/csearchdialog.cpp
+++ b/src/frontend/searchdialog/csearchdialog.cpp
@@ -63,10 +63,9 @@ void CSearchDialog::openDialog(const QList<CSwordModuleInfo*> modules, const QSt
m_staticDialog->activateWindow();
}
-void CSearchDialog::closeDialog()
-{
- if (m_staticDialog != 0)
- m_staticDialog->closeButtonClicked();
+void CSearchDialog::closeDialog() {
+ if (m_staticDialog != 0)
+ m_staticDialog->closeButtonClicked();
}
CSearchDialog* CSearchDialog::getSearchDialog() {
@@ -99,11 +98,11 @@ void CSearchDialog::startSearch() {
// first check the search string for errors
{
- QString TestString(originalSearchText);
- QRegExp ReservedWords("heading:|footnote:|morph:|strong:");
- if (TestString.replace(ReservedWords, "").simplified().isEmpty()) {
- return;
- }
+ QString TestString(originalSearchText);
+ QRegExp ReservedWords("heading:|footnote:|morph:|strong:");
+ if (TestString.replace(ReservedWords, "").simplified().isEmpty()) {
+ return;
+ }
}
searchText = prepareSearchText(originalSearchText);
diff --git a/src/frontend/searchdialog/csearchdialog.h b/src/frontend/searchdialog/csearchdialog.h
index 98034fc..55bded4 100644
--- a/src/frontend/searchdialog/csearchdialog.h
+++ b/src/frontend/searchdialog/csearchdialog.h
@@ -34,7 +34,7 @@ class CSearchDialog : public QDialog {
Q_OBJECT
public:
static void openDialog(const QList<CSwordModuleInfo*> modules, const QString& searchText = QString::null, QWidget* parentDialog = 0);
- static void closeDialog();
+ static void closeDialog();
protected:
friend class CSearchAnalysisScene;
diff --git a/src/frontend/settingsdialogs/btshortcutseditor.cpp b/src/frontend/settingsdialogs/btshortcutseditor.cpp
index 3c9027d..f92a27e 100644
--- a/src/frontend/settingsdialogs/btshortcutseditor.cpp
+++ b/src/frontend/settingsdialogs/btshortcutseditor.cpp
@@ -155,6 +155,8 @@ void BtShortcutsEditor::commitChanges() {
// puts actions and shortcut keys into QTableWidget
void BtShortcutsEditor::addCollection(BtActionCollection* collection, const QString& title) {
+ Q_UNUSED(title); /// \todo Is this correct?
+
QList<QAction*> actionList = collection->actions();
int count;
count = actionList.count();
@@ -217,6 +219,8 @@ QTableWidget* BtShortcutsEditor::createShortcutsTable() {
// called when a different action name row is selected
void BtShortcutsEditor::changeRow(int row, int column) {
+ Q_UNUSED(column); /// \todo Is this correct?
+
BtShortcutsEditorItem* item = getShortcutsEditor(row);
m_currentRow = row;
QKeySequence defaultKeys = item->getDefaultKeys();
@@ -290,6 +294,8 @@ QWidget* BtShortcutsEditor::createShortcutChooser() {
// called when the none radio button is clicked
void BtShortcutsEditor::noneButtonClicked(bool checked) {
+ Q_UNUSED(checked); /// \todo Is this correct?
+
if (m_currentRow < 0)
return;
BtShortcutsEditorItem* item = getShortcutsEditor(m_currentRow);
@@ -302,6 +308,8 @@ void BtShortcutsEditor::noneButtonClicked(bool checked) {
// called when the default radio button is clicked
void BtShortcutsEditor::defaultButtonClicked(bool checked) {
+ Q_UNUSED(checked); /// \todo Is this correct?
+
if (m_currentRow < 0)
return;
BtShortcutsEditorItem* item = getShortcutsEditor(m_currentRow);
@@ -315,6 +323,8 @@ void BtShortcutsEditor::defaultButtonClicked(bool checked) {
// called when the custom radio button is clicked
void BtShortcutsEditor::customButtonClicked(bool checked) {
+ Q_UNUSED(checked); /// \todo Is this correct?
+
if (m_currentRow < 0)
return;
diff --git a/src/frontend/settingsdialogs/cacceleratorsettings.cpp b/src/frontend/settingsdialogs/cacceleratorsettings.cpp
index 9fe7a9b..636b9cc 100644
--- a/src/frontend/settingsdialogs/cacceleratorsettings.cpp
+++ b/src/frontend/settingsdialogs/cacceleratorsettings.cpp
@@ -239,6 +239,8 @@ void CAcceleratorSettingsPage::save() {
}
void CAcceleratorSettingsPage::slotKeyChooserTypeChanged(const QString& title) {
+ Q_UNUSED(title); /// \todo Is this correct?
+
int index = m_typeChooser->currentIndex();
m_keyChooserStack->setCurrentIndex(index);
diff --git a/src/main.cpp b/src/main.cpp
index f265ad7..3064522 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -20,6 +20,7 @@
#include <QVariant>
#include "backend/bookshelfmodel/btbookshelftreemodel.h"
#include "backend/config/cbtconfig.h"
+#include "backend/managers/cswordbackend.h"
#include "bibletime.h"
#include "bibletime_dbus_adaptor.h"
#include "bibletimeapp.h"
@@ -33,28 +34,60 @@
#endif
+namespace {
+
bool showDebugMessages;
+#ifdef Q_WS_WIN
+
+FILE *out_fd = 0;
+#define DEBUG_STREAM (out_fd != 0 ? out_fd :\
+ out_fd = fopen(QDir::homePath().append("/BibleTime Debug.txt").toLocal8Bit().data(),"w"))
+#define CLOSE_DEBUG_STREAM { if (out_fd != 0) fclose(out_fd); }
+
+#else
+
+#define DEBUG_STREAM (stderr)
+#define CLOSE_DEBUG_STREAM
+
+#endif
+
+} // anonymous namespace
+
+
void myMessageOutput( QtMsgType type, const char *msg ) {
//we use this messagehandler to switch debugging off in final releases
+ FILE* outFd = 0;
switch (type) {
case QtDebugMsg:
if (showDebugMessages) { //only show messages if they are enabled!
- fprintf( stderr, "(BibleTime %s) Debug: %s\n", BT_VERSION, msg );
+ outFd = DEBUG_STREAM;
+ if (outFd != 0)
+ fprintf(outFd, "(BibleTime " BT_VERSION ") Debug: %s\n", msg);
}
break;
case QtWarningMsg:
- //if (showDebugMessages) //comment out for releases so users don't get our debug warnings
- fprintf( stderr, "(BibleTime %s) WARNING: %s\n", BT_VERSION, msg );
+#ifndef QT_NO_DEBUG // don't show in release builds so users don't get our debug warnings
+ outFd = DEBUG_STREAM;
+ if (outFd != 0)
+ fprintf(outFd, "(BibleTime " BT_VERSION ") WARNING: %s\n", msg);
+#endif
break;
case QtFatalMsg:
case QtCriticalMsg:
- fprintf( stderr, "(BibleTime %s) _FATAL_: %s\nPlease report this bug! (http://www.bibletime.info/development_help.html)", BT_VERSION, msg );
+ outFd = DEBUG_STREAM;
+ if (outFd != 0)
+ fprintf(outFd,
+ "(BibleTime " BT_VERSION ") _FATAL_: %s\nPlease report this bug! "
+ "(http://www.bibletime.info/development_help.html)",
+ msg);
abort(); // dump core on purpose
}
}
void registerMetaTypes() {
+ qRegisterMetaType<CSwordBackend::FilterOptions>();
+ qRegisterMetaType<CSwordBackend::DisplayOptions>();
qRegisterMetaTypeStreamOperators<BtBookshelfTreeModel::Grouping>("BtBookshelfTreeModel::Grouping");
}
@@ -63,7 +96,20 @@ void registerMetaTypes() {
int main(int argc, char* argv[]) {
namespace DU = util::directory;
-// qInstallMsgHandler( myMessageOutput );
+ BibleTimeApp app(argc, argv); //for QApplication
+ app.setApplicationName("bibletime");
+ app.setApplicationVersion(BT_VERSION);
+
+ showDebugMessages = QCoreApplication::arguments().contains("--debug");
+
+#ifdef Q_WS_WIN
+ // Use the default Qt message handler if --debug is not specified
+ // This works with Visual Studio debugger Output Window
+ if (showDebugMessages)
+ qInstallMsgHandler( myMessageOutput );
+#else
+ qInstallMsgHandler( myMessageOutput );
+#endif
#ifdef BT_ENABLE_TESTING
if (QString(argv[1]) == QString("--run-tests")) {
@@ -77,18 +123,14 @@ int main(int argc, char* argv[]) {
command line argument handling.
*/
- BibleTimeApp app(argc, argv); //for QApplication
- app.setApplicationName("bibletime");
- app.setApplicationVersion(BT_VERSION);
-
#ifdef Q_WS_WIN
- // On Windows, add a path for Qt plugins to be loaded from
+ // On Windows, add a path for Qt plugins to be loaded from
app.addLibraryPath(app.applicationDirPath() + "/plugins");
- // Must set HOME var on Windows
- QString homeDir(getenv("APPDATA"));
- _putenv_s("HOME", qPrintable(homeDir));
+ // Must set HOME var on Windows
+ QString homeDir(getenv("APPDATA"));
+ _putenv_s("HOME", qPrintable(homeDir));
#endif
@@ -100,14 +142,14 @@ int main(int argc, char* argv[]) {
}
#ifdef Q_WS_WIN
- // change directory to the Sword or .sword directory in the $HOME dir so that
- // the sword.conf is found. It points to the sword/locales.d directory
- QString homeSwordDir = util::directory::getUserHomeDir().absolutePath();
- QDir dir;
- dir.setCurrent(homeSwordDir);
+ // change directory to the Sword or .sword directory in the $HOME dir so that
+ // the sword.conf is found. It points to the sword/locales.d directory
+ QString homeSwordDir = util::directory::getUserHomeDir().absolutePath();
+ QDir dir;
+ dir.setCurrent(homeSwordDir);
#endif
- // This is needed for languagemgr language names to work, they use \uxxxx escape sequences in string literals
+ // This is needed for languagemgr language names to work, they use \uxxxx escape sequences in string literals
QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));
//first install QT's own translations
QTranslator qtTranslator;
@@ -118,9 +160,6 @@ int main(int argc, char* argv[]) {
BibleTimeTranslator.load( QString("bibletime_ui_").append(QLocale::system().name()), DU::getLocaleDir().canonicalPath());
app.installTranslator(&BibleTimeTranslator);
- // This is the QT4 version, will only work if main App is QApplication
- // A binary option (on / off)
- showDebugMessages = QCoreApplication::arguments().contains("--debug");
app.setProperty("--debug", QVariant(showDebugMessages));
//Migrate configuration data, if neccessary
@@ -148,6 +187,8 @@ int main(int argc, char* argv[]) {
QDBusConnection::sessionBus().registerObject("/BibleTime", &bibleTime);
#endif
- return app.exec();
+ int r = app.exec();
+ CLOSE_DEBUG_STREAM;
+ return r;
}
diff --git a/src/util/cresmgr.cpp b/src/util/cresmgr.cpp
index 80d9d2c..56fe5b1 100644
--- a/src/util/cresmgr.cpp
+++ b/src/util/cresmgr.cpp
@@ -136,6 +136,11 @@ const QString icon = "tile_vert.svg";
const QKeySequence accel(Qt::CTRL + Qt::ALT + Qt::Key_G);
const char* actionName = "windowAutoTileVertical_action";
}
+namespace autoTile {
+const QString icon = "tile_auto.svg";
+const QKeySequence accel(Qt::CTRL + Qt::ALT + Qt::Key_I);
+const char* actionName = "windowAutoTile_action";
+}
namespace autoCascade {
const QString icon = "cascade_auto.svg";
const QKeySequence accel(Qt::CTRL + Qt::ALT + Qt::Key_J);
@@ -152,6 +157,11 @@ const QString icon = "tile_vert.svg";
const QKeySequence accel(Qt::CTRL + Qt::Key_G);
const char* actionName = "windowTileVertical_action";
}
+namespace tile {
+const QString icon = "tile.svg";
+const QKeySequence accel(Qt::CTRL + Qt::Key_I);
+const char* actionName = "windowTile_action";
+}
namespace cascade {
const QString icon = "cascade.svg";
const QKeySequence accel(Qt::CTRL + Qt::Key_J);
@@ -236,6 +246,9 @@ const QString icon = "displayconfig.svg";
}
namespace general {
+const QString removemoduleicon = "fileclose";
+const QString addmoduleicon = "plus";
+const QString replacemoduleicon = "checkbox";
namespace search {
const QString icon = "find.svg";
const QKeySequence accel(Qt::CTRL + Qt::Key_N);
diff --git a/src/util/cresmgr.h b/src/util/cresmgr.h
index 6f001b9..0d239f0 100644
--- a/src/util/cresmgr.h
+++ b/src/util/cresmgr.h
@@ -140,6 +140,11 @@ extern const QString icon;
extern const QKeySequence accel;
extern const char* actionName;
}
+namespace autoTile {
+extern const QString icon;
+extern const QKeySequence accel;
+extern const char* actionName;
+}
namespace autoCascade {
extern const QString icon;
extern const QKeySequence accel;
@@ -156,6 +161,11 @@ extern const QString icon;
extern const QKeySequence accel;
extern const char* actionName;
}
+namespace tile {
+extern const QString icon;
+extern const QKeySequence accel;
+extern const char* actionName;
+}
namespace cascade {
extern const QString icon;
extern const QKeySequence accel;
@@ -246,6 +256,9 @@ extern const QString icon;
}
namespace general {
+extern const QString removemoduleicon;
+extern const QString addmoduleicon;
+extern const QString replacemoduleicon;
namespace search {
extern const QString icon;
extern const QKeySequence accel;
diff --git a/src/util/directory.cpp b/src/util/directory.cpp
index c307066..809b435 100644
--- a/src/util/directory.cpp
+++ b/src/util/directory.cpp
@@ -48,7 +48,7 @@ QDir cachedSharedSwordDir;
static const char* BIBLETIME = "Bibletime";
static const char* SWORD_DIR = "Sword";
#else
-static const char* BIBLETIME =".bibletime";
+static const char* BIBLETIME = ".bibletime";
static const char* SWORD_DIR = ".sword";
#endif
} // anonymous namespace
@@ -70,16 +70,16 @@ bool initDirectoryCache() {
return false;
}
- cachedSharedSwordDir = QDir(getenv("ALLUSERSPROFILE")); // sword dir for Windows only
+ cachedSharedSwordDir = QDir(getenv("ALLUSERSPROFILE")); // sword dir for Windows only
if (!cachedSharedSwordDir.cd("Application Data")) {
qWarning() << "Cannot find ALLUSERSPROFILE\\Application Data";
return false;
- }
+ }
if (!cachedSharedSwordDir.cd(SWORD_DIR)) {
if (!cachedSharedSwordDir.mkdir(SWORD_DIR) || !cachedSharedSwordDir.cd(SWORD_DIR)) {
- qWarning() << "Cannot find ALLUSERSPROFILE\\Application Data\\Sword";
- return false;
- }
+ qWarning() << "Cannot find ALLUSERSPROFILE\\Application Data\\Sword";
+ return false;
+ }
}
#endif
@@ -277,15 +277,14 @@ void copyRecursive(const QString &src, const QString &dest) {
}
}
-QString convertDirSeparators(const QString& path)
-{
- QString result = path;
+QString convertDirSeparators(const QString& path) {
+ QString result = path;
#ifdef Q_WS_WIN
- result.replace("/", "\\");
+ result.replace("/", "\\");
#else
- result.replace("\\", "/");
+ result.replace("\\", "/");
#endif
- return result;
+ return result;
}
#ifdef Q_WS_WIN
diff --git a/src/util/directory.h b/src/util/directory.h
index 9666c14..1b460d0 100644
--- a/src/util/directory.h
+++ b/src/util/directory.h
@@ -55,14 +55,14 @@ unsigned long getDirSizeRecursive(const QString &dir);
*/
void copyRecursive(const QString &src, const QString &dest);
-/** Convert directory path separators to those for each platform
+/** Convert directory path separators to those for each platform
* Windows = "\", Others = "/"
*/
QString convertDirSeparators(const QString& path);
#ifdef Q_WS_WIN // Windows only directories
-/** Return the path to the sword dir., Windows only
+/** Return the path to the sword dir., Windows only
C:\Program Files\BibleTime\share\sword
*/
QDir getApplicationSwordDir();
diff --git a/src/util/tool.h b/src/util/tool.h
index 838616a..9dc753f 100644
--- a/src/util/tool.h
+++ b/src/util/tool.h
@@ -22,58 +22,58 @@ class QWidget;
namespace util {
namespace tool {
- /**
- * Converts HTML text to plain text.
- * This function converts some HTML tags in text (e.g. <br/> to \n)
- * @return The text withput HTML tags and with converted <br/> to \n
- */
- QString htmlToText(const QString&);
- /**
- * Converts text to HTML converting some text commands into HTML tags (e.g. \n to <br/>)
- * @return The HTML formatted text we got after changing \n to <br/>
- */
- QString textToHTML(const QString&);
- /**
- * Creates the file filename and put the text of parameter "text" into the file.
- * @return True if saving was sucessful, otherwise false
- */
- bool savePlainFile( const QString& filename, const QString& text, const bool& forceOverwrite = false, QTextCodec* fileCodec = QTextCodec::codecForLocale());
- /**
- * Returns the icon used for the module given as aparameter.
- */
- QIcon getIconForModule( CSwordModuleInfo* );
- /**
- * Returns the name for the icon used for the module given as aparameter.
- */
- QString getIconNameForModule( CSwordModuleInfo* );
+/**
+ * Converts HTML text to plain text.
+ * This function converts some HTML tags in text (e.g. <br/> to \n)
+ * @return The text withput HTML tags and with converted <br/> to \n
+ */
+QString htmlToText(const QString&);
+/**
+* Converts text to HTML converting some text commands into HTML tags (e.g. \n to <br/>)
+* @return The HTML formatted text we got after changing \n to <br/>
+*/
+QString textToHTML(const QString&);
+/**
+* Creates the file filename and put the text of parameter "text" into the file.
+* @return True if saving was sucessful, otherwise false
+*/
+bool savePlainFile( const QString& filename, const QString& text, const bool& forceOverwrite = false, QTextCodec* fileCodec = QTextCodec::codecForLocale());
+/**
+* Returns the icon used for the module given as aparameter.
+*/
+QIcon getIconForModule( CSwordModuleInfo* );
+/**
+* Returns the name for the icon used for the module given as aparameter.
+*/
+QString getIconNameForModule( CSwordModuleInfo* );
- /** Returns a label to explain difficult things of dialogs.
- * This function returns a label with heading "heading" and explanation "text". This label should be used to
- * explain difficult things of the GUI, e.g. in the optionsdialog.
- */
- QLabel* explanationLabel(QWidget* parent, const QString& heading, const QString& text );
- /**
- * Returns true if the character at position "pos" of text is inside an HTML tag. Returns false if it's not inside an HTML tag.
- */
- bool inHTMLTag(int pos, QString & text);
+/** Returns a label to explain difficult things of dialogs.
+* This function returns a label with heading "heading" and explanation "text". This label should be used to
+* explain difficult things of the GUI, e.g. in the optionsdialog.
+*/
+QLabel* explanationLabel(QWidget* parent, const QString& heading, const QString& text );
+/**
+* Returns true if the character at position "pos" of text is inside an HTML tag. Returns false if it's not inside an HTML tag.
+*/
+bool inHTMLTag(int pos, QString & text);
- /** Return the module's tooltip text
- * @param module The module required for the tooltip
- * @return The tooltip text for the passed module
- */
- QString moduleToolTip(CSwordModuleInfo* module);
+/** Return the module's tooltip text
+* @param module The module required for the tooltip
+* @return The tooltip text for the passed module
+*/
+QString moduleToolTip(CSwordModuleInfo* module);
- /** Return the module's tooltip text for a remote module
- * @param module The module required for the tooltip
- * @return The tooltip text for the passed module
- */
- QString remoteModuleToolTip(CSwordModuleInfo* module, QString localVer);
+/** Return the module's tooltip text for a remote module
+* @param module The module required for the tooltip
+* @return The tooltip text for the passed module
+*/
+QString remoteModuleToolTip(CSwordModuleInfo* module, QString localVer);
- /**
- * Returns the width in pixels for a string which has mCount 'M' letters, using the specified widget's font.
- * This can be used when setting the size for a widget. It may be better to roughly calculate the size based on some text width rather than use pixels directly.
- */
- int mWidth(const QWidget* widget, int mCount);
+/**
+* Returns the width in pixels for a string which has mCount 'M' letters, using the specified widget's font.
+* This can be used when setting the size for a widget. It may be better to roughly calculate the size based on some text width rather than use pixels directly.
+*/
+int mWidth(const QWidget* widget, int mCount);
}
}