3
* This file is part of BibleTime's source code, http://www.bibletime.info/.
5
* Copyright 1999-2006 by the BibleTime developers.
6
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
12
#include "cbookreadwindow.h"
13
#include "cmodulechooserbar.h"
16
#include "backend/cswordtreekey.h"
18
#include "frontend/display/cdisplay.h"
19
#include "frontend/keychooser/cbooktreechooser.h"
20
#include "frontend/cprofilewindow.h"
21
#include "frontend/cbtconfig.h"
23
#include "util/ctoolclass.h"
24
#include "util/cresmgr.h"
27
#include <qsplitter.h>
32
#include <kdeversion.h>
34
using namespace Profile;
36
CBookReadWindow::CBookReadWindow(ListCSwordModuleInfo modules, CMDIArea* parent, const char *name) : CLexiconReadWindow(modules, parent, name) {}
38
CBookReadWindow::~CBookReadWindow() {}
40
void CBookReadWindow::applyProfileSettings( CProfileWindow* profileWindow ) {
41
CLexiconReadWindow::applyProfileSettings(profileWindow);
43
const bool enable = static_cast<bool>( profileWindow->windowSettings() );
45
m_treeAction->activate();
49
void CBookReadWindow::storeProfileSettings( CProfileWindow* profileWindow ) {
50
CLexiconReadWindow::storeProfileSettings(profileWindow);
52
//store information about our show tree structure button
53
profileWindow->setWindowSettings( static_cast<int>( m_treeAction->isChecked() ) );
56
void CBookReadWindow::initActions() {
57
CLexiconReadWindow::initActions();
58
//cleanup, not a clean oo-solution
59
Q_ASSERT(actionCollection()->action("nextEntry"));
60
Q_ASSERT(actionCollection()->action("previousEntry"));
61
actionCollection()->action("nextEntry")->setEnabled(false);
62
actionCollection()->action("previousEntry")->setEnabled(false);
64
m_treeAction = new KToggleAction(
65
i18n("Toggle tree view"),
66
CResMgr::displaywindows::bookWindow::toggleTree::icon,
67
CResMgr::displaywindows::bookWindow::toggleTree::accel,
68
this, SLOT(treeToggled()),
69
actionCollection(), "toggleTree");
71
CBTConfig::setupAccelSettings(CBTConfig::bookWindow, actionCollection());
74
void CBookReadWindow::insertKeyboardActions( KActionCollection* const a ) {
76
i18n("Toggle tree view"),
77
CResMgr::displaywindows::bookWindow::toggleTree::icon,
78
CResMgr::displaywindows::bookWindow::toggleTree::accel,
81
// new KAction(i18n("Copy reference only"), KShortcut(0), a, "copyReferenceOnly");
82
new KAction(i18n("Copy entry with text"), KShortcut(0), a, "copyEntryWithText");
83
// new KAction(i18n("Copy selected text"), KShortcut(0), a, "copySelectedText");
84
new KAction(i18n("Save entry as plain text"), KShortcut(0), a, "saveEntryAsPlainText");
85
new KAction(i18n("Save entry as HTML"), KShortcut(0), a, "saveEntryAsHTML");
86
// new KAction(i18n("Print reference only"), KShortcut(0), a, "printReferenceOnly");
87
new KAction(i18n("Print entry with text"), KShortcut(0), a, "printEntryWithText");
91
/** No descriptions */
92
void CBookReadWindow::initConnections() {
93
CLexiconReadWindow::initConnections();
95
connect(m_treeChooser, SIGNAL(keyChanged(CSwordKey*)),
96
this, SLOT(lookup(CSwordKey*)));
97
connect(m_treeChooser, SIGNAL(keyChanged(CSwordKey*)),
98
keyChooser(), SLOT(updateKey(CSwordKey*)));
99
connect(keyChooser(), SIGNAL(keyChanged(CSwordKey*)),
100
m_treeChooser, SLOT(updateKey(CSwordKey*)));
104
void CBookReadWindow::initView() {
105
QSplitter* splitter = new QSplitter(this);
107
setMainToolBar( new KToolBar(this) );
108
addDockWindow(mainToolBar());
110
m_treeChooser = new CBookTreeChooser(modules(), key(), splitter);
111
setDisplayWidget( CDisplay::createReadInstance(this, splitter) );
113
setKeyChooser( CKeyChooser::createInstance(modules(), key(), mainToolBar()) );
115
setModuleChooserBar( new CModuleChooserBar(modules(), modules().first()->type(), this) );
116
moduleChooserBar()->setButtonLimit(1);
117
addDockWindow( moduleChooserBar() );
119
setButtonsToolBar( new KToolBar(this) );
120
addDockWindow( buttonsToolBar() );
121
setDisplaySettingsButton( new CDisplaySettingsButton( &displayOptions(), &filterOptions(), modules(), buttonsToolBar()) );
123
m_treeChooser->hide();
125
splitter->setResizeMode(m_treeChooser, QSplitter::Stretch);
126
setCentralWidget( splitter );
127
setIcon(CToolClass::getIconForModule(modules().first()));
130
void CBookReadWindow::initToolbars() {
131
Q_ASSERT(m_treeAction);
132
Q_ASSERT(m_actions.backInHistory);
134
m_actions.backInHistory->plug( mainToolBar(), 0 );
135
m_actions.forwardInHistory->plug( mainToolBar(), 1 );
137
mainToolBar()->insertWidget(0,keyChooser()->sizeHint().width(),keyChooser());
139
m_treeAction->plug(buttonsToolBar());
140
m_treeAction->setChecked(false);
142
buttonsToolBar()->insertWidget(2,displaySettingsButton()->size().width(),displaySettingsButton());
144
KAction* action = actionCollection()->action(
145
CResMgr::displaywindows::general::search::actionName );
147
action->plug(buttonsToolBar());
150
#if KDE_VERSION_MINOR < 1
151
action->plugAccel( accel() );
155
/** Is called when the action was executed to toggle the tree view. */
156
void CBookReadWindow::treeToggled() {
157
if (m_treeAction->isChecked()) {
158
m_treeChooser->show();
161
m_treeChooser->hide();
165
/** Reimplementation to take care of the tree chooser. */
166
void CBookReadWindow::modulesChanged() {
167
CLexiconReadWindow::modulesChanged();
168
m_treeChooser->setModules(modules());
172
void CBookReadWindow::setupPopupMenu() {
173
CLexiconReadWindow::setupPopupMenu();
175
popup()->changeTitle(-1, CToolClass::getIconForModule(modules().first()), i18n("Book window"));