Bibletime – a bible study tool
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

creadwindow.cpp 5.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  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. //BibleTime includes
  10. #include "creadwindow.h"
  11. #include "backend/centrydisplay.h"
  12. #include "backend/cdisplayrendering.h"
  13. #include "backend/cswordkey.h"
  14. #include "frontend/cbtconfig.h"
  15. #include "frontend/cexportmanager.h"
  16. #include "frontend/cmdiarea.h"
  17. #include "frontend/cprofilewindow.h"
  18. #include "frontend/displaywindow/cmodulechooserbar.h"
  19. #include "frontend/keychooser/ckeychooser.h"
  20. #include "frontend/searchdialog/csearchdialog.h"
  21. #include "util/cresmgr.h"
  22. //KDE includes
  23. #include <tdepopupmenu.h>
  24. #include <tdeaction.h>
  25. #include <tdeaccel.h>
  26. #include <tdestdaccel.h>
  27. #include <tdelocale.h>
  28. using namespace Profile;
  29. CReadWindow::CReadWindow(ListCSwordModuleInfo modules, CMDIArea* parent, const char *name )
  30. : CDisplayWindow(modules,parent,name),
  31. m_displayWidget(0) {
  32. // installEventFilter(this);
  33. }
  34. CReadWindow::~CReadWindow() {
  35. // tqWarning("destructor of CReadWindow");
  36. }
  37. /** Returns the display widget of this window. */
  38. CReadDisplay* const CReadWindow::displayWidget() {
  39. return m_displayWidget;
  40. }
  41. /** Sets the display widget of this display window. */
  42. void CReadWindow::setDisplayWidget( CReadDisplay* newDisplay ) {
  43. CDisplayWindow::setDisplayWidget(newDisplay);
  44. if (m_displayWidget) {
  45. disconnect(m_displayWidget->connectionsProxy(), TQT_SIGNAL(referenceClicked(const TQString&, const TQString&)), this, TQT_SLOT(lookup(const TQString&, const TQString&)));
  46. disconnect(m_displayWidget->connectionsProxy(), TQT_SIGNAL(referenceDropped(const TQString&)), this, TQT_SLOT(lookup(const TQString&)));
  47. }
  48. m_displayWidget = newDisplay;
  49. connect(
  50. m_displayWidget->connectionsProxy(),
  51. TQT_SIGNAL(referenceClicked(const TQString&, const TQString&)),
  52. this,
  53. TQT_SLOT(lookup(const TQString&, const TQString&))
  54. );
  55. connect(
  56. m_displayWidget->connectionsProxy(),
  57. TQT_SIGNAL(referenceDropped(const TQString&)),
  58. this,
  59. TQT_SLOT(lookup(const TQString&))
  60. );
  61. }
  62. /** Lookup the given entry. */
  63. void CReadWindow::lookup( CSwordKey* newKey ) {
  64. Q_ASSERT(newKey);
  65. using namespace Rendering;
  66. Q_ASSERT(isReady() && newKey && modules().first());
  67. if (!isReady() || !newKey || !modules().first()) {
  68. return;
  69. }
  70. Q_ASSERT(modules().first()->getDisplay());
  71. CEntryDisplay* display = modules().first()->getDisplay();
  72. if (display) { //do we have a display object?
  73. displayWidget()->setText(
  74. display->text(
  75. modules(),
  76. newKey->key(),
  77. displayOptions(),
  78. filterOptions()
  79. )
  80. );
  81. }
  82. if (key() != newKey) {
  83. key()->key(newKey->key());
  84. }
  85. setCaption( windowCaption() );
  86. // tqDebug("[CReadWindow::lookup] Moving to anchor %s", CDisplayRendering::keyToHTMLAnchor(key()->key()).latin1());
  87. displayWidget()->moveToAnchor( CDisplayRendering::keyToHTMLAnchor(key()->key()) );
  88. }
  89. /** Store the settings of this window in the given CProfileWindow object. */
  90. void CReadWindow::storeProfileSettings(CProfileWindow * const settings) {
  91. TQRect rect;
  92. rect.setX(parentWidget()->x());
  93. rect.setY(parentWidget()->y());
  94. rect.setWidth(width());
  95. rect.setHeight(height());
  96. settings->setGeometry(rect);
  97. // settings->setScrollbarPositions( m_htmlWidget->view()->horizontalScrollBar()->value(), m_htmlWidget->view()->verticalScrollBar()->value() );
  98. settings->setType(modules().first()->type());
  99. settings->setMaximized(isMaximized() || parentWidget()->isMaximized());
  100. settings->setFocus( (this == mdi()->activeWindow()) ); //set property to true if this window is the active one.
  101. if (key()) {
  102. sword::VerseKey* vk = dynamic_cast<sword::VerseKey*>(key());
  103. TQString oldLang;
  104. if (vk) {
  105. oldLang = TQString(vk->getLocale());
  106. vk->setLocale("en"); //save english locale names as default!
  107. }
  108. settings->setKey( key()->key() );
  109. if (vk) {
  110. vk->setLocale(oldLang.latin1());
  111. }
  112. }
  113. TQStringList mods;
  114. ListCSwordModuleInfo allMods = modules();
  115. ListCSwordModuleInfo::iterator end_it = allMods.end();
  116. for (ListCSwordModuleInfo::iterator it(allMods.begin()); it != end_it; ++it) {
  117. mods.append((*it)->name());
  118. }
  119. settings->setModules(mods);
  120. }
  121. void CReadWindow::applyProfileSettings(CProfileWindow * const settings) {
  122. // parentWidget()->setUpdatesEnabled(false);
  123. setUpdatesEnabled(false);
  124. if (settings->maximized()) { //maximize this window
  125. // Use parentWidget() to call showMaximized. Otherwise we'd get lot's of X11 errors
  126. parentWidget()->showMaximized();
  127. }
  128. else {
  129. const TQRect rect = settings->geometry();
  130. resize(rect.width(), rect.height());
  131. parentWidget()->move(rect.x(), rect.y());
  132. }
  133. setUpdatesEnabled(true);
  134. }
  135. void CReadWindow::insertKeyboardActions( TDEActionCollection* const ) {}
  136. /** No descriptions */
  137. void CReadWindow::copyDisplayedText() {
  138. CExportManager mgr(TQString::null);
  139. mgr.copyKey(key(), CExportManager::Text, true);
  140. }
  141. /*!
  142. \fn CReadWindow::resizeEvent(TQResizeEvent* e)
  143. */
  144. void CReadWindow::resizeEvent(TQResizeEvent* /*e*/) {
  145. displayWidget()->moveToAnchor(
  146. Rendering::CDisplayRendering::keyToHTMLAnchor(key()->key())
  147. );
  148. }
  149. void CReadWindow::openSearchStrongsDialog() {
  150. // tqWarning("looking for lemma %s", displayWidget()->getCurrentNodeInfo()[CDisplay::Lemma].latin1() );
  151. TQString searchText = TQString();
  152. if (displayWidget()->getCurrentNodeInfo()[CDisplay::Lemma] != TQString()) {
  153. searchText.append("strong:").append(displayWidget()->getCurrentNodeInfo() [CDisplay::Lemma]);
  154. }
  155. Search::CSearchDialog::openDialog( modules(), searchText, 0 );
  156. }
  157. #include "creadwindow.moc"