Bibletime – a bible study tool
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.

bibletime.h 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422
  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. #ifndef BIBLETIME_H
  10. #define BIBLETIME_H
  11. //Own includes
  12. #include "bibletimeinterface.h"
  13. //Frontend includes
  14. #include "frontend/cprofilemgr.h"
  15. #include "frontend/cprofile.h"
  16. #include "frontend/displaywindow/cdisplaywindow.h"
  17. //Backend includes
  18. #include "backend/cswordmoduleinfo.h"
  19. //KDE includes
  20. #include <tdemainwindow.h>
  21. //forward: BT classes
  22. class CMDIArea;
  23. class CDisplayWindow;
  24. class CMainIndex;
  25. namespace InfoDisplay {
  26. class CInfoDisplay;
  27. }
  28. //KDE classes
  29. class TDEToggleAction;
  30. class TDEAccel;
  31. class TDEPopupMenu;
  32. class TDEAction;
  33. class TDEActionMenu;
  34. class TDEActionCollection;
  35. //QT classes
  36. class TQPopupMenu;
  37. class TQProgressDialog;
  38. class TQSplitter;
  39. /**
  40. * @page backend The structure of the backend
  41. * <p>
  42. * The backend implementation for Sword is called CSwordBackend, the classes we use
  43. * to work with keys are called CSwordVerseKey and CSwordLDKey, both are derived from
  44. * the class CSwordKey.
  45. * The CSwordKey derived classes used for Sword do also inherit the classes
  46. * VerseKey (CSwordVerseKey)
  47. * and SWKey (CSwordLDKey).
  48. * </p>
  49. * <p>
  50. * The classes used to handle all module based stuff are derived from CModuleInfo.
  51. * The module classes are: CSwordModuleInfo (for Sword modules),
  52. * CSwordBibleModuleInfo (for bibles), CSwordCommentaryModuleInfo (for commentaries) and
  53. * CSwordLexiconModuleInfo (for lexicons).
  54. * Have a look at the class documentation of the mentioned classes to learn how the
  55. * structure of them looks like and which class inherits which other class.
  56. * </p>
  57. * <p>
  58. * The first objects which should be created in the application is the backend
  59. * (for Sword the class is called CSwordBackend).
  60. * Then create all the different module classes for the correct Sword modules.
  61. * Have a look at
  62. * BibleTime::initBackens() to see how it's done in BibleTime.@br
  63. * Later you can work with them for example by using the CSwordKey and
  64. * CSwordModuleInfo derived class.
  65. * </p>
  66. */
  67. /**
  68. * @page frontend The structure of the frontend
  69. *
  70. * <p>
  71. * The frontend contains the classes which interact with the user. For example the main index,
  72. * the display windows, the searchdialog or the other parts.
  73. * </p><p>
  74. * The main index is implemented in the class CGroupManager, the items of the
  75. * main index are implemented in the class CGroupManagerItem.
  76. * Each CGroupManagerItem has a type() function which returns the type of
  77. * the object (Module, Bookmark or Group).<BR>
  78. * The display windows are all derived from the base class CPresenter.
  79. * The display windows which handle Sword modules are all derived from the
  80. * CSwordPresenter class.
  81. * The display windows which provide functionality are CBiblePresenter for
  82. * Bibles, CCommentaryPresenter for commentaries and CLexiconPresenter for
  83. * lexicon and dictionaries.
  84. * CSwordPresenter provides the essential base functions which are
  85. * reimplemented in the derived classes (for example CSwordPresenter::lookup).<BR>
  86. * </p><p>
  87. * Another important part of the frontend are the keychoosers.
  88. * They provide an interface to choose a key of a module.
  89. * The interface for different module types is different.
  90. * The base class is CKeyChooser which is the factory for the derived classes.
  91. * Use the function CKeyChooser::createInstance to get the correct
  92. * keychooser implementation for the desired module.<BR>
  93. * </p>
  94. */
  95. /** @mainpage BibleTime - sourcecode documentation
  96. * BibleTime main page.
  97. * <p>This is the sourcecode documentation of BibleTime, a Bible study tool for KDE/Linux.
  98. * BibleTime is devided in two major parts, the backend and the frontend.
  99. * The backend is mainly a wrapper around Sword's classes to use TQt functionality
  100. * to allow easy access to it's functionality and to have it in a (more or less :)
  101. * object oriented structure.</p><BR>
  102. * <p>
  103. * -Introduction to the backend: @ref backend<BR>
  104. * -Introduction to the frontend: @ref frontend.<BR>
  105. * The main class of BibleTime is called @ref BibleTime, which is the main window
  106. * and initializes all important parts at startup. The text display windows
  107. * belong to the @ref frontend.
  108. * </p>
  109. */
  110. /** BibleTime's main class.
  111. * The main class of BibleTime. Here are the main widgets created.
  112. *
  113. * This is the main class of BibleTime! This class creates the GUI, the TDEAction objects
  114. * and connects to some slots. Please insert the creation of actions in initActions,
  115. * the creation of widgets into initView and the connect(...) calls into initConnections.
  116. * Reading from a config file on creation time should go into readSettings(), saving into
  117. * saveSettings().
  118. * This is the general way of all BibleTime classes.
  119. */
  120. class BibleTime : public TDEMainWindow, virtual public BibleTimeInterface {
  121. friend class CMDIArea;
  122. Q_OBJECT
  123. public:
  124. /**
  125. * construtor of BibleTime
  126. */
  127. BibleTime();
  128. /**
  129. * destrutor of BibleTime
  130. */
  131. virtual ~BibleTime();
  132. virtual void polish();
  133. /**
  134. * Reads the settings from the configfile and sets the right properties.
  135. */
  136. void readSettings();
  137. /**
  138. * Saves the settings of this class
  139. */
  140. void saveSettings();
  141. /**
  142. * Restores the workspace if the flaf for this is set in the config.
  143. */
  144. void restoreWorkspace();
  145. /**
  146. * Apply the settings given by the profile p
  147. */
  148. void applyProfileSettings( Profile::CProfile* p );
  149. /**
  150. * Stores the settings of the mainwindow in the profile p
  151. */
  152. void storeProfileSettings( Profile::CProfile* p );
  153. public slots:
  154. /**
  155. * Shows the daily tip
  156. */
  157. void slotHelpTipOfDay();
  158. /**
  159. * Opens the optionsdialog of BibleTime.
  160. */
  161. void slotSettingsOptions();
  162. /**
  163. * Opens the optionsdialog of BibleTime.
  164. */
  165. void slotSwordSetupDialog();
  166. /**
  167. * Opens the handbook.
  168. */
  169. void openOnlineHelp_Handbook();
  170. /**
  171. * Opens the bible study howto.
  172. */
  173. void openOnlineHelp_Howto();
  174. /**
  175. * Sets the plain caption of the main window
  176. */
  177. virtual void setPlainCaption( const TQString& );
  178. /**
  179. * Sets the caption of the mainwindow
  180. */
  181. virtual void setCaption(const TQString&);
  182. /**
  183. * Processes the commandline options given to BibleTime.
  184. */
  185. void processCommandline();
  186. protected: // Protected methods
  187. /**
  188. * Initializes the view of this widget
  189. */
  190. void initView();
  191. /**
  192. * Initializes the menubar of BibleTime.
  193. */
  194. void initMenubar();
  195. /**
  196. * Initializes the TQT_SIGNAL / TQT_SLOT connections
  197. */
  198. void initConnections();
  199. /**
  200. * Initializes the backend
  201. */
  202. void initBackends();
  203. /**
  204. * Initializes the action objects of the GUI
  205. */
  206. void initActions();
  207. /**
  208. * Refreshes all presenter supporting at least in of the features given as parameter.
  209. */
  210. void refreshDisplayWindows();
  211. /**
  212. * Called before a window is closed
  213. */
  214. bool queryClose();
  215. /**
  216. * Called before quit.
  217. */
  218. bool queryExit();
  219. /**
  220. * Reimplementation used for session management.
  221. */
  222. void readProperties(TDEConfig* config);
  223. /**
  224. * Reimplementation used for sessions management.
  225. */
  226. void saveProperties(TDEConfig* myConfig);
  227. protected slots:
  228. /**
  229. * Creates a new presenter in the MDI area according to the type of the module.
  230. */
  231. CDisplayWindow* createReadDisplayWindow(ListCSwordModuleInfo modules, const TQString& key);
  232. CDisplayWindow* createReadDisplayWindow(CSwordModuleInfo* module, const TQString& key);
  233. CDisplayWindow* createWriteDisplayWindow(CSwordModuleInfo* module, const TQString& key, const CDisplayWindow::WriteWindowType& type);
  234. /**
  235. * Is called when the window menu is about to show ;-)
  236. */
  237. void slotWindowMenuAboutToShow();
  238. /**
  239. * This slot is connected with the windowAutoTile_action object
  240. */
  241. void slotAutoTileVertical();
  242. /**
  243. * This slot is connected with the windowAutoTile_action object
  244. */
  245. void slotAutoTileHorizontal();
  246. /**
  247. * This slot is connected with the windowAutoCascade_action object
  248. */
  249. void slotAutoCascade();
  250. void slotUpdateWindowArrangementActions( TDEAction* );
  251. void slotCascade();
  252. void slotTileVertical();
  253. void slotTileHorizontal();
  254. void slotManualArrangementMode();
  255. /**
  256. * Is called when a client was selected in the window menu
  257. */
  258. void slotWindowMenuActivated();
  259. /**
  260. * Shows/hides the toolbar
  261. */
  262. void slotToggleToolbar();
  263. /**
  264. * Opens a toolbar editor
  265. */
  266. void slotSettingsToolbar();
  267. /**
  268. * Shows or hides the main index part
  269. */
  270. void slotToggleMainIndex();
  271. /**
  272. * Shows or hides the info display part.
  273. */
  274. void slotToggleInfoDisplay();
  275. /**
  276. * Saves to the profile with the menu id ID
  277. */
  278. void saveProfile(int ID);
  279. /**
  280. * Saves the current settings into the currently activatred profile.
  281. */
  282. void saveProfile(Profile::CProfile* p);
  283. /**
  284. * Deletes the chosen session from the menu and from disk.
  285. */
  286. void deleteProfile(int ID);
  287. /**
  288. * Loads the profile with the menu id ID
  289. */
  290. void loadProfile(int ID);
  291. /**
  292. * Loads the profile with the menu ID id
  293. */
  294. void loadProfile(Profile::CProfile* p);
  295. /**
  296. * Toggles between normal and fullscreen mode.
  297. */
  298. void toggleFullscreen();
  299. /**
  300. * Is called when settings in the optionsdialog have been
  301. * changed (ok or apply)
  302. */
  303. void slotSettingsChanged();
  304. /**
  305. * Is called when settings in the sword setup dialog have been
  306. * changed (ok or apply)
  307. */
  308. void slotSwordSetupChanged();
  309. /**
  310. * Called when search button is pressed
  311. **/
  312. void slotSearchModules();
  313. /**
  314. * Called for search default bible
  315. **/
  316. void slotSearchDefaultBible();
  317. /**
  318. Saves current settings into a new profile.
  319. */
  320. void saveToNewProfile();
  321. /**
  322. * Slot to refresh the save profile and load profile menus.
  323. */
  324. void refreshProfileMenus();
  325. private:
  326. TQPopupMenu* m_windowMenu;
  327. TQPopupMenu* m_editMenu;
  328. /** VIEW menu actions */
  329. TDEToggleAction* m_viewToolbar_action;
  330. TDEToggleAction* m_viewMainIndex_action;
  331. TDEToggleAction* m_viewInfoDisplay_action;
  332. /** WINDOW menu actions */
  333. TDEAction* m_windowCascade_action;
  334. TDEAction* m_windowTileHorizontal_action;
  335. TDEAction* m_windowTileVertical_action;
  336. TDEActionMenu* m_windowArrangementMode_action;
  337. TDEToggleAction* m_windowManualMode_action;
  338. TDEToggleAction* m_windowAutoCascade_action;
  339. TDEToggleAction* m_windowAutoTileVertical_action;
  340. TDEToggleAction* m_windowAutoTileHorizontal_action;
  341. TDEAction* m_windowCloseAll_action;
  342. TDEActionCollection* m_windowActionCollection;
  343. TDEActionMenu* m_windowSaveProfile_action;
  344. TDEAction* m_windowSaveToNewProfile_action;
  345. TDEActionMenu* m_windowLoadProfile_action;
  346. TDEActionMenu* m_windowDeleteProfile_action;
  347. TDEToggleAction* m_windowFullscreen_action;
  348. TQPtrList<TDEAction> m_windowOpenWindowsList;
  349. KHelpMenu* m_helpMenu;
  350. bool m_initialized;
  351. /**
  352. * The list of installed SWORD modules
  353. */
  354. ListCSwordModuleInfo* m_moduleList;
  355. TQProgressDialog* m_progress;
  356. Profile::CProfile* m_currentProfile;
  357. TQSplitter* m_mainSplitter;
  358. TQSplitter* m_leftPaneSplitter;
  359. CMDIArea* m_mdi;
  360. Profile::CProfileMgr m_profileMgr;
  361. CSwordBackend* m_backend;
  362. CMainIndex* m_mainIndex;
  363. InfoDisplay::CInfoDisplay* m_infoDisplay;
  364. protected: //DCOP interface implementation
  365. //helper function
  366. void syncAllModulesByType(const CSwordModuleInfo::ModuleType type, const TQString& key);
  367. //see bibletimeinterface.h for a documentation of these functions
  368. virtual void closeAllModuleWindows();
  369. virtual void syncAllBibles(const TQString& key);
  370. virtual void syncAllCommentaries(const TQString& key);
  371. virtual void syncAllLexicons(const TQString& key);
  372. virtual void syncAllVerseBasedModules(const TQString& key);
  373. virtual void openWindow(const TQString& moduleName, const TQString& key);
  374. virtual void openDefaultBible(const TQString& key);
  375. virtual TQString getCurrentReference();
  376. virtual TQStringList searchInModule(const TQString& module, const TQString& searchText);
  377. virtual TQStringList searchInOpenModules(const TQString& searchText);
  378. virtual TQStringList searchInDefaultBible(const TQString& searchText);
  379. virtual TQStringList getModulesOfType(const TQString& type);
  380. virtual void reloadModules();
  381. };
  382. #endif