summaryrefslogtreecommitdiff
path: root/src/frontend/displaywindow
diff options
context:
space:
mode:
Diffstat (limited to 'src/frontend/displaywindow')
-rw-r--r--src/frontend/displaywindow/btactioncollection.cpp20
-rw-r--r--src/frontend/displaywindow/btactioncollection.h2
-rw-r--r--src/frontend/displaywindow/btdisplaysettingsbutton.cpp14
-rw-r--r--src/frontend/displaywindow/btdisplaysettingsbutton.h22
-rw-r--r--src/frontend/displaywindow/btmodulechooserbar.cpp39
-rw-r--r--src/frontend/displaywindow/btmodulechooserbar.h21
-rw-r--r--src/frontend/displaywindow/btmodulechooserbutton.cpp3
-rw-r--r--src/frontend/displaywindow/btmodulechooserbutton.h2
-rw-r--r--src/frontend/displaywindow/bttextwindowheader.cpp19
-rw-r--r--src/frontend/displaywindow/bttextwindowheader.h19
-rw-r--r--src/frontend/displaywindow/bttextwindowheaderwidget.cpp3
-rw-r--r--src/frontend/displaywindow/bttextwindowheaderwidget.h2
-rw-r--r--src/frontend/displaywindow/bttoolbarpopupaction.cpp15
-rw-r--r--src/frontend/displaywindow/bttoolbarpopupaction.h5
-rw-r--r--src/frontend/displaywindow/btwindowmodulechooser.h12
-rw-r--r--src/frontend/displaywindow/cbiblereadwindow.cpp47
-rw-r--r--src/frontend/displaywindow/cbiblereadwindow.h4
-rw-r--r--src/frontend/displaywindow/cbookreadwindow.cpp59
-rw-r--r--src/frontend/displaywindow/cbookreadwindow.h4
-rw-r--r--src/frontend/displaywindow/ccommentaryreadwindow.cpp35
-rw-r--r--src/frontend/displaywindow/ccommentaryreadwindow.h4
-rw-r--r--src/frontend/displaywindow/cdisplaywindow.cpp161
-rw-r--r--src/frontend/displaywindow/cdisplaywindow.h120
-rw-r--r--src/frontend/displaywindow/cdisplaywindowfactory.cpp33
-rw-r--r--src/frontend/displaywindow/cdisplaywindowfactory.h6
-rw-r--r--src/frontend/displaywindow/chtmlwritewindow.cpp105
-rw-r--r--src/frontend/displaywindow/chtmlwritewindow.h35
-rw-r--r--src/frontend/displaywindow/clexiconreadwindow.cpp68
-rw-r--r--src/frontend/displaywindow/clexiconreadwindow.h27
-rw-r--r--src/frontend/displaywindow/cplainwritewindow.cpp172
-rw-r--r--src/frontend/displaywindow/cplainwritewindow.h28
-rw-r--r--src/frontend/displaywindow/creadwindow.cpp15
-rw-r--r--src/frontend/displaywindow/creadwindow.h18
-rw-r--r--src/frontend/displaywindow/cwritewindow.cpp10
-rw-r--r--src/frontend/displaywindow/cwritewindow.h33
35 files changed, 722 insertions, 460 deletions
diff --git a/src/frontend/displaywindow/btactioncollection.cpp b/src/frontend/displaywindow/btactioncollection.cpp
index f1956d5..9c26143 100644
--- a/src/frontend/displaywindow/btactioncollection.cpp
+++ b/src/frontend/displaywindow/btactioncollection.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2009 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -21,8 +21,10 @@
class BtActionItem : public QObject {
public:
- BtActionItem(QObject* parent)
- : QObject(parent) {
+ BtActionItem(QAction *action, QObject *parent = 0)
+ : QObject(parent), defaultKeys(action->shortcut()), action(action)
+ {
+ // Intentionally empty
}
QKeySequence defaultKeys;
QAction* action;
@@ -56,13 +58,11 @@ QAction* BtActionCollection::action(const QString& name) {
QAction* BtActionCollection::addAction(const QString& name, QAction* action) {
Q_ASSERT(action != 0);
- Q_ASSERT(m_actions[name] == 0); /// \todo replacing actions is ok???
- int count;
- count = m_actions.count();
- BtActionItem* item = new BtActionItem(this);
- item->action = action;
- item->defaultKeys = action->shortcut();
- m_actions[name] = item;
+ if (m_actions.contains(name)) {
+ delete m_actions[name];
+ }
+ BtActionItem* item = new BtActionItem(action, this);
+ m_actions.insert(name, item);
return action;
}
diff --git a/src/frontend/displaywindow/btactioncollection.h b/src/frontend/displaywindow/btactioncollection.h
index 9a02958..2ce273d 100644
--- a/src/frontend/displaywindow/btactioncollection.h
+++ b/src/frontend/displaywindow/btactioncollection.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2009 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/displaywindow/btdisplaysettingsbutton.cpp b/src/frontend/displaywindow/btdisplaysettingsbutton.cpp
index e809efc..2fa1d2d 100644
--- a/src/frontend/displaywindow/btdisplaysettingsbutton.cpp
+++ b/src/frontend/displaywindow/btdisplaysettingsbutton.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -15,7 +15,6 @@
#include <QToolTip>
#include <QToolButton>
#include "util/directory.h"
-#include "util/cpointers.h"
#include "util/cresmgr.h"
@@ -37,7 +36,8 @@ BtDisplaySettingsButton::BtDisplaySettingsButton(QWidget *parent)
}
void BtDisplaySettingsButton::setDisplayOptions(
- const CSwordBackend::DisplayOptions &displaySettings, bool repopulate)
+ const DisplayOptions &displaySettings,
+ bool repopulate)
{
m_displayOptions = displaySettings;
if (repopulate) {
@@ -46,7 +46,7 @@ void BtDisplaySettingsButton::setDisplayOptions(
}
void BtDisplaySettingsButton::setFilterOptions(
- const CSwordBackend::FilterOptions &moduleSettings,
+ const FilterOptions &moduleSettings,
bool repopulate)
{
m_filterOptions = moduleSettings;
@@ -55,7 +55,9 @@ void BtDisplaySettingsButton::setFilterOptions(
}
}
-void BtDisplaySettingsButton::setModules(const QList<CSwordModuleInfo*> &modules) {
+void BtDisplaySettingsButton::setModules(
+ const QList<const CSwordModuleInfo*> &modules)
+{
m_modules = modules;
repopulateMenu();
}
@@ -225,7 +227,7 @@ void BtDisplaySettingsButton::addMenuEntry(QAction *action, bool checked) {
}
bool BtDisplaySettingsButton::isOptionAvailable(const CSwordModuleInfo::FilterTypes option) {
- foreach (CSwordModuleInfo *module, m_modules) {
+ Q_FOREACH (const 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
index e947e83..489395e 100644
--- a/src/frontend/displaywindow/btdisplaysettingsbutton.h
+++ b/src/frontend/displaywindow/btdisplaysettingsbutton.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -13,6 +13,7 @@
#include <QToolButton>
#include "backend/managers/cswordbackend.h"
+#include "btglobal.h"
class CSwordModuleInfo;
@@ -27,15 +28,18 @@ class BtDisplaySettingsButton: public QToolButton {
public:
BtDisplaySettingsButton(QWidget *parent = 0);
- void setDisplayOptions(const CSwordBackend::DisplayOptions &displaySettings,
+ public slots:
+ void setDisplayOptions(const DisplayOptions &displaySettings,
bool repopulate = true);
- void setFilterOptions(const CSwordBackend::FilterOptions &moduleSettings,
+ void setFilterOptions(const FilterOptions &moduleSettings,
bool repopulate = true);
- void setModules(const QList<CSwordModuleInfo*> &modules);
+
+ void setModules(const QList<const CSwordModuleInfo*> &modules);
signals:
- void sigFilterOptionsChanged(CSwordBackend::FilterOptions filterOptions);
- void sigDisplayOptionsChanged(CSwordBackend::DisplayOptions displayOptions);
+ void sigFilterOptionsChanged(FilterOptions filterOptions);
+ void sigDisplayOptionsChanged(DisplayOptions displayOptions);
+ void sigModulesChanged(const QList<CSwordModuleInfo*> &modules);
void sigChanged(void);
protected slots:
@@ -51,9 +55,9 @@ class BtDisplaySettingsButton: public QToolButton {
void addMenuEntry(QAction *action, bool checked);
private:
- CSwordBackend::FilterOptions m_filterOptions;
- CSwordBackend::DisplayOptions m_displayOptions;
- QList<CSwordModuleInfo*> m_modules;
+ FilterOptions m_filterOptions;
+ DisplayOptions m_displayOptions;
+ QList<const CSwordModuleInfo*> m_modules;
QMenu *m_popup;
QAction *m_lineBreakAction;
diff --git a/src/frontend/displaywindow/btmodulechooserbar.cpp b/src/frontend/displaywindow/btmodulechooserbar.cpp
index e07e739..29be862 100644
--- a/src/frontend/displaywindow/btmodulechooserbar.cpp
+++ b/src/frontend/displaywindow/btmodulechooserbar.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -17,24 +17,18 @@
#include <QToolBar>
-BtModuleChooserBar::BtModuleChooserBar(QStringList useModules, CSwordModuleInfo::ModuleType type, CReadWindow *parent)
+BtModuleChooserBar::BtModuleChooserBar(QWidget *parent)
: QToolBar(parent),
- BtWindowModuleChooser(parent, type),
- m_idCounter(0) {
+ BtWindowModuleChooser(CSwordModuleInfo::Unknown, 0),
+ m_idCounter(0),
+ m_window(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();
@@ -48,10 +42,6 @@ void BtModuleChooserBar::backendModulesChanged() {
}
}
-void BtModuleChooserBar::slotWindowModulesChanged() {
- windowModulesChanged();
-}
-
void BtModuleChooserBar::adjustButtonCount(bool adjustToZero) {
//qDebug() << "BtModuleChooserBar::ajustButtonCount";
int buttonCountDifference = 0;
@@ -67,11 +57,7 @@ void BtModuleChooserBar::adjustButtonCount(bool adjustToZero) {
//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();
+ delete m_buttonList.takeFirst();
}
}
// if there are more modules than buttons, add buttons
@@ -82,7 +68,7 @@ void BtModuleChooserBar::adjustButtonCount(bool adjustToZero) {
}
}
-void BtModuleChooserBar::windowModulesChanged() {
+void BtModuleChooserBar::slotWindowModulesChanged() {
//qDebug() << "BtModuleChooserBar::windowModulesChanged";
m_modules = m_window->getModuleList();
adjustButtonCount();
@@ -105,10 +91,16 @@ BtModuleChooserButton* BtModuleChooserBar::addButton() {
return b;
}
+
/** Sets the modules which are chosen in this module chooser bar. */
-void BtModuleChooserBar::setModules( QStringList useModules ) {
+void BtModuleChooserBar::setModules( QStringList useModules,CSwordModuleInfo::ModuleType type, CReadWindow* window) {
qDebug() << "BtModuleChooserBar::setModules";
m_modules = useModules;
+ m_window = window;
+ m_moduleType = type;
+
+ clear();
+
adjustButtonCount(true);
//if (!useModules.count()) return;
@@ -120,6 +112,9 @@ void BtModuleChooserBar::setModules( QStringList useModules ) {
}
updateButtonMenus();
qDebug() << "BtModuleChooserBar::setModules end";
+
+ connect(m_window, SIGNAL(sigModuleListSet(QStringList)), SLOT(slotBackendModulesChanged()));
+ connect(m_window, SIGNAL(sigModuleListChanged()), SLOT(slotWindowModulesChanged()));
}
void BtModuleChooserBar::updateButtonMenus() {
diff --git a/src/frontend/displaywindow/btmodulechooserbar.h b/src/frontend/displaywindow/btmodulechooserbar.h
index 7ae903c..977d3c0 100644
--- a/src/frontend/displaywindow/btmodulechooserbar.h
+++ b/src/frontend/displaywindow/btmodulechooserbar.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -21,31 +21,26 @@ class BtModuleChooserButton;
class BtModuleChooserBar: public QToolBar, public BtWindowModuleChooser {
Q_OBJECT
public:
- BtModuleChooserBar(QStringList useModules, CSwordModuleInfo::ModuleType type, CReadWindow* parent);
+ BtModuleChooserBar(QWidget* parent);
+ /** Initialize with module list.*/
+ void setModules( QStringList useModules,CSwordModuleInfo::ModuleType type, CReadWindow* window);
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();
+ void slotBackendModulesChanged();
+
/**
* The window module list was changed, i.e. 1 module added, removed or replaced.
*/
- virtual void windowModulesChanged();
+ void slotWindowModulesChanged();
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();
/**
@@ -56,6 +51,8 @@ class BtModuleChooserBar: public QToolBar, public BtWindowModuleChooser {
private:
int m_idCounter;
+ CReadWindow* m_window;
+ CSwordModuleInfo::ModuleType m_moduleType;
QList<BtModuleChooserButton*> m_buttonList;
};
diff --git a/src/frontend/displaywindow/btmodulechooserbutton.cpp b/src/frontend/displaywindow/btmodulechooserbutton.cpp
index 549123f..9c8ad2f 100644
--- a/src/frontend/displaywindow/btmodulechooserbutton.cpp
+++ b/src/frontend/displaywindow/btmodulechooserbutton.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -20,7 +20,6 @@
#include "frontend/displaywindow/btmodulechooserbar.h"
#include "util/cresmgr.h"
#include "util/directory.h"
-#include "util/cpointers.h"
BtModuleChooserButton::BtModuleChooserButton(BtModuleChooserBar *parent, CSwordModuleInfo::ModuleType mtype)
diff --git a/src/frontend/displaywindow/btmodulechooserbutton.h b/src/frontend/displaywindow/btmodulechooserbutton.h
index 9835eb0..270603b 100644
--- a/src/frontend/displaywindow/btmodulechooserbutton.h
+++ b/src/frontend/displaywindow/btmodulechooserbutton.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/displaywindow/bttextwindowheader.cpp b/src/frontend/displaywindow/bttextwindowheader.cpp
index cd5392f..5bacf2b 100644
--- a/src/frontend/displaywindow/bttextwindowheader.cpp
+++ b/src/frontend/displaywindow/bttextwindowheader.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -22,9 +22,12 @@
#include <QAction>
#include <QDebug>
-BtTextWindowHeader::BtTextWindowHeader ( CDisplayWindow* window, CSwordModuleInfo::ModuleType modtype, QStringList modules )
- : QWidget ( window ),
- BtWindowModuleChooser(window, modtype) {
+BtTextWindowHeader::BtTextWindowHeader(CSwordModuleInfo::ModuleType modtype,
+ QStringList modules,
+ CDisplayWindow *window)
+ : QWidget(window),
+ BtWindowModuleChooser(modtype, window)
+{
QHBoxLayout* layout = new QHBoxLayout ( this );
layout->setContentsMargins(0, 0, 0, 0);
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
@@ -37,10 +40,6 @@ BtTextWindowHeader::BtTextWindowHeader ( CDisplayWindow* window, CSwordModuleInf
BtTextWindowHeader::~BtTextWindowHeader() {}
void BtTextWindowHeader::slotBackendModulesChanged() {
- backendModulesChanged();
-}
-
-void BtTextWindowHeader::backendModulesChanged() {
m_modules = m_window->getModuleList();
adjustWidgetCount();
@@ -55,10 +54,6 @@ void BtTextWindowHeader::backendModulesChanged() {
}
void BtTextWindowHeader::slotWindowModulesChanged() {
- windowModulesChanged();
-}
-
-void BtTextWindowHeader::windowModulesChanged() {
m_modules = m_window->getModuleList();
adjustWidgetCount();
updateWidgets();
diff --git a/src/frontend/displaywindow/bttextwindowheader.h b/src/frontend/displaywindow/bttextwindowheader.h
index a3e6b6b..1ea86b4 100644
--- a/src/frontend/displaywindow/bttextwindowheader.h
+++ b/src/frontend/displaywindow/bttextwindowheader.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -22,19 +22,20 @@ class BtTextWindowHeaderWidget;
class BtTextWindowHeader: public QWidget, public BtWindowModuleChooser {
Q_OBJECT
public:
- BtTextWindowHeader(CDisplayWindow* window, CSwordModuleInfo::ModuleType modtype, QStringList modules);
+ BtTextWindowHeader(CSwordModuleInfo::ModuleType modtype, QStringList modules, CDisplayWindow *window);
virtual ~BtTextWindowHeader();
public slots:
+ /**
+ The backend module list was updated, module list and widgets must be updated from
+ scratch.
+ */
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();
+ /**
+ The window module list was updated, module list and widgets must be updated.
+ */
+ void slotWindowModulesChanged();
signals:
/** User selected a module from menu to replace another module*/
diff --git a/src/frontend/displaywindow/bttextwindowheaderwidget.cpp b/src/frontend/displaywindow/bttextwindowheaderwidget.cpp
index 3858efb..f0829bc 100644
--- a/src/frontend/displaywindow/bttextwindowheaderwidget.cpp
+++ b/src/frontend/displaywindow/bttextwindowheaderwidget.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -24,7 +24,6 @@
#include "frontend/displaywindow/bttextwindowheader.h"
#include "util/cresmgr.h"
#include "util/directory.h"
-#include "util/cpointers.h"
const char* ActionType = "ActionType";
diff --git a/src/frontend/displaywindow/bttextwindowheaderwidget.h b/src/frontend/displaywindow/bttextwindowheaderwidget.h
index 2b5379e..d2bbe40 100644
--- a/src/frontend/displaywindow/bttextwindowheaderwidget.h
+++ b/src/frontend/displaywindow/bttextwindowheaderwidget.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/displaywindow/bttoolbarpopupaction.cpp b/src/frontend/displaywindow/bttoolbarpopupaction.cpp
index 49b145e..1a5593b 100644
--- a/src/frontend/displaywindow/bttoolbarpopupaction.cpp
+++ b/src/frontend/displaywindow/bttoolbarpopupaction.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2009 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -15,15 +15,18 @@
#include <QToolButton>
-class BtToolButton : public QToolButton {
+namespace {
+
+class BtToolButton: public QToolButton {
public:
- BtToolButton(QWidget* parent = 0) : QToolButton(parent) {
- }
+ inline BtToolButton(QWidget *parent = 0)
+ : QToolButton(parent) {}
private:
- void nextCheckState() {
- }
+ virtual inline void nextCheckState() {}
};
+} // anonymous namespace
+
// This class provides a toolbar widget that has a icon plus a right side down arrow
// The icon is typically set to a back or forward arrow and the down arrow has a popup
diff --git a/src/frontend/displaywindow/bttoolbarpopupaction.h b/src/frontend/displaywindow/bttoolbarpopupaction.h
index 202a006..ebbc848 100644
--- a/src/frontend/displaywindow/bttoolbarpopupaction.h
+++ b/src/frontend/displaywindow/bttoolbarpopupaction.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2009 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -32,9 +32,6 @@ class BtToolBarPopupAction : public QWidgetAction {
// Function to catch the Shortcut event and emit the triggered signal
virtual bool event(QEvent* e);
- signals:
- void triggered();
-
protected:
QWidget* createWidget(QWidget* parent);
diff --git a/src/frontend/displaywindow/btwindowmodulechooser.h b/src/frontend/displaywindow/btwindowmodulechooser.h
index c30c284..1cf3fd1 100644
--- a/src/frontend/displaywindow/btwindowmodulechooser.h
+++ b/src/frontend/displaywindow/btwindowmodulechooser.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -35,20 +35,20 @@ class CDisplayWindow;
*/
class BtWindowModuleChooser {
public:
- BtWindowModuleChooser ( CDisplayWindow* parentWindow, CSwordModuleInfo::ModuleType moduleType )
- : m_window ( parentWindow ), m_moduleType ( moduleType ) {}
+ BtWindowModuleChooser(CSwordModuleInfo::ModuleType moduleType,
+ CDisplayWindow *parentWindow)
+ : 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;
+ virtual void slotBackendModulesChanged() = 0;
/** Modules have been added, replaced or removed in the window without backend changing.*/
- virtual void windowModulesChanged() = 0;
+ virtual void slotWindowModulesChanged() = 0;
protected:
diff --git a/src/frontend/displaywindow/cbiblereadwindow.cpp b/src/frontend/displaywindow/cbiblereadwindow.cpp
index 70dbd35..868dd8d 100644
--- a/src/frontend/displaywindow/cbiblereadwindow.cpp
+++ b/src/frontend/displaywindow/cbiblereadwindow.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2009 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -46,8 +46,8 @@ CBibleReadWindow::~CBibleReadWindow() {
void CBibleReadWindow::applyProfileSettings(CProfileWindow* const settings) {
/**
- \todo Make \ref CProfileWindow properly handle these things so we wouldn't have to mess
- around with bits.
+ \todo Make CProfileWindow properly handle these things so we wouldn't have
+ to mess around with bits.
*/
CLexiconReadWindow::applyProfileSettings(settings);
@@ -68,14 +68,17 @@ void CBibleReadWindow::applyProfileSettings(CProfileWindow* const settings) {
displayOptions().lineBreaks = (result & 0x1000) != 0;
displayOptions().verseNumbers = (result & 0x2000) != 0;
- displaySettingsButton()->setFilterOptions(filterOptions(), false);
- displaySettingsButton()->setDisplayOptions(displayOptions());
+ emit sigFilterOptionsChanged(filterOptions());
+ emit sigDisplayOptionsChanged(displayOptions());
+
+ // Apply settings to display:
+ lookup();
}
void CBibleReadWindow::storeProfileSettings( CProfileWindow * const settings) {
/**
- \todo Make \ref CProfileWindow properly handle these things so we wouldn't have to mess
- around with bits.
+ \todo Make CProfileWindow properly handle these things so we wouldn't have
+ to mess around with bits.
*/
int result = 0x0000;
@@ -142,13 +145,13 @@ void CBibleReadWindow::insertKeyboardActions( BtActionCollection* const a ) {
qaction->setShortcut(QKeySequence::Print);
a->addAction("printChapter", qaction);
-// qaction = new QAction( /* QIcon(CResMgr::displaywindows::general::findStrongs::icon), */ tr("Strong's search"), a);
-// qaction->setShortcut(CResMgr::displaywindows::general::findStrongs::accel);
-// qaction->setToolTip(tr("Find all occurences of the Strong number currently under the mouse cursor"));
-// a->addAction(CResMgr::displaywindows::general::findStrongs::actionName, qaction);
+// qaction = new QAction( /* QIcon(CResMgr::displaywindows::general::findStrongs::icon), */ tr("Strong's search"), a);
+// qaction->setShortcut(CResMgr::displaywindows::general::findStrongs::accel);
+// qaction->setToolTip(tr("Find all occurences of the Strong number currently under the mouse cursor"));
+// a->addAction(CResMgr::displaywindows::general::findStrongs::actionName, qaction);
-// qaction = new QAction(tr("Reference only"), a );
-// a->addAction("copyReferenceOnly", qaction);
+// qaction = new QAction(tr("Reference only"), a );
+// a->addAction("copyReferenceOnly", qaction);
qaction = new QAction(tr("Text of reference"), a);
a->addAction("copyTextOfReference", qaction);
@@ -364,7 +367,7 @@ void CBibleReadWindow::previousVerse() {
}
}
-/** rapper around key() to return the right type of key. */
+/** wrapper around key() to return the right type of key. */
CSwordVerseKey* CBibleReadWindow::verseKey() {
CSwordVerseKey* k = dynamic_cast<CSwordVerseKey*>(CDisplayWindow::key());
Q_ASSERT(k);
@@ -380,7 +383,7 @@ void CBibleReadWindow::copyDisplayedText() {
CSwordVerseKey vk(*verseKey());
vk.LowerBound(dummy);
- CSwordBibleModuleInfo* bible = dynamic_cast<CSwordBibleModuleInfo*>(modules().first());
+ const CSwordBibleModuleInfo* bible = dynamic_cast<const CSwordBibleModuleInfo*>(modules().first());
dummy.Verse(bible->verseCount(dummy.book(), dummy.Chapter()));
vk.UpperBound(dummy);
@@ -391,10 +394,8 @@ void CBibleReadWindow::copyDisplayedText() {
/** Saves the chapter as valid HTML page. */
void CBibleReadWindow::saveChapterHTML() {
//saves the complete chapter to disk
- CSwordBibleModuleInfo* bible = dynamic_cast<CSwordBibleModuleInfo*>(modules().first());
- Q_ASSERT(bible);
- if (!bible) //shouldn't happen
- return;
+ Q_ASSERT(dynamic_cast<const CSwordBibleModuleInfo*>(modules().first()) != 0);
+ const CSwordBibleModuleInfo *bible = static_cast<const CSwordBibleModuleInfo*>(modules().first());
CSwordVerseKey dummy(*verseKey());
dummy.Verse(1);
@@ -419,7 +420,7 @@ void CBibleReadWindow::saveChapterPlain() {
dummy.Verse(1);
vk.LowerBound(dummy);
- CSwordBibleModuleInfo* bible = dynamic_cast<CSwordBibleModuleInfo*>(modules().first());
+ const CSwordBibleModuleInfo* bible = dynamic_cast<const CSwordBibleModuleInfo*>(modules().first());
dummy.Verse(bible->verseCount(dummy.book(), dummy.Chapter()));
vk.UpperBound(dummy);
@@ -436,7 +437,7 @@ void CBibleReadWindow::reload(CSwordBackend::SetupChangedReason reason) {
}
//refresh the book lists
- verseKey()->setLocale( backend()->booknameLanguage().toLatin1() );
+ verseKey()->setLocale( CSwordBackend::instance()->booknameLanguage().toLatin1() );
keyChooser()->refreshContent();
CBTConfig::setupAccelSettings(CBTConfig::bibleWindow, actionCollection());
@@ -477,3 +478,7 @@ void CBibleReadWindow::syncWindows() {
}
}
}
+
+void CBibleReadWindow::setupMainWindowToolBars() {
+ CLexiconReadWindow::setupMainWindowToolBars();
+}
diff --git a/src/frontend/displaywindow/cbiblereadwindow.h b/src/frontend/displaywindow/cbiblereadwindow.h
index 11f0275..117c778 100644
--- a/src/frontend/displaywindow/cbiblereadwindow.h
+++ b/src/frontend/displaywindow/cbiblereadwindow.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2009 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -48,6 +48,8 @@ class CBibleReadWindow : public CLexiconReadWindow {
virtual void initToolbars();
virtual void initConnections();
virtual void initView();
+ /** Called to add actions to mainWindow toolbars */
+ virtual void setupMainWindowToolBars();
/**
* Reimplementation.
*/
diff --git a/src/frontend/displaywindow/cbookreadwindow.cpp b/src/frontend/displaywindow/cbookreadwindow.cpp
index 062d42d..3aba333 100644
--- a/src/frontend/displaywindow/cbookreadwindow.cpp
+++ b/src/frontend/displaywindow/cbookreadwindow.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2009 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -13,6 +13,7 @@
#include <QMenu>
#include <QSplitter>
#include <QToolBar>
+#include "bibletime.h"
#include "backend/config/cbtconfig.h"
#include "backend/keys/cswordtreekey.h"
#include "frontend/display/cdisplay.h"
@@ -91,29 +92,27 @@ void CBookReadWindow::initConnections() {
/** Init the view */
void CBookReadWindow::initView() {
QSplitter* splitter = new QSplitter(this);
+ m_treeChooser = new CBookTreeChooser(modules(), history(), key(), splitter);
+ setDisplayWidget( CDisplay::createReadInstance(this, splitter) );
+ m_treeChooser->hide();
+ // Create Navigation toolbar
setMainToolBar( new QToolBar(this) );
mainToolBar()->setAllowedAreas(Qt::TopToolBarArea);
mainToolBar()->setFloatable(false);
-
addToolBar(mainToolBar());
+ setKeyChooser( CKeyChooser::createInstance(modules(), history(), key(), mainToolBar()) );
- m_treeChooser = new CBookTreeChooser(modules(), key(), splitter);
- setDisplayWidget( CDisplay::createReadInstance(this, splitter) );
-
- setKeyChooser( CKeyChooser::createInstance(modules(), key(), mainToolBar()) );
-
- setModuleChooserBar( new BtModuleChooserBar(getModuleList(), modules().first()->type(), this) );
+ // Create the Works toolbar
+ setModuleChooserBar( new BtModuleChooserBar(this));
+ moduleChooserBar()->setModules(getModuleList(), modules().first()->type(), this);
addToolBar(moduleChooserBar());
+ // Create the Tools toolbar
setButtonsToolBar( new QToolBar(this) );
buttonsToolBar()->setAllowedAreas(Qt::TopToolBarArea);
buttonsToolBar()->setFloatable(false);
-
- setDisplaySettingsButton(new BtDisplaySettingsButton(buttonsToolBar()));
-
addToolBar(buttonsToolBar());
- m_treeChooser->hide();
setCentralWidget( splitter );
setWindowIcon(util::tool::getIconForModule(modules().first()));
@@ -125,18 +124,44 @@ void CBookReadWindow::initToolbars() {
mainToolBar()->addAction(m_actions.backInHistory);
mainToolBar()->addAction(m_actions.forwardInHistory);
-
mainToolBar()->addWidget(keyChooser());
- buttonsToolBar()->addAction(m_treeAction);
+ // Tools toolbar
+ buttonsToolBar()->addAction(m_treeAction); // Tree
m_treeAction->setChecked(false);
+ BtDisplaySettingsButton* button = new BtDisplaySettingsButton(buttonsToolBar());
+ setDisplaySettingsButton(button);
+ buttonsToolBar()->addWidget(button); // Display settings
+ QAction* action = qobject_cast<QAction*>(actionCollection()->action(
+ CResMgr::displaywindows::general::search::actionName ));
+ if (action) {
+ buttonsToolBar()->addAction(action); // Search
+ }
+}
- buttonsToolBar()->addWidget(displaySettingsButton());
-
+void CBookReadWindow::setupMainWindowToolBars() {
+ // Navigation toolbar
+ btMainWindow()->navToolBar()->addAction(m_actions.backInHistory); //1st button
+ btMainWindow()->navToolBar()->addAction(m_actions.forwardInHistory); //2nd button
+ CKeyChooser* keyChooser = CKeyChooser::createInstance(modules(), history(), key(), btMainWindow()->navToolBar() );
+ btMainWindow()->navToolBar()->addWidget(keyChooser);
+ bool ok = connect(keyChooser, SIGNAL(keyChanged(CSwordKey*)), this, SLOT(lookupSwordKey(CSwordKey*)));
+ Q_ASSERT(ok);
+ ok = connect(this, SIGNAL(sigKeyChanged(CSwordKey*)), keyChooser, SLOT(updateKey(CSwordKey*)) );
+ Q_ASSERT(ok);
+
+ // Works toolbar
+ btMainWindow()->worksToolBar()->setModules(getModuleList(), modules().first()->type(), this);
+
+ // Tools toolbar
+ btMainWindow()->toolsToolBar()->addAction(m_treeAction); // Tree
+ BtDisplaySettingsButton* button = new BtDisplaySettingsButton(buttonsToolBar());
+ setDisplaySettingsButton(button);
+ btMainWindow()->toolsToolBar()->addWidget(button); // Display settings
QAction* action = qobject_cast<QAction*>(actionCollection()->action(
CResMgr::displaywindows::general::search::actionName ));
if (action) {
- buttonsToolBar()->addAction(action);
+ btMainWindow()->toolsToolBar()->addAction(action); // Search
}
}
diff --git a/src/frontend/displaywindow/cbookreadwindow.h b/src/frontend/displaywindow/cbookreadwindow.h
index b059aff..8b85504 100644
--- a/src/frontend/displaywindow/cbookreadwindow.h
+++ b/src/frontend/displaywindow/cbookreadwindow.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's BtActionCollection code, http://www.bibletime.info/.
*
-* Copyright 1999-2009 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime BtActionCollection code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -48,6 +48,8 @@ class CBookReadWindow : public CLexiconReadWindow {
virtual void initToolbars();
virtual void initConnections();
virtual void initView();
+ /** Called to add actions to mainWindow toolbars */
+ virtual void setupMainWindowToolBars();
virtual void setupPopupMenu();
diff --git a/src/frontend/displaywindow/ccommentaryreadwindow.cpp b/src/frontend/displaywindow/ccommentaryreadwindow.cpp
index 4b4d3c2..b1a291f 100644
--- a/src/frontend/displaywindow/ccommentaryreadwindow.cpp
+++ b/src/frontend/displaywindow/ccommentaryreadwindow.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2009 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -15,9 +15,11 @@
#include <QToolBar>
#include "backend/config/cbtconfig.h"
#include "backend/keys/cswordversekey.h"
+#include "bibletime.h"
#include "frontend/display/cdisplay.h"
#include "frontend/display/creaddisplay.h"
#include "frontend/displaywindow/btactioncollection.h"
+#include "frontend/displaywindow/btmodulechooserbar.h"
#include "frontend/keychooser/ckeychooser.h"
#include "frontend/profile/cprofilewindow.h"
#include "util/directory.h"
@@ -29,6 +31,7 @@ CCommentaryReadWindow::CCommentaryReadWindow(QList<CSwordModuleInfo*> modules, C
}
void CCommentaryReadWindow::insertKeyboardActions(BtActionCollection* const a) {
+ namespace DU = util::directory;
QAction* qaction;
qaction = new QAction(tr("Next book"), a);
@@ -54,6 +57,13 @@ void CCommentaryReadWindow::insertKeyboardActions(BtActionCollection* const a) {
qaction = new QAction(tr("Previous verse"), a);
qaction->setShortcut(CResMgr::displaywindows::bibleWindow::previousVerse::accel);
a->addAction("previousVerse", qaction);
+
+ qaction = new QAction(QIcon(DU::getIcon(CResMgr::displaywindows::commentaryWindow::syncWindow::icon)),
+ tr("Synchronize"), a);
+ qaction->setCheckable(true);
+ qaction->setShortcut(CResMgr::displaywindows::commentaryWindow::syncWindow::accel);
+ qaction->setToolTip(tr("Synchronize the displayed entry of this work with the active Bible window"));
+ a->addAction(CResMgr::displaywindows::commentaryWindow::syncWindow::actionName, qaction);
}
void CCommentaryReadWindow::initActions() {
@@ -91,6 +101,10 @@ void CCommentaryReadWindow::initActions() {
QObject::connect(qaction, SIGNAL(triggered()), this, SLOT(previousVerse()) );
addAction(qaction);
+ qaction = ac->action(CResMgr::displaywindows::commentaryWindow::syncWindow::actionName);
+ m_syncButton = qaction;
+ addAction(qaction);
+
CBTConfig::setupAccelSettings(CBTConfig::commentaryWindow, actionCollection());
}
@@ -107,28 +121,21 @@ void CCommentaryReadWindow::storeProfileSettings( CProfileWindow* profileWindow
}
void CCommentaryReadWindow::initToolbars() {
- namespace DU = util::directory;
-
CLexiconReadWindow::initToolbars();
-
- m_syncButton = new QAction(
- QIcon(DU::getIcon(CResMgr::displaywindows::commentaryWindow::syncWindow::icon)),
- tr("Synchronize"),
- actionCollection()
- );
- m_syncButton->setCheckable(true);
- m_syncButton->setShortcut(CResMgr::displaywindows::commentaryWindow::syncWindow::accel);
- m_syncButton->setToolTip(tr("Synchronize the displayed entry of this work with the active Bible window"));
- actionCollection()->addAction(CResMgr::displaywindows::commentaryWindow::syncWindow::actionName, m_syncButton);
buttonsToolBar()->addAction(m_syncButton);
}
+void CCommentaryReadWindow::setupMainWindowToolBars() {
+ CLexiconReadWindow::setupMainWindowToolBars();
+ btMainWindow()->toolsToolBar()->addAction(m_syncButton);
+}
+
/** Reimplementation to handle the keychooser refresh. */
void CCommentaryReadWindow::reload(CSwordBackend::SetupChangedReason reason) {
CLexiconReadWindow::reload(reason);
//refresh the book lists
- verseKey()->setLocale( backend()->booknameLanguage().toLatin1() );
+ verseKey()->setLocale( CSwordBackend::instance()->booknameLanguage().toLatin1() );
keyChooser()->refreshContent();
CBTConfig::setupAccelSettings(CBTConfig::commentaryWindow, actionCollection());
diff --git a/src/frontend/displaywindow/ccommentaryreadwindow.h b/src/frontend/displaywindow/ccommentaryreadwindow.h
index d75da67..679906c 100644
--- a/src/frontend/displaywindow/ccommentaryreadwindow.h
+++ b/src/frontend/displaywindow/ccommentaryreadwindow.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2009 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -54,6 +54,8 @@ class CCommentaryReadWindow : public CLexiconReadWindow {
protected:
virtual void initActions();
virtual void initToolbars();
+ /** Called to add actions to mainWindow toolbars */
+ virtual void setupMainWindowToolBars();
private:
QAction* m_syncButton;
diff --git a/src/frontend/displaywindow/cdisplaywindow.cpp b/src/frontend/displaywindow/cdisplaywindow.cpp
index 3900a92..2b712c7 100644
--- a/src/frontend/displaywindow/cdisplaywindow.cpp
+++ b/src/frontend/displaywindow/cdisplaywindow.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -35,30 +35,34 @@ using namespace Profile;
CDisplayWindow::CDisplayWindow(QList<CSwordModuleInfo*> modules, CMDIArea *parent)
: QMainWindow(parent),
+ m_actionCollection(0),
m_mdi(parent),
- m_displaySettingsButton(0),
m_keyChooser(0),
m_swordKey(0),
m_isReady(false),
m_moduleChooserBar(0),
m_mainToolBar(0),
+ m_buttonsToolBar(0),
+ m_formatToolBar(0),
+ m_headerBar(0),
m_popupMenu(0),
- m_displayWidget(0) {
+ m_displayWidget(0),
+ m_history(0) {
qDebug() << "CDisplayWindow::CDisplayWindow";
setAttribute(Qt::WA_DeleteOnClose); //we want to destroy this window when it is closed
- parent->addSubWindow(this);
m_actionCollection = new BtActionCollection(this);
setModules(modules);
// Connect this to the backend module list changes
- connect(CPointers::backend(),
+ connect(CSwordBackend::instance(),
SIGNAL(sigSwordSetupChanged(CSwordBackend::SetupChangedReason)),
SLOT(reload(CSwordBackend::SetupChangedReason)));
- BibleTime* mainwindow = dynamic_cast<BibleTime*>(m_mdi->parent());
+ BibleTime* mainwindow = btMainWindow();
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)) );
+ connect(mainwindow, SIGNAL(toggledTextWindowFormatToolbar(bool)), SLOT(slotShowFormatToolBar(bool)) );
}
CDisplayWindow::~CDisplayWindow() {
@@ -66,6 +70,33 @@ CDisplayWindow::~CDisplayWindow() {
m_swordKey = 0;
}
+BibleTime* CDisplayWindow::btMainWindow() {
+ return dynamic_cast<BibleTime*>(m_mdi->parent());
+}
+
+void CDisplayWindow::setToolBarsHidden() {
+ // Hide current window toolbars
+ if (mainToolBar())
+ mainToolBar()->setHidden(true);
+ if (buttonsToolBar())
+ buttonsToolBar()->setHidden(true);
+ if (moduleChooserBar())
+ moduleChooserBar()->setHidden(true);
+ if (formatToolBar())
+ formatToolBar()->setHidden(true);
+}
+void CDisplayWindow::clearMainWindowToolBars() {
+ // Clear main window toolbars, except for works toolbar
+ btMainWindow()->navToolBar()->clear();
+ btMainWindow()->toolsToolBar()->clear();
+ btMainWindow()->formatToolBar()->clear();
+}
+
+void CDisplayWindow::windowActivated() {
+ clearMainWindowToolBars();
+ setupMainWindowToolBars();
+}
+
/** Returns the right window caption. */
const QString CDisplayWindow::windowCaption() {
if (!m_modules.count()) {
@@ -76,10 +107,10 @@ const QString CDisplayWindow::windowCaption() {
}
/** Returns the used modules as a pointer list */
-QList<CSwordModuleInfo*> CDisplayWindow::modules() {
+const QList<const CSwordModuleInfo*> CDisplayWindow::modules() const {
//qDebug() << "CDisplayWindow::modules";
- return CPointers::backend()->getPointerList(m_modules);
+ return CSwordBackend::instance()->getConstPointerList(m_modules);
}
void CDisplayWindow::insertKeyboardActions( BtActionCollection* a ) {
@@ -188,7 +219,7 @@ void CDisplayWindow::reload(CSwordBackend::SetupChangedReason) {
//first make sure all used Sword modules are still present
QMutableStringListIterator it(m_modules);
while (it.hasNext()) {
- if (!backend()->findModuleByName(it.next())) {
+ if (!CSwordBackend::instance()->findModuleByName(it.next())) {
it.remove();
}
}
@@ -234,13 +265,15 @@ void CDisplayWindow::slotRemoveModule(int index) {
}
/** Sets the new display options for this window. */
-void CDisplayWindow::setDisplayOptions(const CSwordBackend::DisplayOptions &displayOptions) {
+void CDisplayWindow::setDisplayOptions(const DisplayOptions &displayOptions) {
m_displayOptions = displayOptions;
+ emit sigDisplayOptionsChanged(m_displayOptions);
}
/** Sets the new filter options of this window. */
-void CDisplayWindow::setFilterOptions(const CSwordBackend::FilterOptions &filterOptions) {
+void CDisplayWindow::setFilterOptions(const FilterOptions &filterOptions) {
m_filterOptions = filterOptions;
+ emit sigFilterOptionsChanged(m_filterOptions);
}
/** Set the ready status */
@@ -264,6 +297,12 @@ void CDisplayWindow::setKey( CSwordKey* key ) {
m_swordKey = key;
}
+BTHistory* CDisplayWindow::history() {
+ if (m_history == 0)
+ m_history = new BTHistory(this);
+ return m_history;
+}
+
void CDisplayWindow::modulesChanged() {
// this would only set the stringlist again
//if (moduleChooserBar()) { //necessary for write windows
@@ -273,11 +312,8 @@ void CDisplayWindow::modulesChanged() {
close();
}
else {
- if (displaySettingsButton()) {
- displaySettingsButton()->setModules(modules());
- }
-
- key()->module(modules().first());
+ emit sigModulesChanged(modules());
+ key()->setModule(modules().first());
keyChooser()->setModules(modules());
}
}
@@ -298,7 +334,7 @@ void CDisplayWindow::setModuleChooserBar( BtModuleChooserBar* bar ) {
}
}
-/** Sets the module header of text area. */
+/** Setup the module header of text area. */
void CDisplayWindow::setHeaderBar( QToolBar* header ) {
m_headerBar = header;
header->setMovable(false);
@@ -328,73 +364,92 @@ bool CDisplayWindow::init() {
parentWidget()->setFocusPolicy(Qt::ClickFocus);
initActions();
initToolbars();
+ if ( ! CBTConfig::get(CBTConfig::showToolbarsInEachWindow))
+ setToolBarsHidden();
+ btMainWindow()->clearMdiToolBars();
+ clearMainWindowToolBars();
initConnections();
setupPopupMenu();
m_filterOptions = CBTConfig::getFilterOptionDefaults();
m_displayOptions = CBTConfig::getDisplayOptionDefaults();
- if (displaySettingsButton()) {
- displaySettingsButton()->setFilterOptions(m_filterOptions, false);
- displaySettingsButton()->setDisplayOptions(m_displayOptions, false);
- displaySettingsButton()->setModules(modules());
- }
+ emit sigDisplayOptionsChanged(m_displayOptions);
+ emit sigFilterOptionsChanged(m_filterOptions);
+ emit sigModulesChanged(modules());
setReady(true);
return true;
}
-/** Sets the main toolbar. */
-void CDisplayWindow::setMainToolBar( QToolBar* bar ) {
- m_mainToolBar = bar;
+static void prepareToolBar(QToolBar* bar, const QString& title, bool visible) {
bar->setAllowedAreas(Qt::TopToolBarArea);
bar->setFloatable(false);
- bar->setWindowTitle(tr("Navigation"));
- bar->setVisible(CBTConfig::get(CBTConfig::showTextWindowNavigator));
+ bar->setWindowTitle(title);
+ bar->setVisible(visible);
}
-/** Sets the main toolbar. */
+/** Setup the Navigation toolbar. */
+void CDisplayWindow::setMainToolBar( QToolBar* bar ) {
+ prepareToolBar(bar, tr("Navigation"), CBTConfig::get(CBTConfig::showTextWindowNavigator) );
+ m_mainToolBar = bar;
+}
+
+/** Setup the Tools toolbar. */
void CDisplayWindow::setButtonsToolBar( QToolBar* bar ) {
+ prepareToolBar(bar, tr("Tool"), CBTConfig::get(CBTConfig::showTextWindowToolButtons) );
m_buttonsToolBar = bar;
- 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( BtDisplaySettingsButton* button ) {
- if (m_displaySettingsButton) {
- m_displaySettingsButton->disconnect(this);
- }
+/** Setup the Format toolbar. */
+void CDisplayWindow::setFormatToolBar( QToolBar* bar ) {
+ prepareToolBar(bar, tr("Format"), true );
+ m_formatToolBar = bar;
+}
- m_displaySettingsButton = button;
+/** Sets the display settings button. */
+void CDisplayWindow::setDisplaySettingsButton(BtDisplaySettingsButton *button) {
+ connect(this, SIGNAL(sigDisplayOptionsChanged(const DisplayOptions&)),
+ button, SLOT(setDisplayOptions(const DisplayOptions&)));
+ connect(this, SIGNAL(sigFilterOptionsChanged(const FilterOptions&)),
+ button, SLOT(setFilterOptions(const FilterOptions&)));
+ connect(this, SIGNAL(sigModulesChanged(const QList<const CSwordModuleInfo*>&)),
+ button, SLOT(setModules(const QList<const CSwordModuleInfo*>&)));
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(sigFilterOptionsChanged(const FilterOptions&)),
+ this, SLOT(setFilterOptions(const FilterOptions&)));
+ connect(button, SIGNAL(sigDisplayOptionsChanged(const DisplayOptions&)),
+ this, SLOT(setDisplayOptions(const DisplayOptions&)));
connect(button, SIGNAL(sigChanged()),
this, SLOT(lookup()));
}
void CDisplayWindow::slotShowHeader(bool show) {
- headerBar()->setVisible(show);
+ if (headerBar())
+ headerBar()->setVisible(show);
}
void CDisplayWindow::slotShowNavigator(bool show) {
- mainToolBar()->setVisible(show);
+ if (mainToolBar())
+ mainToolBar()->setVisible(show);
}
void CDisplayWindow::slotShowToolButtons(bool show) {
- buttonsToolBar()->setVisible(show);
+ if (buttonsToolBar())
+ buttonsToolBar()->setVisible(show);
}
void CDisplayWindow::slotShowModuleChooser(bool show) {
- moduleChooserBar()->setVisible(show);
+ if (moduleChooserBar())
+ moduleChooserBar()->setVisible(show);
+}
+
+void CDisplayWindow::slotShowFormatToolBar(bool show) {
+ if (formatToolBar())
+ formatToolBar()->setVisible(show);
}
/** Lookup the current key. Used to refresh the display. */
@@ -407,25 +462,25 @@ void CDisplayWindow::lookupModKey( const QString& moduleName, const QString& key
return;
}
- CSwordModuleInfo* m = backend()->findModuleByName(moduleName);
- Q_ASSERT(m);
+ CSwordModuleInfo *m = CSwordBackend::instance()->findModuleByName(moduleName);
if (!m) {
- return;
+ return; /// \todo check if this is correct behavior
}
/// \todo check for containsRef compat
if (m && modules().contains(m)) {
- key()->key(keyName);
+ key()->setKey(keyName);
keyChooser()->setKey(key()); //the key chooser does send an update signal
+ emit sigKeyChanged(key());
}
- else { //given module not displayed in this window
+ else { //given module not displayed in this window
//if the module is displayed in another display window we assume a wrong drop
//create a new window for the given module
QList<CSwordModuleInfo*> mList;
mList.append(m);
- Q_ASSERT(qobject_cast<BibleTime*>(mdi()->parent()) != 0);
- BibleTime *mainWindow(static_cast<BibleTime*>(mdi()->parent()));
+ BibleTime *mainWindow = btMainWindow();
+ Q_ASSERT(mainWindow != 0);
mainWindow->createReadDisplayWindow(mList, keyName);
}
}
diff --git a/src/frontend/displaywindow/cdisplaywindow.h b/src/frontend/displaywindow/cdisplaywindow.h
index b23d856..c54aab0 100644
--- a/src/frontend/displaywindow/cdisplaywindow.h
+++ b/src/frontend/displaywindow/cdisplaywindow.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2009 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -11,10 +11,10 @@
#define CDISPLAYWINDOW_H
#include <QMainWindow>
-#include "util/cpointers.h"
#include <QStringList>
#include "backend/managers/cswordbackend.h"
+#include "btglobal.h"
#include "frontend/profile/cprofilewindow.h"
@@ -23,29 +23,30 @@ class CDisplay;
class BtDisplaySettingsButton;
class CKeyChooser;
class CMDIArea;
-//class CModuleChooserBar;
class BtModuleChooserBar;
-class CReadWindow;
class CSwordModuleInfo;
-class CWriteWindow;
class QCloseEvent;
class QMenu;
class QToolBar;
-
-/** The base class for all display windows of BibleTime.
+class BTHistory;
+class BibleTime;
+
+/** The base class for all display windows of BibleTime.
+ *
+ * Inherits QMainWindow.
+ *
+ * Inherited by CReadWindow and CWriteWindow.
+ *
* @author The BibleTime team
*/
-class CDisplayWindow : public QMainWindow, public CPointers {
+class CDisplayWindow : public QMainWindow {
Q_OBJECT
public:
- enum WriteWindowType {
- HTMLWindow = 1,
- PlainTextWindow = 2
- };
/** Insert the keyboard accelerators of this window into the given actioncollection.*/
static void insertKeyboardActions( BtActionCollection* const a );
+ /** Returns pointer to the mdi area object.*/
inline CMDIArea *mdi() const {
return m_mdi;
}
@@ -54,7 +55,7 @@ class CDisplayWindow : public QMainWindow, public CPointers {
const QString windowCaption();
/** Returns the used modules as a pointer list.*/
- QList<CSwordModuleInfo*> modules();
+ const QList<const CSwordModuleInfo*> modules() const;
/** Returns the used modules as a string list. */
inline const QStringList &getModuleList() const {
@@ -64,16 +65,16 @@ class CDisplayWindow : public QMainWindow, public CPointers {
/** 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.*/
+ /** Load the settings the given CProfileWindow object into this window.*/
virtual void applyProfileSettings( Profile::CProfileWindow* profileWindow ) = 0;
/** Returns the display options used by this display window. */
- inline const CSwordBackend::DisplayOptions &displayOptions() const {
+ inline const DisplayOptions &displayOptions() const {
return m_displayOptions;
}
/** Returns the filter options used by this window. */
- inline const CSwordBackend::FilterOptions &filterOptions() const {
+ inline const FilterOptions &filterOptions() const {
return m_filterOptions;
}
@@ -88,6 +89,9 @@ class CDisplayWindow : public QMainWindow, public CPointers {
/** Returns true if the window may be closed.*/
virtual bool queryClose();
+ /** Returns history for this window */
+ BTHistory* history();
+
/** Returns the keychooser widget of this display window. */
inline CKeyChooser *keyChooser() const {
return m_keyChooser;
@@ -114,6 +118,9 @@ class CDisplayWindow : public QMainWindow, public CPointers {
/** Sets and inits the properties of the tool buttons toolbar.*/
void setButtonsToolBar( QToolBar* bar );
+ /** Sets and inits the properties of the format toolbar.*/
+ void setFormatToolBar( QToolBar* bar );
+
/** Returns the main navigation toolbar. */
inline QToolBar *mainToolBar() const {
return m_mainToolBar;
@@ -124,14 +131,14 @@ class CDisplayWindow : public QMainWindow, public CPointers {
return m_buttonsToolBar;
}
+ /** Returns the format toolbar. */
+ inline QToolBar *formatToolBar() const {
+ return m_formatToolBar;
+ }
+
/** Initialize the toolbars.*/
virtual void initToolbars() = 0;
- /** Returns the display settings button. */
- inline BtDisplaySettingsButton *displaySettingsButton() const {
- return m_displaySettingsButton;
- }
-
/** Sets the display settings button.*/
void setDisplaySettingsButton( BtDisplaySettingsButton* button );
@@ -154,6 +161,15 @@ class CDisplayWindow : public QMainWindow, public CPointers {
return false;
};
+ /**
+ * Return pointer to the BibleTime main window
+ */
+ BibleTime* btMainWindow();
+ /**
+ * Called when this window is activated
+ */
+ void windowActivated();
+
inline BtActionCollection *actionCollection() const {
return m_actionCollection;
}
@@ -167,6 +183,23 @@ class CDisplayWindow : public QMainWindow, public CPointers {
void sigModuleRemoved(int index);
/** The module list of window changed but backend list didn't.*/
void sigModuleListChanged();
+
+ /**
+ Signal emitted when display options are changed.
+ */
+ void sigDisplayOptionsChanged(const DisplayOptions &displayOptions);
+
+ /**
+ Signal emitted when display options are changed.
+ */
+ void sigFilterOptionsChanged(const FilterOptions &filterOptions);
+
+ /** signal for change of modules */
+ void sigModulesChanged(const QList<const CSwordModuleInfo*> &modules);
+
+ /** signal for sword key change */
+ void sigKeyChanged(CSwordKey* key);
+
public slots:
/** Receives a signal telling that a module should be added.*/
void slotAddModule(int index, QString module);
@@ -188,6 +221,7 @@ class CDisplayWindow : public QMainWindow, public CPointers {
void slotShowNavigator(bool show);
void slotShowToolButtons(bool show);
void slotShowModuleChooser(bool show);
+ void slotShowFormatToolBar(bool show);
void slotShowHeader(bool show);
protected:
@@ -197,13 +231,17 @@ class CDisplayWindow : public QMainWindow, public CPointers {
CDisplayWindow(QList<CSwordModuleInfo*> modules, CMDIArea* parent);
virtual ~CDisplayWindow();
- /** Returns the display options used by this display window. */
- inline CSwordBackend::DisplayOptions &displayOptions() {
+ /**
+ \returns the display options used by this display window.
+ */
+ inline DisplayOptions &displayOptions() {
return m_displayOptions;
}
- /** Returns the filter options used by this window. */
- inline CSwordBackend::FilterOptions &filterOptions() {
+ /**
+ \returns the filter options used by this window.
+ */
+ inline FilterOptions &filterOptions() {
return m_filterOptions;
}
@@ -242,18 +280,31 @@ class CDisplayWindow : public QMainWindow, public CPointers {
/** Returns the installed RMB popup menu.*/
QMenu* popup();
+ /** Called to add actions to mainWindow toolbars */
+ virtual void setupMainWindowToolBars() = 0;
+
virtual void closeEvent(QCloseEvent* e);
+ void setToolBarsHidden();
+ void clearMainWindowToolBars();
+
protected slots:
- /** Sets the new filter options of this window.*/
- void setFilterOptions(const CSwordBackend::FilterOptions &filterOptions);
+ /**
+ Sets the new filter options of this window.
+ */
+ void setFilterOptions(const FilterOptions &filterOptions);
- /** Sets the new display options for this window.*/
- void setDisplayOptions(const CSwordBackend::DisplayOptions &displayOptions);
+ /**
+ Sets the new display options for this window.
+ */
+ void setDisplayOptions(const DisplayOptions &displayOptions);
virtual void modulesChanged();
- /** Lookup the current key. Used to refresh the display.*/
+ /**
+ Lookup the current key. Used to refresh the display. This also needs to be called
+ after programmatically changing filter/display options.
+ */
void lookup();
virtual void updatePopupMenu();
@@ -270,22 +321,23 @@ class CDisplayWindow : public QMainWindow, public CPointers {
BtActionCollection* m_actionCollection;
CMDIArea* m_mdi;
- //we may only cache the module names bacause after a backend relaod the pointers are invalid!
+ //we may only cache the module names bacause after a backend reload the pointers are invalid!
QStringList m_modules;
- CSwordBackend::FilterOptions m_filterOptions;
- CSwordBackend::DisplayOptions m_displayOptions;
+ FilterOptions m_filterOptions;
+ DisplayOptions m_displayOptions;
- BtDisplaySettingsButton* m_displaySettingsButton;
CKeyChooser* m_keyChooser;
CSwordKey* m_swordKey;
bool m_isReady;
BtModuleChooserBar* m_moduleChooserBar;
QToolBar* m_mainToolBar;
QToolBar* m_buttonsToolBar;
+ QToolBar* m_formatToolBar;
QToolBar* m_headerBar;
QMenu* m_popupMenu;
CDisplay* m_displayWidget;
+ BTHistory* m_history;
};
#endif
diff --git a/src/frontend/displaywindow/cdisplaywindowfactory.cpp b/src/frontend/displaywindow/cdisplaywindowfactory.cpp
index 05fa963..9e1b5f6 100644
--- a/src/frontend/displaywindow/cdisplaywindowfactory.cpp
+++ b/src/frontend/displaywindow/cdisplaywindowfactory.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2009 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -25,24 +25,29 @@
CReadWindow* CDisplayWindowFactory::createReadInstance(QList<CSwordModuleInfo*> modules, CMDIArea* parent) {
qDebug() << "CDisplayWindowFactory::createReadInstance";
+ CReadWindow* win = 0;
switch (modules.first()->type()) {
case CSwordModuleInfo::Bible:
- return new CBibleReadWindow(modules, parent);
+ win = new CBibleReadWindow(modules, parent);
+ break;
case CSwordModuleInfo::Commentary:
- return new CCommentaryReadWindow(modules, parent);
+ win = new CCommentaryReadWindow(modules, parent);
+ break;
case CSwordModuleInfo::Lexicon:
- return new CLexiconReadWindow(modules, parent);
+ win = new CLexiconReadWindow(modules, parent);
+ break;
case CSwordModuleInfo::GenericBook:
- return new CBookReadWindow(modules, parent);
+ win = new CBookReadWindow(modules, parent);
+ break;
default:
qWarning("unknown module type");
break;
}
- return 0;
+ return win;
}
-CWriteWindow* CDisplayWindowFactory::createWriteInstance(QList<CSwordModuleInfo*> modules, CMDIArea* parent, const CDisplayWindow::WriteWindowType type) {
- if (type == CDisplayWindow::HTMLWindow) {
+CWriteWindow* CDisplayWindowFactory::createWriteInstance(QList<CSwordModuleInfo*> modules, CMDIArea* parent, const CWriteWindow::WriteWindowType type) {
+ if (type == CWriteWindow::HTMLWindow) {
return new CHTMLWriteWindow(modules, parent);
}
else {
@@ -50,3 +55,15 @@ CWriteWindow* CDisplayWindowFactory::createWriteInstance(QList<CSwordModuleInfo*
}
return 0;
}
+
+const CSwordModuleInfo::ModuleType CDisplayWindowFactory::getModuleType(QObject* widget) {
+ if (qobject_cast<CBibleReadWindow*>(widget) != 0 )
+ return CSwordModuleInfo::Bible;
+ if (qobject_cast<CCommentaryReadWindow*>(widget) != 0 )
+ return CSwordModuleInfo::Commentary;
+ if (qobject_cast<CBookReadWindow*>(widget) != 0 )
+ return CSwordModuleInfo::GenericBook;
+ if (qobject_cast<CLexiconReadWindow*>(widget) != 0 )
+ return CSwordModuleInfo::Lexicon;
+ return CSwordModuleInfo::Unknown;
+}
diff --git a/src/frontend/displaywindow/cdisplaywindowfactory.h b/src/frontend/displaywindow/cdisplaywindowfactory.h
index b4d856a..06d9aa4 100644
--- a/src/frontend/displaywindow/cdisplaywindowfactory.h
+++ b/src/frontend/displaywindow/cdisplaywindowfactory.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2009 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -11,6 +11,7 @@
#define CDISPLAYWINDOWFACTORY_H
#include "frontend/displaywindow/cdisplaywindow.h"
+#include "frontend/displaywindow/cwritewindow.h"
class CMDIArea;
@@ -22,7 +23,8 @@ class CWriteWindow;
class CDisplayWindowFactory {
public:
static CReadWindow* createReadInstance(QList<CSwordModuleInfo*> modules, CMDIArea* parent);
- static CWriteWindow* createWriteInstance(QList<CSwordModuleInfo*> modules, CMDIArea* parent, const CDisplayWindow::WriteWindowType type = CDisplayWindow::HTMLWindow);
+ static CWriteWindow* createWriteInstance(QList<CSwordModuleInfo*> modules, CMDIArea* parent, const CWriteWindow::WriteWindowType type = CWriteWindow::HTMLWindow);
+ static const CSwordModuleInfo::ModuleType getModuleType(QObject* widget);
private:
CDisplayWindowFactory();
diff --git a/src/frontend/displaywindow/chtmlwritewindow.cpp b/src/frontend/displaywindow/chtmlwritewindow.cpp
index 31cb92b..df36080 100644
--- a/src/frontend/displaywindow/chtmlwritewindow.cpp
+++ b/src/frontend/displaywindow/chtmlwritewindow.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -11,10 +11,12 @@
#include <QAction>
#include <QToolBar>
+#include "bibletime.h"
#include "backend/keys/cswordkey.h"
#include "frontend/display/chtmlwritedisplay.h"
#include "frontend/display/cwritedisplay.h"
#include "frontend/displaywindow/btactioncollection.h"
+#include "frontend/displaywindow/btmodulechooserbar.h"
#include "frontend/keychooser/ckeychooser.h"
#include "frontend/profile/cprofilewindow.h"
#include "util/directory.h"
@@ -35,13 +37,25 @@ void CHTMLWriteWindow::initView() {
setDisplayWidget( writeDisplay );
setCentralWidget( displayWidget()->view() );
+ // Create Navigation toolbar
setMainToolBar( new QToolBar(this) );
- mainToolBar()->setAllowedAreas(Qt::TopToolBarArea);
- mainToolBar()->setFloatable(false);
addToolBar(mainToolBar());
- setKeyChooser( CKeyChooser::createInstance(modules(), key(), mainToolBar()) );
- mainToolBar()->addWidget(keyChooser());
+ // Create the Tools toolbar
+ setButtonsToolBar( new QToolBar(this) );
+ addToolBar(buttonsToolBar());
+
+ // Create the Format toolbar
+ setFormatToolBar( new QToolBar(this) );
+ addToolBar(formatToolBar());
+}
+
+void CHTMLWriteWindow::initActions() {
+ insertKeyboardActions(actionCollection());
+ CPlainWriteWindow::initActions();
+}
+
+void CHTMLWriteWindow::insertKeyboardActions( BtActionCollection* const a) {
}
void CHTMLWriteWindow::initConnections() {
@@ -54,76 +68,32 @@ void CHTMLWriteWindow::initConnections() {
void CHTMLWriteWindow::initToolbars() {
namespace DU = util::directory;
- //setup the main toolbar
- m_actions.syncWindow = new QAction(
- DU::getIcon(CResMgr::displaywindows::commentaryWindow::syncWindow::icon),
- tr("Sync with active Bible"),
- actionCollection()
- );
- m_actions.syncWindow->setCheckable(true);
- m_actions.syncWindow->setShortcut(CResMgr::displaywindows::commentaryWindow::syncWindow::accel);
- m_actions.syncWindow->setToolTip(tr("Synchronize (show the same verse) with the active Bible window"));
- actionCollection()->addAction(CResMgr::displaywindows::commentaryWindow::syncWindow::actionName, m_actions.syncWindow);
- mainToolBar()->addAction(m_actions.syncWindow);
-
- m_actions.saveText = new QAction(
- DU::getIcon(CResMgr::displaywindows::writeWindow::saveText::icon),
- tr("Save text"),
- actionCollection()
- );
- m_actions.saveText->setShortcut(CResMgr::displaywindows::writeWindow::saveText::accel);
- m_actions.saveText->setToolTip( tr("Save text") );
- QObject::connect(m_actions.saveText, SIGNAL(triggered()), this, SLOT( saveCurrentText() ) );
- actionCollection()->addAction(CResMgr::displaywindows::writeWindow::saveText::actionName, m_actions.saveText);
- mainToolBar()->addAction(m_actions.saveText);
-
-
- m_actions.deleteEntry = new QAction(
- DU::getIcon(CResMgr::displaywindows::writeWindow::deleteEntry::icon),
- tr("Delete current entry"),
- actionCollection()
- );
- m_actions.deleteEntry->setShortcut(CResMgr::displaywindows::writeWindow::deleteEntry::accel);
- m_actions.deleteEntry->setToolTip( tr("Delete current entry (no undo)") );
- QObject::connect(m_actions.deleteEntry, SIGNAL(triggered()), this, SLOT( deleteEntry() ) );
- actionCollection()->addAction(CResMgr::displaywindows::writeWindow::deleteEntry::actionName, m_actions.deleteEntry);
- mainToolBar()->addAction(m_actions.deleteEntry);
-
- m_actions.restoreText = new QAction(
- DU::getIcon(CResMgr::displaywindows::writeWindow::restoreText::icon),
- tr("Restore original text"),
- actionCollection()
- );
- m_actions.restoreText->setShortcut(CResMgr::displaywindows::writeWindow::restoreText::accel);
- m_actions.restoreText->setToolTip( tr("Restore original text, new text will be lost") );
- QObject::connect(m_actions.restoreText, SIGNAL(triggered()), this, SLOT( restoreText() ) );
- actionCollection()->addAction(CResMgr::displaywindows::writeWindow::restoreText::actionName, m_actions.restoreText);
- mainToolBar()->addAction(m_actions.restoreText);
-
- //html formatting toolbar
- QToolBar* bar = new QToolBar(this);
- bar->setAllowedAreas(Qt::TopToolBarArea);
- bar->setFloatable(false);
- ((CWriteDisplay*)displayWidget())->setupToolbar( bar, actionCollection() );
- addToolBar(bar);
+ CPlainWriteWindow::initToolbars();
+
+ //Formatting toolbar
+ ((CWriteDisplay*)displayWidget())->setupToolbar( formatToolBar(), actionCollection() );
}
void CHTMLWriteWindow::storeProfileSettings( CProfileWindow* profileWindow ) {
CWriteWindow::storeProfileSettings(profileWindow);
- profileWindow->setWindowSettings( m_actions.syncWindow->isChecked() );
+ QAction* action = actionCollection()->action(CResMgr::displaywindows::commentaryWindow::syncWindow::actionName);
+ profileWindow->setWindowSettings( action->isChecked() );
}
void CHTMLWriteWindow::applyProfileSettings( CProfileWindow* profileWindow ) {
CWriteWindow::applyProfileSettings(profileWindow);
if (profileWindow->windowSettings()) {
- m_actions.syncWindow->setChecked(true);
+ QAction* action = actionCollection()->action(CResMgr::displaywindows::commentaryWindow::syncWindow::actionName);
+ action->setChecked(true);
}
}
/** Is called when the current text was changed. */
void CHTMLWriteWindow::textChanged() {
- m_actions.saveText->setEnabled( ((CWriteDisplay*)displayWidget())->isModified() );
- m_actions.restoreText->setEnabled( ((CWriteDisplay*)displayWidget())->isModified() );
+ QAction* action = actionCollection()->action(CResMgr::displaywindows::writeWindow::saveText::actionName);
+ action->setEnabled( ((CWriteDisplay*)displayWidget())->isModified() );
+ action = actionCollection()->action(CResMgr::displaywindows::writeWindow::restoreText::actionName);
+ action->setEnabled( ((CWriteDisplay*)displayWidget())->isModified() );
}
/** Loads the original text from the module. */
@@ -134,7 +104,8 @@ void CHTMLWriteWindow::restoreText() {
}
bool CHTMLWriteWindow::syncAllowed() const {
- return m_actions.syncWindow->isChecked();
+ QAction* action = actionCollection()->action(CResMgr::displaywindows::commentaryWindow::syncWindow::actionName);
+ return action->isChecked();
}
/** Saves the text for the current key. Directly writes the changed text into the module. */
@@ -148,8 +119,8 @@ void CHTMLWriteWindow::saveCurrentText( const QString& /*key*/ ) {
const QString& oldKey = this->key()->key();
if ( modules().first()->isWritable() ) {
- modules().first()->write(this->key(), t );
- this->key()->key( oldKey );
+ const_cast<CSwordModuleInfo*>(modules().first())->write(this->key(), t);
+ this->key()->setKey(oldKey);
((CWriteDisplay*)displayWidget())->setModified(false);
textChanged();
@@ -161,3 +132,9 @@ void CHTMLWriteWindow::saveCurrentText( const QString& /*key*/ ) {
.arg( tr("Either the module may not be edited, or you do not have write permission.") ) );
}
}
+
+void CHTMLWriteWindow::setupMainWindowToolBars() {
+ CPlainWriteWindow::setupMainWindowToolBars();
+ //Formatting toolbar
+ ((CWriteDisplay*)displayWidget())->setupToolbar( btMainWindow()->formatToolBar(), actionCollection() );
+}
diff --git a/src/frontend/displaywindow/chtmlwritewindow.h b/src/frontend/displaywindow/chtmlwritewindow.h
index 4d140cf..b669f94 100644
--- a/src/frontend/displaywindow/chtmlwritewindow.h
+++ b/src/frontend/displaywindow/chtmlwritewindow.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -15,7 +15,11 @@
class QAction;
-/** The WYSIWYG implementation of the editor.
+/**
+ * The write window class which offers a WYSIWYG text editor for creating a personal commentary.
+ *
+ * Inherits CPlainWriteWindow.
+ *
* @author The BibleTime team
*/
class CHTMLWriteWindow : public CPlainWriteWindow {
@@ -28,11 +32,15 @@ class CHTMLWriteWindow : public CPlainWriteWindow {
* Store the settings of this window in the given CProfileWindow object.
*/
virtual void storeProfileSettings( Profile::CProfileWindow* );
+
/**
* Store the settings of this window in the given profile window.
*/
virtual void applyProfileSettings( Profile::CProfileWindow* );
+ /**
+ * Returns true if the sync toolbar is enabled.
+ */
virtual bool syncAllowed() const;
protected:
@@ -42,9 +50,20 @@ class CHTMLWriteWindow : public CPlainWriteWindow {
virtual void initView();
virtual void initConnections();
virtual void initToolbars();
- virtual CDisplayWindow::WriteWindowType writeWindowType() {
- return CDisplayWindow::HTMLWindow;
+ virtual void initActions();
+
+ /**
+ * Insert the keyboard accelerators of this window into the given KAccel object.
+ */
+ static void insertKeyboardActions( BtActionCollection* const a );
+
+ virtual CWriteWindow::WriteWindowType writeWindowType() {
+ return CWriteWindow::HTMLWindow;
}
+ /**
+ * Called to add actions to mainWindow toolbars
+ */
+ virtual void setupMainWindowToolBars();
protected slots:
/**
@@ -59,14 +78,6 @@ class CHTMLWriteWindow : public CPlainWriteWindow {
* Saves the text for the current key. Directly writes the changed text into the module.
*/
virtual void saveCurrentText( const QString& );
- private:
- struct {
- QAction* saveText;
- QAction* restoreText;
- QAction* deleteEntry;
- QAction* syncWindow;
- }
- m_actions;
};
#endif
diff --git a/src/frontend/displaywindow/clexiconreadwindow.cpp b/src/frontend/displaywindow/clexiconreadwindow.cpp
index 894c787..dae85e3 100644
--- a/src/frontend/displaywindow/clexiconreadwindow.cpp
+++ b/src/frontend/displaywindow/clexiconreadwindow.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2009 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -16,6 +16,7 @@
#include <QMenu>
#include <QDebug>
+#include "bibletime.h"
#include "backend/config/cbtconfig.h"
#include "backend/keys/cswordldkey.h"
#include "backend/keys/cswordkey.h"
@@ -154,7 +155,7 @@ void CLexiconReadWindow::initConnections() {
Q_ASSERT(keyChooser());
connect(keyChooser(), SIGNAL(keyChanged(CSwordKey*)), this, SLOT(lookupSwordKey(CSwordKey*)));
- connect(keyChooser()->history(), SIGNAL(historyChanged(bool, bool)), this, SLOT(slotUpdateHistoryButtons(bool, bool)));
+ connect(history(), SIGNAL(historyChanged(bool, bool)), this, SLOT(slotUpdateHistoryButtons(bool, bool)));
//connect the history actions to the right slots
bool ok = connect(
@@ -182,42 +183,81 @@ void CLexiconReadWindow::initConnections() {
void CLexiconReadWindow::initView() {
qDebug() << "CLexiconReadWindow::initView";
+
+ // Create display widget for this window
setDisplayWidget( CDisplay::createReadInstance(this) );
+ setCentralWidget( displayWidget()->view() );
+ setWindowIcon(util::tool::getIconForModule(modules().first()));
+
+ // Create the Navigation toolbar
setMainToolBar( new QToolBar(this) );
addToolBar(mainToolBar());
- setKeyChooser( CKeyChooser::createInstance(modules(), key(), mainToolBar()) );
- mainToolBar()->addWidget(keyChooser());
- setModuleChooserBar( new BtModuleChooserBar(getModuleList(), modules().first()->type(), this) );
+
+ // Create keychooser
+ setKeyChooser( CKeyChooser::createInstance(modules(), history(), key(), mainToolBar()) );
+
+ // Create the Works toolbar
+ setModuleChooserBar( new BtModuleChooserBar(this));
+ moduleChooserBar()->setModules(getModuleList(), modules().first()->type(), this);
addToolBar(moduleChooserBar());
+
+ // Create the Tools toolbar
setButtonsToolBar( new QToolBar(this) );
addToolBar(buttonsToolBar());
+
+ // Create the Text Header toolbar
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() );
}
void CLexiconReadWindow::initToolbars() {
- //main toolbar
+ //Navigation toolbar
Q_ASSERT(m_actions.backInHistory);
+ mainToolBar()->addWidget(keyChooser());
mainToolBar()->addAction(m_actions.backInHistory); //1st button
mainToolBar()->addAction(m_actions.forwardInHistory); //2nd button
- //buttons toolbar
+ //Tools toolbar
QAction* action = qobject_cast<QAction*>(actionCollection()->action(
CResMgr::displaywindows::general::search::actionName));
Q_ASSERT( action );
if (action) {
buttonsToolBar()->addAction(action);
}
+ BtDisplaySettingsButton* button = new BtDisplaySettingsButton(buttonsToolBar());
+ setDisplaySettingsButton(button);
+ buttonsToolBar()->addWidget(button);
- setDisplaySettingsButton(new BtDisplaySettingsButton(buttonsToolBar()));
+ // Text Header toolbar
+ BtTextWindowHeader *h = new BtTextWindowHeader(modules().first()->type(), getModuleList(), this);
+ headerBar()->addWidget(h);
+}
- /// \todo find the right place for the button
- buttonsToolBar()->addWidget(displaySettingsButton());
+void CLexiconReadWindow::setupMainWindowToolBars() {
+ // Navigation toolbar
+ CKeyChooser* keyChooser = CKeyChooser::createInstance(modules(), history(), key(), btMainWindow()->navToolBar() );
+ btMainWindow()->navToolBar()->addWidget(keyChooser);
+ bool ok = connect(keyChooser, SIGNAL(keyChanged(CSwordKey*)), this, SLOT(lookupSwordKey(CSwordKey*)));
+ Q_ASSERT(ok);
+ ok = connect(this, SIGNAL(sigKeyChanged(CSwordKey*)), keyChooser, SLOT(updateKey(CSwordKey*)) );
+ Q_ASSERT(ok);
+ btMainWindow()->navToolBar()->addAction(m_actions.backInHistory); //1st button
+ btMainWindow()->navToolBar()->addAction(m_actions.forwardInHistory); //2nd button
+
+ // Works toolbar
+ btMainWindow()->worksToolBar()->setModules(getModuleList(), modules().first()->type(), this);
+
+ // Tools toolbar
+ QAction* action = actionCollection()->action(
+ CResMgr::displaywindows::general::search::actionName);
+ Q_ASSERT( action );
+ if (action) {
+ btMainWindow()->toolsToolBar()->addAction(action);
+ }
+ BtDisplaySettingsButton* button = new BtDisplaySettingsButton(buttonsToolBar());
+ setDisplaySettingsButton(button);
+ btMainWindow()->toolsToolBar()->addWidget(button);
}
void CLexiconReadWindow::setupPopupMenu() {
diff --git a/src/frontend/displaywindow/clexiconreadwindow.h b/src/frontend/displaywindow/clexiconreadwindow.h
index 2a32cec..36b47db 100644
--- a/src/frontend/displaywindow/clexiconreadwindow.h
+++ b/src/frontend/displaywindow/clexiconreadwindow.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2009 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -22,26 +22,21 @@ class CSwordKey;
class QAction;
class QMenu;
-/**
- *@author The BibleTime team
+/** The class used to display lexicons. It is also used as the class that other display window types are derived from.
+ *
+ * Inherits CReadWindow.
+ *
+ * Inherited by CBibleReadWindow, CBookReadWindow, and CCommentaryReadWindow.
+ *
+ * @author The BibleTime team
*/
class CLexiconReadWindow : public CReadWindow {
Q_OBJECT
public:
CLexiconReadWindow(QList<CSwordModuleInfo*> modules, CMDIArea* parent);
virtual ~CLexiconReadWindow();
- /**
- * Store the settings of this window in the given CProfileWindow object.
- */
- // virtual void storeProfileSettings( CProfileWindow* profileWindow );
- /**
- * Store the settings of this window in the given profile window.
- */
- // virtual void applyProfileSettings( CProfileWindow* profileWindow );
- /**
- * Reimplementation.
- */
- // static void insertKeyboardActions( KAccel* a );
+
+ /** Insert the keyboard accelerators of this window into the given actioncollection.*/
static void insertKeyboardActions( BtActionCollection* const a );
public slots:
@@ -58,6 +53,8 @@ class CLexiconReadWindow : public CReadWindow {
virtual void updatePopupMenu();
virtual void setupPopupMenu();
+ /** Called to add actions to mainWindow toolbars */
+ virtual void setupMainWindowToolBars();
struct ActionsStruct {
BtToolBarPopupAction* backInHistory;
diff --git a/src/frontend/displaywindow/cplainwritewindow.cpp b/src/frontend/displaywindow/cplainwritewindow.cpp
index 6394998..ad3b978 100644
--- a/src/frontend/displaywindow/cplainwritewindow.cpp
+++ b/src/frontend/displaywindow/cplainwritewindow.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -13,10 +13,12 @@
#include <QDebug>
#include <QRegExp>
#include <QToolBar>
+#include "bibletime.h"
#include "backend/config/cbtconfig.h"
#include "backend/keys/cswordkey.h"
#include "frontend/display/cwritedisplay.h"
#include "frontend/displaywindow/btactioncollection.h"
+#include "frontend/displaywindow/btmodulechooserbar.h"
#include "frontend/keychooser/ckeychooser.h"
#include "frontend/profile/cprofilewindow.h"
#include "util/cresmgr.h"
@@ -40,69 +42,52 @@ void CPlainWriteWindow::initView() {
setDisplayWidget( CDisplay::createWriteInstance(this) );
setCentralWidget( displayWidget()->view() );
+ // Create Navigation toolbar
setMainToolBar( new QToolBar(this) );
- mainToolBar()->setAllowedAreas(Qt::TopToolBarArea);
- mainToolBar()->setFloatable(false);
addToolBar(mainToolBar());
- addToolBarBreak();
- setKeyChooser( CKeyChooser::createInstance(modules(), key(), mainToolBar()) );
- mainToolBar()->addWidget(keyChooser());
+ // Create the Tools toolbar
+ setButtonsToolBar( new QToolBar(this) );
+ addToolBar(buttonsToolBar());
}
void CPlainWriteWindow::initToolbars() {
namespace DU = util::directory;
- m_actions.syncWindow = new QAction(
- //KIcon(CResMgr::displaywindows::commentaryWindow::syncWindow::icon),
- DU::getIcon(CResMgr::displaywindows::commentaryWindow::syncWindow::icon),
- tr("Sync with active Bible"),
- actionCollection()
- );
- m_actions.syncWindow->setCheckable(true);
- m_actions.syncWindow->setShortcut(CResMgr::displaywindows::commentaryWindow::syncWindow::accel);
- m_actions.syncWindow->setToolTip(tr("Synchronize (show the same verse) with the active Bible window"));
- mainToolBar()->addAction(m_actions.syncWindow);
- actionCollection()->addAction(CResMgr::displaywindows::commentaryWindow::syncWindow::actionName, m_actions.syncWindow);
-
-
- m_actions.saveText = new QAction(
- //KIcon(CResMgr::displaywindows::writeWindow::saveText::icon),
- DU::getIcon(CResMgr::displaywindows::writeWindow::saveText::icon),
- tr("Save text"),
- actionCollection()
- );
- m_actions.saveText->setShortcut(CResMgr::displaywindows::writeWindow::saveText::accel);
- QObject::connect(m_actions.saveText, SIGNAL(triggered()), this, SLOT(saveCurrentText()));
- m_actions.saveText->setToolTip( tr("Save text") );
- actionCollection()->addAction(CResMgr::displaywindows::writeWindow::saveText::actionName, m_actions.saveText);
- mainToolBar()->addAction(m_actions.saveText);
-
-
- m_actions.deleteEntry = new QAction(
- //KIcon(CResMgr::displaywindows::writeWindow::deleteEntry::icon),
- DU::getIcon(CResMgr::displaywindows::writeWindow::deleteEntry::icon),
- tr("Delete current entry"),
- actionCollection()
- );
- m_actions.deleteEntry->setShortcut(CResMgr::displaywindows::writeWindow::deleteEntry::accel);
- QObject::connect(m_actions.deleteEntry, SIGNAL(triggered()), this, SLOT(deleteEntry()) );
- m_actions.deleteEntry->setToolTip( tr("Delete current entry (no undo)") );
- actionCollection()->addAction(CResMgr::displaywindows::writeWindow::deleteEntry::actionName, m_actions.deleteEntry);
- mainToolBar()->addAction(m_actions.deleteEntry);
+ // Navigation toolbar
+ setKeyChooser( CKeyChooser::createInstance(modules(),
+ history(), key(), mainToolBar()) );
+ mainToolBar()->addWidget(keyChooser());
+ // Tools toolbar
+ QAction* action = actionCollection()->action(CResMgr::displaywindows::commentaryWindow::syncWindow::actionName);
+ buttonsToolBar()->addAction(action);
+ action = actionCollection()->action(CResMgr::displaywindows::writeWindow::saveText::actionName);
+ buttonsToolBar()->addAction(action);
+ action = actionCollection()->action(CResMgr::displaywindows::writeWindow::deleteEntry::actionName);
+ buttonsToolBar()->addAction(action);
+ action = actionCollection()->action(CResMgr::displaywindows::writeWindow::restoreText::actionName);
+ buttonsToolBar()->addAction(action);
+}
- m_actions.restoreText = new QAction(
- //KIcon(CResMgr::displaywindows::writeWindow::restoreText::icon),
- DU::getIcon(CResMgr::displaywindows::writeWindow::restoreText::icon),
- tr("Restore original text"),
- actionCollection()
- );
- m_actions.restoreText->setShortcut(CResMgr::displaywindows::writeWindow::restoreText::accel);
- QObject::connect(m_actions.restoreText, SIGNAL(triggered()), this, SLOT(restoreText()) );
- m_actions.restoreText->setToolTip( tr("Restore original text, new text will be lost") );
- actionCollection()->addAction(CResMgr::displaywindows::writeWindow::restoreText::actionName, m_actions.restoreText);
- mainToolBar()->addAction(m_actions.restoreText);
+void CPlainWriteWindow::setupMainWindowToolBars() {
+ // Navigation toolbar
+ CKeyChooser* keyChooser = CKeyChooser::createInstance(modules(), history(), key(), btMainWindow()->navToolBar() );
+ btMainWindow()->navToolBar()->addWidget(keyChooser);
+ bool ok = connect(keyChooser, SIGNAL(keyChanged(CSwordKey*)), this, SLOT(lookupSwordKey(CSwordKey*)));
+ Q_ASSERT(ok);
+ ok = connect(keyChooser, SIGNAL(beforeKeyChange(const QString&)), this, SLOT(beforeKeyChange(const QString&)));
+ Q_ASSERT(ok);
+
+ // Tools toolbar
+ QAction* action = actionCollection()->action(CResMgr::displaywindows::commentaryWindow::syncWindow::actionName);
+ btMainWindow()->toolsToolBar()->addAction(action);
+ action = actionCollection()->action(CResMgr::displaywindows::writeWindow::saveText::actionName);
+ btMainWindow()->toolsToolBar()->addAction(action);
+ action = actionCollection()->action(CResMgr::displaywindows::writeWindow::deleteEntry::actionName);
+ btMainWindow()->toolsToolBar()->addAction(action);
+ action = actionCollection()->action(CResMgr::displaywindows::writeWindow::restoreText::actionName);
+ btMainWindow()->toolsToolBar()->addAction(action);
}
void CPlainWriteWindow::initConnections() {
@@ -113,13 +98,15 @@ void CPlainWriteWindow::initConnections() {
void CPlainWriteWindow::storeProfileSettings( CProfileWindow* profileWindow ) {
CWriteWindow::storeProfileSettings(profileWindow);
- profileWindow->setWindowSettings( m_actions.syncWindow->isChecked() );
+ QAction* action = actionCollection()->action(CResMgr::displaywindows::commentaryWindow::syncWindow::actionName);
+ profileWindow->setWindowSettings( action->isChecked() );
}
void CPlainWriteWindow::applyProfileSettings( CProfileWindow* profileWindow ) {
CWriteWindow::applyProfileSettings(profileWindow);
if (profileWindow->windowSettings()) {
- m_actions.syncWindow->setChecked(true);
+ QAction* action = actionCollection()->action(CResMgr::displaywindows::commentaryWindow::syncWindow::actionName);
+ action->setChecked(true);
}
}
@@ -134,8 +121,8 @@ void CPlainWriteWindow::saveCurrentText( const QString& /*key*/ ) {
const QString& oldKey = this->key()->key();
if ( modules().first()->isWritable() ) {
- modules().first()->write(this->key(), t );
- this->key()->key( oldKey );
+ const_cast<CSwordModuleInfo*>(modules().first())->write(this->key(), t);
+ this->key()->setKey(oldKey);
((CWriteDisplay*)displayWidget())->setModified(false);
textChanged();
@@ -158,13 +145,15 @@ void CPlainWriteWindow::restoreText() {
/** Is called when the current text was changed. */
void CPlainWriteWindow::textChanged() {
- m_actions.saveText->setEnabled( ((CWriteDisplay*)displayWidget())->isModified() );
- m_actions.restoreText->setEnabled( ((CWriteDisplay*)displayWidget())->isModified() );
+ QAction* action = actionCollection()->action(CResMgr::displaywindows::writeWindow::saveText::actionName);
+ action->setEnabled( ((CWriteDisplay*)displayWidget())->isModified() );
+ action = actionCollection()->action(CResMgr::displaywindows::writeWindow::restoreText::actionName);
+ action->setEnabled( ((CWriteDisplay*)displayWidget())->isModified() );
}
/** Deletes the module entry and clears the edit widget, */
void CPlainWriteWindow::deleteEntry() {
- modules().first()->deleteEntry( key() );
+ const_cast<CSwordModuleInfo*>(modules().first())->deleteEntry(key());
lookupSwordKey( key() );
((CWriteDisplay*)displayWidget())->setModified(false);
}
@@ -173,11 +162,68 @@ void CPlainWriteWindow::deleteEntry() {
void CPlainWriteWindow::setupPopupMenu() {}
bool CPlainWriteWindow::syncAllowed() const {
- return m_actions.syncWindow->isChecked();
+ QAction* action = actionCollection()->action(CResMgr::displaywindows::commentaryWindow::syncWindow::actionName);
+ return action->isChecked();
}
void CPlainWriteWindow::initActions() {
+ insertKeyboardActions(actionCollection());
+
+ QAction* action = actionCollection()->action(CResMgr::displaywindows::commentaryWindow::syncWindow::actionName);
+ bool ok = QObject::connect(action, SIGNAL(triggered()), this, SLOT(saveCurrentText()));
+ Q_ASSERT(ok);
+
+ action = actionCollection()->action(CResMgr::displaywindows::writeWindow::saveText::actionName);
+ ok = QObject::connect(action, SIGNAL(triggered()), this, SLOT(saveCurrentText()));
+ Q_ASSERT(ok);
+
+ action = actionCollection()->action(CResMgr::displaywindows::writeWindow::deleteEntry::actionName);
+ ok = QObject::connect(action, SIGNAL(triggered()), this, SLOT(deleteEntry()) );
+ Q_ASSERT(ok);
+
+ action = actionCollection()->action(CResMgr::displaywindows::writeWindow::restoreText::actionName);
+ ok = QObject::connect(action, SIGNAL(triggered()), this, SLOT(restoreText()) );
+ Q_ASSERT(ok);
}
-void CPlainWriteWindow::insertKeyboardActions( BtActionCollection* const ) {
+void CPlainWriteWindow::insertKeyboardActions( BtActionCollection* const a) {
+
+ namespace DU = util::directory;
+
+ QAction* action = new QAction(
+ DU::getIcon(CResMgr::displaywindows::commentaryWindow::syncWindow::icon),
+ tr("Sync with active Bible"),
+ a
+ );
+ action->setCheckable(true);
+ action->setShortcut(CResMgr::displaywindows::commentaryWindow::syncWindow::accel);
+ action->setToolTip(tr("Synchronize (show the same verse) with the active Bible window"));
+ a->addAction(CResMgr::displaywindows::commentaryWindow::syncWindow::actionName, action);
+
+ action = new QAction(
+ DU::getIcon(CResMgr::displaywindows::writeWindow::saveText::icon),
+ tr("Save text"),
+ a
+ );
+ action->setShortcut(CResMgr::displaywindows::writeWindow::saveText::accel);
+ action->setToolTip( tr("Save text") );
+ a->addAction(CResMgr::displaywindows::writeWindow::saveText::actionName, action);
+
+ action = new QAction(
+ DU::getIcon(CResMgr::displaywindows::writeWindow::deleteEntry::icon),
+ tr("Delete current entry"),
+ a
+ );
+ action->setShortcut(CResMgr::displaywindows::writeWindow::deleteEntry::accel);
+ action->setToolTip( tr("Delete current entry (no undo)") );
+ a->addAction(CResMgr::displaywindows::writeWindow::deleteEntry::actionName, action);
+
+ action = new QAction(
+ DU::getIcon(CResMgr::displaywindows::writeWindow::restoreText::icon),
+ tr("Restore original text"),
+ a
+ );
+ action->setShortcut(CResMgr::displaywindows::writeWindow::restoreText::accel);
+ action->setToolTip( tr("Restore original text, new text will be lost") );
+ a->addAction(CResMgr::displaywindows::writeWindow::restoreText::actionName, action);
}
diff --git a/src/frontend/displaywindow/cplainwritewindow.h b/src/frontend/displaywindow/cplainwritewindow.h
index ec9fe5e..9d3f29c 100644
--- a/src/frontend/displaywindow/cplainwritewindow.h
+++ b/src/frontend/displaywindow/cplainwritewindow.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -17,7 +17,12 @@ class BtActionCollection;
class QAction;
class QString;
-/** The write window class which offers a plain editor for source code editing.
+/** The write window class which offers a plain text editor for creating a personal commentary.
+ *
+ * Inherits CWriteWindow.
+ *
+ * Inherited by CHTMLWriteWindow.
+ *
* @author The BibleTime team
*/
class CPlainWriteWindow : public CWriteWindow {
@@ -39,6 +44,10 @@ class CPlainWriteWindow : public CWriteWindow {
* Setups the popup menu of this display widget.
*/
virtual void setupPopupMenu();
+
+ /**
+ * Returns true if the sync toolbar is enabled.
+ */
virtual bool syncAllowed() const;
protected: // Protected methods
@@ -48,10 +57,12 @@ class CPlainWriteWindow : public CWriteWindow {
virtual void initView();
virtual void initConnections();
virtual void initToolbars();
- virtual CDisplayWindow::WriteWindowType writeWindowType() {
- return CDisplayWindow::PlainTextWindow;
+ virtual CWriteWindow::WriteWindowType writeWindowType() {
+ return CWriteWindow::PlainTextWindow;
};
+ /** Called to add actions to mainWindow toolbars */
+ virtual void setupMainWindowToolBars();
/**
* Initializes the intern keyboard actions.
*/
@@ -61,15 +72,6 @@ class CPlainWriteWindow : public CWriteWindow {
*/
static void insertKeyboardActions( BtActionCollection* const a );
- private:
- struct {
- QAction* saveText;
- QAction* deleteEntry;
- QAction* restoreText;
- QAction* syncWindow;
- }
- m_actions;
-
protected slots: // Protected slots
/**
* Saves the text for the current key. Directly writes the changed text into the module.
diff --git a/src/frontend/displaywindow/creadwindow.cpp b/src/frontend/displaywindow/creadwindow.cpp
index 07c0abb..4c18b0b 100644
--- a/src/frontend/displaywindow/creadwindow.cpp
+++ b/src/frontend/displaywindow/creadwindow.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -83,13 +83,13 @@ void CReadWindow::lookupSwordKey( CSwordKey* newKey ) {
using namespace Rendering;
-// Q_ASSERT(isReady() && newKey && modules().first());
+// Q_ASSERT(isReady() && newKey && modules().first());
if (!isReady() || !newKey || modules().empty() || !modules().first()) {
return;
}
if (key() != newKey) {
- key()->key(newKey->key());
+ key()->setKey(newKey->key());
}
/// \todo next-TODO how about options?
@@ -146,11 +146,8 @@ void CReadWindow::storeProfileSettings(CProfileWindow * const settings) {
}
QStringList mods;
-
- QList<CSwordModuleInfo*> allMods = modules();
- QList<CSwordModuleInfo*>::iterator end_it = allMods.end();
- for (QList<CSwordModuleInfo*>::iterator it(allMods.begin()); it != end_it; ++it) {
- mods.append((*it)->name());
+ Q_FOREACH (const CSwordModuleInfo *module, modules()) {
+ mods.append(module->name());
}
settings->setModules(mods);
}
@@ -191,7 +188,7 @@ void CReadWindow::resizeEvent(QResizeEvent* /*e*/) {
}
void CReadWindow::openSearchStrongsDialog() {
-// qWarning("looking for lemma %s", displayWidget()->getCurrentNodeInfo()[CDisplay::Lemma].latin1() );
+// qWarning("looking for lemma %s", displayWidget()->getCurrentNodeInfo()[CDisplay::Lemma].latin1() );
QString searchText = QString::null;
if (displayWidget()->getCurrentNodeInfo()[CDisplay::Lemma] != QString::null) {
diff --git a/src/frontend/displaywindow/creadwindow.h b/src/frontend/displaywindow/creadwindow.h
index 7a529b8..855baa2 100644
--- a/src/frontend/displaywindow/creadwindow.h
+++ b/src/frontend/displaywindow/creadwindow.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -20,12 +20,18 @@ class BtActionCollection;
class QResizeEvent;
/** The base class for all read-only display windows.
+ *
+ * Inherits CDisplayWindow.
+ *
+ * Inherited by CLexiconReadWindow
+ *
* @author The BibleTime team
*/
class CReadWindow : public CDisplayWindow {
Q_OBJECT
public:
+ /** Insert the keyboard accelerators of this window into the given actioncollection.*/
static void insertKeyboardActions( BtActionCollection* const a );
CReadWindow(QList<CSwordModuleInfo*> modules, CMDIArea* parent);
@@ -35,7 +41,7 @@ class CReadWindow : public CDisplayWindow {
*/
virtual void storeProfileSettings(Profile::CProfileWindow * const settings);
/**
- * Store the settings of this window in the given CProfileWindow object.
+ * Load the settings the given CProfileWindow object into this window.
*/
virtual void applyProfileSettings(Profile::CProfileWindow * const settings);
@@ -45,9 +51,13 @@ class CReadWindow : public CDisplayWindow {
*/
virtual void setDisplayWidget( CDisplay* newDisplay );
/**
+ * Reimplemented Qt function for resize of window.
*/
virtual void resizeEvent(QResizeEvent* e);
+ /** Called to add actions to mainWindow toolbars.*/
+ virtual void setupMainWindowToolBars() = 0;
+
protected slots:
/**
* Load the text using the key
@@ -62,8 +72,8 @@ class CReadWindow : public CDisplayWindow {
* Update the status of the popup menu entries.
*/
virtual void copyDisplayedText();
- /** Open the search dialog with the strong info of the last clicked word.
- *
+ /**
+ * Open the search dialog with the strong info of the last clicked word.
*/
void openSearchStrongsDialog();
diff --git a/src/frontend/displaywindow/cwritewindow.cpp b/src/frontend/displaywindow/cwritewindow.cpp
index 7496dd7..3369d8a 100644
--- a/src/frontend/displaywindow/cwritewindow.cpp
+++ b/src/frontend/displaywindow/cwritewindow.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -65,10 +65,8 @@ void CWriteWindow::storeProfileSettings(CProfileWindow * const settings) {
}
QStringList mods;
- QList<CSwordModuleInfo*> allMods = modules();
- QList<CSwordModuleInfo*>::iterator end_it = allMods.end();
- for (QList<CSwordModuleInfo*>::iterator it(allMods.begin()); it != end_it; ++it) {
- mods.append((*it)->name());
+ Q_FOREACH(const CSwordModuleInfo *m, modules()) {
+ mods.append(m->name());
}
settings->setModules(mods);
}
@@ -103,7 +101,7 @@ void CWriteWindow::lookupSwordKey( CSwordKey* newKey ) {
return;
if (key() != newKey) { //set passage of newKey to key() if they're different, otherwise we'd get mixed up if we look up newkey which may have a different module set
- key()->key(newKey->key());
+ key()->setKey(newKey->key());
}
if ( modules().count() ) {
diff --git a/src/frontend/displaywindow/cwritewindow.h b/src/frontend/displaywindow/cwritewindow.h
index 5d6a316..7a5a524 100644
--- a/src/frontend/displaywindow/cwritewindow.h
+++ b/src/frontend/displaywindow/cwritewindow.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -18,11 +18,22 @@ class CWriteDisplay;
class QString;
/** The base class for all write-only display windows.
+ *
+ * Inherits CDisplayWindow.
+ *
+ * Inherited by CPlainWriteWindow.
+ *
*@author The BibleTime team
*/
class CWriteWindow : public CDisplayWindow {
Q_OBJECT
public:
+ enum WriteWindowType {
+ HTMLWindow = 1,
+ PlainTextWindow = 2
+ };
+
+ /** Insert the keyboard accelerators of this window into the given actioncollection.*/
static void insertKeyboardActions( BtActionCollection* const a );
CWriteWindow(QList<CSwordModuleInfo*> modules, CMDIArea* parent);
@@ -32,10 +43,14 @@ class CWriteWindow : public CDisplayWindow {
*/
virtual void storeProfileSettings(Profile::CProfileWindow * const settings);
/**
- * Store the settings of this window in the given CProfileWindow object.
+ * Load the settings the given CProfileWindow object into this window.
*/
virtual void applyProfileSettings(Profile::CProfileWindow * const settings);
+
+ /** Initializes the signal / slot connections of this display window.*/
virtual void initConnections();
+
+ /** Initializes the internel keyboard actions.*/
virtual void initActions();
public slots:
@@ -47,14 +62,22 @@ class CWriteWindow : public CDisplayWindow {
protected: // Protected methods
/**
- * Saves the given text as text of the given key. Use this function
- * as backend in each write window implementation.
+ * Set the displayWidget which is a subclass of QWebPage.
*/
void setDisplayWidget( CDisplay* display );
- virtual CDisplayWindow::WriteWindowType writeWindowType() = 0;
+
+ /** Returns the type of the write window.*/
+ virtual CWriteWindow::WriteWindowType writeWindowType() = 0;
+
+ /** Returns true if the window may be closed.*/
virtual bool queryClose();
+
+ /** Saves the text for the current key. Directly writes the changed text into the module. */
virtual void saveCurrentText( const QString& key ) = 0;
+ /** Called to add actions to mainWindow toolbars */
+ virtual void setupMainWindowToolBars() = 0;
+
protected slots:
/** Save text to the module
*/