summaryrefslogtreecommitdiff
path: root/src/frontend/displaywindow
diff options
context:
space:
mode:
authorRoberto C. Sanchez <roberto@connexer.com>2014-10-21 22:48:19 -0400
committerRoberto C. Sanchez <roberto@connexer.com>2014-10-21 22:48:19 -0400
commit1af3b165c9377702ca62a64112bc089a6f575c30 (patch)
tree4df9cca5543b2cab5ca56dbb1214d7d3b1f291e3 /src/frontend/displaywindow
parent5b5fd0dce407556f98ed8edee89dc830bf1437b1 (diff)
Imported Upstream version 2.0~beta2
Diffstat (limited to 'src/frontend/displaywindow')
-rw-r--r--src/frontend/displaywindow/btactioncollection.cpp38
-rw-r--r--src/frontend/displaywindow/btactioncollection.h32
-rw-r--r--src/frontend/displaywindow/bttoolbarpopupaction.cpp51
-rw-r--r--src/frontend/displaywindow/bttoolbarpopupaction.h45
-rw-r--r--src/frontend/displaywindow/cbiblereadwindow.cpp480
-rw-r--r--src/frontend/displaywindow/cbiblereadwindow.h144
-rw-r--r--src/frontend/displaywindow/cbookreadwindow.cpp195
-rw-r--r--src/frontend/displaywindow/cbookreadwindow.h69
-rw-r--r--src/frontend/displaywindow/cbuttons.cpp191
-rw-r--r--src/frontend/displaywindow/cbuttons.h77
-rw-r--r--src/frontend/displaywindow/ccommentaryreadwindow.cpp198
-rw-r--r--src/frontend/displaywindow/ccommentaryreadwindow.h72
-rw-r--r--src/frontend/displaywindow/cdisplaywindow.cpp497
-rw-r--r--src/frontend/displaywindow/cdisplaywindow.h264
-rw-r--r--src/frontend/displaywindow/cdisplaywindowfactory.cpp57
-rw-r--r--src/frontend/displaywindow/cdisplaywindowfactory.h34
-rw-r--r--src/frontend/displaywindow/chtmlwritewindow.cpp163
-rw-r--r--src/frontend/displaywindow/chtmlwritewindow.h75
-rw-r--r--src/frontend/displaywindow/clexiconreadwindow.cpp367
-rw-r--r--src/frontend/displaywindow/clexiconreadwindow.h118
-rw-r--r--src/frontend/displaywindow/cmodulechooserbar.cpp127
-rw-r--r--src/frontend/displaywindow/cmodulechooserbar.h77
-rw-r--r--src/frontend/displaywindow/cmodulechooserbutton.cpp211
-rw-r--r--src/frontend/displaywindow/cmodulechooserbutton.h82
-rw-r--r--src/frontend/displaywindow/cplainwritewindow.cpp183
-rw-r--r--src/frontend/displaywindow/cplainwritewindow.h96
-rw-r--r--src/frontend/displaywindow/creadwindow.cpp205
-rw-r--r--src/frontend/displaywindow/creadwindow.h79
-rw-r--r--src/frontend/displaywindow/cwritewindow.cpp161
-rw-r--r--src/frontend/displaywindow/cwritewindow.h72
30 files changed, 4460 insertions, 0 deletions
diff --git a/src/frontend/displaywindow/btactioncollection.cpp b/src/frontend/displaywindow/btactioncollection.cpp
new file mode 100644
index 0000000..f71709a
--- /dev/null
+++ b/src/frontend/displaywindow/btactioncollection.cpp
@@ -0,0 +1,38 @@
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2009 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+#include "btactioncollection.h"
+
+BtActionCollection::BtActionCollection(QObject* parent)
+ : QObject(parent)
+{
+}
+
+BtActionCollection::~BtActionCollection()
+{
+}
+
+QAction* BtActionCollection::action(const QString& name)
+{
+ Q_ASSERT(m_actions[name] != 0);
+ return m_actions[name];
+}
+
+void BtActionCollection::addAction(const QString& name, QAction* action)
+{
+ Q_ASSERT(action != 0);
+// Q_ASSERT(m_actions[name] == 0); // TODO - replacing actions is ok???
+ m_actions[name] = action;
+}
+
+void BtActionCollection::addAction(const QString &name, const QObject *receiver)
+{
+}
+
+
diff --git a/src/frontend/displaywindow/btactioncollection.h b/src/frontend/displaywindow/btactioncollection.h
new file mode 100644
index 0000000..23ee1cf
--- /dev/null
+++ b/src/frontend/displaywindow/btactioncollection.h
@@ -0,0 +1,32 @@
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2009 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+#ifndef BT_ACTION_COLLECTION_S
+#define BT_ACTION_COLLECTION_S
+
+#include <QObject>
+#include <QMap>
+
+class QString;
+class QAction;
+
+class BtActionCollection : public QObject
+{
+ Q_OBJECT
+public:
+ BtActionCollection(QObject* parent);
+ ~BtActionCollection();
+ void addAction(const QString& name, QAction* action);
+ void addAction(const QString &name, const QObject *receiver);
+ QAction* action(const QString& name);
+
+private:
+ QMap<QString, QAction*> m_actions;
+};
+
+#endif
diff --git a/src/frontend/displaywindow/bttoolbarpopupaction.cpp b/src/frontend/displaywindow/bttoolbarpopupaction.cpp
new file mode 100644
index 0000000..907a779
--- /dev/null
+++ b/src/frontend/displaywindow/bttoolbarpopupaction.cpp
@@ -0,0 +1,51 @@
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2009 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+#include "bttoolbarpopupaction.h"
+#include <QMenu>
+#include <QToolButton>
+#include <QAction>
+
+// 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
+// menu when clicked. The menu is typicallly populated with history actions.
+BtToolBarPopupAction::BtToolBarPopupAction(const QIcon& icon, const QString& text, QObject* parent)
+ : QWidgetAction(parent), m_icon(icon), m_text(text)
+{
+ m_menu = new QMenu();
+}
+
+BtToolBarPopupAction::~BtToolBarPopupAction()
+{
+ delete m_menu;
+}
+
+QMenu* BtToolBarPopupAction::popupMenu() const
+{
+ return m_menu;
+}
+
+QWidget* BtToolBarPopupAction::createWidget(QWidget* parent)
+{
+ m_button = new QToolButton(parent);
+ setIcon(m_icon);
+ setToolTip(m_text);
+ m_button->setDefaultAction(this);
+ m_button->setPopupMode(QToolButton::MenuButtonPopup);
+ m_button->setMenu(m_menu);
+ bool ok = connect(m_button, SIGNAL(pressed()), this, SLOT(buttonPressed()));
+ Q_ASSERT(ok);;
+ return m_button;
+}
+
+void BtToolBarPopupAction::buttonPressed()
+{
+ emit triggered();
+}
+
diff --git a/src/frontend/displaywindow/bttoolbarpopupaction.h b/src/frontend/displaywindow/bttoolbarpopupaction.h
new file mode 100644
index 0000000..63ed491
--- /dev/null
+++ b/src/frontend/displaywindow/bttoolbarpopupaction.h
@@ -0,0 +1,45 @@
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2009 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+#ifndef BT_TOOLBAR_POPUP_ACTION_H
+#define BT_TOOLBAR_POPUP_ACTION_H
+
+#include <QWidgetAction>
+
+class QMenu;
+class QString;
+class QIcon;
+class QToolButton;
+
+// This class manages the toolbar display for going forward and backward in history.
+class BtToolBarPopupAction : public QWidgetAction
+{
+ Q_OBJECT
+public:
+
+ BtToolBarPopupAction(const QIcon& icon, const QString& text, QObject* parent);
+ ~BtToolBarPopupAction();
+ QMenu* popupMenu() const;
+
+signals:
+ void triggered();
+
+protected:
+ QWidget* createWidget(QWidget* parent);
+
+private slots:
+ void buttonPressed();
+
+private:
+ QMenu* m_menu;
+ QToolButton* m_button;
+ QIcon m_icon;
+ QString m_text;
+};
+
+#endif
diff --git a/src/frontend/displaywindow/cbiblereadwindow.cpp b/src/frontend/displaywindow/cbiblereadwindow.cpp
new file mode 100644
index 0000000..15354fa
--- /dev/null
+++ b/src/frontend/displaywindow/cbiblereadwindow.cpp
@@ -0,0 +1,480 @@
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2008 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+
+
+#include "cbiblereadwindow.h"
+#include "btactioncollection.h"
+
+#include "ccommentaryreadwindow.h"
+#include "cbuttons.h"
+
+#include "backend/keys/cswordversekey.h"
+#include "backend/drivers/cswordbiblemoduleinfo.h"
+
+#include "frontend/profile/cprofilewindow.h"
+#include "frontend/cexportmanager.h"
+#include "backend/config/cbtconfig.h"
+#include "frontend/cmdiarea.h"
+#include "frontend/display/creaddisplay.h"
+#include "frontend/keychooser/ckeychooser.h"
+
+#include "util/ctoolclass.h"
+#include "util/cresmgr.h"
+#include "util/directoryutil.h"
+
+#include <math.h>
+
+//Qt includes
+#include <QWidget>
+#include <QTimer>
+#include <QEvent>
+#include <QApplication>
+#include <QMenu>
+#include <QMdiSubWindow>
+#include <QAction>
+#include <QMenu>
+#include <QMenu>
+
+using namespace Profile;
+
+CBibleReadWindow::CBibleReadWindow(QList<CSwordModuleInfo*> moduleList, CMDIArea* parent)
+ : CLexiconReadWindow(moduleList, parent)
+{
+ qDebug("CBibleReadWindow::CBibleReadWindow");
+}
+
+CBibleReadWindow::~CBibleReadWindow() {}
+
+void CBibleReadWindow::applyProfileSettings( CProfileWindow* const settings ) {
+ CLexiconReadWindow::applyProfileSettings(settings);
+
+ const int count = displaySettingsButton()->menuItemCount();
+ int result = settings->windowSettings();
+ for (int i = count-1; i>=1; i--) {
+ if (result-(int)pow((double)2,i-1)>= 0) { //2^i was added before, so item with index i is set
+ result -= (int)pow((double)2,i-1);
+ displaySettingsButton()->setItemStatus(i,true);
+ }
+ else {
+ displaySettingsButton()->setItemStatus(i,false);
+ }
+ }
+ displaySettingsButton()->setChanged();
+}
+
+void CBibleReadWindow::storeProfileSettings( CProfileWindow* const settings ) {
+ CLexiconReadWindow::storeProfileSettings(settings);
+
+ const int count = displaySettingsButton()->menuItemCount();
+ int result = 0;
+ //now check every item
+ for (int i = 1; i < count; i++) { //first item is a title
+ if (displaySettingsButton()->itemStatus(i)) //item is checked
+ result += (int)pow((double)2,i-1);//add 2^i (the i. digit in binary)
+ }
+ settings->setWindowSettings(result);
+}
+
+
+/** Reimplementation. */
+void CBibleReadWindow::insertKeyboardActions( BtActionCollection* const a ) {
+
+ QAction* qaction;
+
+ qaction = new QAction(tr("Next book"), a);
+ qaction->setShortcut(CResMgr::displaywindows::bibleWindow::nextBook::accel);
+ a->addAction("nextBook", qaction);
+
+ qaction = new QAction(tr("Previous book"), a);
+ qaction->setShortcut( CResMgr::displaywindows::bibleWindow::previousBook::accel);
+ a->addAction("previousBook", qaction);
+
+ qaction = new QAction(tr("Next chapter"), a);
+ qaction->setShortcut(CResMgr::displaywindows::bibleWindow::nextChapter::accel);
+ a->addAction("nextChapter", qaction);
+
+ qaction = new QAction(tr("Previous chapter"), a);
+ qaction->setShortcut(CResMgr::displaywindows::bibleWindow::previousChapter::accel);
+ a->addAction("previousChapter", qaction);
+
+ qaction = new QAction(tr("Next verse"), a);
+ qaction->setShortcut(CResMgr::displaywindows::bibleWindow::nextVerse::accel);
+ a->addAction("nextVerse", qaction);
+
+ qaction = new QAction(tr("Previous verse"), a);
+ qaction->setShortcut(CResMgr::displaywindows::bibleWindow::previousVerse::accel);
+ a->addAction("previousVerse", qaction);
+
+
+ //popup menu items
+ // new KAction(tr("Select all"), KStdAccel::selectAll(), a, "selectAll");
+
+ //copy menu items
+ // new KAction(tr("Copy reference only"), KShortcut(0), a, "copyReferenceOnly");
+ // new KAction(tr("Text of reference"), KShortcut(0), a, "copyTextOfReference");
+ // new KAction(tr("Reference with text"), KShortcut(0), a, "copyReferenceWithText");
+ qaction = new QAction(tr("Copy chapter"), a);
+ a->addAction("copyChapter", qaction);
+ // new KAction(tr("Copy selected text"), KStdAccel::copy(), a, "copySelectedText");
+
+ //save menu
+ // new KAction(tr("Reference with text"), KShortcut(0), a, "saveReferenceWithText");
+ qaction = new QAction(tr("Save chapter as plain text"), a);
+ a->addAction("saveChapterAsPlainText", qaction);
+
+ qaction = new QAction(tr("Save chapter as HTML"), a);
+ a->addAction("saveChapterAsHTML", qaction);
+ // new KAction(tr("Reference with text"), KShortcut(0), a, "saveReferenceWithText");
+
+ //print
+ qaction = new QAction(tr("Print chapter"), a);
+ qaction->setShortcut(QKeySequence::Print);
+ a->addAction("printChapter", qaction);
+}
+
+void CBibleReadWindow::initActions() {
+ qDebug("CBibleReadWindow::initActions");
+
+ BtActionCollection* ac = actionCollection();
+ CBibleReadWindow::insertKeyboardActions(ac);
+ CLexiconReadWindow::initActions(); //make sure the predefined actions are available
+
+ //cleanup, not a clean oo-solution
+ ac->action("nextEntry")->setEnabled(false);
+ ac->action("previousEntry")->setEnabled(false);
+
+ QAction* qaction;
+
+ qaction = new QAction(tr("Next book"), ac);
+ qaction->setShortcut(CResMgr::displaywindows::bibleWindow::nextBook::accel);
+ QObject::connect(qaction, SIGNAL(triggered()), this, SLOT(nextBook()) );
+ ac->addAction("nextBook", qaction);
+
+ qaction = new QAction(tr("Previous book"), ac);
+ qaction->setShortcut(CResMgr::displaywindows::bibleWindow::previousBook::accel);
+ QObject::connect(qaction, SIGNAL(triggered()), this, SLOT(previousBook()) );
+ ac->addAction("previousBook", qaction);
+
+ qaction = new QAction(tr("Next chapter"), ac);
+ qaction->setShortcut(CResMgr::displaywindows::bibleWindow::nextChapter::accel);
+ QObject::connect(qaction, SIGNAL(triggered()), this, SLOT(nextChapter()) );
+ ac->addAction("nextChapter", qaction);
+
+ qaction = new QAction(tr("Previous chapter"),ac);
+ qaction->setShortcut(CResMgr::displaywindows::bibleWindow::previousChapter::accel);
+ QObject::connect(qaction, SIGNAL(triggered()), this, SLOT(previousChapter()) );
+ ac->addAction("previousChapter", qaction);
+
+ qaction = new QAction(tr("Next verse"), ac);
+ qaction->setShortcut(CResMgr::displaywindows::bibleWindow::nextVerse::accel);
+ QObject::connect(qaction, SIGNAL(triggered()), this, SLOT(nextVerse()) );
+ ac->addAction("nextVerse", qaction);
+
+ qaction = new QAction(tr("Previous verse"), ac);
+ qaction->setShortcut(CResMgr::displaywindows::bibleWindow::previousVerse::accel);
+ QObject::connect(qaction, SIGNAL(triggered()), this, SLOT(previousVerse()) );
+ ac->addAction("previousVerse", qaction);
+
+ m_actions.selectAll = qobject_cast<QAction*>(ac->action("selectAll"));
+ Q_ASSERT(m_actions.selectAll);
+
+ m_actions.findText = qobject_cast<QAction*>(ac->action("findText"));
+ Q_ASSERT(m_actions.findText);
+
+ m_actions.findStrongs = new QAction(
+// QIcon(CResMgr::displaywindows::general::findStrongs::icon),
+ tr("Strong's search"),
+ ac
+ );
+ m_actions.findStrongs->setShortcut(CResMgr::displaywindows::general::findStrongs::accel);
+ m_actions.findStrongs->setToolTip(tr("Find all occurences of the Strong number currently under the mouse cursor"));
+ QObject::connect(m_actions.findStrongs, SIGNAL(triggered()), this, SLOT(openSearchStrongsDialog()) );
+ ac->addAction(CResMgr::displaywindows::general::findStrongs::actionName, m_actions.findStrongs);
+
+ m_actions.copy.referenceOnly = new QAction(tr("Reference only"), ac );
+ QObject::connect(m_actions.copy.referenceOnly, SIGNAL(triggered()), displayWidget()->connectionsProxy(), SLOT(copyAnchorOnly()));
+ ac->addAction("copyReferenceOnly", m_actions.copy.referenceOnly);
+
+ m_actions.copy.referenceTextOnly = new QAction(tr("Text of reference"), ac);
+ QObject::connect(m_actions.copy.referenceTextOnly, SIGNAL(triggered()), displayWidget()->connectionsProxy(), SLOT(copyAnchorTextOnly()) );
+ ac->addAction("copyTextOfReference", m_actions.copy.referenceTextOnly);
+
+ m_actions.copy.referenceAndText = new QAction(tr("Reference with text"), ac);
+ QObject::connect(m_actions.copy.referenceAndText, SIGNAL(triggered()), displayWidget()->connectionsProxy(), SLOT(copyAnchorWithText()) );
+ ac->addAction( "copyReferenceWithText", m_actions.copy.referenceAndText);
+
+ m_actions.copy.chapter = new QAction(tr("Chapter"), ac);
+ QObject::connect(m_actions.copy.chapter, SIGNAL(triggered()), this, SLOT(copyDisplayedText()) );
+ ac->addAction("copyChapter", m_actions.copy.chapter);
+
+ m_actions.copy.selectedText = qobject_cast<QAction*>(ac->action("copySelectedText"));
+ Q_ASSERT(m_actions.copy.selectedText);
+
+ m_actions.save.referenceAndText = new QAction(tr("Reference with text"), ac );
+ QObject::connect(m_actions.save.referenceAndText, SIGNAL(triggered()), displayWidget()->connectionsProxy(), SLOT(saveAnchorWithText()) );
+ ac->addAction("saveReferenceWithText", m_actions.save.referenceAndText);
+
+ m_actions.save.chapterAsPlain = new QAction(tr("Chapter as plain text"), ac);
+ QObject::connect(m_actions.save.chapterAsPlain, SIGNAL(triggered()), this, SLOT(saveChapterPlain()) );
+ ac->addAction("saveChapterAsPlainText", m_actions.save.chapterAsPlain);
+
+ m_actions.save.chapterAsHTML = new QAction(tr("Chapter as HTML"), ac);
+ QObject::connect(m_actions.save.chapterAsHTML, SIGNAL(triggered()), this, SLOT(saveChapterHTML()) );
+ ac->addAction("saveChapterAsHTML", m_actions.save.chapterAsHTML);
+
+ m_actions.print.reference = new QAction(tr("Reference with text"), ac);
+ QObject::connect(m_actions.print.reference, SIGNAL(triggered()), this, SLOT(printAnchorWithText()) );
+ ac->addAction("saveReferenceWithText", m_actions.print.reference);
+
+ m_actions.print.chapter = new QAction(tr("Chapter"), ac);
+ QObject::connect(m_actions.print.chapter, SIGNAL(triggered()), this, SLOT(printAll()) );
+ ac->addAction("printChapter", m_actions.print.chapter);
+
+// CBTConfig::setupAccelSettings(CBTConfig::bibleWindow, ac);
+}
+
+void CBibleReadWindow::initConnections() {
+ CLexiconReadWindow::initConnections();
+}
+
+void CBibleReadWindow::initToolbars() {
+ CLexiconReadWindow::initToolbars();
+}
+
+void CBibleReadWindow::initView() {
+ CLexiconReadWindow::initView();
+
+ parentWidget()->installEventFilter( this );
+}
+
+/** Reimplementation. */
+void CBibleReadWindow::setupPopupMenu() {
+ popup()->setTitle(tr("Bible window"));
+ popup()->setIcon(CToolClass::getIconForModule(modules().first()) );
+ popup()->addAction(m_actions.findText);
+ popup()->addAction(m_actions.findStrongs);
+ popup()->addAction(m_actions.selectAll);
+
+ popup()->addSeparator();
+
+ m_actions.copyMenu = new QMenu(tr("Copy..."), popup());
+ m_actions.copyMenu->addAction(m_actions.copy.referenceOnly);
+ m_actions.copyMenu->addAction(m_actions.copy.referenceTextOnly);
+ m_actions.copyMenu->addAction(m_actions.copy.referenceAndText);
+ m_actions.copyMenu->addAction(m_actions.copy.chapter);
+
+ m_actions.copyMenu->addSeparator();
+
+ m_actions.copyMenu->addAction(m_actions.copy.selectedText);
+ popup()->addMenu(m_actions.copyMenu);
+
+ m_actions.saveMenu = new QMenu(tr("Save..."), popup());
+ m_actions.saveMenu->addAction(m_actions.save.referenceAndText);
+ m_actions.saveMenu->addAction(m_actions.save.chapterAsPlain);
+ m_actions.saveMenu->addAction(m_actions.save.chapterAsHTML);
+ // Save raw HTML action for debugging purposes
+ if (qApp->property("--debug").toBool()) {
+ QAction* debugAction = new QAction("Raw HTML", this);
+ QObject::connect(debugAction, SIGNAL(triggered()), this, SLOT(saveRawHTML()));
+ m_actions.saveMenu->addAction(debugAction);
+ } // end of Save Raw HTML
+ popup()->addMenu(m_actions.saveMenu);
+
+ m_actions.printMenu = new QMenu(tr("Print..."), popup());
+ m_actions.printMenu->addAction(m_actions.print.reference);
+ m_actions.printMenu->addAction(m_actions.print.chapter);
+ popup()->addMenu(m_actions.printMenu);
+}
+
+/** Reimplemented. */
+void CBibleReadWindow::updatePopupMenu() {
+ qWarning("CBibleReadWindow::updatePopupMenu()");
+
+ //enable the action depending on the supported module features
+// bool hasStrongs = false;
+// QList<CSwordModuleInfo*> mods = modules();
+// for (QList<CSwordModuleInfo*>::iterator it = mods.begin(); it != mods.end(); ++it) {
+// if ( (*it)->has( CSwordModuleInfo::strongNumbers ) ) {
+// hasStrongs = true;
+// break;
+// }
+// }
+//
+// m_actions.findStrongs->setEnabled( hasStrongs );
+ m_actions.findStrongs->setEnabled( displayWidget()->getCurrentNodeInfo()[CDisplay::Lemma] != QString::null );
+
+
+ m_actions.copy.referenceOnly->setEnabled( ((CReadDisplay*)displayWidget())->hasActiveAnchor() );
+ m_actions.copy.referenceTextOnly->setEnabled( ((CReadDisplay*)displayWidget())->hasActiveAnchor() );
+ m_actions.copy.referenceAndText->setEnabled( ((CReadDisplay*)displayWidget())->hasActiveAnchor() );
+ m_actions.copy.selectedText->setEnabled( ((CReadDisplay*)displayWidget())->hasSelection() );
+
+ m_actions.save.referenceAndText->setEnabled( ((CReadDisplay*)displayWidget())->hasActiveAnchor() );
+
+ m_actions.print.reference->setEnabled( ((CReadDisplay*)displayWidget())->hasActiveAnchor() );
+}
+
+/** Moves to the next book. */
+void CBibleReadWindow::nextBook() {
+ if (verseKey()->next(CSwordVerseKey::UseBook)) {
+ keyChooser()->setKey(key());
+ }
+}
+
+/** Moves one book behind. */
+void CBibleReadWindow::previousBook() {
+ if (verseKey()->previous(CSwordVerseKey::UseBook)) {
+ keyChooser()->setKey(key());
+ }
+}
+
+/** Moves to the next book. */
+void CBibleReadWindow::nextChapter() {
+ if (verseKey()->next(CSwordVerseKey::UseChapter)) {
+ keyChooser()->setKey(key());
+ }
+}
+
+/** Moves one book behind. */
+void CBibleReadWindow::previousChapter() {
+ if (verseKey()->previous(CSwordVerseKey::UseChapter)) {
+ keyChooser()->setKey(key());
+ }
+}
+
+/** Moves to the next book. */
+void CBibleReadWindow::nextVerse() {
+ if (verseKey()->next(CSwordVerseKey::UseVerse)) {
+ keyChooser()->setKey(key());
+ }
+}
+
+/** Moves one book behind. */
+void CBibleReadWindow::previousVerse() {
+ if (verseKey()->previous(CSwordVerseKey::UseVerse)) {
+ keyChooser()->setKey(key());
+ }
+}
+
+/** rapper around key() to return the right type of key. */
+CSwordVerseKey* CBibleReadWindow::verseKey() {
+ CSwordVerseKey* k = dynamic_cast<CSwordVerseKey*>(CDisplayWindow::key());
+ Q_ASSERT(k);
+
+ return k;
+}
+
+/** Copies the current chapter into the clipboard. */
+void CBibleReadWindow::copyDisplayedText() {
+ CSwordVerseKey dummy(*verseKey());
+ dummy.Verse(1);
+
+ CSwordVerseKey vk(*verseKey());
+ vk.LowerBound(dummy);
+
+ CSwordBibleModuleInfo* bible = dynamic_cast<CSwordBibleModuleInfo*>(modules().first());
+ dummy.Verse(bible->verseCount(dummy.book(), dummy.Chapter()));
+ vk.UpperBound(dummy);
+
+ CExportManager mgr(tr("Copy chapter to clipboard ..."), false, tr("Copying"), filterOptions(), displayOptions());
+ mgr.copyKey(&vk, CExportManager::Text, true);
+}
+
+/** 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;
+
+ CSwordVerseKey dummy(*verseKey());
+ dummy.Verse(1);
+
+ CSwordVerseKey vk(*verseKey());
+ vk.LowerBound(dummy);
+
+ dummy.Verse(bible->verseCount(dummy.book(), dummy.Chapter()));
+ vk.UpperBound(dummy);
+
+ CExportManager mgr(tr("Saving chapter ..."), true, tr("Saving"), filterOptions(), displayOptions());
+ mgr.saveKey(&vk, CExportManager::HTML, true);
+}
+
+/** Saves the chapter as valid HTML page. */
+void CBibleReadWindow::saveChapterPlain() {
+ //saves the complete chapter to disk
+
+ CSwordVerseKey vk(*verseKey());
+ CSwordVerseKey dummy(*verseKey());
+
+ dummy.Verse(1);
+ vk.LowerBound(dummy);
+
+ CSwordBibleModuleInfo* bible = dynamic_cast<CSwordBibleModuleInfo*>(modules().first());
+ dummy.Verse(bible->verseCount(dummy.book(), dummy.Chapter()));
+ vk.UpperBound(dummy);
+
+ CExportManager mgr(tr("Saving chapter ..."), true, tr("Saving"), filterOptions(),displayOptions());
+ mgr.saveKey(&vk, CExportManager::Text, true);
+}
+
+void CBibleReadWindow::reload(CSwordBackend::SetupChangedReason reason) {
+ CLexiconReadWindow::reload(reason);
+
+ if (m_modules.count() == 0) {
+ close();
+ return;
+ }
+
+ //refresh the book lists
+// qDebug("lang is %s",backend()->booknameLanguage().latin1());
+ verseKey()->setLocale( backend()->booknameLanguage().toLatin1() );
+ keyChooser()->refreshContent();
+
+// CBTConfig::setupAccelSettings(CBTConfig::readWindow, actionCollection()); //setup the predefined actions
+// CBTConfig::setupAccelSettings(CBTConfig::bibleWindow, actionCollection());
+}
+
+/** No descriptions */
+bool CBibleReadWindow::eventFilter( QObject* o, QEvent* e) {
+ const bool ret = CLexiconReadWindow::eventFilter(o,e);
+
+ // Q_ASSERT(o->inherits("CDisplayWindow"));
+ // qWarning("class: %s", o->className());
+ if (e && (e->type() == QEvent::FocusIn)) { //sync other windows to this active
+
+ /* This is a hack to work around a KHTML problem (similair to the Drag&Drop problem we had):
+ * If new HTML content is loaded from inside a kHTML event handler
+ * the widget's state will be confused, i.e. it's scrolling without having
+ * the mousebutton clicked.
+ *
+ * This is not really in a KHTML event handler but works anyway.
+ * Sometime KDE/Qt is hard to use ...
+ */
+ QTimer::singleShot(0, this, SLOT(syncWindows()));
+ }
+
+ return ret;
+}
+
+void CBibleReadWindow::lookupSwordKey( CSwordKey* newKey ) {
+ CLexiconReadWindow::lookupSwordKey(newKey);
+ syncWindows();
+}
+
+void CBibleReadWindow::syncWindows() {
+ foreach (QMdiSubWindow* subWindow, mdi()->subWindowList()) {
+ CDisplayWindow* w = dynamic_cast<CDisplayWindow*>(subWindow->widget());
+ if (w && w->syncAllowed()) {
+ w->lookupKey( key()->key() );
+ }
+ }
+}
diff --git a/src/frontend/displaywindow/cbiblereadwindow.h b/src/frontend/displaywindow/cbiblereadwindow.h
new file mode 100644
index 0000000..e044463
--- /dev/null
+++ b/src/frontend/displaywindow/cbiblereadwindow.h
@@ -0,0 +1,144 @@
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2008 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+
+
+#ifndef CBIBLEREADWINDOW_H
+#define CBIBLEREADWINDOW_H
+
+//BibleTime includes
+#include "clexiconreadwindow.h"
+
+
+
+class CTransliterationButton;
+class CSwordKey;
+class CSwordVerseKey;
+
+class BtActionCollection;
+class QAction;
+class QMenu;
+
+class QObject;
+class QEvent;
+
+
+
+/**The read display window for Bibles.
+ *@author The BibleTime team
+ */
+
+class CBibleReadWindow : public CLexiconReadWindow {
+ Q_OBJECT
+public:
+ CBibleReadWindow(QList<CSwordModuleInfo*> modules, CMDIArea* parent);
+ virtual ~CBibleReadWindow();
+ /**
+ * Store the settings of this window in the given CProfileWindow object.
+ */
+ virtual void storeProfileSettings( Profile::CProfileWindow* const settings );
+ /**
+ * Store the settings of this window in the given profile window.
+ */
+ virtual void applyProfileSettings( Profile::CProfileWindow* const settings );
+ /**
+ * Reimplementation.
+ */
+ static void insertKeyboardActions( BtActionCollection* const a );
+
+protected:
+ virtual void initActions();
+ virtual void initToolbars();
+ virtual void initConnections();
+ virtual void initView();
+ /**
+ * Reimplementation.
+ */
+ virtual void setupPopupMenu();
+ /**
+ * Reimplemented.
+ */
+ virtual void updatePopupMenu();
+ /** Event filter.
+ * Reimplementation of the event filter to filter out events like focus in.
+ */
+ virtual bool eventFilter( QObject* o, QEvent* e);
+
+ struct {
+ QAction* selectAll;
+ QAction* findText;
+ QAction* findStrongs;
+
+ QMenu* copyMenu;
+ struct {
+ QAction* referenceOnly;
+ QAction* referenceTextOnly;
+ QAction* referenceAndText;
+ QAction* chapter;
+ QAction* selectedText;
+ }
+ copy;
+
+ QMenu* saveMenu;
+ struct {
+ QAction* referenceAndText;
+ QAction* chapterAsPlain;
+ QAction* chapterAsHTML;
+ }
+ save;
+
+ QMenu* printMenu;
+ struct {
+ QAction* reference;
+ QAction* chapter;
+ }
+ print;
+ }
+ m_actions;
+
+
+public slots:
+ void nextBook();
+ void previousBook();
+ void nextChapter();
+ void previousChapter();
+ void nextVerse();
+ void previousVerse();
+ /**
+ * Refreshes the content of this display window and the content of the keychooser.
+ */
+ virtual void reload(CSwordBackend::SetupChangedReason reason);
+
+protected slots: // Protected slots
+ /**
+ * Copies the current chapter into the clipboard.
+ */
+ void copyDisplayedText();
+ /**
+ * Saves the chapter as valid HTML page.
+ */
+ void saveChapterHTML();
+ /**
+ * Saves the chapter as valid HTML page.
+ */
+ void saveChapterPlain();
+ virtual void lookupSwordKey( CSwordKey* newKey );
+ void syncWindows();
+
+private:
+ friend class CCommentaryReadWindow;
+ /**
+ * Wrapper around key() to return the right type of key.
+ */
+ CSwordVerseKey* verseKey();
+
+ // CTransliterationButton* m_transliterationButton;
+};
+
+#endif
diff --git a/src/frontend/displaywindow/cbookreadwindow.cpp b/src/frontend/displaywindow/cbookreadwindow.cpp
new file mode 100644
index 0000000..657238f
--- /dev/null
+++ b/src/frontend/displaywindow/cbookreadwindow.cpp
@@ -0,0 +1,195 @@
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2008 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+
+
+#include "cbookreadwindow.h"
+#include "bttoolbarpopupaction.h"
+#include "btactioncollection.h"
+
+#include "cmodulechooserbar.h"
+#include "cbuttons.h"
+
+#include "backend/keys/cswordtreekey.h"
+
+#include "frontend/display/cdisplay.h"
+#include "frontend/keychooser/cbooktreechooser.h"
+#include "frontend/profile/cprofilewindow.h"
+#include "backend/config/cbtconfig.h"
+
+#include "util/ctoolclass.h"
+#include "util/cresmgr.h"
+
+#include <QSplitter>
+#include <QToolBar>
+#include <QMenu>
+#include <QAction>
+
+using namespace Profile;
+
+CBookReadWindow::CBookReadWindow(QList<CSwordModuleInfo*> modules, CMDIArea* parent) : CLexiconReadWindow(modules, parent) {}
+
+CBookReadWindow::~CBookReadWindow() {}
+
+void CBookReadWindow::applyProfileSettings( CProfileWindow* profileWindow )
+{
+ CLexiconReadWindow::applyProfileSettings(profileWindow);
+
+ const bool enable = static_cast<bool>( profileWindow->windowSettings() );
+ if (enable) {
+ m_treeAction->activate(QAction::Trigger);
+ }
+}
+
+void CBookReadWindow::storeProfileSettings( CProfileWindow* profileWindow )
+{
+ CLexiconReadWindow::storeProfileSettings(profileWindow);
+
+ //store information about our show tree structure button
+ profileWindow->setWindowSettings( static_cast<int>( m_treeAction->isChecked() ) );
+}
+
+void CBookReadWindow::initActions()
+{
+ CLexiconReadWindow::initActions();
+ BtActionCollection* ac = actionCollection();
+ //cleanup, not a clean oo-solution
+ Q_ASSERT(ac->action("nextEntry"));
+ Q_ASSERT(ac->action("previousEntry"));
+ ac->action("nextEntry")->setEnabled(false);
+ ac->action("previousEntry")->setEnabled(false);
+
+ m_treeAction = new QAction(
+ QIcon(CResMgr::displaywindows::bookWindow::toggleTree::icon),
+ tr("Toggle tree view"),
+ ac
+ );
+ m_treeAction->setCheckable(true);
+ m_treeAction->setShortcut(CResMgr::displaywindows::bookWindow::toggleTree::accel);
+ QObject::connect(m_treeAction, SIGNAL(triggered()), this, SLOT(treeToggled()) );
+ ac->addAction("toggleTree", m_treeAction);
+
+// CBTConfig::setupAccelSettings(CBTConfig::bookWindow, ac);
+}
+
+void CBookReadWindow::insertKeyboardActions( BtActionCollection* const a )
+{
+ QAction* qaction;
+
+ qaction = new QAction(
+ QIcon(CResMgr::displaywindows::bookWindow::toggleTree::icon),
+ tr("Toggle tree view"),
+ a
+ );
+ qaction->setCheckable(true);
+ qaction->setShortcut(CResMgr::displaywindows::bookWindow::toggleTree::accel);
+ a->addAction("toggleTree", qaction);
+
+ // new QAction(tr("Copy reference only"), KShortcut(0), a, "copyReferenceOnly");
+ qaction = new QAction(tr("Copy entry with text"), a);
+ a->addAction("copyEntryWithText", qaction);
+ // new QAction(tr("Copy selected text"), KShortcut(0), a, "copySelectedText");
+ qaction = new QAction(tr("Save entry as plain text"), a);
+ a->addAction("saveEntryAsPlainText", qaction);
+ qaction = new QAction(tr("Save entry as HTML"),a);
+ a->addAction("saveEntryAsHTML", qaction);
+ // new QAction(tr("Print reference only"), KShortcut(0), a, "printReferenceOnly");
+ qaction = new QAction(tr("Print entry with text"), a);
+ a->addAction("printEntryWithText", qaction);
+
+}
+
+/** No descriptions */
+void CBookReadWindow::initConnections()
+{
+ CLexiconReadWindow::initConnections();
+
+ connect(m_treeChooser, SIGNAL(keyChanged(CSwordKey*)), this, SLOT(lookupSwordKey(CSwordKey*)));
+ connect(m_treeChooser, SIGNAL(keyChanged(CSwordKey*)), keyChooser(), SLOT(updateKey(CSwordKey*)));
+ connect(keyChooser(), SIGNAL(keyChanged(CSwordKey*)), m_treeChooser, SLOT(updateKey(CSwordKey*)));
+}
+
+/** Init the view */
+void CBookReadWindow::initView()
+{
+ QSplitter* splitter = new QSplitter(this);
+
+ setMainToolBar( new QToolBar(this) );
+ addToolBar(mainToolBar());
+ //addDockWindow(mainToolBar());
+
+ m_treeChooser = new CBookTreeChooser(modules(), key(), splitter);
+ setDisplayWidget( CDisplay::createReadInstance(this, splitter) );
+
+ setKeyChooser( CKeyChooser::createInstance(modules(), key(), mainToolBar()) );
+
+ setModuleChooserBar( new CModuleChooserBar(modules(), modules().first()->type(), this) );
+ moduleChooserBar()->setButtonLimit(1);
+ addToolBar(moduleChooserBar());
+ //addDockWindow( moduleChooserBar() );
+
+ setButtonsToolBar( new QToolBar(this) );
+ //addDockWindow( buttonsToolBar() );
+ setDisplaySettingsButton( new CDisplaySettingsButton( &displayOptions(), &filterOptions(), modules(), buttonsToolBar()) );
+ addToolBar(buttonsToolBar());
+ m_treeChooser->hide();
+
+ //splitter->setResizeMode(m_treeChooser, QSplitter::Stretch);
+ setCentralWidget( splitter );
+ setWindowIcon(CToolClass::getIconForModule(modules().first()));
+}
+
+void CBookReadWindow::initToolbars()
+{
+ Q_ASSERT(m_treeAction);
+ Q_ASSERT(m_actions.backInHistory);
+
+ mainToolBar()->addAction(m_actions.backInHistory);
+ mainToolBar()->addAction(m_actions.forwardInHistory);
+
+ mainToolBar()->addWidget(keyChooser());
+
+ buttonsToolBar()->addAction(m_treeAction);
+ m_treeAction->setChecked(false);
+
+ buttonsToolBar()->addWidget(displaySettingsButton());
+
+ QAction* action = qobject_cast<QAction*>(actionCollection()->action(
+ CResMgr::displaywindows::general::search::actionName ));
+ if (action) {
+ buttonsToolBar()->addAction(action);
+ }
+
+ //#if KDE_VERSION_MINOR < 1
+ //action->plugAccel( accel() );
+ //#endif
+}
+
+/** Is called when the action was executed to toggle the tree view. */
+void CBookReadWindow::treeToggled()
+{
+ if (m_treeAction->isChecked()) {
+ m_treeChooser->show();
+ }
+ else {
+ m_treeChooser->hide();
+ }
+}
+
+/** Reimplementation to take care of the tree chooser. */
+void CBookReadWindow::modulesChanged()
+{
+ CLexiconReadWindow::modulesChanged();
+ m_treeChooser->setModules(modules());
+}
+
+void CBookReadWindow::setupPopupMenu()
+{
+ CLexiconReadWindow::setupPopupMenu();
+}
diff --git a/src/frontend/displaywindow/cbookreadwindow.h b/src/frontend/displaywindow/cbookreadwindow.h
new file mode 100644
index 0000000..eaa0c15
--- /dev/null
+++ b/src/frontend/displaywindow/cbookreadwindow.h
@@ -0,0 +1,69 @@
+/*********
+*
+* This file is part of BibleTime's BtActionCollection code, http://www.bibletime.info/.
+*
+* Copyright 1999-2008 by the BibleTime developers.
+* The BibleTime BtActionCollection code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+
+
+#ifndef CBOOKREADWINDOW_H
+#define CBOOKREADWINDOW_H
+
+//BibleTime includes
+#include "clexiconreadwindow.h"
+
+
+class QAction;
+class CBookTreeChooser;
+class BtActionCollection;
+
+
+/**
+ * @author The BibleTime team
+ */
+class CBookReadWindow : public CLexiconReadWindow {
+ Q_OBJECT
+public:
+ static void insertKeyboardActions( BtActionCollection* const a );
+
+ CBookReadWindow(QList<CSwordModuleInfo*> modules, CMDIArea* parent);
+
+ virtual ~CBookReadWindow();
+ /**
+ * Store the settings of this window in the given CProfileWindow object.
+ */
+ virtual void storeProfileSettings( Profile::CProfileWindow* profileWindow );
+ /**
+ * Store the settings of this window in the given profile window.
+ */
+ virtual void applyProfileSettings( Profile::CProfileWindow* profileWindow );
+
+protected:
+ virtual void initActions();
+ virtual void initToolbars();
+ virtual void initConnections();
+ virtual void initView();
+
+ virtual void setupPopupMenu();
+
+ protected slots: // Protected slots
+ /**
+ * Reimplementation to take care of the tree chooser.
+ */
+ virtual void modulesChanged();
+
+private:
+ QAction* m_treeAction;
+ CBookTreeChooser* m_treeChooser;
+
+private slots: // Private slots
+ /**
+ * Is called when the action was executed to toggle the tree view.
+ */
+ void treeToggled();
+};
+
+#endif
diff --git a/src/frontend/displaywindow/cbuttons.cpp b/src/frontend/displaywindow/cbuttons.cpp
new file mode 100644
index 0000000..582e5de
--- /dev/null
+++ b/src/frontend/displaywindow/cbuttons.cpp
@@ -0,0 +1,191 @@
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2008 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+//BibleTime includes
+#include "cbuttons.h"
+
+#include "util/cresmgr.h"
+#include "util/cpointers.h"
+#include "util/directoryutil.h"
+
+//Qt includes
+#include <QString>
+#include <QToolTip>
+#include <QToolButton>
+#include <QHash>
+#include <QMenu>
+
+//KDE includes
+
+
+
+
+CDisplaySettingsButton::CDisplaySettingsButton(CSwordBackend::DisplayOptions *displaySettings, CSwordBackend::FilterOptions *moduleSettings, const QList<CSwordModuleInfo*>& useModules,QWidget *parent )
+: QToolButton(parent) {
+ // qWarning("CDisplaySettingsButton::CDisplaySettingsButton");
+ QToolButton::setIcon(util::filesystem::DirectoryUtil::getIcon(CResMgr::displaywindows::displaySettings::icon));
+
+ m_displaySettings = displaySettings;
+ m_moduleSettings = moduleSettings;
+ m_modules = useModules;
+
+ m_popup = new QMenu(this);
+ setMenu(m_popup);
+ setPopupMode(QToolButton::InstantPopup);
+ setToolTip(tr("Display options"));
+
+ connect(m_popup, SIGNAL(triggered(QAction*)), this, SLOT(optionToggled(QAction*)));
+ populateMenu();
+}
+
+void CDisplaySettingsButton::reset(const QList<CSwordModuleInfo*>& useModules) {
+ m_modules = useModules;
+ populateMenu();
+ //disable the settings button if no options are available
+ if (!populateMenu()) {
+ setEnabled(false);
+ setToolTip(tr("Display settings: No options available"));
+ }
+ else {
+ setEnabled(true);
+ setToolTip(tr("Display settings"));
+ }
+}
+
+
+void CDisplaySettingsButton::optionToggled(QAction* /*action*/) {
+ qDebug("display settings option toggled");
+ //Take each Action and set the corresponding setting.
+ //Using QAction (QObject) property and OptionType enum is a dirty way to do this.
+ //See populateMenu().
+ foreach (QAction* act, m_popup->actions()) {
+ int optionType = act->property("OptionType").toInt();
+ bool checked = act->isChecked();
+ switch(optionType) {
+ case Linebreak:
+ m_displaySettings->lineBreaks = checked;
+ break;
+ case Versenum:
+ m_displaySettings->verseNumbers = checked;
+ break;
+ case Variant:
+ m_moduleSettings->textualVariants = checked;
+ break;
+ case Vowel:
+ m_moduleSettings->hebrewPoints = checked;
+ break;
+ case Accents:
+ m_moduleSettings->greekAccents = checked;
+ break;
+ case Cantillation:
+ m_moduleSettings->hebrewCantillation = checked;
+ break;
+ case Headings:
+ m_moduleSettings->headings = checked;
+ break;
+ case Morphseg:
+ m_moduleSettings->morphSegmentation = checked;
+ break;
+ case Xref:
+ m_moduleSettings->scriptureReferences = checked;
+ break;
+ case WordsofJ:
+ m_moduleSettings->redLetterWords = checked;
+ break;
+ }
+ }
+
+ emit sigChanged();
+}
+
+/** No descriptions */
+int CDisplaySettingsButton::populateMenu() {
+ int ret = 0;
+
+ m_popup->clear();
+
+ // See also optionToggled()
+
+ ret += addMenuEntry(tr("Use linebreaks after each verse"), Linebreak, &m_displaySettings->lineBreaks, (m_modules.first()->type() == CSwordModuleInfo::Bible));
+
+ //show the verse numbers option only for bible modules
+ ret += addMenuEntry(tr("Show verse numbers"), Versenum, &m_displaySettings->verseNumbers, (m_modules.first()->type() == CSwordModuleInfo::Bible));
+
+ ret += addMenuEntry(tr("Show headings"), Headings, &m_moduleSettings->headings,
+ isOptionAvailable(CSwordModuleInfo::headings));
+
+ ret += addMenuEntry(tr("Highlight words of Jesus"), WordsofJ, &m_moduleSettings->redLetterWords,
+ isOptionAvailable(CSwordModuleInfo::redLetterWords ));
+
+ ret += addMenuEntry(tr("Show Hebrew vowel points"), Vowel, &m_moduleSettings->hebrewPoints,
+ isOptionAvailable(CSwordModuleInfo::hebrewPoints ));
+
+ ret += addMenuEntry(tr("Show Hebrew cantillation marks"), Cantillation, &m_moduleSettings->hebrewCantillation,
+ isOptionAvailable(CSwordModuleInfo::hebrewCantillation ));
+
+ ret += addMenuEntry(tr("Show Greek accents"), Accents, &m_moduleSettings->greekAccents,
+ isOptionAvailable(CSwordModuleInfo::greekAccents ));
+
+ ret += addMenuEntry(tr("Use alternative textual variant"), Variant, &m_moduleSettings->textualVariants,
+ isOptionAvailable(CSwordModuleInfo::textualVariants ));
+
+ ret += addMenuEntry(tr("Show scripture cross-references"), Xref, &m_moduleSettings->scriptureReferences,
+ isOptionAvailable(CSwordModuleInfo::scriptureReferences ));
+
+ ret += addMenuEntry(tr("Show morph segmentation"), Morphseg, &m_moduleSettings->morphSegmentation,
+ isOptionAvailable(CSwordModuleInfo::morphSegmentation ));
+
+ return ret;
+}
+
+/** Adds an entry to m_popup. */
+int CDisplaySettingsButton::addMenuEntry( const QString name, OptionType type, const int* option, const bool available) {
+ int ret = 0;
+
+ if (available) {
+ QAction* a = m_popup->addAction(name);
+ //see optionToggled()
+ a->setProperty("OptionType", type);
+ a->setCheckable(true);
+ a->setChecked(*option);
+ ret = 1;
+ }
+
+ return ret;
+}
+
+bool CDisplaySettingsButton::isOptionAvailable( const CSwordModuleInfo::FilterTypes option ) {
+ bool ret = false;
+ QList<CSwordModuleInfo*>::iterator end_it = m_modules.end();
+ for (QList<CSwordModuleInfo*>::iterator it(m_modules.begin()); it != end_it; ++it) {
+ ret = ret || (*it)->has(option);
+ }
+ return ret;
+}
+
+/** Returns the number of usable menu items in the settings menu. */
+int CDisplaySettingsButton::menuItemCount() {
+ return m_popup->actions().count();
+}
+
+/** Sets the item at position pos to the state given as 2nd paramter. */
+void CDisplaySettingsButton::setItemStatus( const int index, const bool checked ) {
+ QAction* action = m_popup->actions().at(index);
+ action->setChecked(checked);
+}
+
+/** Returns the status of the item at position "index" */
+bool CDisplaySettingsButton::itemStatus( const int index ) {
+ return m_popup->actions().at(index)->isChecked();
+}
+
+/** Sets the status to changed. The signal changed will be emitted. */
+void CDisplaySettingsButton::setChanged() {
+ emit sigChanged();
+}
diff --git a/src/frontend/displaywindow/cbuttons.h b/src/frontend/displaywindow/cbuttons.h
new file mode 100644
index 0000000..6d94c53
--- /dev/null
+++ b/src/frontend/displaywindow/cbuttons.h
@@ -0,0 +1,77 @@
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2008 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+
+
+#ifndef CBUTTONS_H
+#define CBUTTONS_H
+
+//BibleTime includes
+#include "backend/managers/cswordbackend.h"
+class CSwordModuleInfo;
+
+//QT includes
+#include <QHash>
+#include <QToolButton>
+
+class QMenu;
+
+/** This class manages the display options of the selected modules.
+ * @author The BibleTime team
+ */
+class CDisplaySettingsButton : public QToolButton {
+ Q_OBJECT
+public:
+
+ CDisplaySettingsButton(CSwordBackend::DisplayOptions *displaySettings, CSwordBackend::FilterOptions *settings, const QList<CSwordModuleInfo*>& useModules, QWidget *parent=0);
+ void reset(const QList<CSwordModuleInfo*>& useModules);
+ /**
+ * Sets the item at position pos to the satet given as 2nd paramter.
+ */
+ void setItemStatus( const int pos, const bool checked );
+ /**
+ * Returns the number of usable menu items in the setttings menu.
+ */
+ int menuItemCount();
+ /**
+ * Returns the status of the item at position "index"
+ */
+ bool itemStatus( const int index );
+ /**
+ * Sets the status to changed. The signal changed will be emitted.
+ */
+ void setChanged();
+
+signals:
+ void sigChanged(void);
+
+protected slots:
+ void optionToggled(QAction* action);
+
+protected:
+
+ /** This enum marks the option types for a display. Used internally.*/
+ enum OptionType {Linebreak, Versenum, Headings, WordsofJ, Vowel, Cantillation, Accents,
+ Variant, Xref, Morphseg};
+
+ CSwordBackend::FilterOptions* m_moduleSettings;
+ CSwordBackend::DisplayOptions* m_displaySettings;
+ CSwordBackend::FilterOptions m_available;
+ QList<CSwordModuleInfo*> m_modules;
+
+ QHash<QString, int> m_dict;
+
+ QMenu* m_popup;
+
+ int populateMenu();
+ bool isOptionAvailable( const CSwordModuleInfo::FilterTypes option);
+ int addMenuEntry( const QString name, OptionType type, const int* option, const bool available);
+};
+
+#endif
diff --git a/src/frontend/displaywindow/ccommentaryreadwindow.cpp b/src/frontend/displaywindow/ccommentaryreadwindow.cpp
new file mode 100644
index 0000000..9228c2d
--- /dev/null
+++ b/src/frontend/displaywindow/ccommentaryreadwindow.cpp
@@ -0,0 +1,198 @@
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2008 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+//BibleTime includes
+#include "ccommentaryreadwindow.h"
+#include "btactioncollection.h"
+
+#include "frontend/profile/cprofilewindow.h"
+#include "backend/config/cbtconfig.h"
+#include "frontend/keychooser/ckeychooser.h"
+#include "frontend/display/cdisplay.h"
+#include "frontend/display/creaddisplay.h"
+
+#include "backend/keys/cswordversekey.h"
+
+#include "util/ctoolclass.h"
+#include "util/cresmgr.h"
+#include "util/directoryutil.h"
+
+#include <QMenu>
+#include <QAction>
+#include <QIcon>
+#include <QToolBar>
+
+using namespace Profile;
+
+CCommentaryReadWindow::CCommentaryReadWindow(QList<CSwordModuleInfo*> modules, CMDIArea* parent) : CLexiconReadWindow(modules, parent) {}
+
+void CCommentaryReadWindow::insertKeyboardActions( BtActionCollection* const a ) {
+
+ QAction* qaction;
+
+ qaction = new QAction(tr("Next book"), a);
+ qaction->setShortcut(CResMgr::displaywindows::bibleWindow::nextBook::accel);
+ a->addAction("nextBook", qaction);
+
+ qaction = new QAction(tr("Previous book"), a);
+ qaction->setShortcut(CResMgr::displaywindows::bibleWindow::previousBook::accel);
+ a->addAction( "previousBook", qaction);
+
+ qaction = new QAction(tr("Next chapter"), a);
+ qaction->setShortcut(CResMgr::displaywindows::bibleWindow::nextChapter::accel);
+ a->addAction("nextChapter", qaction);
+
+ qaction = new QAction(tr("Previous chapter"), a);
+ qaction->setShortcut(CResMgr::displaywindows::bibleWindow::previousChapter::accel);
+ a->addAction("previousChapter", qaction);
+
+ qaction = new QAction(tr("Next verse"), a);
+ qaction->setShortcut(CResMgr::displaywindows::bibleWindow::nextVerse::accel);
+ a->addAction("nextVerse", qaction);
+
+ qaction = new QAction(tr("Previous verse"), a);
+ qaction->setShortcut(CResMgr::displaywindows::bibleWindow::previousVerse::accel);
+ a->addAction("previousVerse", qaction);
+
+}
+
+void CCommentaryReadWindow::applyProfileSettings( CProfileWindow* profileWindow ) {
+ CLexiconReadWindow::applyProfileSettings(profileWindow);
+ if (profileWindow->windowSettings()) {
+ m_syncButton->setChecked(true);
+ }
+}
+
+void CCommentaryReadWindow::storeProfileSettings( CProfileWindow* profileWindow ) {
+ CLexiconReadWindow::storeProfileSettings(profileWindow);
+ profileWindow->setWindowSettings( m_syncButton->isChecked() );
+}
+
+void CCommentaryReadWindow::initToolbars() {
+ CLexiconReadWindow::initToolbars();
+
+ m_syncButton = new QAction(
+ QIcon(util::filesystem::DirectoryUtil::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);
+}
+
+/** Reimplementation to handle the keychooser refresh. */
+void CCommentaryReadWindow::reload(CSwordBackend::SetupChangedReason reason) {
+ CLexiconReadWindow::reload(reason);
+
+ //refresh the book lists
+ verseKey()->setLocale( backend()->booknameLanguage().toLatin1() );
+ keyChooser()->refreshContent();
+}
+
+/** rapper around key() to return the right type of key. */
+CSwordVerseKey* CCommentaryReadWindow::verseKey() {
+ CSwordVerseKey* k = dynamic_cast<CSwordVerseKey*>(CDisplayWindow::key());
+ Q_ASSERT(k);
+ return k;
+}
+
+void CCommentaryReadWindow::initActions() {
+ CLexiconReadWindow::initActions(); //make sure the predefined actions are available
+
+ BtActionCollection* ac = actionCollection();
+
+ //cleanup, not a clean oo-solution
+ ac->action("nextEntry")->setEnabled(false);
+ ac->action("previousEntry")->setEnabled(false);
+
+ QAction* qaction;
+
+ qaction = new QAction(tr("Next book"), ac);
+ qaction->setShortcut(CResMgr::displaywindows::bibleWindow::nextBook::accel);
+ QObject::connect(qaction, SIGNAL(triggered()), this, SLOT(nextBook()) );
+ ac->addAction("nextBook", qaction);
+
+ qaction = new QAction(tr("Previous book"), ac);
+ qaction->setShortcut(CResMgr::displaywindows::bibleWindow::previousBook::accel);
+ QObject::connect(qaction, SIGNAL(triggered()), this, SLOT(previousBook()) );
+ ac->addAction("previousBook", qaction);
+
+ qaction = new QAction(tr("Next chapter"), ac);
+ qaction->setShortcut(CResMgr::displaywindows::bibleWindow::nextChapter::accel);
+ QObject::connect(qaction, SIGNAL(triggered()), this, SLOT(nextChapter()) );
+ ac->addAction("nextChapter", qaction);
+
+ qaction = new QAction(tr("Previous chapter"), ac);
+ qaction->setShortcut(CResMgr::displaywindows::bibleWindow::previousChapter::accel);
+ QObject::connect(qaction, SIGNAL(triggered()), this, SLOT(previousChapter()) );
+ ac->addAction("previousChapter", qaction);
+
+ qaction = new QAction(tr("Next verse"), ac);
+ qaction->setShortcut(CResMgr::displaywindows::bibleWindow::nextVerse::accel);
+ QObject::connect(qaction, SIGNAL(triggered()), this, SLOT(nextVerse()) );
+ ac->addAction("nextVerse", qaction);
+
+ qaction = new QAction(tr("Previous verse"), ac);
+ qaction->setShortcut(CResMgr::displaywindows::bibleWindow::previousVerse::accel);
+ QObject::connect(qaction, SIGNAL(triggered()), this, SLOT(previousVerse()) );
+ ac->addAction("previousVerse", qaction);
+
+// CBTConfig::setupAccelSettings(CBTConfig::commentaryWindow, actionCollection());
+}
+
+/** Moves to the next book. */
+void CCommentaryReadWindow::nextBook() {
+ if (verseKey()->next(CSwordVerseKey::UseBook))
+ keyChooser()->setKey(key());
+}
+
+/** Moves one book behind. */
+void CCommentaryReadWindow::previousBook() {
+ if (verseKey()->previous(CSwordVerseKey::UseBook))
+ keyChooser()->setKey(key());
+}
+
+/** Moves to the next book. */
+void CCommentaryReadWindow::nextChapter() {
+ if (verseKey()->next(CSwordVerseKey::UseChapter))
+ keyChooser()->setKey(key());
+}
+
+/** Moves one book behind. */
+void CCommentaryReadWindow::previousChapter() {
+ if (verseKey()->previous(CSwordVerseKey::UseChapter))
+ keyChooser()->setKey(key());
+}
+
+/** Moves to the next book. */
+void CCommentaryReadWindow::nextVerse() {
+ if (verseKey()->next(CSwordVerseKey::UseVerse))
+ keyChooser()->setKey(key());
+}
+
+/** Moves one book behind. */
+void CCommentaryReadWindow::previousVerse() {
+ if (verseKey()->previous(CSwordVerseKey::UseVerse))
+ keyChooser()->setKey(key());
+}
+
+bool CCommentaryReadWindow::syncAllowed() const {
+ return m_syncButton->isChecked();
+}
+
+
+/*!
+ \fn CCommentaryReadWindow::setupPopupMenu()
+ */
+void CCommentaryReadWindow::setupPopupMenu() {
+ CLexiconReadWindow::setupPopupMenu();
+}
diff --git a/src/frontend/displaywindow/ccommentaryreadwindow.h b/src/frontend/displaywindow/ccommentaryreadwindow.h
new file mode 100644
index 0000000..1bac735
--- /dev/null
+++ b/src/frontend/displaywindow/ccommentaryreadwindow.h
@@ -0,0 +1,72 @@
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2008 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+
+
+#ifndef CCOMMENTARYREADWINDOW_H
+#define CCOMMENTARYREADWINDOW_H
+
+//BibleTime includes
+#include "cbiblereadwindow.h"
+
+//Qt includes
+//#include <qwidget.h>
+
+
+class QAction;
+class CSwordVerseKey;
+class BtActionCollection;
+
+/**
+ *@author The BibleTime team
+ */
+
+class CCommentaryReadWindow : public CLexiconReadWindow {
+ Q_OBJECT
+public:
+ /**
+ * Reimplementation.
+ */
+ static void insertKeyboardActions( BtActionCollection* const a );
+
+ CCommentaryReadWindow(QList<CSwordModuleInfo*> modules, CMDIArea* parent);
+ /**
+ * Store the settings of this window in the given CProfileWindow object.
+ */
+ virtual void storeProfileSettings( Profile::CProfileWindow* profileWindow );
+ /**
+ * Store the settings of this window in the given profile window.
+ */
+ virtual void applyProfileSettings( Profile::CProfileWindow* profileWindow );
+ virtual bool syncAllowed() const;
+
+public slots: // Public slots
+ void nextBook();
+ void previousBook();
+ void nextChapter();
+ void previousChapter();
+ void nextVerse();
+ void previousVerse();
+ /**
+ * Reimplementation to handle the keychooser refresh.
+ */
+ virtual void reload(CSwordBackend::SetupChangedReason);
+
+protected:
+ virtual void initActions();
+ virtual void initToolbars();
+
+private:
+ QAction* m_syncButton;
+ CSwordVerseKey* verseKey();
+protected:
+ virtual void setupPopupMenu();
+};
+
+#endif
diff --git a/src/frontend/displaywindow/cdisplaywindow.cpp b/src/frontend/displaywindow/cdisplaywindow.cpp
new file mode 100644
index 0000000..59fccab
--- /dev/null
+++ b/src/frontend/displaywindow/cdisplaywindow.cpp
@@ -0,0 +1,497 @@
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2008 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+#include "cdisplaywindow.h"
+#include "bttoolbarpopupaction.h"
+#include "btactioncollection.h"
+
+#include "cmodulechooserbar.h"
+#include "cbuttons.h"
+#include "backend/keys/cswordkey.h"
+#include "frontend/keychooser/ckeychooser.h"
+#include "frontend/keychooser/bthistory.h"
+#include "frontend/display/cdisplay.h"
+#include "frontend/cmdiarea.h"
+#include "frontend/profile/cprofilewindow.h"
+#include "backend/config/cbtconfig.h"
+#include "frontend/searchdialog/csearchdialog.h"
+#include "util/cresmgr.h"
+#include "util/directoryutil.h"
+
+#include <QWidget>
+#include <QCloseEvent>
+#include <QStringList>
+#include <QDebug>
+#include <QMenu>
+
+using namespace Profile;
+
+CDisplayWindow::CDisplayWindow(QList<CSwordModuleInfo*> modules, CMDIArea *parent)
+ : QMainWindow(parent),
+ m_mdi(parent),
+ m_filterOptions(),
+ m_displayOptions(),
+ m_displaySettingsButton(0),
+ m_keyChooser(0),
+ m_swordKey(0),
+ m_isReady(false),
+ m_moduleChooserBar(0),
+ m_mainToolBar(0),
+ m_popupMenu(0),
+ m_displayWidget(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(), SIGNAL(sigSwordSetupChanged(CSwordBackend::SetupChangedReason)), SLOT(reload(CSwordBackend::SetupChangedReason)));
+ //KMainWindow::setAttribute(Qt::WA_DeleteOnClose); //what about QMdiSubWindow?
+}
+
+CDisplayWindow::~CDisplayWindow() {
+ delete m_swordKey;
+ m_swordKey = 0;
+}
+
+CMDIArea* CDisplayWindow::mdi() const {
+ return m_mdi;
+}
+
+/** Returns the right window caption. */
+const QString CDisplayWindow::windowCaption() {
+ if (!m_modules.count()) {
+ return QString::null;
+ }
+
+ return QString(key()->key()).append(" (").append(m_modules.join(" | ")).append(")");
+}
+
+/** Returns the used modules as a QPtrList */
+QList<CSwordModuleInfo*> CDisplayWindow::modules() {
+ QList<CSwordModuleInfo*> mods;
+
+ for (QStringList::iterator it = m_modules.begin(); it != m_modules.end(); ++it) {
+ Q_ASSERT(backend()->findModuleByName(*it));
+ if (CSwordModuleInfo* m = backend()->findModuleByName(*it)) {
+ mods.append(m);
+ }
+ }
+
+ return mods;
+}
+
+/** Set the window caption. */
+void CDisplayWindow::setCaption( const QString& ) {
+ QWidget::setWindowTitle( windowCaption() );
+ m_mdi->emitWindowCaptionChanged();
+}
+
+void CDisplayWindow::insertKeyboardActions( BtActionCollection* a ) {
+ qDebug() << "CDisplayWindow::insertKeyboardActions: ac: " << a;
+
+ QAction* actn = new QAction(QIcon(), tr("Zoom in"), 0);
+ actn->setShortcut(QKeySequence::ZoomIn);
+ a->addAction("zoomIn", actn);
+ //a->addAction(KStandardAction::ZoomIn, "zoomIn", 0, 0);
+ actn = new QAction(QIcon(), tr("Zoom out"), 0);
+ actn->setShortcut(QKeySequence::ZoomOut);
+ a->addAction("zoomIn", actn);
+ //a->addAction(KStandardAction::ZoomOut, "zoomOut", 0, 0);
+ actn = new QAction(QIcon(), tr("Close"), 0);
+ actn->setShortcut(QKeySequence::Close);
+ a->addAction("closeWindow", actn);
+ //a->addAction(KStandardAction::Close, "closeWindow", 0, 0);
+ actn = new QAction(QIcon(), tr("Select all"), 0);
+ actn->setShortcut(QKeySequence::SelectAll);
+ a->addAction("selectAll", actn);
+ //a->addAction(KStandardAction::SelectAll, "selectAll", 0, 0);
+ actn = new QAction(QIcon(), tr("Copy"), 0);
+ actn->setShortcut(QKeySequence::Copy);
+ a->addAction("copySelectedText", actn);
+ //a->addAction(KStandardAction::Copy, "copySelectedText", 0, 0);
+ actn = new QAction(QIcon(), tr("Find..."), 0);
+ actn->setShortcut(QKeySequence::Find);
+ a->addAction("findText", actn);
+ //a->addAction(KStandardAction::Find, "findText", 0, 0);
+
+ BtToolBarPopupAction* action = new BtToolBarPopupAction(
+ QIcon(util::filesystem::DirectoryUtil::getIcon(CResMgr::displaywindows::general::backInHistory::icon)),
+ tr("Back in history"),
+ a
+ );
+ action->setShortcut(CResMgr::displaywindows::general::backInHistory::accel);
+ a->addAction(CResMgr::displaywindows::general::backInHistory::actionName, action);
+
+ action = new BtToolBarPopupAction(
+ QIcon(util::filesystem::DirectoryUtil::getIcon(CResMgr::displaywindows::general::forwardInHistory::icon)),
+ tr("Forward in history"),
+ a
+ );
+ action->setShortcut(CResMgr::displaywindows::general::forwardInHistory::accel);
+ a->addAction(CResMgr::displaywindows::general::forwardInHistory::actionName, action);
+}
+
+void CDisplayWindow::initActions()
+{
+ qDebug("CDisplayWindow::initActions");
+
+ BtActionCollection* ac = actionCollection();
+
+ QAction* kaction = new QAction(
+ QIcon(util::filesystem::DirectoryUtil::getIcon(CResMgr::displaywindows::general::search::icon)),
+ tr("Open the search dialog with the works of this window"),
+ ac
+ );
+ kaction->setShortcut(CResMgr::displaywindows::general::search::accel);
+ QObject::connect(kaction, SIGNAL(triggered()), this, SLOT(slotSearchInModules()));
+ ac->addAction(CResMgr::displaywindows::general::search::actionName, kaction);
+
+ CDisplayConnections* conn = displayWidget()->connectionsProxy();
+
+ QAction* actn = new QAction(QIcon(), tr("Zoom in"), ac);
+ actn->setShortcut(QKeySequence::ZoomIn);
+ QObject::connect(actn, SIGNAL(triggered()), conn, SLOT(zoomIn()));
+ ac->addAction("zoomIn", actn);
+ addAction(actn);
+ //a->addAction(KStandardAction::ZoomIn, "zoomIn", 0, 0);
+ actn = new QAction(QIcon(), tr("Zoom out"), ac);
+ actn->setShortcut(QKeySequence::ZoomOut);
+ QObject::connect(actn, SIGNAL(triggered()), conn, SLOT(zoomOut()));
+ ac->addAction("zoomOut", actn);
+ addAction(actn);
+ //a->addAction(KStandardAction::ZoomOut, "zoomOut", 0, 0);
+ actn = new QAction(QIcon(), tr("Close"), ac);
+ actn->setShortcut(QKeySequence::Close);
+ QObject::connect(actn, SIGNAL(triggered()), this, SLOT(close()));
+ ac->addAction("closeWindow", actn);
+ addAction(actn);
+ //a->addAction(KStandardAction::Close, "closeWindow", 0, 0);
+ actn = new QAction(QIcon(), tr("Select all"), ac);
+ actn->setShortcut(QKeySequence::SelectAll);
+ QObject::connect(actn, SIGNAL(triggered()), conn, SLOT(selectAll()));
+ ac->addAction("selectAll", actn);
+ addAction(actn);
+ //a->addAction(KStandardAction::SelectAll, "selectAll", 0, 0);
+ actn = new QAction(QIcon(), tr("Copy"), ac);
+ actn->setShortcut(QKeySequence::Copy);
+ QObject::connect(actn, SIGNAL(triggered()), conn, SLOT(copySelection()));
+ ac->addAction("copySelectedText", actn);
+ addAction(actn);
+ //a->addAction(KStandardAction::Copy, "copySelectedText", 0, 0);
+ actn = new QAction(QIcon(), tr("Find..."), ac);
+ actn->setShortcut(QKeySequence::Find);
+ QObject::connect(actn, SIGNAL(triggered()), conn, SLOT(openFindTextDialog()));
+ ac->addAction("findText", actn);
+ addAction(actn);
+ //a->addAction(KStandardAction::Find, "findText", 0, 0);
+
+ BtToolBarPopupAction* popupaction = new BtToolBarPopupAction(
+ QIcon(util::filesystem::DirectoryUtil::getIcon(CResMgr::displaywindows::general::backInHistory::icon)),
+ tr("Back in history"),
+ ac
+ );
+ bool ok = QObject::connect(popupaction, SIGNAL(triggered()), keyChooser()->history(), SLOT(back()));
+ Q_ASSERT(ok);
+ ac->addAction(CResMgr::displaywindows::general::backInHistory::actionName, popupaction);
+
+ popupaction = new BtToolBarPopupAction(
+ QIcon(util::filesystem::DirectoryUtil::getIcon(CResMgr::displaywindows::general::forwardInHistory::icon)),
+ tr("Forward in history"),
+ ac
+ );
+ ok = QObject::connect(popupaction, SIGNAL(triggered()), keyChooser()->history(), SLOT(fw()) );
+ Q_ASSERT(ok);
+ ac->addAction(CResMgr::displaywindows::general::forwardInHistory::actionName, popupaction);
+
+}
+
+/** Refresh the settings of this window. */
+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())) {
+ it.remove();
+ }
+ }
+
+ if (m_modules.count() == 0){
+ close();
+ return;
+ }
+
+ if (keyChooser()) keyChooser()->setModules( modules(), false );
+
+ if (m_moduleChooserBar) { //necessary for edit windows which have now chooser bar
+ m_moduleChooserBar->setModules(modules());
+ }
+ modulesChanged();
+ lookup();
+}
+
+/** Returns the filter options used by this window. */
+CSwordBackend::FilterOptions& CDisplayWindow::filterOptions() {
+ return m_filterOptions;
+}
+
+/** Returns the display options used by this display window. */
+CSwordBackend::DisplayOptions& CDisplayWindow::displayOptions() {
+ return m_displayOptions;
+}
+
+/** Sets the new display options for this window. */
+void CDisplayWindow::setDisplayOptions( const CSwordBackend::DisplayOptions& displayOptions ) {
+ m_displayOptions = displayOptions;
+}
+
+/** Sets the new filter options of this window. */
+void CDisplayWindow::setFilterOptions( CSwordBackend::FilterOptions& filterOptions ) {
+ m_filterOptions = filterOptions;
+}
+
+/** Returns true if the widget is ready for use. */
+bool CDisplayWindow::isReady() const {
+ return m_isReady;
+}
+
+/** Set the ready status */
+void CDisplayWindow::setReady( const bool& ready ) {
+ m_isReady = ready;
+}
+
+/** Returns true if the window may be closed. */
+bool CDisplayWindow::queryClose() {
+ return true;
+}
+
+/** Returns the keychooser widget of this display window. */
+CKeyChooser* CDisplayWindow::keyChooser() const {
+ return m_keyChooser;
+}
+
+/** Sets the keychooser widget for this display window. */
+void CDisplayWindow::setKeyChooser( CKeyChooser* ck ) {
+ m_keyChooser = ck;
+}
+
+/** Returns the key of this display window. */
+CSwordKey* CDisplayWindow::key() const {
+ Q_ASSERT( m_swordKey );
+ return m_swordKey;
+}
+
+/** Sets the new sword key. */
+void CDisplayWindow::setKey( CSwordKey* key ) {
+ Q_ASSERT( key );
+ m_swordKey = key;
+}
+
+void CDisplayWindow::modulesChanged() {
+ if (moduleChooserBar()) { //necessary for write windows
+ setModules( m_moduleChooserBar->getModuleList() );
+ }
+
+ if (!modules().count()) {
+ close();
+ }
+ else {
+ if (displaySettingsButton()) {
+ displaySettingsButton()->reset(modules());
+ }
+
+ key()->module(modules().first());
+ keyChooser()->setModules(modules());
+ }
+}
+
+/** Returns the module chooser bar. */
+CModuleChooserBar* CDisplayWindow::moduleChooserBar() const {
+ return m_moduleChooserBar;
+}
+
+/** Sets the module chooser bar. */
+void CDisplayWindow::setModuleChooserBar( CModuleChooserBar* bar ) {
+ if (m_moduleChooserBar) {
+ disconnect(m_moduleChooserBar, SIGNAL(sigChanged()), this, SLOT(modulesChanged()));
+ }
+
+ //if a new bar should be set!
+ if (bar) {
+ m_moduleChooserBar = bar;
+ connect(bar, SIGNAL(sigChanged()), SLOT(modulesChanged()));
+ }
+}
+
+/** Sets the modules. */
+void CDisplayWindow::setModules( const QList<CSwordModuleInfo*>& newModules ) {
+ qDebug("CDisplayWindow::setModules");
+ m_modules.clear();
+
+ foreach (CSwordModuleInfo* mod, newModules) {
+ m_modules.append(mod->name());
+ }
+}
+
+/** Initialize the window. Call this method from the outside, because calling this in the constructor is not possible! */
+bool CDisplayWindow::init() {
+ qDebug("CDisplayWindow::init");
+ initView();
+ setMinimumSize( 100,100 );
+
+ setCaption(windowCaption());
+ //setup focus stuff.
+ setFocusPolicy(Qt::ClickFocus);
+ parentWidget()->setFocusPolicy(Qt::ClickFocus);
+ initActions();
+ initToolbars();
+ initConnections();
+ setupPopupMenu();
+
+ m_filterOptions = CBTConfig::getFilterOptionDefaults();
+ m_displayOptions = CBTConfig::getDisplayOptionDefaults();
+ if (displaySettingsButton()) {
+ displaySettingsButton()->reset(modules());
+ }
+
+ setReady(true);
+ return true;
+}
+
+/** Returns the main toolbar. */
+QToolBar* CDisplayWindow::mainToolBar() const {
+ return m_mainToolBar;
+}
+
+/** Returns the main toolbar. */
+QToolBar* CDisplayWindow::buttonsToolBar() const {
+ return m_buttonsToolBar;
+}
+
+/** Sets the main toolbar. */
+void CDisplayWindow::setMainToolBar( QToolBar* bar ) {
+ m_mainToolBar = bar;
+}
+
+/** Sets the main toolbar. */
+void CDisplayWindow::setButtonsToolBar( QToolBar* bar ) {
+ m_buttonsToolBar = bar;
+}
+
+/** Returns the display settings button */
+CDisplaySettingsButton* CDisplayWindow::displaySettingsButton() const {
+ return m_displaySettingsButton;
+}
+
+/** Sets the display settings button. */
+void CDisplayWindow::setDisplaySettingsButton( CDisplaySettingsButton* button ) {
+ if (m_displaySettingsButton)
+ disconnect(m_displaySettingsButton, SIGNAL( sigChanged() ),this, SLOT(lookup() ));
+
+ m_displaySettingsButton = button;
+ connect(m_displaySettingsButton, SIGNAL(sigChanged()),this, SLOT(lookup()));
+}
+
+/** Lookup the current key. Used to refresh the display. */
+void CDisplayWindow::lookup() {
+ lookupSwordKey( key() );
+}
+
+void CDisplayWindow::lookupModKey( const QString& moduleName, const QString& keyName ) {
+ if (!isReady()) {
+ return;
+ }
+
+ CSwordModuleInfo* m = backend()->findModuleByName(moduleName);
+ Q_ASSERT(m);
+ if (!m) {
+ return;
+ }
+
+ //ToDo: check for containsRef compat
+ if (m && modules().contains(m)) {
+ key()->key(keyName);
+ keyChooser()->setKey(key()); //the key chooser does send an update signal
+ }
+ 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);
+ mdi()->emitCreateDisplayWindow(mList, keyName);
+ }
+}
+
+void CDisplayWindow::lookupKey( const QString& keyName ) {
+ /* This function is called for example after a bookmark was dropped on this window
+ */
+ Q_ASSERT(modules().first());
+
+ //qDebug("CDisplayWindow::lookup: %s", keyName.latin1());
+ lookupModKey(modules().first()->name(), keyName);
+}
+
+/** Update the status of the popup menu entries. */
+void CDisplayWindow::updatePopupMenu() {}
+
+
+///** Returns the installed popup menu. */
+QMenu* CDisplayWindow::popup() {
+ // qWarning("CReadWindow::popup()");
+ if (!m_popupMenu) {
+ m_popupMenu = new QMenu(this);
+ connect(m_popupMenu, SIGNAL(aboutToShow()), this, SLOT(updatePopupMenu()));
+ if (displayWidget()) {
+ displayWidget()->installPopup(m_popupMenu);
+ }
+ /* else {
+ qWarning("CDisplayWindow:: can't instal popup menu");
+ }*/
+ }
+ return m_popupMenu;
+}
+
+/** Returns the display widget used by this implementation of CDisplayWindow. */
+CDisplay* CDisplayWindow::displayWidget() const {
+ Q_ASSERT(m_displayWidget);
+ return m_displayWidget;
+}
+
+/** Sets the display widget used by this display window. */
+void CDisplayWindow::setDisplayWidget( CDisplay* newDisplay ) {
+ m_displayWidget = newDisplay;
+}
+
+void CDisplayWindow::closeEvent(QCloseEvent* e) {
+ if (!queryClose()) {
+ e->ignore();
+ }
+ else {
+ e->accept();
+ }
+}
+
+void CDisplayWindow::slotSearchInModules() {
+ Search::CSearchDialog::openDialog(modules());
+}
+
+void CDisplayWindow::printAll() {
+ m_displayWidget->connectionsProxy()->printAll( m_displayOptions, m_filterOptions);
+}
+
+void CDisplayWindow::printAnchorWithText() {
+ m_displayWidget->connectionsProxy()->printAnchorWithText( m_displayOptions, m_filterOptions);
+}
+
+BtActionCollection* CDisplayWindow::actionCollection()
+{
+ return m_actionCollection;
+}
diff --git a/src/frontend/displaywindow/cdisplaywindow.h b/src/frontend/displaywindow/cdisplaywindow.h
new file mode 100644
index 0000000..1eb7d06
--- /dev/null
+++ b/src/frontend/displaywindow/cdisplaywindow.h
@@ -0,0 +1,264 @@
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2008 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+#ifndef CDISPLAYWINDOW_H
+#define CDISPLAYWINDOW_H
+
+//BibleTime includes
+#include "util/cpointers.h"
+
+class CSwordModuleInfo;
+#include "backend/managers/cswordbackend.h"
+
+#include "frontend/profile/cprofilewindow.h"
+
+//Qt includes
+#include <QStringList>
+#include <QMainWindow>
+
+//Forward declarations
+class CMDIArea;
+class CReadWindow;
+class CWriteWindow;
+class CDisplaySettingsButton;
+class CDisplay;
+class CKeyChooser;
+class CModuleChooserBar;
+class QCloseEvent;
+
+class QToolBar;
+class QCloseEvent;
+class QMenu;
+class BtActionCollection;
+
+/** The base class for all display windows of BibleTime.
+ * @author The BibleTime team
+ */
+
+class CDisplayWindow : public QMainWindow, public CPointers {
+ Q_OBJECT
+public:
+ enum WriteWindowType {
+ HTMLWindow = 1,
+ PlainTextWindow = 2
+ };
+
+ /**
+ * Insert the keyboard accelerators of this window into the given KAccel object.
+ */
+ // static void insertKeyboardActions( KAccel* const accel );
+ static void insertKeyboardActions( BtActionCollection* const a );
+
+ CMDIArea* mdi() const;
+ /**
+ * Returns the right window caption.
+ */
+ const QString windowCaption();
+ /**
+ * Returns the used modules as a QPtrList
+ */
+ QList<CSwordModuleInfo*> modules();
+ /**
+ * Store the settings of this window in the given CProfileWindow object.
+ */
+ virtual void storeProfileSettings( Profile::CProfileWindow* profileWindow ) = 0;
+ /**
+ * Store the settings of this window in the given profile window.
+ */
+ virtual void applyProfileSettings( Profile::CProfileWindow* profileWindow ) = 0;
+ /**
+ * Set the window caption.
+ */
+ virtual void setCaption( const QString& );
+ /**
+ * Sets the new filter options of this window.
+ */
+ void setFilterOptions( CSwordBackend::FilterOptions& filterOptions );
+ /**
+ * Sets the new display options for this window.
+ */
+ void setDisplayOptions( const CSwordBackend::DisplayOptions& displayOptions );
+ /**
+ * Returns the display options used by this display window.
+ */
+ CSwordBackend::DisplayOptions& displayOptions();
+ /**
+ * Returns the filter options used by this window.
+ */
+ CSwordBackend::FilterOptions& filterOptions();
+ /**
+ * Set the ready status
+ */
+ void setReady( const bool& ready );
+ /**
+ * Returns true if the widget is ready for use.
+ */
+ bool isReady() const;
+ /**
+ * Returns true if the window may be closed.
+ */
+ virtual bool queryClose();
+ /**
+ * Returns the keychooser widget of this display window.
+ */
+ CKeyChooser* keyChooser() const;
+ /**
+ * Sets the new sword key.
+ */
+ void setKey( CSwordKey* key );
+ /**
+ * Returns the key of this display window.
+ */
+ CSwordKey* key() const;
+ /**
+ * Initialize the window. Call this method from the outside, because calling this in the constructor is not possible!
+ */
+ virtual bool init();
+ /**
+ * Sets the main toolbar.
+ */
+ void setMainToolBar( QToolBar* bar );
+ /**
+ * Sets the buttons toolbar.
+ */
+ void setButtonsToolBar( QToolBar* bar );
+ /**
+ * Returns the main toolbar.
+ */
+ QToolBar* mainToolBar() const;
+ /**
+ * Returns the buttons toolbar.
+ */
+ QToolBar* buttonsToolBar() const;
+ /**
+ * Initialize the toolbars
+ */
+ virtual void initToolbars() = 0;
+ /**
+ * Returns the display settings button
+ */
+ CDisplaySettingsButton* displaySettingsButton() const;
+ /**
+ * Sets the display settings button.
+ */
+ void setDisplaySettingsButton( CDisplaySettingsButton* button );
+ virtual void setupPopupMenu() = 0;
+ /**
+ * Returns the display widget used by this implementation of CDisplayWindow.
+ */
+ virtual CDisplay* displayWidget() const;
+ /**
+ * Sets the display widget used by this display window.
+ */
+ virtual void setDisplayWidget( CDisplay* newDisplay );
+
+ /** Returns whether syncs to the active window are allowed at this time for this display window
+ * @return boolean value whether sync is allowed
+ */
+ virtual bool syncAllowed() const {
+ return false;
+ };
+
+ BtActionCollection* actionCollection();
+
+public slots:
+ /**
+ * Lookup the specified key in the given module. If the module is not chosen withing
+ * this display window create a new displaywindow with the right module in it.
+ */
+ virtual void lookupModKey( const QString& module, const QString& key );
+ /**
+ * Lookup the key in the chosen modules.
+ */
+ virtual void lookupKey( const QString& key );
+ /**
+ * Refresh the settings of this window.
+ */
+ virtual void reload(CSwordBackend::SetupChangedReason reason);
+
+protected:
+ friend class CMDIArea;
+ friend class CBibleReadWindow;
+
+ CDisplayWindow(QList<CSwordModuleInfo*> modules, CMDIArea* parent);
+ virtual ~CDisplayWindow();
+ /**
+ * Initializes the intern keyboard actions.
+ */
+ virtual void initActions();
+ /**
+ * Sets the keychooser widget for this display window.
+ */
+ void setKeyChooser( CKeyChooser* ck );
+ /**
+ * Returns the module chooser bar.
+ */
+ CModuleChooserBar* moduleChooserBar() const;
+ /**
+ * Lookup the given key.
+ */
+ virtual void lookupSwordKey( CSwordKey* ) = 0;
+ /**
+ * Sets the module chooser bar.
+ */
+ void setModuleChooserBar( CModuleChooserBar* bar );
+ /**
+ * Sets the modules.
+ */
+ void setModules( const QList<CSwordModuleInfo*>& modules );
+ /**
+ * Initializes the signal / slot connections of this display window.
+ */
+ virtual void initConnections() = 0;
+ /**
+ * Initialize the view of this display window.
+ */
+ virtual void initView() = 0;
+ /**
+ * Returns the installed popup menu.
+ */
+ QMenu* popup();
+ virtual void closeEvent(QCloseEvent* e);
+
+protected slots:
+ virtual void modulesChanged();
+ /**
+ * Lookup the current key. Used to refresh the display.
+ */
+ void lookup();
+ virtual void updatePopupMenu();
+
+ void slotSearchInModules();
+
+ void printAll();
+ void printAnchorWithText();
+
+
+private:
+ BtActionCollection* m_actionCollection;
+ CMDIArea* m_mdi;
+
+ //we may only cache the module names bacause after a backend relaod the pointers are invalid!
+ QStringList m_modules;
+
+ CSwordBackend::FilterOptions m_filterOptions;
+ CSwordBackend::DisplayOptions m_displayOptions;
+
+ CDisplaySettingsButton* m_displaySettingsButton;
+ CKeyChooser* m_keyChooser;
+ CSwordKey* m_swordKey;
+ bool m_isReady;
+ CModuleChooserBar* m_moduleChooserBar;
+ QToolBar* m_mainToolBar;
+ QToolBar* m_buttonsToolBar;
+ QMenu* m_popupMenu;
+ CDisplay* m_displayWidget;
+};
+
+#endif
diff --git a/src/frontend/displaywindow/cdisplaywindowfactory.cpp b/src/frontend/displaywindow/cdisplaywindowfactory.cpp
new file mode 100644
index 0000000..d386ecf
--- /dev/null
+++ b/src/frontend/displaywindow/cdisplaywindowfactory.cpp
@@ -0,0 +1,57 @@
+//
+// C++ Implementation: cdisplaywindowfactory
+//
+// Description:
+//
+//
+// Author: The BibleTime team <info@bibletime.info>, (C) 2007
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#include "cdisplaywindowfactory.h"
+
+#include "creadwindow.h"
+#include "cbiblereadwindow.h"
+#include "ccommentaryreadwindow.h"
+#include "clexiconreadwindow.h"
+#include "cbookreadwindow.h"
+#include "cwritewindow.h"
+#include "cplainwritewindow.h"
+#include "chtmlwritewindow.h"
+
+
+#include "backend/drivers/cswordmoduleinfo.h"
+#include "frontend/cmdiarea.h"
+
+
+CReadWindow* CDisplayWindowFactory::createReadInstance(QList<CSwordModuleInfo*> modules, CMDIArea* parent)
+{
+ qDebug("CDisplayWindowFactory::createReadInstance");
+ switch (modules.first()->type()) {
+ case CSwordModuleInfo::Bible:
+ return new CBibleReadWindow(modules, parent);
+ case CSwordModuleInfo::Commentary:
+ return new CCommentaryReadWindow(modules, parent);
+ case CSwordModuleInfo::Lexicon:
+ return new CLexiconReadWindow(modules, parent);
+ case CSwordModuleInfo::GenericBook:
+ return new CBookReadWindow(modules, parent);
+ default:
+ qWarning("unknown module type");
+ break;
+ }
+ return 0;
+}
+
+
+CWriteWindow* CDisplayWindowFactory::createWriteInstance(QList<CSwordModuleInfo*> modules, CMDIArea* parent, const CDisplayWindow::WriteWindowType type)
+{
+ if (type == CDisplayWindow::HTMLWindow) {
+ return new CHTMLWriteWindow(modules, parent);
+ }
+ else {
+ return new CPlainWriteWindow(modules, parent);
+ }
+ return 0;
+}
diff --git a/src/frontend/displaywindow/cdisplaywindowfactory.h b/src/frontend/displaywindow/cdisplaywindowfactory.h
new file mode 100644
index 0000000..4bc4372
--- /dev/null
+++ b/src/frontend/displaywindow/cdisplaywindowfactory.h
@@ -0,0 +1,34 @@
+//
+// C++ Interface: cdisplaywindowfactory
+//
+// Description:
+//
+//
+// Author: The BibleTime team <info@bibletime.info>, (C) 2007
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#ifndef CDISPLAYWINDOWFACTORY_H
+#define CDISPLAYWINDOWFACTORY_H
+
+#include "cdisplaywindow.h"
+
+class CSwordModuleInfo;
+
+
+class CReadWindow;
+class CWriteWindow;
+class CMDIArea;
+
+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);
+
+private:
+ CDisplayWindowFactory();
+};
+
+#endif
diff --git a/src/frontend/displaywindow/chtmlwritewindow.cpp b/src/frontend/displaywindow/chtmlwritewindow.cpp
new file mode 100644
index 0000000..7e97aa6
--- /dev/null
+++ b/src/frontend/displaywindow/chtmlwritewindow.cpp
@@ -0,0 +1,163 @@
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2008 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+
+
+#include "chtmlwritewindow.h"
+#include "btactioncollection.h"
+
+//frontend includes
+#include "frontend/keychooser/ckeychooser.h"
+#include "frontend/profile/cprofilewindow.h"
+#include "frontend/display/cwritedisplay.h"
+#include "frontend/display/chtmlwritedisplay.h"
+
+#include "backend/keys/cswordkey.h"
+
+#include "util/cresmgr.h"
+#include "util/directoryutil.h"
+
+//Qt includes
+#include <QToolBar>
+#include <QMessageBox>
+#include <QAction>
+
+using namespace Profile;
+
+CHTMLWriteWindow::CHTMLWriteWindow(QList<CSwordModuleInfo*> modules, CMDIArea* parent)
+: CPlainWriteWindow(modules, parent) {}
+
+CHTMLWriteWindow::~CHTMLWriteWindow() {}
+
+void CHTMLWriteWindow::initView() {
+ CWriteDisplay* writeDisplay = CDisplay::createWriteInstance(this, CDisplay::HTMLDisplay);
+ Q_ASSERT(writeDisplay);
+ setDisplayWidget( writeDisplay );
+ setCentralWidget( displayWidget()->view() );
+
+ setMainToolBar( new QToolBar(this) );
+ addToolBar(mainToolBar());
+
+ setKeyChooser( CKeyChooser::createInstance(modules(), key(), mainToolBar()) );
+ mainToolBar()->addWidget(keyChooser());
+}
+
+void CHTMLWriteWindow::initConnections() {
+ CWriteWindow::initConnections();
+
+ connect(keyChooser(), SIGNAL(keyChanged(CSwordKey*)), this, SLOT(lookupSwordKey(CSwordKey*)));
+ connect(displayWidget()->connectionsProxy(), SIGNAL(textChanged()), this, SLOT(textChanged()) );
+}
+
+void CHTMLWriteWindow::initToolbars() {
+ //setup the main toolbar
+ m_actions.syncWindow = new QAction(
+ util::filesystem::DirectoryUtil::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(
+ util::filesystem::DirectoryUtil::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(
+ util::filesystem::DirectoryUtil::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(
+ util::filesystem::DirectoryUtil::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);
+ ((CWriteDisplay*)displayWidget())->setupToolbar( bar, actionCollection() );
+ addToolBar(bar);
+}
+
+void CHTMLWriteWindow::storeProfileSettings( CProfileWindow* profileWindow ) {
+ CWriteWindow::storeProfileSettings(profileWindow);
+ profileWindow->setWindowSettings( m_actions.syncWindow->isChecked() );
+}
+
+void CHTMLWriteWindow::applyProfileSettings( CProfileWindow* profileWindow ) {
+ CWriteWindow::applyProfileSettings(profileWindow);
+ if (profileWindow->windowSettings()) {
+ m_actions.syncWindow->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() );
+}
+
+/** Loads the original text from the module. */
+void CHTMLWriteWindow::restoreText() {
+ lookupSwordKey(key());
+ ((CWriteDisplay*)displayWidget())->setModified(false);
+ textChanged();
+}
+
+bool CHTMLWriteWindow::syncAllowed() const {
+ return m_actions.syncWindow->isChecked();
+}
+
+/** Saves the text for the current key. Directly writes the changed text into the module. */
+void CHTMLWriteWindow::saveCurrentText( const QString& /*key*/ ) {
+ QString t = ((CHTMLWriteDisplay*)displayWidget())->toHtml();
+ //since t is a complete HTML page at the moment, strip away headers and footers of a HTML page
+ QRegExp re("(?:<html.*>.+<body.*>)", Qt::CaseInsensitive); //remove headers, case insensitive
+ re.setMinimal(true);
+ t.replace(re, "");
+ t.replace(QRegExp("</body></html>", Qt::CaseInsensitive), "");//remove footer
+
+ const QString& oldKey = this->key()->key();
+ if( modules().first()->isWritable() ) {
+ modules().first()->write(this->key(), t );
+ this->key()->key( oldKey );
+
+ ((CWriteDisplay*)displayWidget())->setModified(false);
+ textChanged();
+ }
+ else {
+ QMessageBox::critical( this, tr("Module not writable"),
+ QString::fromLatin1("<qt><b>%1</b><br />%2</qt>")
+ .arg( tr("Module is not writable.") )
+ .arg( tr("Either the module may not be edited, or you do not have write permission.") ) );
+ }
+}
diff --git a/src/frontend/displaywindow/chtmlwritewindow.h b/src/frontend/displaywindow/chtmlwritewindow.h
new file mode 100644
index 0000000..9c50957
--- /dev/null
+++ b/src/frontend/displaywindow/chtmlwritewindow.h
@@ -0,0 +1,75 @@
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2008 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+
+
+#ifndef CHTMLWRITEWINDOW_H
+#define CHTMLWRITEWINDOW_H
+
+//BibleTime includes
+#include "cplainwritewindow.h"
+
+class QAction;
+
+
+/** The WYSIWYG implementation of the editor.
+ * @author The BibleTime team
+ */
+class CHTMLWriteWindow : public CPlainWriteWindow {
+ Q_OBJECT
+public:
+ CHTMLWriteWindow(QList<CSwordModuleInfo*> modules, CMDIArea* parent);
+ virtual ~CHTMLWriteWindow();
+
+ /**
+ * 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* );
+
+ virtual bool syncAllowed() const;
+
+protected: // Protected methods
+ /**
+ * Initialize the state of this widget.
+ */
+ virtual void initView();
+ virtual void initConnections();
+ virtual void initToolbars();
+ virtual CDisplayWindow::WriteWindowType writeWindowType() {
+ return CDisplayWindow::HTMLWindow;
+ };
+
+protected slots:
+ /**
+ * Is called when the current text was changed.
+ */
+ virtual void textChanged();
+ /**
+ * Loads the original text from the module.
+ */
+ virtual void restoreText();
+ /**
+ * 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
new file mode 100644
index 0000000..703e40c
--- /dev/null
+++ b/src/frontend/displaywindow/clexiconreadwindow.cpp
@@ -0,0 +1,367 @@
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2008 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+
+
+//BibleTime includes
+#include "clexiconreadwindow.h"
+#include "btactioncollection.h"
+
+#include "cmodulechooserbar.h"
+#include "cbuttons.h"
+#include "bttoolbarpopupaction.h"
+
+#include "backend/keys/cswordkey.h"
+#include "backend/keys/cswordldkey.h"
+
+#include "backend/config/cbtconfig.h"
+#include "frontend/cexportmanager.h"
+#include "frontend/display/cdisplay.h"
+#include "frontend/display/creaddisplay.h"
+#include "frontend/display/bthtmlreaddisplay.h"
+#include "frontend/keychooser/ckeychooser.h"
+#include "frontend/keychooser/bthistory.h"
+
+#include "util/ctoolclass.h"
+#include "util/cresmgr.h"
+#include "util/directoryutil.h"
+
+#include <QMenu>
+#include <QApplication>
+#include <QFile>
+#include <QFileDialog>
+#include <QAction>
+
+CLexiconReadWindow::CLexiconReadWindow(QList<CSwordModuleInfo*> moduleList, CMDIArea* parent)
+ : CReadWindow(moduleList, parent)
+{
+ qDebug("CLexiconReadWindow::CLexiconReadWindow");
+ moduleList.first();
+ setKey( CSwordKey::createInstance(moduleList.first()) );
+}
+
+CLexiconReadWindow::~CLexiconReadWindow() {}
+
+void CLexiconReadWindow::insertKeyboardActions( BtActionCollection* const a )
+{
+ qDebug("CLexiconReadWindow::insertKeyboardActions");
+ QAction* kaction;
+ kaction = new QAction( tr("Next entry"), a);
+ kaction->setShortcut(CResMgr::displaywindows::lexiconWindow::nextEntry::accel);
+ a->addAction("nextEntry", kaction);
+
+ kaction = new QAction( tr("Previous entry"), a);
+ kaction->setShortcut( CResMgr::displaywindows::lexiconWindow::previousEntry::accel);
+ a->addAction("previousEntry", kaction);
+
+ kaction = new QAction(tr("Copy reference only"), a);
+ a->addAction("copyReferenceOnly", kaction);
+
+ kaction = new QAction(tr("Copy selected text"), a);
+ a->addAction("copySelectedText", kaction);
+
+ kaction = new QAction(tr("Save entry as HTML"), a);
+ a->addAction("saveHtml", kaction);
+
+ kaction = new QAction(tr("Print reference only"), a);
+ a->addAction("printReferenceOnly", kaction);
+}
+
+void CLexiconReadWindow::initActions()
+{
+ qDebug("CLexiconReadWindow::initActions");
+
+ BtActionCollection* ac = actionCollection();
+ CLexiconReadWindow::insertKeyboardActions(ac);
+ CReadWindow::initActions();
+
+ m_actions.backInHistory = dynamic_cast<BtToolBarPopupAction*>(
+ ac->action(CResMgr::displaywindows::general::backInHistory::actionName) );
+ Q_ASSERT(m_actions.backInHistory);
+
+ m_actions.forwardInHistory = dynamic_cast<BtToolBarPopupAction*>(
+ ac->action(CResMgr::displaywindows::general::forwardInHistory::actionName) );
+ Q_ASSERT(m_actions.forwardInHistory);
+
+ QAction* kaction;
+
+ kaction = new QAction(tr("Next entry"), ac );
+ kaction->setShortcut( CResMgr::displaywindows::lexiconWindow::nextEntry::accel);
+ QObject::connect(kaction, SIGNAL(triggered()), this, SLOT( nextEntry() ) );
+ ac->addAction("nextEntry", kaction);
+
+ kaction = new QAction(tr("Previous entry"), ac );
+ kaction->setShortcut( CResMgr::displaywindows::lexiconWindow::previousEntry::accel);
+ QObject::connect(kaction, SIGNAL(triggered()), this, SLOT( previousEntry() ) );
+ ac->addAction("previousEntry", kaction);
+
+ m_actions.selectAll = qobject_cast<QAction*>(ac->action("selectAll"));
+ //TODO: Q_ASSERT(m_actions.selectAll);
+
+ m_actions.findText = qobject_cast<QAction*>(ac->action("findText"));
+ //TODO: Q_ASSERT(m_actions.findText);
+
+ m_actions.findStrongs = new QAction(
+// QIcon(CResMgr::displaywindows::general::findStrongs::icon),
+ tr("Strong's Search"),
+ ac
+ );
+ m_actions.findStrongs->setShortcut(CResMgr::displaywindows::general::findStrongs::accel);
+ QObject::connect(m_actions.findStrongs, SIGNAL(triggered()), this, SLOT(openSearchStrongsDialog()) );
+ ac->addAction(CResMgr::displaywindows::general::findStrongs::actionName, m_actions.findStrongs);
+
+ m_actions.copy.reference = new QAction(tr("Reference only"), ac );
+ QObject::connect(m_actions.copy.reference, SIGNAL(triggered()), displayWidget()->connectionsProxy(), SLOT(copyAnchorOnly()) );
+ ac->addAction("copyReferenceOnly", m_actions.copy.reference);
+
+ m_actions.copy.entry = new QAction(tr("Entry with text"), ac );
+ QObject::connect(m_actions.copy.entry, SIGNAL(triggered()), displayWidget()->connectionsProxy(), SLOT(copyAll()) );
+ ac->addAction("copyEntryWithText", m_actions.copy.entry);
+
+ Q_ASSERT(ac->action("copySelectedText"));
+ m_actions.copy.selectedText = qobject_cast<QAction*>(ac->action("copySelectedText"));
+
+ m_actions.save.entryAsPlain = new QAction(tr("Entry as plain text"), ac );
+ QObject::connect(m_actions.save.entryAsPlain, SIGNAL(triggered()), this, SLOT(saveAsPlain()) );
+ ac->addAction("saveEntryAsPlain", m_actions.save.entryAsPlain);
+
+ m_actions.save.entryAsHTML = new QAction(tr("Entry as HTML"), ac );
+ QObject::connect(m_actions.save.entryAsHTML, SIGNAL(triggered()), this, SLOT(saveAsHTML()));
+ ac->addAction("saveEntryAsHTML", m_actions.save.entryAsHTML);
+
+ m_actions.print.reference = new QAction(tr("Reference only"), ac);
+ QObject::connect(m_actions.print.reference, SIGNAL(triggered()), this, SLOT(printAnchorWithText()));
+ ac->addAction("printReferenceOnly", m_actions.print.reference);
+
+ m_actions.print.entry = new QAction(tr("Entry with text"), ac);
+ QObject::connect(m_actions.print.entry, SIGNAL(triggered()), this, SLOT(printAll()));
+ ac->addAction("printEntryWithText", m_actions.print.entry);
+
+ // init with the user defined settings
+ qDebug("call CBTConfig::setupAccelSettings(CBTConfig::lexiconWindow, ac); and end CLexiconReadWindow::initActions");
+// CBTConfig::setupAccelSettings(CBTConfig::lexiconWindow, ac);
+}
+
+/** No descriptions */
+void CLexiconReadWindow::initConnections()
+{
+ qDebug("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 the history actions to the right slots
+ bool ok = connect(
+ m_actions.backInHistory->popupMenu(), SIGNAL(aboutToShow()),
+ this, SLOT(slotFillBackHistory())
+ );
+ Q_ASSERT(ok);
+ ok = connect(
+ m_actions.backInHistory->popupMenu(), SIGNAL(triggered(QAction*)),
+ keyChooser()->history(), SLOT(move(QAction*))
+ );
+ Q_ASSERT(ok);
+ ok = connect(
+ m_actions.forwardInHistory->popupMenu(), SIGNAL(aboutToShow()),
+ this, SLOT(slotFillForwardHistory())
+ );
+ Q_ASSERT(ok);
+ ok = connect(
+ m_actions.forwardInHistory->popupMenu(), SIGNAL(triggered(QAction*)),
+ keyChooser()->history(), SLOT(move(QAction*))
+ );
+ Q_ASSERT(ok);
+
+}
+
+void CLexiconReadWindow::initView()
+{
+ qDebug("CLexiconReadWindow::initView");
+ setDisplayWidget( CDisplay::createReadInstance(this) );
+ setMainToolBar( new QToolBar(this) );
+ addToolBar(mainToolBar());
+ setKeyChooser( CKeyChooser::createInstance(modules(), key(), mainToolBar()) );
+ mainToolBar()->addWidget(keyChooser());
+ setModuleChooserBar( new CModuleChooserBar(modules(), modules().first()->type(), this) );
+ moduleChooserBar()->adjustSize();
+ addToolBar(moduleChooserBar());
+ setButtonsToolBar( new QToolBar(this) );
+ addToolBar(buttonsToolBar());
+ setWindowIcon(CToolClass::getIconForModule(modules().first()));
+ setCentralWidget( displayWidget()->view() );
+}
+
+void CLexiconReadWindow::initToolbars()
+{
+ //main toolbar
+ Q_ASSERT(m_actions.backInHistory);
+ mainToolBar()->addAction(m_actions.backInHistory); //1st button
+ mainToolBar()->addAction(m_actions.forwardInHistory); //2nd button
+
+ //buttons toolbar
+ QAction* action = qobject_cast<QAction*>(actionCollection()->action(
+ CResMgr::displaywindows::general::search::actionName));
+ Q_ASSERT( action );
+ if (action) {
+ buttonsToolBar()->addAction(action);
+ }
+ setDisplaySettingsButton( new CDisplaySettingsButton( &displayOptions(), &filterOptions(), modules(), buttonsToolBar()) );
+
+ //TODO: find the right place for the button
+ buttonsToolBar()->addWidget(displaySettingsButton());
+}
+
+void CLexiconReadWindow::setupPopupMenu()
+{
+ popup()->setTitle(tr("Lexicon window"));
+ popup()->setIcon(CToolClass::getIconForModule(modules().first()));
+ popup()->addAction(m_actions.findText);
+ popup()->addAction(m_actions.findStrongs);
+ popup()->addAction(m_actions.selectAll);
+ popup()->addSeparator();
+
+ m_actions.copyMenu = new QMenu(tr("Copy..."), popup());
+
+ m_actions.copyMenu->addAction(m_actions.copy.reference);
+ m_actions.copyMenu->addAction(m_actions.copy.entry);
+ m_actions.copyMenu->addSeparator();
+ m_actions.copyMenu->addAction(m_actions.copy.selectedText);
+ popup()->addMenu(m_actions.copyMenu);
+
+ m_actions.saveMenu = new QMenu(
+ tr("Save..."),
+ popup()
+ );
+ m_actions.saveMenu->addAction(m_actions.save.entryAsPlain);
+ m_actions.saveMenu->addAction(m_actions.save.entryAsHTML);
+
+ // Save raw HTML action for debugging purposes
+ if (qApp->property("--debug").toBool()) {
+ QAction* debugAction = new QAction("Raw HTML", this);
+ QObject::connect(debugAction, SIGNAL(triggered()), this, SLOT(saveRawHTML()));
+ m_actions.saveMenu->addAction(debugAction);
+ } // end of Save Raw HTML
+
+ popup()->addMenu(m_actions.saveMenu);
+
+ m_actions.printMenu = new QMenu(
+ tr("Print..."),
+ popup()
+ );
+ m_actions.printMenu->addAction(m_actions.print.reference);
+ m_actions.printMenu->addAction(m_actions.print.entry);
+ popup()->addMenu(m_actions.printMenu);
+}
+
+/** Reimplemented. */
+void CLexiconReadWindow::updatePopupMenu()
+{
+ //enable the action depending on the supported module features
+
+ m_actions.findStrongs->setEnabled( displayWidget()->getCurrentNodeInfo()[CDisplay::Lemma] != QString::null );
+
+ m_actions.copy.reference->setEnabled( ((CReadDisplay*)displayWidget())->hasActiveAnchor() );
+ m_actions.copy.selectedText->setEnabled( displayWidget()->hasSelection() );
+
+ m_actions.print.reference->setEnabled( ((CReadDisplay*)displayWidget())->hasActiveAnchor() );
+}
+
+/** No descriptions */
+void CLexiconReadWindow::nextEntry()
+{
+ keyChooser()->setKey(ldKey()->NextEntry());
+}
+
+/** No descriptions */
+void CLexiconReadWindow::previousEntry()
+{
+ keyChooser()->setKey(ldKey()->PreviousEntry());
+}
+
+/** Reimplementation to return the right key. */
+CSwordLDKey* CLexiconReadWindow::ldKey()
+{
+ return dynamic_cast<CSwordLDKey*>(CDisplayWindow::key());
+}
+
+/** This function saves the entry as html using the CExportMgr class. */
+void CLexiconReadWindow::saveAsHTML() {
+ CExportManager mgr(tr("Saving entry ..."), true, tr("Saving"), filterOptions(), displayOptions());
+ mgr.saveKey(key(), CExportManager::HTML, true);
+}
+
+/** Saving the raw HTML for debugging purposes */
+void CLexiconReadWindow::saveRawHTML()
+{
+ //qDebug("CLexiconReadWindow::saveRawHTML");
+ QString savefilename = QFileDialog::getSaveFileName();
+ if (savefilename.isEmpty()) return;
+ QFile file(savefilename);
+ BtHtmlReadDisplay* disp = dynamic_cast<BtHtmlReadDisplay*>(displayWidget());
+ if (disp) {
+ if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
+ qDebug("could not open file");
+ return;
+ }
+ QString source = disp->text();
+ file.write(source.toUtf8());
+ //qDebug() << "wrote" << bytes << "bytes";
+ file.close();
+ file.flush();
+ } else {
+ qDebug("No htmlreaddisplay widget!");
+ }
+
+}
+
+/** This function saves the entry as html using the CExportMgr class. */
+void CLexiconReadWindow::saveAsPlain()
+{
+ CExportManager mgr(tr("Saving entry ..."), true, tr("Saving"), filterOptions(), displayOptions());
+ mgr.saveKey(key(), CExportManager::Text, true);
+}
+
+void CLexiconReadWindow::slotFillBackHistory()
+{
+ qDebug("CLexiconReadWindow::slotFillBackHistory");
+
+ QMenu* menu = m_actions.backInHistory->popupMenu();
+ menu->clear();
+
+ //TODO: take the history list and fill the menu
+ QListIterator<QAction*> it(keyChooser()->history()->getBackList());
+ while (it.hasNext()) {
+ menu->addAction(it.next());
+ }
+}
+
+void CLexiconReadWindow::slotFillForwardHistory()
+{
+ qDebug("CLexiconReadWindow::slotFillForwardHistory");
+
+ QMenu* menu = m_actions.forwardInHistory->popupMenu();
+ menu->clear();
+ //TODO: take the history list and fill the menu using addAction
+ QListIterator<QAction*> it(keyChooser()->history()->getFwList());
+ while (it.hasNext()) {
+ menu->addAction(it.next());
+ }
+}
+
+
+void CLexiconReadWindow::slotUpdateHistoryButtons(bool backEnabled, bool fwEnabled)
+{
+ qDebug("CLexiconReadWindow::slotUpdateHistoryButtons");
+ Q_ASSERT(m_actions.backInHistory);
+ Q_ASSERT(keyChooser());
+
+ m_actions.backInHistory->setEnabled( backEnabled );
+ m_actions.forwardInHistory->setEnabled( fwEnabled );
+}
diff --git a/src/frontend/displaywindow/clexiconreadwindow.h b/src/frontend/displaywindow/clexiconreadwindow.h
new file mode 100644
index 0000000..cea9096
--- /dev/null
+++ b/src/frontend/displaywindow/clexiconreadwindow.h
@@ -0,0 +1,118 @@
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2008 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+
+
+#ifndef CLEXICONREADWINDOW_H
+#define CLEXICONREADWINDOW_H
+
+//BibleTime includes
+#include "creadwindow.h"
+#include "frontend/keychooser/ckeychooser.h"
+class BtToolBarPopupAction;
+
+class CSwordKey;
+class CSwordLDKey;
+
+class KToolBarPopupAction;
+class BtActionCollection;
+class QAction;
+class QMenu;
+
+/**
+ *@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 );
+ static void insertKeyboardActions( BtActionCollection* const a );
+
+protected:
+ virtual void initActions();
+ virtual void initToolbars();
+ virtual void initConnections();
+ virtual void initView();
+ virtual void updatePopupMenu();
+ virtual void setupPopupMenu();
+
+
+ struct ActionsStruct {
+ BtToolBarPopupAction* backInHistory;
+ BtToolBarPopupAction* forwardInHistory;
+
+ QAction* selectAll;
+ QAction* findText;
+ QAction* findStrongs;
+
+ QMenu* copyMenu;
+ struct {
+ QAction* reference;
+ QAction* entry;
+ QAction* selectedText;
+ }
+ copy;
+
+ QMenu* saveMenu;
+ struct {
+ QAction* reference;
+ QAction* entryAsPlain;
+ QAction* entryAsHTML;
+ }
+ save;
+
+ QMenu* printMenu;
+ struct {
+ QAction* reference;
+ QAction* entry;
+ }
+ print;
+ }
+ m_actions;
+
+private:
+ /**
+ * Reimplementation to return the right key.
+ */
+ CSwordLDKey* ldKey();
+
+protected slots: // Protected slots
+ void previousEntry();
+ void nextEntry();
+ /**
+ * This function saves the entry as html using the CExportMgr class.
+ */
+ void saveAsHTML();
+ /**
+ * This function saves the entry as plain text using the CExportMgr class.
+ */
+ void saveAsPlain();
+ void saveRawHTML();
+
+ void slotFillBackHistory();
+ void slotFillForwardHistory();
+
+ void slotUpdateHistoryButtons(bool backEnabled, bool fwEnabled);
+};
+
+#endif
diff --git a/src/frontend/displaywindow/cmodulechooserbar.cpp b/src/frontend/displaywindow/cmodulechooserbar.cpp
new file mode 100644
index 0000000..fc891ad
--- /dev/null
+++ b/src/frontend/displaywindow/cmodulechooserbar.cpp
@@ -0,0 +1,127 @@
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2008 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+#include "cmodulechooserbar.h"
+
+#include "cmodulechooserbutton.h"
+
+#include <QList>
+#include <QDebug>
+#include <QAction>
+#include <QToolBar>
+
+CModuleChooserBar::CModuleChooserBar(QList<CSwordModuleInfo*> useModules, CSwordModuleInfo::ModuleType type, QWidget *parent)
+ : QToolBar(parent),
+ m_moduleType(type),
+ m_idCounter(0),
+ m_buttonLimit(-1) //-1 means no limit
+{
+ //insert buttons if useModules != 0
+ QList<CSwordModuleInfo*>::iterator end_it = useModules.end();
+ for (QList<CSwordModuleInfo*>::iterator it(useModules.begin()); it != end_it; ++it) {
+ if ((m_buttonLimit != -1) && ( m_buttonLimit <= (int)m_buttonList.count()) ) { //we reached the button limit
+ break;
+ }
+ addButton( *it );
+ }
+
+ // We can add a button to choose an additional module
+ if ( (m_buttonLimit == -1) || (m_buttonLimit > (int)m_buttonList.count()) ) {
+ addButton(0); //add a button without module set
+ }
+}
+
+CModuleChooserButton* CModuleChooserBar::addButton( CSwordModuleInfo* const module )
+{
+ CModuleChooserButton* b = new CModuleChooserButton(module, m_moduleType, ++m_idCounter, this);
+ QAction* a = addWidget(b);
+ m_buttonList.append(b);
+ connect( b, SIGNAL(sigAddButton()), this, SLOT(addButton()) );
+ connect( b, SIGNAL(sigRemoveButton(const int)), this, SLOT(removeButton(const int)) );
+ connect( b, SIGNAL(sigChanged()), SIGNAL(sigChanged()) );
+ connect( b, SIGNAL(sigChanged()), SLOT(updateMenuItems()) );
+ a->setVisible(true);
+ updateMenuItems(); //make sure the items are up to date with the newest module list
+ return b;
+}
+
+void CModuleChooserBar::addButton( ) {
+ addButton(0);
+}
+
+//change current with next and remove
+/** Removes a button from the toolbar */
+void CModuleChooserBar::removeButton( const int ID ) {
+ QMutableListIterator<CModuleChooserButton*> it(m_buttonList);
+ while (it.hasNext()) {
+ CModuleChooserButton* b = it.next();
+ if (b->getId() == ID) { //found the right button to remove
+ it.remove();
+ b->deleteLater();
+ break;
+ }
+ }
+ emit sigChanged();
+ updateMenuItems(); //make sure the items are up to date with the newest module list
+}
+
+/** Returns a list of selected modules. */
+QList<CSwordModuleInfo*> CModuleChooserBar::getModuleList() {
+ QList<CSwordModuleInfo*> list;
+ foreach (CModuleChooserButton* b, m_buttonList)
+ {
+ if (b->module()) list.append( b->module() );
+ }
+ return list;
+}
+
+//change current with remove
+/** Sets the number of the maximum count of buttons. */
+void CModuleChooserBar::setButtonLimit(const int limit) {
+ m_buttonLimit = limit;
+ if (limit == -1) //no need to delete buttons
+ return;
+
+ const int tooMuch = m_buttonList.size() - limit;
+ for (int i = 0; i < tooMuch; ++i) {
+ CModuleChooserButton* b = m_buttonList.takeLast();
+ b->deleteLater();
+ }
+
+ updateMenuItems();
+}
+
+/** Sets the modules which are chosen in this module chooser bar. */
+void CModuleChooserBar::setModules( QList<CSwordModuleInfo*> useModules ) {
+ setButtonLimit(0);
+ setButtonLimit(-1); //these two lines clear the bar
+
+ if (!useModules.count()) return;
+
+ QList<CSwordModuleInfo*>::iterator end_it = useModules.end();
+ for (QList<CSwordModuleInfo*>::iterator it(useModules.begin()); it != end_it; ++it) {
+ if ( (m_buttonLimit != -1) && (m_buttonLimit <= (int)m_buttonList.count()) ) {
+ break;
+ }
+ addButton( *it );
+ }
+
+ if ( (m_buttonLimit == -1) || (m_buttonLimit > (int)m_buttonList.count()) ) {
+ addButton(0);//add button without module set
+ }
+
+ updateMenuItems();
+}
+
+void CModuleChooserBar::updateMenuItems() {
+ resize(sizeHint());
+ update(); //seems to be neccessary to enforce display of the layout changes when a button was removed or added
+ foreach (CModuleChooserButton* b, m_buttonList)
+ b->updateMenuItems();
+}
diff --git a/src/frontend/displaywindow/cmodulechooserbar.h b/src/frontend/displaywindow/cmodulechooserbar.h
new file mode 100644
index 0000000..d21fcb9
--- /dev/null
+++ b/src/frontend/displaywindow/cmodulechooserbar.h
@@ -0,0 +1,77 @@
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2008 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+#ifndef CMODULECHOOSERBAR_H
+#define CMODULECHOOSERBAR_H
+
+//BibleTime includes
+#include "backend/drivers/cswordmoduleinfo.h"
+
+#include "util/cpointers.h"
+
+//Qt includes
+#include <QList>
+#include <QToolBar>
+
+class CModuleChooserButton;
+class QWidget;
+
+/**
+ * @author The BibleTime team
+ */
+class CModuleChooserBar : public QToolBar {
+ Q_OBJECT
+public:
+ /**
+ * Default constructor
+ */
+ CModuleChooserBar(QList<CSwordModuleInfo*> useModules, CSwordModuleInfo::ModuleType type, QWidget *parent=0);
+ /**
+ * Returns a list of selected modules.
+ */
+ QList<CSwordModuleInfo*> getModuleList();
+ /**
+ * Sets the number of the maximum count of buttons.
+ */
+ void setButtonLimit( const int limit);
+ /**
+ * Sets the modules which are chosen in this module chooser bar.
+ */
+ void setModules( QList<CSwordModuleInfo*> modules );
+
+signals:
+ void sigChanged();
+
+protected:
+ /**
+ * Adds a button to the toolbar
+ */
+ CModuleChooserButton* addButton( CSwordModuleInfo* const module );
+
+protected slots: // Protected slots
+ /*
+ * This slot calls the addButton function above to add a button.
+ */
+ void addButton();
+ /**
+ * Removes a button from the toolbar
+ */
+ void removeButton( const int ID );
+ /** */
+ void updateMenuItems();
+
+private:
+ CSwordModuleInfo::ModuleType m_moduleType;
+ int m_idCounter;
+ int m_buttonLimit;
+ QList<CModuleChooserButton*> m_buttonList;
+
+};
+
+#endif
diff --git a/src/frontend/displaywindow/cmodulechooserbutton.cpp b/src/frontend/displaywindow/cmodulechooserbutton.cpp
new file mode 100644
index 0000000..dd5a9ee
--- /dev/null
+++ b/src/frontend/displaywindow/cmodulechooserbutton.cpp
@@ -0,0 +1,211 @@
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2008 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+#include "cmodulechooserbutton.h"
+
+#include "cmodulechooserbar.h"
+
+#include "backend/managers/cswordbackend.h"
+
+#include "backend/config/cbtconfig.h"
+
+#include "util/cresmgr.h"
+#include "util/directoryutil.h"
+
+//Qt includes
+#include <QString>
+#include <QToolTip>
+#include <QHash>
+#include <QToolButton>
+#include <QMenu>
+#include <QtDebug>
+
+CModuleChooserButton::CModuleChooserButton(CSwordModuleInfo* useModule,CSwordModuleInfo::ModuleType type, const int id, CModuleChooserBar *parent)
+ : QToolButton(parent),
+ m_id(id), m_popup(0), m_moduleChooserBar(parent)
+{
+ m_moduleType = type;
+ m_module = useModule;
+ m_hasModule = (m_module) ? true : false;
+
+ setIcon( util::filesystem::DirectoryUtil::getIcon(iconName()) );
+ setPopupMode(QToolButton::InstantPopup);
+
+ populateMenu();
+}
+
+CModuleChooserButton::~CModuleChooserButton() {
+ qDeleteAll(m_submenus);
+ m_submenus.clear();
+ delete m_popup; //not necessary, because has "this" as parent?
+}
+
+/** Returns the icon used for the current status. */
+const QString CModuleChooserButton::iconName() {
+ switch (m_moduleType) {
+ case CSwordModuleInfo::Bible:
+ return (m_hasModule) ? CResMgr::modules::bible::icon_unlocked : CResMgr::modules::bible::icon_add;
+ case CSwordModuleInfo::Commentary:
+ return (m_hasModule) ? CResMgr::modules::commentary::icon_unlocked : CResMgr::modules::commentary::icon_add;
+ case CSwordModuleInfo::Lexicon:
+ return m_hasModule ? CResMgr::modules::lexicon::icon_unlocked : CResMgr::modules::lexicon::icon_add;
+ case CSwordModuleInfo::GenericBook:
+ return m_hasModule ? CResMgr::modules::book::icon_unlocked : CResMgr::modules::book::icon_add;
+ default: //return as default the bible icon
+ return CResMgr::modules::bible::icon_unlocked;
+ }
+}
+
+CSwordModuleInfo* CModuleChooserButton::module() {
+ foreach (QMenu* popup, m_submenus) {
+ foreach (QAction* action, popup->actions()) {
+ if ( action->isChecked() ) { //idAt -> , isItemChecked -> QAction::isChecked
+ QString mod = action->text(); //popup->text(popup->idAt(i)); //text ->
+ mod.remove(QChar('&')); //remove hotkey indicators
+ return backend()->findModuleByName( mod.left(mod.indexOf(" ")) );
+ }
+ }
+ }
+ return 0; //"none" selected
+}
+
+/** Returns the id used for this button. */
+int CModuleChooserButton::getId() const {
+ return m_id;
+}
+
+/** Is called after a module was selected in the popup */
+void CModuleChooserButton::moduleChosen( QAction* action ) {
+
+ QListIterator<QMenu*> it(m_submenus);
+ while (it.hasNext()) {
+ QMenu* popup = it.next();
+ foreach (QAction* a, popup->actions()) {
+ a->setChecked(false);
+ }
+ action->setChecked(true);
+ }
+
+ m_noneAction->setChecked(false); //uncheck the "none" item
+ if (action->text().remove(QChar('&')) == tr("NONE")) { // note: this is for m_popup, the toplevel!
+ if (m_hasModule) {
+ emit sigRemoveButton(m_id);
+ return;
+ }
+ }
+ else {
+ if (!m_hasModule) {
+ emit sigAddButton();
+ }
+
+ m_hasModule = true;
+ m_module = module();
+
+ setIcon( util::filesystem::DirectoryUtil::getIcon(iconName()) );
+ emit sigChanged();
+
+ if (m_module) {
+ setToolTip( tr("Select a work") + " [" + m_module->name() + "]" );
+ }
+ else {
+ setToolTip( tr("Select an additional work") );
+ }
+ }
+}
+
+/** No descriptions */
+void CModuleChooserButton::populateMenu() {
+ qDeleteAll(m_submenus);
+ m_submenus.clear();
+ delete m_popup;
+ m_popup = new QMenu(this);
+
+ if (m_module) {
+ this->setToolTip( tr("Select a work") + " [" + m_module->name() + "]" );
+ }
+ else {
+ this->setToolTip( tr("Select an additional work") );
+ }
+
+ m_noneAction = m_popup->addAction(tr("NONE"));
+ m_noneAction->setCheckable(true);
+ if (!m_module) m_noneAction->setChecked(true);
+
+ m_popup->addSeparator();
+ connect(m_popup, SIGNAL(triggered(QAction*)), this, SLOT(moduleChosen(QAction*)));
+ setMenu(m_popup);
+
+
+ // ******* Add languages and modules ********
+
+ // Filters: add only non-hidden and right type
+ BTModuleTreeItem::HiddenOff hiddenFilter;
+ TypeFilter typeFilter(m_moduleType);
+ QList<BTModuleTreeItem::Filter*> filters;
+ if (!CBTConfig::get(CBTConfig::bookshelfShowHidden)) {
+ filters.append(&hiddenFilter);
+ }
+ filters.append(&typeFilter);
+ BTModuleTreeItem root(filters, BTModuleTreeItem::LangMod);
+ // add all items recursively
+ addItemToMenu(&root, m_popup);
+
+}
+
+void CModuleChooserButton::addItemToMenu(BTModuleTreeItem* item, QMenu* menu)
+{
+ foreach (BTModuleTreeItem* i, item->children()) {
+
+ if (i->type() == BTModuleTreeItem::Language) {
+ // argument menu was m_popup, create and add a new lang menu to it
+ QMenu* langMenu = new QMenu(i->text(), this);
+ menu->addMenu(langMenu);
+ m_submenus.append(langMenu);
+ connect(langMenu, SIGNAL(triggered(QAction*)), this, SLOT(moduleChosen(QAction*)));
+ // add the module items to the lang menu
+ addItemToMenu(i, langMenu);
+ }
+ else {
+ // item must be module, create and add it to the lang menu
+ QString name(i->text());
+ name.append(" ").append(i->moduleInfo()->isLocked() ? tr("[locked]") : QString::null);
+ QAction* modItem = new QAction(name, menu);
+ modItem->setCheckable(true);
+ if ( m_module && i->text() == m_module->name()) modItem->setChecked(true);
+ menu->addAction(modItem);
+ }
+ }
+}
+
+void CModuleChooserButton::updateMenuItems() {
+ QString moduleName;
+ CSwordModuleInfo* module = 0;
+ QList<CSwordModuleInfo*> chosenModules = m_moduleChooserBar->getModuleList();
+
+ //for ( QMenu* popup = m_submenus.first(); popup; popup = m_submenus.next() ) {
+ QListIterator<QMenu*> it(m_submenus);
+ while (it.hasNext()) {
+ QMenu* popup = it.next();
+ foreach (QAction* action, popup->actions()) {
+ moduleName = action->text();
+ moduleName.remove(QChar('&')); //remove Hotkey indicator
+ module = backend()->findModuleByName( moduleName.left(moduleName.lastIndexOf(" ")) );
+
+ //Q_ASSERT(module);
+ if (!module) qWarning("Can't find module with name %s", moduleName.toLatin1().data());
+
+ bool alreadyChosen = chosenModules.contains( module );
+ if (m_module) {
+ alreadyChosen = alreadyChosen && (m_module->name() != moduleName);
+ }
+ //grey it out, it was chosen already
+ action->setEnabled(!alreadyChosen);
+ }
+ }
+}
diff --git a/src/frontend/displaywindow/cmodulechooserbutton.h b/src/frontend/displaywindow/cmodulechooserbutton.h
new file mode 100644
index 0000000..7715bf3
--- /dev/null
+++ b/src/frontend/displaywindow/cmodulechooserbutton.h
@@ -0,0 +1,82 @@
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2008 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+#ifndef CMODULECHOOSERBUTTON_H
+#define CMODULECHOOSERBUTTON_H
+
+//BibleTime includes
+class CSwordModuleInfo;
+#include "backend/btmoduletreeitem.h"
+#include "util/cpointers.h"
+
+//Qt includes
+#include <QToolButton>
+#include <QList>
+
+class QMenu;
+class CModuleChooserBar;
+
+/** The CModuleChooserButton displays a list of submenus sorted by language which contain the possible modules
+ * which can be displayed together with the first one.
+ * @author The BibleTime team
+ */
+class CModuleChooserButton : public QToolButton, public CPointers {
+ Q_OBJECT
+public:
+
+ /** Filter out modules of wrong type. See populateMenu() and BTModuleTreeItem. */
+ struct TypeFilter : public BTModuleTreeItem::Filter {
+ TypeFilter(CSwordModuleInfo::ModuleType t) {m_mType = t;}
+ bool filter(CSwordModuleInfo* mi) { return (mi->type() == m_mType); }
+ CSwordModuleInfo::ModuleType m_mType;
+ };
+
+ CModuleChooserButton(CSwordModuleInfo* useModule, CSwordModuleInfo::ModuleType type, const int id, CModuleChooserBar *parent);
+ ~CModuleChooserButton();
+
+ CSwordModuleInfo* module();
+ /**
+ * Returns the id used for this button.
+ */
+ int getId() const;
+ void updateMenuItems();
+
+protected:
+ /** Populates the menu with language submenus and module items. */
+ void populateMenu();
+ /** Adds items to the menu recursively. */
+ void addItemToMenu(BTModuleTreeItem* item, QMenu* menu);
+
+private:
+ /**
+ * Returns the icon used for the current status.
+ */
+ const QString iconName();
+
+ bool m_hasModule;
+ int m_id;
+ QAction* m_noneAction;
+ CSwordModuleInfo::ModuleType m_moduleType;
+ CSwordModuleInfo* m_module;
+
+ QMenu* m_popup;
+ QList<QMenu*> m_submenus;
+
+ CModuleChooserBar* m_moduleChooserBar;
+
+
+private slots:
+ void moduleChosen(QAction* action );
+
+signals:
+ void sigRemoveButton(const int ID);
+ void sigAddButton();
+ void sigChanged();
+};
+#endif
diff --git a/src/frontend/displaywindow/cplainwritewindow.cpp b/src/frontend/displaywindow/cplainwritewindow.cpp
new file mode 100644
index 0000000..9f12020
--- /dev/null
+++ b/src/frontend/displaywindow/cplainwritewindow.cpp
@@ -0,0 +1,183 @@
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2008 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+#include "cplainwritewindow.h"
+#include "btactioncollection.h"
+
+#include "frontend/display/cwritedisplay.h"
+
+#include "frontend/keychooser/ckeychooser.h"
+#include "frontend/profile/cprofilewindow.h"
+#include "backend/config/cbtconfig.h"
+
+#include "backend/keys/cswordkey.h"
+
+#include "util/cresmgr.h"
+#include "util/directoryutil.h"
+
+#include <QRegExp>
+#include <QToolBar>
+#include <QMessageBox>
+#include <QDebug>
+#include <QAction>
+
+using namespace Profile;
+
+CPlainWriteWindow::CPlainWriteWindow(QList<CSwordModuleInfo*> moduleList, CMDIArea* parent) :
+ CWriteWindow(moduleList, parent)
+{
+ setKey( CSwordKey::createInstance(moduleList.first()) );
+}
+
+
+CPlainWriteWindow::~CPlainWriteWindow() {}
+
+/** Initialize the state of this widget. */
+void CPlainWriteWindow::initView() {
+ // qWarning("CPlainWriteWindow::initView()");
+ setDisplayWidget( CDisplay::createWriteInstance(this) );
+ setCentralWidget( displayWidget()->view() );
+
+ setMainToolBar( new QToolBar(this) );
+ addToolBar(mainToolBar());
+ addToolBarBreak();
+
+ setKeyChooser( CKeyChooser::createInstance(modules(), key(), mainToolBar()) );
+ mainToolBar()->addWidget(keyChooser());
+}
+
+void CPlainWriteWindow::initToolbars() {
+ m_actions.syncWindow = new QAction(
+ //KIcon(CResMgr::displaywindows::commentaryWindow::syncWindow::icon),
+ util::filesystem::DirectoryUtil::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),
+ util::filesystem::DirectoryUtil::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),
+ util::filesystem::DirectoryUtil::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);
+
+
+ m_actions.restoreText = new QAction(
+ //KIcon(CResMgr::displaywindows::writeWindow::restoreText::icon),
+ util::filesystem::DirectoryUtil::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::initConnections() {
+ CWriteWindow::initConnections();
+ QObject::connect(keyChooser(), SIGNAL(keyChanged(CSwordKey*)), this, SLOT(lookupSwordKey(CSwordKey*)));
+ QObject::connect(displayWidget()->connectionsProxy(), SIGNAL(textChanged()), this, SLOT(textChanged()) );
+}
+
+void CPlainWriteWindow::storeProfileSettings( CProfileWindow* profileWindow ) {
+ CWriteWindow::storeProfileSettings(profileWindow);
+ profileWindow->setWindowSettings( m_actions.syncWindow->isChecked() );
+}
+
+void CPlainWriteWindow::applyProfileSettings( CProfileWindow* profileWindow ) {
+ CWriteWindow::applyProfileSettings(profileWindow);
+ if (profileWindow->windowSettings()) {
+ m_actions.syncWindow->setChecked(true);
+ }
+}
+
+/** Saves the text for the current key. Directly writes the changed text into the module. */
+void CPlainWriteWindow::saveCurrentText( const QString& /*key*/ ) {
+ QString t = ((CWriteDisplay*)displayWidget())->plainText();
+ //since t is a complete HTML page at the moment, strip away headers and footers of a HTML page
+ QRegExp re("(?:<html.*>.+<body.*>)", Qt::CaseInsensitive); //remove headers, case insensitive
+ re.setMinimal(true);
+ t.replace(re, "");
+ t.replace(QRegExp("</body></html>", Qt::CaseInsensitive), "");//remove footer
+
+ const QString& oldKey = this->key()->key();
+ if( modules().first()->isWritable() ) {
+ modules().first()->write(this->key(), t );
+ this->key()->key( oldKey );
+
+ ((CWriteDisplay*)displayWidget())->setModified(false);
+ textChanged();
+ }
+ else {
+ QMessageBox::critical( this, tr("Module not writable"),
+ QString::fromLatin1("<qt><B>%1</B><BR>%2</qt>")
+ .arg( tr("Module is not writable.") )
+ .arg( tr("Either the module may not be edited, or "
+ "you do not have write permission.") ) );
+ }
+}
+
+/** Loads the original text from the module. */
+void CPlainWriteWindow::restoreText() {
+ lookupSwordKey(key());
+ ((CWriteDisplay*)displayWidget())->setModified(false);
+ textChanged();
+}
+
+/** 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() );
+}
+
+/** Deletes the module entry and clears the edit widget, */
+void CPlainWriteWindow::deleteEntry() {
+ modules().first()->deleteEntry( key() );
+ lookupSwordKey( key() );
+ ((CWriteDisplay*)displayWidget())->setModified(false);
+}
+
+/** Setups the popup menu of this display widget. */
+void CPlainWriteWindow::setupPopupMenu() {}
+
+bool CPlainWriteWindow::syncAllowed() const {
+ return m_actions.syncWindow->isChecked();
+}
+
+void CPlainWriteWindow::initActions() {
+}
+
+void CPlainWriteWindow::insertKeyboardActions( BtActionCollection* const ) {
+}
diff --git a/src/frontend/displaywindow/cplainwritewindow.h b/src/frontend/displaywindow/cplainwritewindow.h
new file mode 100644
index 0000000..1ed4215
--- /dev/null
+++ b/src/frontend/displaywindow/cplainwritewindow.h
@@ -0,0 +1,96 @@
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2008 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+
+
+#ifndef CPLAINWRITEWINDOW_H
+#define CPLAINWRITEWINDOW_H
+
+//BibleTime includes
+#include "cwritewindow.h"
+
+
+class QAction;
+class BtActionCollection;
+
+class QString;
+
+/** The write window class which offers a plain editor for source code editing.
+ * @author The BibleTime team
+ */
+class CPlainWriteWindow : public CWriteWindow {
+ Q_OBJECT
+public:
+ CPlainWriteWindow( QList<CSwordModuleInfo*> modules, CMDIArea* parent);
+ virtual ~CPlainWriteWindow();
+
+ /**
+ * Store the settings of this window in the given CProfileWindow object.
+ */
+ virtual void storeProfileSettings( Profile::CProfileWindow* profileWindow );
+ /**
+ * Store the settings of this window in the given profile window.
+ */
+ virtual void applyProfileSettings( Profile::CProfileWindow* profileWindow );
+
+ /**
+ * Setups the popup menu of this display widget.
+ */
+ virtual void setupPopupMenu();
+ virtual bool syncAllowed() const;
+
+protected: // Protected methods
+ /**
+ * Initialize the state of this widget.
+ */
+ virtual void initView();
+ virtual void initConnections();
+ virtual void initToolbars();
+ virtual CDisplayWindow::WriteWindowType writeWindowType() {
+ return CDisplayWindow::PlainTextWindow;
+ };
+
+ /**
+ * Initializes the intern keyboard actions.
+ */
+ virtual void initActions();
+ /**
+ * Insert the keyboard accelerators of this window into the given KAccel object.
+ */
+ 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.
+ */
+ virtual void saveCurrentText( const QString& );
+ /**
+ * Is called when the current text was changed.
+ */
+ virtual void textChanged();
+ /**
+ * Loads the original text from the module.
+ */
+ virtual void restoreText();
+ /**
+ * Deletes the module entry and clears the edit widget.
+ */
+ virtual void deleteEntry();
+};
+
+#endif
diff --git a/src/frontend/displaywindow/creadwindow.cpp b/src/frontend/displaywindow/creadwindow.cpp
new file mode 100644
index 0000000..d446d30
--- /dev/null
+++ b/src/frontend/displaywindow/creadwindow.cpp
@@ -0,0 +1,205 @@
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2008 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+//BibleTime includes
+#include "creadwindow.h"
+#include "btactioncollection.h"
+
+#include "frontend/display/bthtmlreaddisplay.h"
+typedef BtHtmlReadDisplay HTMLREADDISPLAY;
+
+#include "backend/rendering/centrydisplay.h"
+#include "backend/rendering/cdisplayrendering.h"
+#include "backend/keys/cswordkey.h"
+#include "backend/keys/cswordversekey.h"
+
+#include "frontend/cexportmanager.h"
+#include "frontend/cmdiarea.h"
+#include "frontend/profile/cprofilewindow.h"
+#include "frontend/searchdialog/csearchdialog.h"
+
+#include <QResizeEvent>
+#include <QMdiSubWindow>
+#include <QDebug>
+
+using namespace Profile;
+
+CReadWindow::CReadWindow(QList<CSwordModuleInfo*> modules, CMDIArea* parent)
+ : CDisplayWindow(modules,parent),
+ m_displayWidget(0)
+{
+ qDebug("CReadWindow::CReadWindow");
+ // installEventFilter(this);
+}
+
+CReadWindow::~CReadWindow() {
+ // qWarning("destructor of CReadWindow");
+}
+
+/** Sets the display widget of this display window. */
+void CReadWindow::setDisplayWidget( CDisplay* newDisplay ) {
+ Q_ASSERT(dynamic_cast<CReadDisplay*>(newDisplay));
+ CDisplayWindow::setDisplayWidget(newDisplay);
+ if (m_displayWidget) {
+ disconnect(m_displayWidget->connectionsProxy(), SIGNAL(referenceClicked(const QString&, const QString&)), this, SLOT(lookupModKey(const QString&, const QString&)));
+ disconnect(m_displayWidget->connectionsProxy(), SIGNAL(referenceDropped(const QString&)), this, SLOT(lookupKey(const QString&)));
+
+ HTMLREADDISPLAY* v = dynamic_cast<HTMLREADDISPLAY*>(m_displayWidget);
+ if (v) {
+ QObject::disconnect(v, SIGNAL(completed()), this, SLOT(slotMoveToAnchor()) );
+ }
+
+ }
+
+ m_displayWidget = (CReadDisplay*)newDisplay;
+ connect(
+ m_displayWidget->connectionsProxy(),
+ SIGNAL(referenceClicked(const QString&, const QString&)),
+ this,
+ SLOT(lookupModKey(const QString&, const QString&))
+ );
+
+ connect(
+ m_displayWidget->connectionsProxy(),
+ SIGNAL(referenceDropped(const QString&)),
+ this,
+ SLOT(lookupKey(const QString&))
+ );
+ HTMLREADDISPLAY* v = dynamic_cast<HTMLREADDISPLAY*>(m_displayWidget);
+ if (v)
+ {
+ QObject::connect(v, SIGNAL(completed()), this, SLOT(slotMoveToAnchor()) );
+ }
+}
+
+/** Lookup the given entry. */
+void CReadWindow::lookupSwordKey( CSwordKey* newKey ) {
+ qDebug() << "CReadWindow::lookup newKey" << newKey->key();
+ Q_ASSERT(newKey);
+
+ using namespace Rendering;
+
+// Q_ASSERT(isReady() && newKey && modules().first());
+ if (!isReady() || !newKey || modules().empty() || !modules().first()) {
+ return;
+ }
+
+ if (key() != newKey) {
+ key()->key(newKey->key());
+ }
+
+ //next-TODO: how about options?
+ Q_ASSERT(modules().first()->getDisplay());
+ CEntryDisplay* display = modules().first()->getDisplay();
+ if (display) { //do we have a display object?
+ displayWidget()->setText(
+ display->text(
+ modules(),
+ newKey->key(),
+ displayOptions(),
+ filterOptions()
+ )
+ );
+ }
+
+ setCaption( windowCaption() );
+
+ // moving to anchor happens in slotMoveToAnchor which catches the completed() signal from KHTMLPart
+
+ qDebug() << "CReadWindow::lookup end, key is :" << newKey->key();
+}
+
+void CReadWindow::slotMoveToAnchor()
+{
+ qDebug("CReadWindow::slotMoveToAnchor");
+ ((CReadDisplay*)displayWidget())->moveToAnchor( Rendering::CDisplayRendering::keyToHTMLAnchor(key()->key()) );
+}
+
+/** Store the settings of this window in the given CProfileWindow object. */
+void CReadWindow::storeProfileSettings(CProfileWindow * const settings) {
+ QRect rect;
+ rect.setX(parentWidget()->x());
+ rect.setY(parentWidget()->y());
+ rect.setWidth(width());
+ rect.setHeight(height());
+ settings->setGeometry(rect);
+
+ // settings->setScrollbarPositions( m_htmlWidget->view()->horizontalScrollBar()->value(), m_htmlWidget->view()->verticalScrollBar()->value() );
+ settings->setType(modules().first()->type());
+ settings->setMaximized(isMaximized() || parentWidget()->isMaximized());
+ settings->setFocus( (this == dynamic_cast<CReadWindow*>(mdi()->activeSubWindow()) ) ); //set property to true if this window is the active one.
+
+ if (key()) {
+ sword::VerseKey* vk = dynamic_cast<sword::VerseKey*>(key());
+ QString oldLang;
+ if (vk) {
+ oldLang = QString(vk->getLocale());
+ vk->setLocale("en"); //save english locale names as default!
+ }
+ settings->setKey( key()->key() );
+ if (vk) {
+ vk->setLocale(oldLang.toLatin1());
+ }
+ }
+
+ 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());
+ }
+ settings->setModules(mods);
+}
+
+void CReadWindow::applyProfileSettings(CProfileWindow * const settings) {
+ // parentWidget()->setUpdatesEnabled(false);
+ setUpdatesEnabled(false);
+
+ if (settings->maximized()) { //maximize this window
+ // Use parentWidget() to call showMaximized. Otherwise we'd get lot's of X11 errors
+ parentWidget()->showMaximized();
+ }
+ else {
+ const QRect rect = settings->geometry();
+ parentWidget()->resize(rect.width(), rect.height());
+ parentWidget()->move(rect.x(), rect.y());
+ }
+
+ setUpdatesEnabled(true);
+}
+
+void CReadWindow::insertKeyboardActions( BtActionCollection* const ) {}
+
+/** No descriptions */
+void CReadWindow::copyDisplayedText() {
+ CExportManager mgr(QString::null);
+ mgr.copyKey(key(), CExportManager::Text, true);
+}
+
+
+/*!
+ \fn CReadWindow::resizeEvent(QResizeEvent* e)
+ */
+void CReadWindow::resizeEvent(QResizeEvent* /*e*/) {
+ if (displayWidget()) {
+ ((CReadDisplay*)displayWidget())->moveToAnchor(Rendering::CDisplayRendering::keyToHTMLAnchor(key()->key()));
+ }
+}
+
+void CReadWindow::openSearchStrongsDialog() {
+// qWarning("looking for lemma %s", displayWidget()->getCurrentNodeInfo()[CDisplay::Lemma].latin1() );
+ QString searchText = QString::null;
+
+ if (displayWidget()->getCurrentNodeInfo()[CDisplay::Lemma] != QString::null) {
+ searchText.append("strong:").append(displayWidget()->getCurrentNodeInfo() [CDisplay::Lemma]);
+ }
+
+ Search::CSearchDialog::openDialog( modules(), searchText, 0 );
+}
diff --git a/src/frontend/displaywindow/creadwindow.h b/src/frontend/displaywindow/creadwindow.h
new file mode 100644
index 0000000..3630b58
--- /dev/null
+++ b/src/frontend/displaywindow/creadwindow.h
@@ -0,0 +1,79 @@
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2008 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+
+
+#ifndef CREADWINDOW_H
+#define CREADWINDOW_H
+
+//BibleTime includes
+#include "cdisplaywindow.h"
+
+#include "frontend/display/cdisplay.h"
+#include "frontend/display/creaddisplay.h"
+
+
+class BtActionCollection;
+class QResizeEvent;
+
+
+/** The base class for all read-only display windows.
+ * @author The BibleTime team
+ */
+
+class CReadWindow : public CDisplayWindow {
+ Q_OBJECT
+public:
+ // static void insertKeyboardActions( KAccel* const a );
+ static void insertKeyboardActions( BtActionCollection* const a );
+
+ CReadWindow(QList<CSwordModuleInfo*> modules, CMDIArea* parent);
+ virtual ~CReadWindow();
+ /**
+ * Store the settings of this window in the given CProfileWindow object.
+ */
+ virtual void storeProfileSettings(Profile::CProfileWindow * const settings);
+ /**
+ * Store the settings of this window in the given CProfileWindow object.
+ */
+ virtual void applyProfileSettings(Profile::CProfileWindow * const settings);
+
+protected: // Protected methods
+ /**
+ * Sets the display widget of this display window.
+ */
+ virtual void setDisplayWidget( CDisplay* newDisplay );
+ /**
+ */
+ virtual void resizeEvent(QResizeEvent* e);
+
+protected slots:
+ /**
+ * Load the text using the key
+ */
+ virtual void lookupSwordKey( CSwordKey* );
+ /**
+ * Catch the signal when the KHTMLPart has finished the layout (anchors are not ready before that).
+ */
+ virtual void slotMoveToAnchor();
+
+ /**
+ * Update the status of the popup menu entries.
+ */
+ virtual void copyDisplayedText();
+ /** Open the search dialog with the strong info of the last clicked word.
+ *
+ */
+ void openSearchStrongsDialog();
+
+private:
+ CReadDisplay* m_displayWidget;
+};
+
+#endif
diff --git a/src/frontend/displaywindow/cwritewindow.cpp b/src/frontend/displaywindow/cwritewindow.cpp
new file mode 100644
index 0000000..0c58bf7
--- /dev/null
+++ b/src/frontend/displaywindow/cwritewindow.cpp
@@ -0,0 +1,161 @@
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2008 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+
+#include "cwritewindow.h"
+
+#include "backend/drivers/cswordmoduleinfo.h"
+#include "backend/keys/cswordversekey.h"
+
+#include "frontend/keychooser/ckeychooser.h"
+#include "frontend/profile/cprofilewindow.h"
+#include "frontend/display/cwritedisplay.h"
+
+
+#include <QMessageBox>
+
+
+using namespace Profile;
+
+CWriteWindow::CWriteWindow(QList<CSwordModuleInfo*> modules, CMDIArea* parent)
+: CDisplayWindow(modules, parent), m_writeDisplay(0) {}
+
+CWriteWindow::~CWriteWindow() {}
+
+
+void CWriteWindow::insertKeyboardActions( BtActionCollection* const ) {}
+
+void CWriteWindow::initConnections() {
+ Q_ASSERT(keyChooser());
+ QObject::connect(keyChooser(), SIGNAL(beforeKeyChange(const QString&)), this, SLOT(beforeKeyChange(const QString&)));
+}
+
+void CWriteWindow::initActions() {}
+
+
+void CWriteWindow::storeProfileSettings(CProfileWindow * const settings) {
+
+ settings->setWriteWindowType( writeWindowType() );
+
+ QRect rect;
+ rect.setX(parentWidget()->x());
+ rect.setY(parentWidget()->y());
+ rect.setWidth(width());
+ rect.setHeight(height());
+ settings->setGeometry(rect);
+
+ // settings->setScrollbarPositions( m_htmlWidget->view()->horizontalScrollBar()->value(), m_htmlWidget->view()->verticalScrollBar()->value() );
+ settings->setType(modules().first()->type());
+ settings->setMaximized(isMaximized() || parentWidget()->isMaximized());
+
+ if (key()) {
+ sword::VerseKey* vk = dynamic_cast<sword::VerseKey*>(key());
+ QString oldLang;
+ if (vk) {
+ oldLang = QString::fromLatin1(vk->getLocale());
+ vk->setLocale("en"); //save english locale names as default!
+ }
+ settings->setKey( key()->key() );
+ if (vk) {
+ vk->setLocale(oldLang.toLatin1());
+ }
+ }
+
+ 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());
+ }
+ settings->setModules(mods);
+}
+
+void CWriteWindow::applyProfileSettings(CProfileWindow * const settings) {
+ setUpdatesEnabled(false);
+
+ if (settings->maximized()) {
+ parentWidget()->showMaximized();
+ }
+ else {
+ const QRect rect = settings->geometry();
+ parentWidget()->resize(rect.width(), rect.height());
+ parentWidget()->move(rect.x(), rect.y());
+ //setGeometry( settings->geometry() );
+ }
+ // displayWidget()->view()->horizontalScrollBar()->setValue( settings->scrollbarPositions().horizontal );
+ // m_htmlWidget->view()->verticalScrollBar()->setValue( settings->scrollbarPositions().vertical );
+
+ setUpdatesEnabled(true);
+}
+
+void CWriteWindow::setDisplayWidget( CDisplay* display ) {
+ Q_ASSERT(dynamic_cast<CWriteDisplay*>(display));
+ CDisplayWindow::setDisplayWidget((CWriteDisplay*)display);
+ m_writeDisplay = (CWriteDisplay*)display;
+}
+
+void CWriteWindow::lookupSwordKey( CSwordKey* newKey ) {
+ //set the raw text to the display widget
+ if (!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());
+ }
+
+ if ( modules().count() ) {
+ displayWidget()->setText( key()->rawText() );
+ }
+ setCaption( windowCaption() );
+}
+
+bool CWriteWindow::queryClose() {
+ //save the text if it has changed
+ if (m_writeDisplay->isModified()) {
+ switch (QMessageBox::question( this, tr("Save Text?"), tr("Save text before closing?"), QMessageBox::Yes|QMessageBox::No|QMessageBox::Cancel, QMessageBox::Yes) ) {
+ case QMessageBox::Yes: //save and close
+ saveCurrentText();
+ m_writeDisplay->setModified( false );
+ return true;
+ case QMessageBox::No: //don't save and close
+ return true;
+ default: // cancel, don't close
+ return false;
+ }
+ }
+ return true;
+}
+
+void CWriteWindow::beforeKeyChange(const QString& key) {
+ Q_ASSERT(displayWidget());
+ Q_ASSERT(keyChooser());
+ if (!isReady()) return;
+
+ //If the text changed and we'd do a lookup ask the user if the text should be saved
+ if (modules().first() && ((CWriteDisplay*)displayWidget())->isModified()) {
+
+ switch (QMessageBox::question( this, tr("Save Text?"), tr("Save changed text?"), QMessageBox::Yes|QMessageBox::No, QMessageBox::Yes) ) {
+ case QMessageBox::Yes: { //save the changes
+ saveCurrentText( key );
+ break;
+ }
+ default: {// set modified to false so it won't ask again
+ ((CWriteDisplay*)displayWidget())->setModified(false);
+ break;
+ }
+ }
+ }
+}
+
+void CWriteWindow::saveCurrentText() {
+ if(key()) {
+ saveCurrentText(key()->key());
+ }
+}
+
diff --git a/src/frontend/displaywindow/cwritewindow.h b/src/frontend/displaywindow/cwritewindow.h
new file mode 100644
index 0000000..c3b47c2
--- /dev/null
+++ b/src/frontend/displaywindow/cwritewindow.h
@@ -0,0 +1,72 @@
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2008 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+#ifndef CWRITEWINDOW_H
+#define CWRITEWINDOW_H
+
+//BibleTime includes
+#include "cdisplaywindow.h"
+
+
+class CWriteDisplay;
+class QString;
+class BtActionCollection;
+
+/**The base class for all write-only display windows.
+ *@author The BibleTime team
+ */
+
+class CWriteWindow : public CDisplayWindow {
+ Q_OBJECT
+public:
+ static void insertKeyboardActions( BtActionCollection* const a );
+
+ CWriteWindow(QList<CSwordModuleInfo*> modules, CMDIArea* parent);
+ virtual ~CWriteWindow();
+ /**
+ * Store the settings of this window in the given CProfileWindow object.
+ */
+ virtual void storeProfileSettings(Profile::CProfileWindow * const settings);
+ /**
+ * Store the settings of this window in the given CProfileWindow object.
+ */
+ virtual void applyProfileSettings(Profile::CProfileWindow * const settings);
+ virtual void initConnections();
+ virtual void initActions();
+
+public slots:
+ /**
+ * Look up the given key and display the text. In our case we offer to edit the text.
+ */
+ virtual void lookupSwordKey( CSwordKey* key );
+
+
+protected: // Protected methods
+ /**
+ * Saves the given text as text of the given key. Use this function
+ * as backend in each write window implementation.
+ */
+ void setDisplayWidget( CDisplay* display );
+ virtual CDisplayWindow::WriteWindowType writeWindowType() = 0;
+ virtual bool queryClose();
+ virtual void saveCurrentText( const QString& key ) = 0;
+
+protected slots:
+ /** Save text to the module
+ */
+ void saveCurrentText();
+ /**
+ */
+ virtual void beforeKeyChange(const QString&);
+
+private:
+ CWriteDisplay* m_writeDisplay;
+};
+
+#endif