~ubuntu-branches/ubuntu/jaunty/bibletime/jaunty

« back to all changes in this revision

Viewing changes to bibletime/frontend/displaywindow/cbookreadwindow.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Ralph Janke
  • Date: 2008-05-10 15:18:16 UTC
  • mfrom: (1.1.6 upstream) (3.1.1 lenny)
  • Revision ID: james.westby@ubuntu.com-20080510151816-bqp8y1to705zd0fm
Tags: 1.6.5.1-1
* New upstream version (Closes: #441161, #271502)
* fixes for new autotools and gcc 4.3 (Closes: #407291)
* added poxml to Build-Depends
* No DFSG necessary anymore since biblestudy howto has 
  now Commons Licence 
* Added libclucene-dev to dev-depends (Closes: #436677)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*********
 
2
*
 
3
* This file is part of BibleTime's source code, http://www.bibletime.info/.
 
4
*
 
5
* Copyright 1999-2006 by the BibleTime developers.
 
6
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
 
7
*
 
8
**********/
 
9
 
 
10
 
 
11
 
 
12
#include "cbookreadwindow.h"
 
13
#include "cmodulechooserbar.h"
 
14
#include "cbuttons.h"
 
15
 
 
16
#include "backend/cswordtreekey.h"
 
17
 
 
18
#include "frontend/display/cdisplay.h"
 
19
#include "frontend/keychooser/cbooktreechooser.h"
 
20
#include "frontend/cprofilewindow.h"
 
21
#include "frontend/cbtconfig.h"
 
22
 
 
23
#include "util/ctoolclass.h"
 
24
#include "util/cresmgr.h"
 
25
 
 
26
//Qt includes
 
27
#include <qsplitter.h>
 
28
 
 
29
//KDE includes
 
30
#include <kaction.h>
 
31
#include <klocale.h>
 
32
#include <kdeversion.h>
 
33
 
 
34
using namespace Profile;
 
35
 
 
36
CBookReadWindow::CBookReadWindow(ListCSwordModuleInfo modules, CMDIArea* parent, const char *name) : CLexiconReadWindow(modules, parent, name) {}
 
37
 
 
38
CBookReadWindow::~CBookReadWindow() {}
 
39
 
 
40
void CBookReadWindow::applyProfileSettings( CProfileWindow* profileWindow ) {
 
41
        CLexiconReadWindow::applyProfileSettings(profileWindow);
 
42
 
 
43
        const bool enable = static_cast<bool>( profileWindow->windowSettings() );
 
44
        if (enable) {
 
45
                m_treeAction->activate();
 
46
        }
 
47
};
 
48
 
 
49
void CBookReadWindow::storeProfileSettings( CProfileWindow* profileWindow ) {
 
50
        CLexiconReadWindow::storeProfileSettings(profileWindow);
 
51
 
 
52
        //store information about our show tree structure button
 
53
        profileWindow->setWindowSettings( static_cast<int>( m_treeAction->isChecked() ) );
 
54
};
 
55
 
 
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);
 
63
 
 
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");
 
70
 
 
71
        CBTConfig::setupAccelSettings(CBTConfig::bookWindow, actionCollection());
 
72
};
 
73
 
 
74
void CBookReadWindow::insertKeyboardActions( KActionCollection* const a ) {
 
75
        new KToggleAction(
 
76
                i18n("Toggle tree view"),
 
77
                CResMgr::displaywindows::bookWindow::toggleTree::icon,
 
78
                CResMgr::displaywindows::bookWindow::toggleTree::accel,
 
79
                a, "toggleTree");
 
80
                
 
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");
 
88
 
 
89
}
 
90
 
 
91
/** No descriptions */
 
92
void CBookReadWindow::initConnections() {
 
93
        CLexiconReadWindow::initConnections();
 
94
 
 
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*)));
 
101
}
 
102
 
 
103
/** Init the view */
 
104
void CBookReadWindow::initView() {
 
105
        QSplitter* splitter = new QSplitter(this);
 
106
 
 
107
        setMainToolBar( new KToolBar(this) );
 
108
        addDockWindow(mainToolBar());
 
109
 
 
110
        m_treeChooser = new CBookTreeChooser(modules(), key(), splitter);
 
111
        setDisplayWidget( CDisplay::createReadInstance(this, splitter) );
 
112
 
 
113
        setKeyChooser( CKeyChooser::createInstance(modules(), key(), mainToolBar()) );
 
114
 
 
115
        setModuleChooserBar( new CModuleChooserBar(modules(), modules().first()->type(), this) );
 
116
        moduleChooserBar()->setButtonLimit(1);
 
117
        addDockWindow( moduleChooserBar() );
 
118
 
 
119
        setButtonsToolBar( new KToolBar(this) );
 
120
        addDockWindow( buttonsToolBar() );
 
121
        setDisplaySettingsButton( new CDisplaySettingsButton( &displayOptions(), &filterOptions(), modules(), buttonsToolBar()) );
 
122
 
 
123
        m_treeChooser->hide();
 
124
 
 
125
        splitter->setResizeMode(m_treeChooser, QSplitter::Stretch);
 
126
        setCentralWidget( splitter );
 
127
        setIcon(CToolClass::getIconForModule(modules().first()));
 
128
}
 
129
 
 
130
void CBookReadWindow::initToolbars() {
 
131
        Q_ASSERT(m_treeAction);
 
132
        Q_ASSERT(m_actions.backInHistory);
 
133
 
 
134
        m_actions.backInHistory->plug( mainToolBar(), 0 );
 
135
        m_actions.forwardInHistory->plug( mainToolBar(), 1 );
 
136
 
 
137
        mainToolBar()->insertWidget(0,keyChooser()->sizeHint().width(),keyChooser());
 
138
 
 
139
        m_treeAction->plug(buttonsToolBar());
 
140
        m_treeAction->setChecked(false);
 
141
 
 
142
        buttonsToolBar()->insertWidget(2,displaySettingsButton()->size().width(),displaySettingsButton());
 
143
 
 
144
        KAction* action = actionCollection()->action(
 
145
                                                  CResMgr::displaywindows::general::search::actionName );
 
146
        if (action) {
 
147
                action->plug(buttonsToolBar());
 
148
        }
 
149
 
 
150
        #if KDE_VERSION_MINOR < 1
 
151
        action->plugAccel( accel() );
 
152
        #endif
 
153
}
 
154
 
 
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();
 
159
        }
 
160
        else {
 
161
                m_treeChooser->hide();
 
162
        }
 
163
}
 
164
 
 
165
/** Reimplementation to take care of the tree chooser. */
 
166
void CBookReadWindow::modulesChanged() {
 
167
        CLexiconReadWindow::modulesChanged();
 
168
        m_treeChooser->setModules(modules());
 
169
        lookup(key());
 
170
}
 
171
 
 
172
void CBookReadWindow::setupPopupMenu() {
 
173
        CLexiconReadWindow::setupPopupMenu();
 
174
 
 
175
        popup()->changeTitle(-1, CToolClass::getIconForModule(modules().first()), i18n("Book window"));
 
176
}