summaryrefslogtreecommitdiff
path: root/src/frontend
diff options
context:
space:
mode:
Diffstat (limited to 'src/frontend')
-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
64 files changed, 2424 insertions, 1332 deletions
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);