summaryrefslogtreecommitdiff
path: root/src/frontend
diff options
context:
space:
mode:
authorRoberto C. Sanchez <roberto@connexer.com>2014-10-21 22:48:27 -0400
committerRoberto C. Sanchez <roberto@connexer.com>2014-10-21 22:48:27 -0400
commitdd2f7ce46df53f2c377c02d1bf4df8adcf092072 (patch)
tree51d4bd5d66a45a24784695c4e99b452b417dc3d1 /src/frontend
parentb954e6dbcceaba3b50aca624e1bddc6db4830829 (diff)
Imported Upstream version 2.3
Diffstat (limited to 'src/frontend')
-rw-r--r--src/frontend/bookshelfmanager/indexpage/btindexpage.cpp14
-rw-r--r--src/frontend/btbookshelfdockwidget.cpp300
-rw-r--r--src/frontend/btbookshelfdockwidget.h94
-rw-r--r--src/frontend/displaywindow/btactioncollection.cpp9
-rw-r--r--src/frontend/displaywindow/cbookreadwindow.cpp5
-rw-r--r--src/frontend/displaywindow/cdisplaywindow.cpp31
-rw-r--r--src/frontend/displaywindow/cdisplaywindow.h1
-rw-r--r--src/frontend/displaywindow/chtmlwritewindow.cpp4
-rw-r--r--src/frontend/displaywindow/clexiconreadwindow.cpp4
-rw-r--r--src/frontend/displaywindow/cmodulechooserbar.cpp2
-rw-r--r--src/frontend/displaywindow/cplainwritewindow.cpp2
-rw-r--r--src/frontend/keychooser/ckeychooserwidget.cpp138
-rw-r--r--src/frontend/keychooser/clexiconkeychooser.cpp1
-rw-r--r--src/frontend/keychooser/versekeychooser/cbiblekeychooser.cpp1
-rw-r--r--src/frontend/keychooser/versekeychooser/ckeyreferencewidget.cpp99
-rw-r--r--src/frontend/keychooser/versekeychooser/ckeyreferencewidget.h4
-rw-r--r--src/frontend/mainindex/bookmarks/cbookmarkindex.h1
-rw-r--r--src/frontend/mainindex/bookshelf/btindexitem.h1
-rw-r--r--src/frontend/mainindex/bookshelf/cbookshelfindex.h1
-rw-r--r--src/frontend/mainindex/btbookshelfview.cpp105
-rw-r--r--src/frontend/mainindex/btbookshelfview.h42
-rw-r--r--src/frontend/mainindex/cmainindex.cpp36
-rw-r--r--src/frontend/mainindex/cmainindex.h57
23 files changed, 765 insertions, 187 deletions
diff --git a/src/frontend/bookshelfmanager/indexpage/btindexpage.cpp b/src/frontend/bookshelfmanager/indexpage/btindexpage.cpp
index 8b2b335..cad5a84 100644
--- a/src/frontend/bookshelfmanager/indexpage/btindexpage.cpp
+++ b/src/frontend/bookshelfmanager/indexpage/btindexpage.cpp
@@ -37,7 +37,7 @@ BtIndexPage::BtIndexPage()
QVBoxLayout *vboxLayout;
QHBoxLayout *hboxLayout;
vboxLayout = new QVBoxLayout(this);
-
+
m_autoDeleteOrphanedIndicesBox = new QCheckBox(this);
m_autoDeleteOrphanedIndicesBox->setToolTip(tr("If selected, those indexes which have no corresponding work will be deleted when BibleTime starts"));
m_autoDeleteOrphanedIndicesBox->setText(tr("Automatically delete orphaned indexes when BibleTime starts"));
@@ -106,15 +106,15 @@ QString BtIndexPage::header()
/** Populates the module list with installed modules and orphaned indices */
void BtIndexPage::populateModuleList() {
m_moduleList->clear();
-
+
// populate installed modules
m_modsWithIndices = new QTreeWidgetItem(m_moduleList);
- m_modsWithIndices->setText(0, tr("Works with indexes"));
+ m_modsWithIndices->setText(0, tr("Indexed Works"));
m_modsWithIndices->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsTristate);
m_modsWithIndices->setExpanded(true);
m_modsWithoutIndices = new QTreeWidgetItem(m_moduleList);
- m_modsWithoutIndices->setText(0, tr("Works without indexes"));
+ m_modsWithoutIndices->setText(0, tr("Unindexed Works"));
m_modsWithoutIndices->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsTristate);
m_modsWithoutIndices->setExpanded(true);
@@ -124,7 +124,7 @@ void BtIndexPage::populateModuleList() {
QList<CSwordModuleInfo*>::iterator end_it = modules.end();
for (QList<CSwordModuleInfo*>::iterator it = modules.begin(); it != end_it; ++it) {
QTreeWidgetItem* item = 0;
-
+
if ((*it)->hasIndex()) {
item = new QTreeWidgetItem(m_modsWithIndices);
item->setText(0, (*it)->name());
@@ -169,7 +169,7 @@ void BtIndexPage::createIndices()
void BtIndexPage::deleteIndices()
{
bool indicesDeleted = false;
-
+
for (int i = 0; i < m_modsWithIndices->childCount(); i++) {
if (m_modsWithIndices->child(i)->checkState(0) == Qt::Checked) {
CSwordModuleInfo* module = CPointers::backend()->findModuleByName(m_modsWithIndices->child(i)->text(0).toUtf8());
@@ -191,7 +191,7 @@ void BtIndexPage::deleteOrphanedIndices()
QDir dir(CSwordModuleInfo::getGlobalBaseIndexLocation());
dir.setFilter(QDir::Dirs);
CSwordModuleInfo* module;
-
+
for (unsigned int i = 0; i < dir.count(); i++) {
if (dir[i] != "." && dir[i] != "..") {
if ( (module = CPointers::backend()->findModuleByName(dir[i])) ) { //mod exists
diff --git a/src/frontend/btbookshelfdockwidget.cpp b/src/frontend/btbookshelfdockwidget.cpp
new file mode 100644
index 0000000..4b73c3a
--- /dev/null
+++ b/src/frontend/btbookshelfdockwidget.cpp
@@ -0,0 +1,300 @@
+/*********
+*
+* 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/btbookshelfdockwidget.h"
+
+#include <QAction>
+#include <QActionGroup>
+#include <QApplication>
+#include <QHBoxLayout>
+#include <QKeyEvent>
+#include <QLabel>
+#include <QLineEdit>
+#include <QMenu>
+#include <QToolBar>
+#include <QToolButton>
+#include <QVBoxLayout>
+#include "backend/bookshelfmodel/btbookshelfmodel.h"
+#include "backend/bookshelfmodel/btbookshelftreemodel.h"
+#include "backend/bookshelfmodel/btcheckstatefilterproxymodel.h"
+#include "backend/bookshelfmodel/btmodulenamefilterproxymodel.h"
+#include "backend/drivers/cswordmoduleinfo.h"
+#include "backend/managers/cswordbackend.h"
+#include "frontend/btaboutmoduledialog.h"
+#include "frontend/mainindex/btbookshelfview.h"
+#include "util/cpointers.h"
+#include "util/cresmgr.h"
+#include "util/directoryutil.h"
+
+BtBookshelfDockWidget::BtBookshelfDockWidget(QWidget *parent, Qt::WindowFlags f)
+ : QDockWidget(parent, f)
+{
+ setObjectName("BookshelfDock");
+
+ // Setup models:
+ m_bookshelfModel = new BtBookshelfModel(this);
+ m_bookshelfModel->addModules(CPointers::backend()->moduleList());
+ m_bookshelfTreeModel = new BtBookshelfTreeModel(this);
+ m_bookshelfTreeModel->setDefaultChecked(true);
+ m_bookshelfTreeModel->setSourceModel(m_bookshelfModel);
+ m_filterProxyModel = new BtCheckStateFilterProxyModel(this);
+ m_filterProxyModel->setFilterRole(BtBookshelfTreeModel::CheckStateRole);
+ m_filterProxyModel->setSourceModel(m_bookshelfTreeModel);
+ m_nameFilterProxyModel = new BtModuleNameFilterProxyModel(this);
+ m_nameFilterProxyModel->setSourceModel(m_filterProxyModel);
+
+ // Setup actions and menus:
+ initMenus();
+
+ // Setup widgets:
+ m_widget = new QWidget(this);
+ QVBoxLayout *layout(new QVBoxLayout);
+ layout->setContentsMargins(0, 0, 0, 0);
+ QHBoxLayout *toolBar(new QHBoxLayout);
+ m_nameFilterLabel = new QLabel(this);
+ toolBar->addWidget(m_nameFilterLabel);
+
+ m_nameFilterEdit = new QLineEdit(this);
+ m_nameFilterEdit->installEventFilter(this);
+ m_nameFilterLabel->setBuddy(m_nameFilterEdit);
+ toolBar->addWidget(m_nameFilterEdit);
+
+ m_groupingButton = new QToolButton(this);
+ m_groupingButton->setPopupMode(QToolButton::InstantPopup);
+ m_groupingButton->setMenu(m_groupingMenu);
+ m_groupingButton->setIcon(m_groupingMenu->icon());
+ m_groupingButton->setAutoRaise(true);
+ toolBar->addWidget(m_groupingButton);
+
+ m_showHideButton = new QToolButton(this);
+ m_showHideButton->setDefaultAction(m_showHideAction);
+ m_showHideButton->setAutoRaise(true);
+ toolBar->addWidget(m_showHideButton);
+ layout->addLayout(toolBar);
+
+ m_view = new BtBookshelfView(this);
+ m_view->setModel(m_nameFilterProxyModel);
+ layout->addWidget(m_view);
+ m_widget->setLayout(layout);
+ setWidget(m_widget);
+
+ connect(CPointers::backend(),
+ SIGNAL(sigSwordSetupChanged(CSwordBackend::SetupChangedReason)),
+ this, SLOT(swordSetupChanged()));
+ connect(m_nameFilterEdit, SIGNAL(textEdited(QString)),
+ m_nameFilterProxyModel, SLOT(setFilterFixedString(QString)));
+ connect(m_view, SIGNAL(contextMenuActivated(QPoint)),
+ this, SLOT(showContextMenu(QPoint)));
+ connect(m_view,
+ SIGNAL(moduleContextMenuActivated(CSwordModuleInfo*,QPoint)),
+ this, SLOT(showItemContextMenu(CSwordModuleInfo*,QPoint)));
+ connect(m_view, SIGNAL(moduleActivated(CSwordModuleInfo*)),
+ this, SIGNAL(moduleOpenTriggered(CSwordModuleInfo*)));
+
+ retranslateInterface();
+}
+
+bool BtBookshelfDockWidget::eventFilter(QObject *object, QEvent *event) {
+ Q_ASSERT(object == m_nameFilterEdit);
+ if (event->type() == QEvent::KeyPress) {
+ QKeyEvent *e = static_cast<QKeyEvent*>(event);
+ switch (e->key()) {
+ case Qt::Key_Up:
+ case Qt::Key_Down:
+ case Qt::Key_Enter:
+ case Qt::Key_Return:
+ QApplication::sendEvent(m_view, event);
+ return true;
+ default:
+ break;
+ }
+ }
+ return false;
+}
+
+void BtBookshelfDockWidget::initMenus() {
+ typedef util::filesystem::DirectoryUtil DU;
+ namespace RM = CResMgr::mainIndex;
+
+ m_contextMenu = new QMenu(this);
+ m_groupingMenu = new QMenu(this);
+ m_contextMenu->addMenu(m_groupingMenu);
+ m_groupingMenu->setIcon(DU::getIcon(RM::grouping::icon));
+ m_groupingActionGroup = new QActionGroup(this);
+ connect(m_groupingActionGroup, SIGNAL(triggered(QAction*)),
+ this, SLOT(groupingActionTriggered(QAction*)));
+
+ m_groupingCatLangAction = new QAction(this);
+ m_groupingCatLangAction->setIcon(DU::getIcon(RM::grouping::icon));
+ m_groupingCatLangAction->setChecked(true);
+ m_groupingActionGroup->addAction(m_groupingCatLangAction);
+ m_groupingMenu->addAction(m_groupingCatLangAction);
+
+ m_groupingCatAction = new QAction(this);
+ m_groupingCatAction->setIcon(DU::getIcon(RM::grouping::icon));
+ m_groupingActionGroup->addAction(m_groupingCatAction);
+ m_groupingMenu->addAction(m_groupingCatAction);
+
+ m_groupingLangCatAction = new QAction(this);
+ m_groupingLangCatAction->setIcon(DU::getIcon(RM::grouping::icon));
+ m_groupingActionGroup->addAction(m_groupingLangCatAction);
+ m_groupingMenu->addAction(m_groupingLangCatAction);
+
+ m_groupingLangAction = new QAction(this);
+ m_groupingLangAction->setIcon(DU::getIcon(RM::grouping::icon));
+ m_groupingActionGroup->addAction(m_groupingLangAction);
+ m_groupingMenu->addAction(m_groupingLangAction);
+
+ m_groupingNoneAction = new QAction(this);
+ m_groupingNoneAction->setIcon(DU::getIcon(RM::grouping::icon));
+ m_groupingActionGroup->addAction(m_groupingNoneAction);
+ m_groupingMenu->addAction(m_groupingNoneAction);
+
+ m_showHideAction = new QAction(this);
+ m_showHideAction->setIcon(DU::getIcon(RM::search::icon));
+ m_showHideAction->setCheckable(true);
+ connect(m_showHideAction, SIGNAL(toggled(bool)),
+ this, SLOT(showHideEnabled(bool)));
+ m_contextMenu->addAction(m_showHideAction);
+
+ m_itemContextMenu = new QMenu(this);
+ m_itemActionGroup = new QActionGroup(this);
+ connect(m_itemActionGroup, SIGNAL(triggered(QAction*)),
+ this, SLOT(itemActionTriggered(QAction*)));
+
+ m_itemOpenAction = new QAction(this);
+ m_itemActionGroup->addAction(m_itemOpenAction);
+ m_itemContextMenu->addAction(m_itemOpenAction);
+
+ m_itemSearchAction = new QAction(this);
+ m_itemSearchAction->setIcon(DU::getIcon(RM::search::icon));
+ m_itemActionGroup->addAction(m_itemSearchAction);
+ m_itemContextMenu->addAction(m_itemSearchAction);
+
+ m_itemEditMenu = new QMenu(this);
+ m_itemEditMenu->setIcon(DU::getIcon(RM::editModuleMenu::icon));
+ m_itemContextMenu->addMenu(m_itemEditMenu);
+ m_itemEditPlainAction = new QAction(this);
+ m_itemEditPlainAction->setIcon(DU::getIcon(RM::editModulePlain::icon));
+ m_itemActionGroup->addAction(m_itemEditPlainAction);
+ m_itemEditMenu->addAction(m_itemEditPlainAction);
+
+ m_itemEditHtmlAction = new QAction(this);
+ m_itemEditHtmlAction->setIcon(DU::getIcon(RM::editModuleHTML::icon));
+ m_itemActionGroup->addAction(m_itemEditHtmlAction);
+ m_itemEditMenu->addAction(m_itemEditHtmlAction);
+
+ m_itemUnlockAction = new QAction(this);
+ m_itemUnlockAction->setIcon(DU::getIcon(RM::unlockModule::icon));
+ m_itemActionGroup->addAction(m_itemUnlockAction);
+ m_itemContextMenu->addAction(m_itemUnlockAction);
+
+ m_itemAboutAction = new QAction(this);
+ m_itemAboutAction->setIcon(DU::getIcon(RM::aboutModule::icon));
+ m_itemActionGroup->addAction(m_itemAboutAction);
+ m_itemContextMenu->addAction(m_itemAboutAction);
+}
+
+void BtBookshelfDockWidget::retranslateInterface() {
+ setWindowTitle(tr("Bookshelf"));
+
+ m_nameFilterLabel->setText(tr("Fi&lter:"));
+ m_groupingButton->setText(tr("Grouping"));
+ m_groupingButton->setToolTip(tr("Change the grouping of items in the bookshelf."));
+
+ m_groupingMenu->setTitle(tr("Grouping"));
+ m_groupingCatLangAction->setText(tr("Category/Language"));
+ m_groupingCatAction->setText(tr("Category"));
+ m_groupingLangCatAction->setText(tr("Language/Category"));
+ m_groupingLangAction->setText(tr("Language"));
+ m_groupingNoneAction->setText(tr("No grouping"));
+ m_showHideAction->setText(tr("Show/hide works"));
+
+ m_itemOpenAction->setText(tr("&Open"));
+ m_itemEditMenu->setTitle(tr("&Edit"));
+ m_itemEditPlainAction->setText(tr("&Plain text"));
+ m_itemEditHtmlAction->setText(tr("&HTML"));
+ m_itemUnlockAction->setText(tr("&Unlock..."));
+ m_itemAboutAction->setText(tr("&About..."));
+}
+
+void BtBookshelfDockWidget::swordSetupChanged() {
+ QSet<CSwordModuleInfo*> added(CPointers::backend()->moduleList().toSet());
+ QSet<CSwordModuleInfo*> removed(m_bookshelfModel->modules().toSet());
+ QSet<CSwordModuleInfo*> t(removed);
+ removed.subtract(added);
+ added.subtract(t);
+ m_bookshelfModel->removeModules(removed);
+ m_bookshelfModel->addModules(added);
+}
+
+void BtBookshelfDockWidget::showContextMenu(QPoint pos) {
+ m_contextMenu->popup(pos);
+}
+
+void BtBookshelfDockWidget::groupingActionTriggered(QAction *action) {
+ BtBookshelfTreeModel::Grouping g;
+ if (action == m_groupingCatAction) {
+ g.append(BtBookshelfTreeModel::GROUP_CATEGORY);
+ } else if (action == m_groupingCatLangAction) {
+ g.append(BtBookshelfTreeModel::GROUP_CATEGORY);
+ g.append(BtBookshelfTreeModel::GROUP_LANGUAGE);
+ } else if (action == m_groupingLangAction) {
+ g.append(BtBookshelfTreeModel::GROUP_LANGUAGE);
+ } else if (action == m_groupingLangCatAction) {
+ g.append(BtBookshelfTreeModel::GROUP_LANGUAGE);
+ g.append(BtBookshelfTreeModel::GROUP_CATEGORY);
+ }
+ m_bookshelfTreeModel->setGroupingOrder(g);
+ m_view->setRootIsDecorated(!g.isEmpty());
+}
+
+void BtBookshelfDockWidget::showHideEnabled(bool enable) {
+ if (enable) {
+ m_bookshelfTreeModel->setCheckable(true);
+ m_filterProxyModel->setEnabled(false);
+ } else {
+ m_filterProxyModel->setEnabled(true);
+ m_bookshelfTreeModel->setCheckable(false);
+ }
+}
+
+void BtBookshelfDockWidget::showItemContextMenu(CSwordModuleInfo *module,
+ QPoint pos)
+{
+ m_itemContextMenu->setProperty("BtModule", qVariantFromValue((void*) module));
+ m_itemSearchAction->setText(tr("&Search in %1...").arg(module->name()));
+ m_itemOpenAction->setEnabled(!module->isLocked());
+ m_itemEditMenu->setEnabled(module->isWritable());
+ m_itemUnlockAction->setEnabled(module->isLocked());
+
+ m_itemContextMenu->popup(pos);
+}
+
+void BtBookshelfDockWidget::itemActionTriggered(QAction *action) {
+ CSwordModuleInfo *module((CSwordModuleInfo*) m_itemContextMenu->property("BtModule").value<void*>());
+ if (module == 0) return;
+
+ if (action == m_itemOpenAction) {
+ emit moduleOpenTriggered(module);
+ } else if (action == m_itemSearchAction) {
+ emit moduleSearchTriggered(module);
+ } else if (action == m_itemEditPlainAction) {
+ emit moduleEditPlainTriggered(module);
+ } else if (action == m_itemEditHtmlAction) {
+ emit moduleEditHtmlTriggered(module);
+ } else if (action == m_itemUnlockAction) {
+ emit moduleUnlockTriggered(module);
+ } else if (action == m_itemAboutAction) {
+ emit moduleAboutTriggered(module);
+ }
+}
diff --git a/src/frontend/btbookshelfdockwidget.h b/src/frontend/btbookshelfdockwidget.h
new file mode 100644
index 0000000..d437c92
--- /dev/null
+++ b/src/frontend/btbookshelfdockwidget.h
@@ -0,0 +1,94 @@
+/*********
+*
+* 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 BTBOOKSHELFDOCKWIDGET_H
+#define BTBOOKSHELFDOCKWIDGET_H
+
+#include <QDockWidget>
+
+class CSwordModuleInfo;
+class BtBookshelfView;
+class BtBookshelfModel;
+class BtBookshelfTreeModel;
+class BtCheckStateFilterProxyModel;
+class BtModuleNameFilterProxyModel;
+class QAction;
+class QActionGroup;
+class QLabel;
+class QLineEdit;
+class QMenu;
+class QToolBar;
+class QToolButton;
+
+class BtBookshelfDockWidget: public QDockWidget {
+ Q_OBJECT
+ public:
+ BtBookshelfDockWidget(QWidget *parent = 0, Qt::WindowFlags f = 0);
+
+ signals:
+ void moduleOpenTriggered(CSwordModuleInfo *module);
+ void moduleSearchTriggered(CSwordModuleInfo *module);
+ void moduleEditPlainTriggered(CSwordModuleInfo *module);
+ void moduleEditHtmlTriggered(CSwordModuleInfo *module);
+ void moduleUnlockTriggered(CSwordModuleInfo *module);
+ void moduleAboutTriggered(CSwordModuleInfo *module);
+
+ protected:
+ bool eventFilter(QObject *object, QEvent *event);
+ void initMenus();
+ void retranslateInterface();
+
+ protected slots:
+ void swordSetupChanged();
+ void showContextMenu(QPoint pos);
+ void groupingActionTriggered(QAction *action);
+ void showHideEnabled(bool enable);
+ void showItemContextMenu(CSwordModuleInfo *module, QPoint pos);
+ void itemActionTriggered(QAction *action);
+
+ protected:
+ // Models:
+ BtBookshelfModel *m_bookshelfModel;
+ BtBookshelfTreeModel *m_bookshelfTreeModel;
+ BtCheckStateFilterProxyModel *m_filterProxyModel;
+ BtModuleNameFilterProxyModel *m_nameFilterProxyModel;
+
+ // Widgets:
+ QWidget *m_widget;
+ BtBookshelfView *m_view;
+ QLabel *m_nameFilterLabel;
+ QLineEdit *m_nameFilterEdit;
+ QToolButton *m_groupingButton;
+ QToolButton *m_showHideButton;
+
+ // Popup menus:
+ QMenu *m_contextMenu;
+ QMenu *m_groupingMenu;
+ QActionGroup *m_groupingActionGroup;
+ QAction *m_groupingCatLangAction;
+ QAction *m_groupingCatAction;
+ QAction *m_groupingLangCatAction;
+ QAction *m_groupingLangAction;
+ QAction *m_groupingNoneAction;
+ QAction *m_showHideAction;
+ QMenu *m_itemContextMenu;
+ QActionGroup *m_itemActionGroup;
+ QAction *m_itemOpenAction;
+ QAction *m_itemSearchAction;
+ QMenu *m_itemEditMenu;
+ QAction *m_itemEditPlainAction;
+ QAction *m_itemEditHtmlAction;
+ QAction *m_itemUnlockAction;
+ QAction *m_itemAboutAction;
+};
+
+#endif // BTBOOKSHELFDOCKWIDGET_H
diff --git a/src/frontend/displaywindow/btactioncollection.cpp b/src/frontend/displaywindow/btactioncollection.cpp
index 046c3c0..fc1a412 100644
--- a/src/frontend/displaywindow/btactioncollection.cpp
+++ b/src/frontend/displaywindow/btactioncollection.cpp
@@ -15,6 +15,7 @@
#include <QSettings>
#include <QString>
#include <QStringList>
+#include <QDebug>
class BtActionItem : public QObject
{
@@ -52,10 +53,10 @@ QList<QAction*> BtActionCollection::actions()
QAction* BtActionCollection::action(const QString& name)
{
- Q_ASSERT(m_actions[name] != 0);
- QAction* action = m_actions[name]->action;
- Q_ASSERT(action != 0);
- return action;
+ if (m_actions.contains(name))
+ return m_actions[name]->action;
+ qWarning() << "A QAction for a shortcut named" << name << "was requested but it is not defined.";
+ return (new QAction(this)); // dummy QAction*
}
QAction* BtActionCollection::addAction(const QString& name, QAction* action)
diff --git a/src/frontend/displaywindow/cbookreadwindow.cpp b/src/frontend/displaywindow/cbookreadwindow.cpp
index 40f737d..465eec9 100644
--- a/src/frontend/displaywindow/cbookreadwindow.cpp
+++ b/src/frontend/displaywindow/cbookreadwindow.cpp
@@ -100,6 +100,9 @@ void CBookReadWindow::initView()
QSplitter* splitter = new QSplitter(this);
setMainToolBar( new QToolBar(this) );
+ mainToolBar()->setAllowedAreas(Qt::TopToolBarArea);
+ mainToolBar()->setFloatable(false);
+
addToolBar(mainToolBar());
m_treeChooser = new CBookTreeChooser(modules(), key(), splitter);
@@ -112,6 +115,8 @@ void CBookReadWindow::initView()
addToolBar(moduleChooserBar());
setButtonsToolBar( new QToolBar(this) );
+ buttonsToolBar()->setAllowedAreas(Qt::TopToolBarArea);
+ buttonsToolBar()->setFloatable(false);
setDisplaySettingsButton( new CDisplaySettingsButton( &displayOptions(), &filterOptions(), modules(), buttonsToolBar()) );
addToolBar(buttonsToolBar());
m_treeChooser->hide();
diff --git a/src/frontend/displaywindow/cdisplaywindow.cpp b/src/frontend/displaywindow/cdisplaywindow.cpp
index 6cf160d..8b4a9cd 100644
--- a/src/frontend/displaywindow/cdisplaywindow.cpp
+++ b/src/frontend/displaywindow/cdisplaywindow.cpp
@@ -129,6 +129,15 @@ void CDisplayWindow::insertKeyboardActions( BtActionCollection* a )
actn->setShortcut(QKeySequence::Find);
a->addAction("findText", actn);
+ actn = new QAction(QIcon(), tr("Change location"), 0);
+ actn->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_L));
+ a->addAction("openLocation", actn);
+
+ actn = new QAction(QIcon(util::filesystem::DirectoryUtil::getIcon(CResMgr::displaywindows::general::search::icon)),
+ tr("Search with works of this window"), 0);
+ actn->setShortcut(CResMgr::displaywindows::general::search::accel);
+ a->addAction(CResMgr::displaywindows::general::search::actionName, actn);
+
BtToolBarPopupAction* action = new BtToolBarPopupAction(
QIcon(util::filesystem::DirectoryUtil::getIcon(CResMgr::displaywindows::general::backInHistory::icon)),
tr("Back in history"),
@@ -154,18 +163,16 @@ void CDisplayWindow::initActions()
CDisplayWindow::insertKeyboardActions(ac);
- QAction* qaction = new QAction(
- QIcon(util::filesystem::DirectoryUtil::getIcon(CResMgr::displaywindows::general::search::icon)),
- tr("Open the search dialog with the works of this window"),
- ac
- );
- qaction->setShortcut(CResMgr::displaywindows::general::search::accel);
- QObject::connect(qaction, SIGNAL(triggered()), this, SLOT(slotSearchInModules()));
- ac->addAction(CResMgr::displaywindows::general::search::actionName, qaction);
+ QAction* actn = ac->action(CResMgr::displaywindows::general::search::actionName);
+ QObject::connect(actn, SIGNAL(triggered()), this, SLOT(slotSearchInModules()));
CDisplayConnections* conn = displayWidget()->connectionsProxy();
- QAction* actn = ac->action("zoomIn");
+ actn = ac->action("openLocation");
+ QObject::connect(actn, SIGNAL(triggered()), this, SLOT(setFocusKeyChooser()));
+ addAction(actn);
+
+ actn = ac->action("zoomIn");
QObject::connect(actn, SIGNAL(triggered()), conn, SLOT(zoomIn()));
addAction(actn);
@@ -536,3 +543,9 @@ 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 80877fb..733f06e 100644
--- a/src/frontend/displaywindow/cdisplaywindow.h
+++ b/src/frontend/displaywindow/cdisplaywindow.h
@@ -202,6 +202,7 @@ protected slots:
void printAnchorWithText();
+ void setFocusKeyChooser();
private:
BtActionCollection* m_actionCollection;
diff --git a/src/frontend/displaywindow/chtmlwritewindow.cpp b/src/frontend/displaywindow/chtmlwritewindow.cpp
index 7e97aa6..cee16e0 100644
--- a/src/frontend/displaywindow/chtmlwritewindow.cpp
+++ b/src/frontend/displaywindow/chtmlwritewindow.cpp
@@ -42,6 +42,8 @@ void CHTMLWriteWindow::initView() {
setCentralWidget( displayWidget()->view() );
setMainToolBar( new QToolBar(this) );
+ mainToolBar()->setAllowedAreas(Qt::TopToolBarArea);
+ mainToolBar()->setFloatable(false);
addToolBar(mainToolBar());
setKeyChooser( CKeyChooser::createInstance(modules(), key(), mainToolBar()) );
@@ -104,6 +106,8 @@ void CHTMLWriteWindow::initToolbars() {
//html formatting toolbar
QToolBar* bar = new QToolBar(this);
+ bar->setAllowedAreas(Qt::TopToolBarArea);
+ bar->setFloatable(false);
((CWriteDisplay*)displayWidget())->setupToolbar( bar, actionCollection() );
addToolBar(bar);
}
diff --git a/src/frontend/displaywindow/clexiconreadwindow.cpp b/src/frontend/displaywindow/clexiconreadwindow.cpp
index 8ceb326..df22de9 100644
--- a/src/frontend/displaywindow/clexiconreadwindow.cpp
+++ b/src/frontend/displaywindow/clexiconreadwindow.cpp
@@ -187,6 +187,8 @@ 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());
@@ -194,6 +196,8 @@ void CLexiconReadWindow::initView()
moduleChooserBar()->adjustSize();
addToolBar(moduleChooserBar());
setButtonsToolBar( new QToolBar(this) );
+ buttonsToolBar()->setAllowedAreas(Qt::TopToolBarArea);
+ buttonsToolBar()->setFloatable(false);
addToolBar(buttonsToolBar());
setWindowIcon(CToolClass::getIconForModule(modules().first()));
setCentralWidget( displayWidget()->view() );
diff --git a/src/frontend/displaywindow/cmodulechooserbar.cpp b/src/frontend/displaywindow/cmodulechooserbar.cpp
index fc891ad..a282c4b 100644
--- a/src/frontend/displaywindow/cmodulechooserbar.cpp
+++ b/src/frontend/displaywindow/cmodulechooserbar.cpp
@@ -22,6 +22,8 @@ CModuleChooserBar::CModuleChooserBar(QList<CSwordModuleInfo*> useModules, CSword
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) {
diff --git a/src/frontend/displaywindow/cplainwritewindow.cpp b/src/frontend/displaywindow/cplainwritewindow.cpp
index 9f12020..71dc603 100644
--- a/src/frontend/displaywindow/cplainwritewindow.cpp
+++ b/src/frontend/displaywindow/cplainwritewindow.cpp
@@ -45,6 +45,8 @@ void CPlainWriteWindow::initView() {
setCentralWidget( displayWidget()->view() );
setMainToolBar( new QToolBar(this) );
+ mainToolBar()->setAllowedAreas(Qt::TopToolBarArea);
+ mainToolBar()->setFloatable(false);
addToolBar(mainToolBar());
addToolBarBreak();
diff --git a/src/frontend/keychooser/ckeychooserwidget.cpp b/src/frontend/keychooser/ckeychooserwidget.cpp
index dd8f7a5..d3e1a55 100644
--- a/src/frontend/keychooser/ckeychooserwidget.cpp
+++ b/src/frontend/keychooser/ckeychooserwidget.cpp
@@ -22,20 +22,46 @@
#include <QLineEdit>
#include <QDebug>
+class BtKeyLineEdit : public QLineEdit
+{
+public:
+ BtKeyLineEdit(QWidget* parent)
+ : QLineEdit(parent)
+ {
+ }
+protected:
+ void focusInEvent(QFocusEvent* event)
+ {
+ Qt::FocusReason reason = event->reason();
+ if (reason == Qt::OtherFocusReason)
+ {
+ selectAll();
+ }
+ QWidget::focusInEvent(event);
+ }
+};
+
+
+
CKCComboBox::CKCComboBox()
-: QComboBox() {
+: QComboBox()
+{
setFocusPolicy(Qt::WheelFocus);
+ setLineEdit(new BtKeyLineEdit(this));
if (lineEdit()) {
installEventFilter( lineEdit() );
}
}
/** Reimplementation. */
-bool CKCComboBox::eventFilter( QObject *o, QEvent *e ) {
- if (e->type() == QEvent::FocusOut) {
+bool CKCComboBox::eventFilter( QObject *o, QEvent *e )
+{
+ if (e->type() == QEvent::FocusOut)
+ {
QFocusEvent* f = static_cast<QFocusEvent*>(e);
- if (o == lineEdit() && f->reason() == Qt::TabFocusReason) {
+ if (o == lineEdit() && f->reason() == Qt::TabFocusReason)
+ {
int index = findText(currentText());
if (index == -1) {
index = 0;// return 0 if not found
@@ -45,18 +71,22 @@ bool CKCComboBox::eventFilter( QObject *o, QEvent *e ) {
return false;
}
- else if (f->reason() == Qt::PopupFocusReason) {
+ else if (f->reason() == Qt::PopupFocusReason)
+ {
return false;
}
- else if (f->reason() == Qt::ActiveWindowFocusReason) {
+ else if (f->reason() == Qt::ActiveWindowFocusReason)
+ {
emit activated(currentText());
return false;
}
- else if (f->reason() == Qt::MouseFocusReason) {
+ else if (f->reason() == Qt::MouseFocusReason)
+ {
emit activated(currentText());
return false;
}
- else if (o == this) {
+ else if (o == this)
+ {
emit activated(currentText());
return false;
}
@@ -66,13 +96,15 @@ bool CKCComboBox::eventFilter( QObject *o, QEvent *e ) {
}
/** Scrolls in the list if the wheel of the mouse was used. */
-void CKCComboBox::wheelEvent( QWheelEvent* e ) {
+void CKCComboBox::wheelEvent( QWheelEvent* e )
+{
return QComboBox::wheelEvent(e);
const signed int change = (int)((float)e->delta()/(float)120);
int current = currentIndex();
- if ((current+change >= 0) && (current+change<count()) ) {
+ if ((current+change >= 0) && (current+change<count()) )
+ {
setCurrentIndex(current+change);
e->accept();
emit activated( currentIndex() );
@@ -84,23 +116,28 @@ void CKCComboBox::wheelEvent( QWheelEvent* e ) {
//**********************************************************************************/
-CKeyChooserWidget::CKeyChooserWidget(int count, const bool useNextPrevSignals, QWidget *parent ) : QWidget(parent) {
+CKeyChooserWidget::CKeyChooserWidget(int count, const bool useNextPrevSignals, QWidget *parent ) : QWidget(parent)
+{
m_useNextPrevSignals = useNextPrevSignals;
- for (int index=1; index <= count; index++) {
+ for (int index=1; index <= count; index++)
+ {
m_list.append( QString::number(index) );
}
init();
reset(m_list,0,false);
}
-CKeyChooserWidget::CKeyChooserWidget(QStringList *list, const bool useNextPrevSignals, QWidget *parent ) : QWidget(parent) {
+CKeyChooserWidget::CKeyChooserWidget(QStringList *list, const bool useNextPrevSignals, QWidget *parent ) : QWidget(parent)
+{
m_useNextPrevSignals = useNextPrevSignals;
- if (list) {
+ if (list)
+ {
m_list = *list; //deep copy the items of list
}
- else {
+ else
+ {
m_list.clear();
}
@@ -108,21 +145,24 @@ CKeyChooserWidget::CKeyChooserWidget(QStringList *list, const bool useNextPrevSi
reset(m_list,0,false);
}
-void CKeyChooserWidget::reset(const int count, int index, bool do_emit) {
+void CKeyChooserWidget::reset(const int count, int index, bool do_emit)
+{
//This prevents the widget from resetting during application load, which
//produces undesirable behavior.
//if (!updatesEnabled())
// return;
m_list.clear();
- for (int i=1; i <= count; i++) { //TODO: CHECK
+ for (int i=1; i <= count; i++)
+ { //TODO: CHECK
m_list.append( QString::number(i) );
}
reset(&m_list,index,do_emit);
}
-void CKeyChooserWidget::reset(QStringList& list, int index, bool do_emit) {
+void CKeyChooserWidget::reset(QStringList& list, int index, bool do_emit)
+{
//This prevents the widget from resetting during application load, which
//produces undesirable behavior.
//if (!updatesEnabled())
@@ -133,7 +173,8 @@ void CKeyChooserWidget::reset(QStringList& list, int index, bool do_emit) {
}
-void CKeyChooserWidget::reset(QStringList *list, int index, bool do_emit) {
+void CKeyChooserWidget::reset(QStringList *list, int index, bool do_emit)
+{
//if (isResetting || !updatesEnabled())
if (isResetting)
return;
@@ -147,18 +188,21 @@ void CKeyChooserWidget::reset(QStringList *list, int index, bool do_emit) {
//DON'T REMOVE THE HIDE: Otherwise QComboBox's sizeHint() function won't work properly
m_comboBox->hide();
m_comboBox->clear();
- if (list) {
+ if (list)
+ {
m_comboBox->insertItems(-1, *list);
}
if (!list || (list && !list->count())) { //nothing in the combobox
setEnabled(false);
}
- else if (!isEnabled()) { //was disabled
+ else if (!isEnabled())
+ { //was disabled
setEnabled(true);
}
- if (list->count()) {
+ if (list->count())
+ {
m_comboBox->setCurrentIndex(index);
}
if (do_emit) {
@@ -177,13 +221,15 @@ void CKeyChooserWidget::reset(QStringList *list, int index, bool do_emit) {
}
/** Initializes this widget. We need this function because we have more than one constructor. */
-void CKeyChooserWidget::init() {
+void CKeyChooserWidget::init()
+{
qDebug("CKeyChooserWidget::init");
oldKey = QString::null;
setFocusPolicy(Qt::WheelFocus);
m_comboBox = new CKCComboBox();
+ setFocusProxy(m_comboBox);
m_comboBox->setAutoCompletion( true );
m_comboBox->setEditable(true);
m_comboBox->setInsertPolicy(QComboBox::NoInsert);
@@ -200,6 +246,7 @@ void CKeyChooserWidget::init() {
m_mainLayout->addSpacing(0);
setTabOrder(m_comboBox, 0);
+ setFocusProxy(m_comboBox);
connect(m_scroller, SIGNAL(scroller_pressed()), SLOT(lock()));
connect(m_scroller, SIGNAL(scroller_released()), SLOT(unlock()));
@@ -215,13 +262,16 @@ void CKeyChooserWidget::init() {
}
/** Is called when the return key was presed in the combobox. */
-void CKeyChooserWidget::slotReturnPressed( /*const QString& text*/) {
+void CKeyChooserWidget::slotReturnPressed( /*const QString& text*/)
+{
Q_ASSERT(comboBox()->lineEdit());
qDebug("return pressed");
QString text = comboBox()->lineEdit()->text();
- for (int index = 0; index < comboBox()->count(); ++index) {
- if (comboBox()->itemText(index) == text) {
+ for (int index = 0; index < comboBox()->count(); ++index)
+ {
+ if (comboBox()->itemText(index) == text)
+ {
// emit changed(index);
emit focusOut(index); // a workaround because focusOut is not checked, the slot connected to changed to check
break;
@@ -230,16 +280,19 @@ void CKeyChooserWidget::slotReturnPressed( /*const QString& text*/) {
}
/** Is called when the current item of the combo box was changed. */
-void CKeyChooserWidget::slotComboChanged(int index) {
+void CKeyChooserWidget::slotComboChanged(int index)
+{
qDebug("CKeyChooserWidget::slotComboChanged(int index)");
- if (!updatesEnabled()) {
+ if (!updatesEnabled())
+ {
return;
}
setUpdatesEnabled(false);
const QString key = comboBox()->itemText( index );
- if (oldKey.isNull() || (oldKey != key)) {
+ if (oldKey.isNull() || (oldKey != key))
+ {
emit changed(index);
}
@@ -249,17 +302,21 @@ void CKeyChooserWidget::slotComboChanged(int index) {
}
/** Sets the tooltips for the given entries using the parameters as text. */
-void CKeyChooserWidget::setToolTips( const QString comboTip, const QString nextEntryTip, const QString scrollButtonTip, const QString previousEntryTip) {
+void CKeyChooserWidget::setToolTips( const QString comboTip, const QString nextEntryTip, const QString scrollButtonTip, const QString previousEntryTip)
+{
comboBox()->setToolTip(comboTip);
m_scroller->setToolTips(nextEntryTip, scrollButtonTip, previousEntryTip);
}
/** Sets the current item to the one with the given text */
-bool CKeyChooserWidget::setItem( const QString item ) {
+bool CKeyChooserWidget::setItem( const QString item )
+{
bool ret = false;
const int count = comboBox()->count();
- for (int i = 0; i < count; ++i) {
- if (comboBox()->itemText(i) == item) {
+ for (int i = 0; i < count; ++i)
+ {
+ if (comboBox()->itemText(i) == item)
+ {
comboBox()->setCurrentIndex(i);
ret = true;
break;
@@ -271,22 +328,26 @@ bool CKeyChooserWidget::setItem( const QString item ) {
}
/* Handlers for the various scroller widgetset. */
-void CKeyChooserWidget::lock() {
+void CKeyChooserWidget::lock()
+{
updatelock = true;
comboBox()->setEditable(false);
oldKey = comboBox()->currentText();
}
-void CKeyChooserWidget::unlock() {
+void CKeyChooserWidget::unlock()
+{
updatelock = false;
comboBox()->setEditable(true);
comboBox()->setEditText(comboBox()->itemText(comboBox()->currentIndex()));
- if (comboBox()->currentText() != oldKey) {
+ if (comboBox()->currentText() != oldKey)
+ {
emit changed(comboBox()->currentIndex());
}
}
-void CKeyChooserWidget::changeCombo(int n) {
+void CKeyChooserWidget::changeCombo(int n)
+{
const int old_index = comboBox()->currentIndex();
int new_index = old_index + n;
@@ -295,7 +356,8 @@ void CKeyChooserWidget::changeCombo(int n) {
if(new_index > max) new_index = max;
if(new_index < 0) new_index = 0;
- if(new_index != old_index) {
+ if(new_index != old_index)
+ {
comboBox()->setCurrentIndex(new_index);
if(!updatelock)
emit changed(new_index);
diff --git a/src/frontend/keychooser/clexiconkeychooser.cpp b/src/frontend/keychooser/clexiconkeychooser.cpp
index 00c02ba..53d8ac0 100644
--- a/src/frontend/keychooser/clexiconkeychooser.cpp
+++ b/src/frontend/keychooser/clexiconkeychooser.cpp
@@ -42,6 +42,7 @@ CLexiconKeyChooser::CLexiconKeyChooser(QList<CSwordModuleInfo*> modules, CSwordK
m_layout->setSizeConstraint(QLayout::SetNoConstraint);
m_widget = new CKeyChooserWidget(0, false, this);
+ setFocusProxy(m_widget);
//don't allow a too high width, try to keep as narrow as possible
//to aid users with smaller screen resolutions
diff --git a/src/frontend/keychooser/versekeychooser/cbiblekeychooser.cpp b/src/frontend/keychooser/versekeychooser/cbiblekeychooser.cpp
index 2bc9e77..afe3482 100644
--- a/src/frontend/keychooser/versekeychooser/cbiblekeychooser.cpp
+++ b/src/frontend/keychooser/versekeychooser/cbiblekeychooser.cpp
@@ -40,6 +40,7 @@ CBibleKeyChooser::CBibleKeyChooser(QList<CSwordModuleInfo*> modules, CSwordKey *
layout->setDirection( QBoxLayout::LeftToRight );
w_ref = new CKeyReferenceWidget(dynamic_cast<CSwordBibleModuleInfo*>(m_modules.first()), m_key, this);
+ setFocusProxy(w_ref);
layout->addWidget(w_ref);
connect(w_ref,SIGNAL(changed(CSwordVerseKey *)),SLOT(refChanged(CSwordVerseKey *)));
diff --git a/src/frontend/keychooser/versekeychooser/ckeyreferencewidget.cpp b/src/frontend/keychooser/versekeychooser/ckeyreferencewidget.cpp
index 11c5ddc..cedb4b3 100644
--- a/src/frontend/keychooser/versekeychooser/ckeyreferencewidget.cpp
+++ b/src/frontend/keychooser/versekeychooser/ckeyreferencewidget.cpp
@@ -31,12 +31,32 @@
#include <QString>
#include <QStringList>
#include <QToolButton>
+#include <QFocusEvent>
+class BtLineEdit : public QLineEdit
+{
+public:
+ BtLineEdit(QWidget* parent)
+ : QLineEdit(parent)
+ {
+ }
+protected:
+ void focusInEvent(QFocusEvent* event)
+ {
+ Qt::FocusReason reason = event->reason();
+ if (reason == Qt::OtherFocusReason)
+ {
+ selectAll();
+ }
+ QWidget::focusInEvent(event);
+ }
+};
-CKeyReferenceWidget::CKeyReferenceWidget( CSwordBibleModuleInfo *mod, CSwordVerseKey *key, QWidget *parent, const char* /*name*/) :
+
+CKeyReferenceWidget::CKeyReferenceWidget( CSwordBibleModuleInfo *mod, CSwordVerseKey *key, QWidget *parent, const char* /*name*/) :
QWidget(parent),
- m_key(new CSwordVerseKey(mod)),
+ m_key(key),
m_dropDownHoverTimer(this)
{
@@ -53,7 +73,8 @@ CKeyReferenceWidget::CKeyReferenceWidget( CSwordBibleModuleInfo *mod, CSwordVers
m_bookScroller = new CScrollerWidgetSet(this);
- m_textbox = new QLineEdit( this );
+ m_textbox = new BtLineEdit( this );
+ setFocusProxy(m_textbox);
m_textbox->setContentsMargins(0, 0, 0, 0);
setKey(key); // The order of these two functions is important.
@@ -127,7 +148,8 @@ CKeyReferenceWidget::CKeyReferenceWidget( CSwordBibleModuleInfo *mod, CSwordVers
connect(m_verseScroller, SIGNAL(scroller_released()), SLOT(slotUpdateUnlock()));
}
-CKeyReferenceWidget::~CKeyReferenceWidget() {
+CKeyReferenceWidget::~CKeyReferenceWidget()
+{
delete m_dropDownButtons;
}
@@ -140,7 +162,8 @@ void CKeyReferenceWidget::setModule(CSwordBibleModuleInfo *m)
}
}
-bool CKeyReferenceWidget::eventFilter(QObject *o, QEvent *e) {
+bool CKeyReferenceWidget::eventFilter(QObject *o, QEvent *e)
+{
if (o != m_dropDownButtons) return false;
switch (e->type()) {
case QEvent::Enter:
@@ -154,7 +177,8 @@ bool CKeyReferenceWidget::eventFilter(QObject *o, QEvent *e) {
}
}
-void CKeyReferenceWidget::enterEvent(QEvent *) {
+void CKeyReferenceWidget::enterEvent(QEvent *)
+{
m_dropDownHoverTimer.stop();
resetDropDownButtons();
@@ -163,18 +187,22 @@ void CKeyReferenceWidget::enterEvent(QEvent *) {
m_dropDownButtons->show();
}
-void CKeyReferenceWidget::leaveEvent(QEvent *) {
+void CKeyReferenceWidget::leaveEvent(QEvent *)
+{
m_dropDownHoverTimer.start();
}
-void CKeyReferenceWidget::resizeEvent(QResizeEvent *event) {
- if (m_dropDownButtons->isVisible()) {
+void CKeyReferenceWidget::resizeEvent(QResizeEvent *event)
+{
+ if (m_dropDownButtons->isVisible())
+ {
resetDropDownButtons();
}
QWidget::resizeEvent(event);
}
-void CKeyReferenceWidget::resetDropDownButtons() {
+void CKeyReferenceWidget::resetDropDownButtons()
+{
m_dropDownButtons->setParent(window());
int h(m_dropDownButtons->layout()->minimumSize().height());
QPoint topLeft(mapTo(window(), QPoint(m_textbox->x(), height())));
@@ -203,7 +231,7 @@ void CKeyReferenceWidget::updateText()
bool CKeyReferenceWidget::setKey(CSwordVerseKey *key)
{
if (!key) return false;
-
+
m_key->key(key->key());
updateText();
return true;
@@ -218,8 +246,7 @@ void CKeyReferenceWidget::slotReturnPressed()
{
m_key->key(m_textbox->text());
updateText();
-
- emit changed(m_key.get());
+ emit changed(m_key);
}
/* Handlers for the various scroller widgetsets. Do we really want a verse scroller? */
@@ -232,58 +259,70 @@ void CKeyReferenceWidget::slotUpdateLock()
void CKeyReferenceWidget::slotUpdateUnlock()
{
updatelock = false;
- if (oldKey != m_key->key()) emit changed(m_key.get());
+ if (oldKey != m_key->key())
+ emit changed(m_key);
}
void CKeyReferenceWidget::slotStepBook(int n)
{
- n > 0 ? m_key->next( CSwordVerseKey::UseBook ) : m_key->previous( CSwordVerseKey::UseBook );
+ CSwordVerseKey key = *m_key;
+ n > 0 ? key.next( CSwordVerseKey::UseBook ) : key.previous( CSwordVerseKey::UseBook );
+ if (!updatelock)
+ emit changed(&key); // does *m_key = key
updateText();
- if (!updatelock) emit changed(m_key.get());
}
void CKeyReferenceWidget::slotStepChapter(int n)
{
- n > 0 ? m_key->next( CSwordVerseKey::UseChapter ) : m_key->previous( CSwordVerseKey::UseChapter );
- updateText();
- if (!updatelock) emit changed(m_key.get());
+ CSwordVerseKey key = *m_key;
+ n > 0 ? key.next( CSwordVerseKey::UseChapter ) : key.previous( CSwordVerseKey::UseChapter );
+ if (!updatelock)
+ emit changed(&key); // does *m_key = key
+ updateText();
}
void CKeyReferenceWidget::slotStepVerse(int n)
{
- n > 0 ? m_key->next( CSwordVerseKey::UseVerse ) : m_key->previous( CSwordVerseKey::UseVerse );
+ CSwordVerseKey key = *m_key;
+ n > 0 ? key.next( CSwordVerseKey::UseVerse ) : key.previous( CSwordVerseKey::UseVerse );
+ if (!updatelock)
+ emit changed(&key); // does *m_key = key
updateText();
- if (!updatelock) emit changed(m_key.get());
}
void CKeyReferenceWidget::slotChangeVerse(int n)
{
- if (m_key->Verse() != n) {
+ if (m_key->Verse() != n)
+ {
m_key->Verse( n );
- setKey( m_key.get() );
+ setKey( m_key );
}
updateText();
- if (!updatelock) emit changed(m_key.get());
+ if (!updatelock) emit changed(m_key);
}
void CKeyReferenceWidget::slotChangeChapter(int n)
{
- if (m_key->Chapter() != n) {
+ if (m_key->Chapter() != n)
+ {
m_key->Chapter( n );
- setKey( m_key.get() );
+ setKey( m_key );
}
updateText();
- if (!updatelock) emit changed(m_key.get());
+ if (!updatelock)
+ emit changed(m_key);
}
void CKeyReferenceWidget::slotChangeBook(QString bookname)
{
- if (m_key->book() != bookname) {
+ if (m_key->book() != bookname)
+ {
m_key->book( bookname );
- setKey( m_key.get() );
+ setKey( m_key );
}
updateText();
- if (!updatelock) emit changed(m_key.get());
+ if (!updatelock)
+ emit changed(m_key);
}
diff --git a/src/frontend/keychooser/versekeychooser/ckeyreferencewidget.h b/src/frontend/keychooser/versekeychooser/ckeyreferencewidget.h
index 0ecb7a9..0324dbe 100644
--- a/src/frontend/keychooser/versekeychooser/ckeyreferencewidget.h
+++ b/src/frontend/keychooser/versekeychooser/ckeyreferencewidget.h
@@ -14,8 +14,6 @@
#include "backend/drivers/cswordbiblemoduleinfo.h"
#include <QWidget>
-
-#include <boost/scoped_ptr.hpp>
#include <QTimer>
@@ -73,7 +71,7 @@ private:
friend class BtChapterDropdownChooserButton;
friend class BtVerseDropdownChooserButton;
- boost::scoped_ptr<CSwordVerseKey> m_key;
+ CSwordVerseKey *m_key;
QLineEdit* m_textbox;
diff --git a/src/frontend/mainindex/bookmarks/cbookmarkindex.h b/src/frontend/mainindex/bookmarks/cbookmarkindex.h
index 39e2df3..340fabc 100644
--- a/src/frontend/mainindex/bookmarks/cbookmarkindex.h
+++ b/src/frontend/mainindex/bookmarks/cbookmarkindex.h
@@ -26,7 +26,6 @@ class CSwordModuleInfo;
#include <QTreeWidgetItem>
class CSearchDialog;
-class CMainIndex;
class QWidget;
class QDropEvent;
class QDragMoveEvent;
diff --git a/src/frontend/mainindex/bookshelf/btindexitem.h b/src/frontend/mainindex/bookshelf/btindexitem.h
index 33d2f7b..d9e74ad 100644
--- a/src/frontend/mainindex/bookshelf/btindexitem.h
+++ b/src/frontend/mainindex/bookshelf/btindexitem.h
@@ -15,7 +15,6 @@
#include <QTreeWidgetItem>
#include <QString>
-class CMainIndex;
class QMimeData;
class QAction;
diff --git a/src/frontend/mainindex/bookshelf/cbookshelfindex.h b/src/frontend/mainindex/bookshelf/cbookshelfindex.h
index f9e56e7..bd21069 100644
--- a/src/frontend/mainindex/bookshelf/cbookshelfindex.h
+++ b/src/frontend/mainindex/bookshelf/cbookshelfindex.h
@@ -27,7 +27,6 @@ class CSwordModuleInfo;
class CSearchDialog;
-class CMainIndex;
class QWidget;
class QDropEvent;
class QDragMoveEvent;
diff --git a/src/frontend/mainindex/btbookshelfview.cpp b/src/frontend/mainindex/btbookshelfview.cpp
new file mode 100644
index 0000000..52d0ec4
--- /dev/null
+++ b/src/frontend/mainindex/btbookshelfview.cpp
@@ -0,0 +1,105 @@
+/*********
+*
+* 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/mainindex/btbookshelfview.h"
+
+#include <QApplication>
+#include <QHeaderView>
+#include <QMouseEvent>
+#include "backend/bookshelfmodel/btbookshelftreemodel.h"
+#include "backend/drivers/cswordmoduleinfo.h"
+
+BtBookshelfView::BtBookshelfView(QWidget *parent)
+ : QTreeView(parent)
+{
+ header()->hide();
+
+ /*
+ Uncommenting the following statement will hide the [+]expand/[-]collapse
+ controls in front of first-level items, which might not be desirable since
+ hiding them also means that one has to do a total of 2 clicks (double-
+ click)to expand or collapse top-level items:
+ */
+ // setRootIsDecorated(false);
+
+ connect(this, SIGNAL(activated(QModelIndex)),
+ this, SLOT(slotItemActivated(QModelIndex)));
+}
+
+BtBookshelfView::~BtBookshelfView() {
+ // Intentionally empty
+}
+
+CSwordModuleInfo *BtBookshelfView::getModule(const QModelIndex &index) const {
+ return (CSwordModuleInfo *) model()
+ ->data(index, BtBookshelfModel::ModulePointerRole).value<void*>();
+}
+
+void BtBookshelfView::keyPressEvent(QKeyEvent *event) {
+ switch (event->key()) {
+ case Qt::Key_Menu:
+ scrollTo(currentIndex());
+ {
+ CSwordModuleInfo *i(getModule(currentIndex()));
+ QRect itemRect(visualRect(currentIndex()));
+ QPoint p(viewport()->mapToGlobal(itemRect.bottomLeft()));
+ if (i == 0) {
+ emit contextMenuActivated(p);
+ } else {
+ emit moduleContextMenuActivated(i, p);
+ }
+ }
+ event->accept();
+ break;
+ case Qt::Key_Return:
+ case Qt::Key_Enter:
+ {
+ QModelIndex i(currentIndex());
+ CSwordModuleInfo *m(getModule(i));
+ if (m != 0) {
+ emit moduleActivated(m);
+ } else {
+ setExpanded(i, !isExpanded(i));
+ }
+ }
+ event->accept();
+ break;
+ default:
+ QTreeView::keyPressEvent(event);
+ break;
+ }
+}
+
+void BtBookshelfView::mousePressEvent(QMouseEvent *event) {
+ if (event->buttons() == Qt::RightButton) {
+ QModelIndex clickedItemIndex(indexAt(event->pos()));
+ if (clickedItemIndex.isValid()) {
+ setCurrentIndex(clickedItemIndex);
+ }
+ CSwordModuleInfo *i(getModule(clickedItemIndex));
+ if (i == 0) {
+ emit contextMenuActivated(mapToGlobal(event->pos()));
+ } else {
+ emit moduleContextMenuActivated(i, mapToGlobal(event->pos()));
+ }
+ event->accept();
+ } else {
+ QTreeView::mousePressEvent(event);
+ }
+}
+
+void BtBookshelfView::slotItemActivated(const QModelIndex &index) {
+ CSwordModuleInfo *i(getModule(index));
+ if (i != 0) {
+ emit moduleActivated(i);
+ }
+}
diff --git a/src/frontend/mainindex/btbookshelfview.h b/src/frontend/mainindex/btbookshelfview.h
new file mode 100644
index 0000000..80c7f31
--- /dev/null
+++ b/src/frontend/mainindex/btbookshelfview.h
@@ -0,0 +1,42 @@
+/*********
+*
+* 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 BTBOOKSHELFVIEW_H
+#define BTBOOKSHELFVIEW_H
+
+#include <QTreeView>
+
+class CSwordModuleInfo;
+
+class BtBookshelfView: public QTreeView {
+ Q_OBJECT
+ public:
+ BtBookshelfView(QWidget *parent = 0);
+ virtual ~BtBookshelfView();
+
+ CSwordModuleInfo *getModule(const QModelIndex &index) const;
+
+ signals:
+ void contextMenuActivated(QPoint pos);
+ void moduleContextMenuActivated(CSwordModuleInfo *item,
+ QPoint pos);
+ void moduleActivated(CSwordModuleInfo *item);
+
+ protected:
+ void keyPressEvent(QKeyEvent *event);
+ void mousePressEvent(QMouseEvent *event);
+
+ protected slots:
+ void slotItemActivated(const QModelIndex &index);
+};
+
+#endif // BTBOOKSHELFVIEW_H
diff --git a/src/frontend/mainindex/cmainindex.cpp b/src/frontend/mainindex/cmainindex.cpp
deleted file mode 100644
index 04341b0..0000000
--- a/src/frontend/mainindex/cmainindex.cpp
+++ /dev/null
@@ -1,36 +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.
-*
-**********/
-
-//BibleTime includes
-#include "cmainindex.h"
-
-#include "backend/drivers/cswordmoduleinfo.h"
-
-#include "bookshelf/cbookshelfindex.h"
-#include "bookmarks/cbookmarkindex.h"
-
-#include <QTabWidget>
-
-
-CMainIndex::CMainIndex(QWidget *parent) : QTabWidget(parent)
-{
- setFocusPolicy(Qt::StrongFocus);
- m_bookmarksPage = new CBookmarkIndex(0);
- m_bookshelfPage = new CBookshelfIndex(0);
- addTab(m_bookshelfPage, tr("Bookshelf"));
- addTab(m_bookmarksPage, tr("Bookmarks"));
-
- //shortcut some signals from pages to signals of this widget so that outsiders
- // do not have to use the pages directly
- QObject::connect(m_bookshelfPage, SIGNAL(createReadDisplayWindow( QList<CSwordModuleInfo*>, const QString& )), this, SIGNAL(createReadDisplayWindow( QList<CSwordModuleInfo*>, const QString& )));
- QObject::connect(m_bookmarksPage, SIGNAL(createReadDisplayWindow( QList<CSwordModuleInfo*>, const QString& )), this, SIGNAL(createReadDisplayWindow( QList<CSwordModuleInfo*>, const QString& )));
-
- QObject::connect(m_bookshelfPage, SIGNAL(createWriteDisplayWindow( CSwordModuleInfo*, const QString&, const CDisplayWindow::WriteWindowType& )), this, SIGNAL(createWriteDisplayWindow( CSwordModuleInfo*, const QString&, const CDisplayWindow::WriteWindowType&)));
-
-}
diff --git a/src/frontend/mainindex/cmainindex.h b/src/frontend/mainindex/cmainindex.h
deleted file mode 100644
index b5d217d..0000000
--- a/src/frontend/mainindex/cmainindex.h
+++ /dev/null
@@ -1,57 +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 CMAININDEX_H
-#define CMAININDEX_H
-
-#include "frontend/displaywindow/cdisplaywindow.h"
-
-#include <QTabWidget>
-#include <QFocusEvent>
-
-class CBookmarkIndex;
-class CBookshelfIndex;
-class CSwordModuleInfo;
-
-/** The class which manages all bookmarks and modules. The modules are put into own, fixed subfolders sorted by language.
- * @author The BibleTime team
- */
-class CMainIndex : public QTabWidget {
- Q_OBJECT
-
-public:
- CMainIndex(QWidget *parent);
- virtual ~CMainIndex() {};
-
- //void reloadSword();
-
- CBookshelfIndex* bookshelfIndex() {return m_bookshelfPage;}
-
-signals:
- /**
- * Is emitted when a module should be opened,
- */
- void createReadDisplayWindow( QList<CSwordModuleInfo*>, const QString& );
- /**
- * Is emitted when a write window should be created.
- */
- void createWriteDisplayWindow( CSwordModuleInfo*, const QString&, const CDisplayWindow::WriteWindowType& );
-
-protected:
- /** QWidget method - move focus to the active page widget */
- virtual void focusInEvent(QFocusEvent*) {currentWidget()->setFocus();}
-
-private:
-
- CBookmarkIndex* m_bookmarksPage;
- CBookshelfIndex* m_bookshelfPage;
-
-};
-
-#endif