bibletime
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

cbookreadwindow.cpp 5.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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. #include "cbookreadwindow.h"
  10. #include "cmodulechooserbar.h"
  11. #include "cbuttons.h"
  12. #include "backend/cswordtreekey.h"
  13. #include "frontend/display/cdisplay.h"
  14. #include "frontend/keychooser/cbooktreechooser.h"
  15. #include "frontend/cprofilewindow.h"
  16. #include "frontend/cbtconfig.h"
  17. #include "util/ctoolclass.h"
  18. #include "util/cresmgr.h"
  19. //TQt includes
  20. #include <tqsplitter.h>
  21. //KDE includes
  22. #include <kaction.h>
  23. #include <klocale.h>
  24. #include <tdeversion.h>
  25. using namespace Profile;
  26. CBookReadWindow::CBookReadWindow(ListCSwordModuleInfo modules, CMDIArea* parent, const char *name) : CLexiconReadWindow(modules, parent, name) {}
  27. CBookReadWindow::~CBookReadWindow() {}
  28. void CBookReadWindow::applyProfileSettings( CProfileWindow* profileWindow ) {
  29. CLexiconReadWindow::applyProfileSettings(profileWindow);
  30. const bool enable = static_cast<bool>( profileWindow->windowSettings() );
  31. if (enable) {
  32. m_treeAction->activate();
  33. }
  34. };
  35. void CBookReadWindow::storeProfileSettings( CProfileWindow* profileWindow ) {
  36. CLexiconReadWindow::storeProfileSettings(profileWindow);
  37. //store information about our show tree structure button
  38. profileWindow->setWindowSettings( static_cast<int>( m_treeAction->isChecked() ) );
  39. };
  40. void CBookReadWindow::initActions() {
  41. CLexiconReadWindow::initActions();
  42. //cleanup, not a clean oo-solution
  43. Q_ASSERT(actionCollection()->action("nextEntry"));
  44. Q_ASSERT(actionCollection()->action("previousEntry"));
  45. actionCollection()->action("nextEntry")->setEnabled(false);
  46. actionCollection()->action("previousEntry")->setEnabled(false);
  47. m_treeAction = new TDEToggleAction(
  48. i18n("Toggle tree view"),
  49. CResMgr::displaywindows::bookWindow::toggleTree::icon,
  50. CResMgr::displaywindows::bookWindow::toggleTree::accel,
  51. TQT_TQOBJECT(this), TQT_SLOT(treeToggled()),
  52. actionCollection(), "toggleTree");
  53. CBTConfig::setupAccelSettings(CBTConfig::bookWindow, actionCollection());
  54. };
  55. void CBookReadWindow::insertKeyboardActions( TDEActionCollection* const a ) {
  56. new TDEToggleAction(
  57. i18n("Toggle tree view"),
  58. CResMgr::displaywindows::bookWindow::toggleTree::icon,
  59. CResMgr::displaywindows::bookWindow::toggleTree::accel,
  60. a, "toggleTree");
  61. // new TDEAction(i18n("Copy reference only"), TDEShortcut(0), a, "copyReferenceOnly");
  62. new TDEAction(i18n("Copy entry with text"), TDEShortcut(0), a, "copyEntryWithText");
  63. // new TDEAction(i18n("Copy selected text"), TDEShortcut(0), a, "copySelectedText");
  64. new TDEAction(i18n("Save entry as plain text"), TDEShortcut(0), a, "saveEntryAsPlainText");
  65. new TDEAction(i18n("Save entry as HTML"), TDEShortcut(0), a, "saveEntryAsHTML");
  66. // new TDEAction(i18n("Print reference only"), TDEShortcut(0), a, "printReferenceOnly");
  67. new TDEAction(i18n("Print entry with text"), TDEShortcut(0), a, "printEntryWithText");
  68. }
  69. /** No descriptions */
  70. void CBookReadWindow::initConnections() {
  71. CLexiconReadWindow::initConnections();
  72. connect(m_treeChooser, TQT_SIGNAL(keyChanged(CSwordKey*)),
  73. TQT_TQOBJECT(this), TQT_SLOT(lookup(CSwordKey*)));
  74. connect(m_treeChooser, TQT_SIGNAL(keyChanged(CSwordKey*)),
  75. keyChooser(), TQT_SLOT(updateKey(CSwordKey*)));
  76. connect(keyChooser(), TQT_SIGNAL(keyChanged(CSwordKey*)),
  77. m_treeChooser, TQT_SLOT(updateKey(CSwordKey*)));
  78. }
  79. /** Init the view */
  80. void CBookReadWindow::initView() {
  81. TQSplitter* splitter = new TQSplitter(this);
  82. setMainToolBar( new TDEToolBar(this) );
  83. addDockWindow(mainToolBar());
  84. m_treeChooser = new CBookTreeChooser(modules(), key(), splitter);
  85. setDisplayWidget( CDisplay::createReadInstance(this, splitter) );
  86. setKeyChooser( CKeyChooser::createInstance(modules(), key(), mainToolBar()) );
  87. setModuleChooserBar( new CModuleChooserBar(modules(), modules().first()->type(), this) );
  88. moduleChooserBar()->setButtonLimit(1);
  89. addDockWindow( moduleChooserBar() );
  90. setButtonsToolBar( new TDEToolBar(this) );
  91. addDockWindow( buttonsToolBar() );
  92. setDisplaySettingsButton( new CDisplaySettingsButton( &displayOptions(), &filterOptions(), modules(), buttonsToolBar()) );
  93. m_treeChooser->hide();
  94. splitter->setResizeMode(m_treeChooser, TQSplitter::Stretch);
  95. setCentralWidget( splitter );
  96. setIcon(CToolClass::getIconForModule(modules().first()));
  97. }
  98. void CBookReadWindow::initToolbars() {
  99. Q_ASSERT(m_treeAction);
  100. Q_ASSERT(m_actions.backInHistory);
  101. m_actions.backInHistory->plug( mainToolBar(), 0 );
  102. m_actions.forwardInHistory->plug( mainToolBar(), 1 );
  103. mainToolBar()->insertWidget(0,keyChooser()->sizeHint().width(),keyChooser());
  104. m_treeAction->plug(buttonsToolBar());
  105. m_treeAction->setChecked(false);
  106. buttonsToolBar()->insertWidget(2,displaySettingsButton()->size().width(),displaySettingsButton());
  107. TDEAction* action = actionCollection()->action(
  108. CResMgr::displaywindows::general::search::actionName );
  109. if (action) {
  110. action->plug(buttonsToolBar());
  111. }
  112. #if TDE_VERSION_MINOR < 1
  113. action->plugAccel( accel() );
  114. #endif
  115. }
  116. /** Is called when the action was executed to toggle the tree view. */
  117. void CBookReadWindow::treeToggled() {
  118. if (m_treeAction->isChecked()) {
  119. m_treeChooser->show();
  120. }
  121. else {
  122. m_treeChooser->hide();
  123. }
  124. }
  125. /** Reimplementation to take care of the tree chooser. */
  126. void CBookReadWindow::modulesChanged() {
  127. CLexiconReadWindow::modulesChanged();
  128. m_treeChooser->setModules(modules());
  129. lookup(key());
  130. }
  131. void CBookReadWindow::setupPopupMenu() {
  132. CLexiconReadWindow::setupPopupMenu();
  133. popup()->changeTitle(-1, CToolClass::getIconForModule(modules().first()), i18n("Book window"));
  134. }