diff options
Diffstat (limited to 'bibletime/util')
-rw-r--r-- | bibletime/util/Makefile.am | 16 | ||||
-rw-r--r-- | bibletime/util/autoptrvector.h | 176 | ||||
-rw-r--r-- | bibletime/util/cpointers.cpp | 58 | ||||
-rw-r--r-- | bibletime/util/cpointers.h | 120 | ||||
-rw-r--r-- | bibletime/util/cresmgr.cpp | 1198 | ||||
-rw-r--r-- | bibletime/util/cresmgr.h | 733 | ||||
-rw-r--r-- | bibletime/util/ctoolclass.cpp | 239 | ||||
-rw-r--r-- | bibletime/util/ctoolclass.h | 80 | ||||
-rw-r--r-- | bibletime/util/directoryutil.cpp | 111 | ||||
-rw-r--r-- | bibletime/util/directoryutil.h | 55 | ||||
-rw-r--r-- | bibletime/util/scoped_resource.h | 181 |
11 files changed, 2967 insertions, 0 deletions
diff --git a/bibletime/util/Makefile.am b/bibletime/util/Makefile.am new file mode 100644 index 0000000..7a4ba4e --- /dev/null +++ b/bibletime/util/Makefile.am @@ -0,0 +1,16 @@ +INCLUDES = $(all_includes) +libutil_a_METASOURCES = AUTO +noinst_LIBRARIES = libutil.a + +libutil_a_SOURCES = cpointers.cpp cresmgr.cpp ctoolclass.cpp directoryutil.cpp + +all_headers = \ +scoped_resource.h \ +cpointers.h \ +cresmgr.h \ +ctoolclass.h \ +autoptrvector.h + +EXTRA_DIST = $(libutil_a_SOURCES) $(all_headers) + +noinst_HEADERS = directoryutil.h diff --git a/bibletime/util/autoptrvector.h b/bibletime/util/autoptrvector.h new file mode 100644 index 0000000..4e8f82b --- /dev/null +++ b/bibletime/util/autoptrvector.h @@ -0,0 +1,176 @@ +/********* +* +* This file is part of BibleTime's source code, http://www.bibletime.info/. +* +* Copyright 1999-2006 by the BibleTime developers. +* The BibleTime source code is licensed under the GNU General Public License version 2.0. +* +**********/ + + + +#ifndef UTILAUTOPTRVECTOR_H +#define UTILAUTOPTRVECTOR_H + +namespace util { + + /** + * This class provides a simple vector which works on pointers. + * All pointer are deeted at destruction time of an AutoPtrVector object. + * This vector uses a single linked list to store the pointers. + * This class provides the methods first(), current() and next() for navigation. + * + * @author Joachim Ansorg + */ + template<class T> + class AutoPtrVector { +public: + /** Default constructor. + * The default constructor. This creates an empty vector. + */ +explicit AutoPtrVector() : m_first(0), m_current(0), m_end(0) {} + ; + + /** Copy constructor using deep copy. + * This does a deep copy of the passed AutoPtrVector. + * @param old The vector to be copied. + */ +AutoPtrVector(AutoPtrVector& old) : m_first(0), m_current(0), m_end(0) { + this->operator=(old); //share the code with the copy operator + /* if (this != &old) { + Item* last = m_first; + Item* prev = 0; + + for (T* c = old.first(); c; c = old.next()) { + last = new Item( new T(*c) ); + + if (prev) { + prev->next = last; + } + + prev = last; + } + }*/ + }; + + AutoPtrVector& operator=(AutoPtrVector& old) { + //at first delete all items, then copy old into new items + clear(); + + if (this != &old) { //only copy if the two pointers are different + Item* last = m_first; + Item* prev = 0; + + for (T* c = old.first(); c; c = old.next()) { + last = new Item( new T(*c) ); + + if (prev) { + prev->next = last; + } + + prev = last; + } + } + + return *this; + }; + + /** Destructor. + * Deletes all the objects which belong to the stored pointers + * @see clear() + */ + virtual ~AutoPtrVector() { + clear(); + }; + + + /** Append an item + * + * Append a new item to this vector. + */ + inline void append(T* type) { + if (!m_first) { //handle the first item special + m_first = new Item( type ); + m_end = m_first; + } + else { + m_end->next = new Item( type ); + m_end = m_end->next; + } + }; + + /** The first item of this vector. + * + * @return The first item of this vector. Null of there are no items. + */ + inline T* const first() const { + m_current = m_first; + return m_current ? m_current->value : 0; + }; + + /** The current item. + * + * @return The current item reached by first() and next() calls + */ + inline T* const current() const { + return m_current->value; + }; + + /** Moves to the next item. + * + * @return Moves to the next item + */ + inline T* const next() const { + if (m_current && m_current->next) { + m_current = m_current->next; + return m_current->value; + } + + return 0; + }; + + /** Returns if this conainer is empty. + * + * @return If this vector has items or not. True if there are no items, false if there are any + */ + inline const bool isEmpty() const { + return bool(m_first == 0); + }; + + /** Clear this vector. + * This deletes all objects which belong to the stored pointers. + */ + inline void clear() { + Item* i = m_first; + Item* current = 0; + + while (i) { + delete i->value; //delete the object which belongs to the stored pointer + + current = i; + i = current->next; + delete current; //delete the current item after we got the next list item + } + }; + +private: + /** + * Our internal helper class to store the pointers in a linked list. + */ + struct Item { +Item(T* t = 0) : value(t), next(0) {} + ; + + T* value; + Item* next; + }; + + mutable Item* m_first; + mutable Item* m_current; + mutable Item* m_end; + }; + +} //end of namespace + + +#endif diff --git a/bibletime/util/cpointers.cpp b/bibletime/util/cpointers.cpp new file mode 100644 index 0000000..f795bba --- /dev/null +++ b/bibletime/util/cpointers.cpp @@ -0,0 +1,58 @@ +/********* +* +* This file is part of BibleTime's source code, http://www.bibletime.info/. +* +* Copyright 1999-2006 by the BibleTime developers. +* The BibleTime source code is licensed under the GNU General Public License version 2.0. +* +**********/ + + + +#include "cpointers.h" + +//BibleTime's backend +#include "backend/cswordbackend.h" +#include "backend/cdisplaytemplatemgr.h" + +//BibleTime's frontend +#include "frontend/cprinter.h" + + +CPointers::PointerCache m_pointerCache; + +void CPointers::setBackend(CSwordBackend* const backend) { + Q_ASSERT( m_pointerCache.backend == 0); + CPointers::deleteBackend(); + m_pointerCache.backend = backend; +} + +void CPointers::setInfoDisplay(InfoDisplay::CInfoDisplay* const infoDisplay) { + Q_ASSERT( m_pointerCache.infoDisplay == 0); + m_pointerCache.infoDisplay = infoDisplay; +} + +void CPointers::deleteBackend() { + delete m_pointerCache.backend; + m_pointerCache.backend = 0; +} + +void CPointers::deleteLanguageMgr() { + delete m_pointerCache.langMgr; + m_pointerCache.langMgr = 0; +} + +void CPointers::deleteDisplayTemplateMgr() { + delete m_pointerCache.displayTemplateMgr; + m_pointerCache.displayTemplateMgr = 0; +} + +/** Returns a pointer to the printer object. */ +CDisplayTemplateMgr* const CPointers::displayTemplateManager() { + if (!m_pointerCache.displayTemplateMgr) { + m_pointerCache.displayTemplateMgr = new CDisplayTemplateMgr(); + } + + return m_pointerCache.displayTemplateMgr; +} + diff --git a/bibletime/util/cpointers.h b/bibletime/util/cpointers.h new file mode 100644 index 0000000..822002f --- /dev/null +++ b/bibletime/util/cpointers.h @@ -0,0 +1,120 @@ +/********* +* +* This file is part of BibleTime's source code, http://www.bibletime.info/. +* +* Copyright 1999-2006 by the BibleTime developers. +* The BibleTime source code is licensed under the GNU General Public License version 2.0. +* +**********/ + + + +#ifndef CPOINTERS_H +#define CPOINTERS_H + +//BibleTime includes +#include "backend/clanguagemgr.h" + +#include "frontend/cinfodisplay.h" + +class CSwordBackend; +class CLanguageMgr; +class CDisplayTemplateMgr; + +namespace InfoDisplay { + class CInfoDisplay; +} + +/** Holds the pointers to important classes like modules, backend etc. + * @author The BibleTime team + */ +class CPointers { +protected: + friend class BibleTime; //BibleTime may initialize this object + friend class BibleTimeApp; //BibleTimeApp may initialize this object + friend int main(int argc, char* argv[]); //main may set the printer + + //Empty virtuaual destructor + virtual ~CPointers() {} + + /** Set the backend. + * @param backend Pointer to the new application-wide Sword backend + */ + static void setBackend(CSwordBackend* const backend); + /** Set the info display. + * @param iDisplay The pointer to the new info display. + */ + static void setInfoDisplay(InfoDisplay::CInfoDisplay* const iDisplay); + + /** Delete the backend. Should be called by BibleTimeApp, + * because the backend should be deleted as late as possible. + */ + static void deleteBackend(); + /** Delete the printer. Should be called by BibleTimeApp, + * because the printer should be deleted as late as possible. + */ + static void deletePrinter(); + /** Delete the language manager. Should be called by BibleTimeApp, + * because the language manager should be deleted as late as possible. + */ + static void deleteLanguageMgr(); + /** Delete the display template manager. Should be called by BibleTimeApp, + * because the template manager should be deleted as late as possible. + */ + static void deleteDisplayTemplateMgr(); + +public: // Public methods + /** Returns a pointer to the backend + * @return The backend pointer. + */ + inline static CSwordBackend* const backend(); + /** Returns a pointer to the language manager + * @return The language manager + */ + inline static CLanguageMgr* const languageMgr(); + /** Returns a pointer to the info display. + * @return The backend pointer. + */ + inline static InfoDisplay::CInfoDisplay* const infoDisplay(); + /** Returns a pointer to the application's display template manager + * @return The backend pointer. + */ + static CDisplayTemplateMgr* const displayTemplateManager(); + + struct PointerCache { + PointerCache() { + backend = 0; + langMgr = 0; + infoDisplay = 0; + displayTemplateMgr = 0; + }; + + CSwordBackend* backend; + CLanguageMgr* langMgr; + InfoDisplay::CInfoDisplay* infoDisplay; + CDisplayTemplateMgr* displayTemplateMgr; + }; +}; + +extern CPointers::PointerCache m_pointerCache; + +/** Returns a pointer to the backend ... */ +inline CSwordBackend* const CPointers::backend() { + return m_pointerCache.backend; +} + +/** Returns a pointer to the backend ... */ +inline CLanguageMgr* const CPointers::languageMgr() { + if (!m_pointerCache.langMgr) { + m_pointerCache.langMgr = new CLanguageMgr(); + } + return m_pointerCache.langMgr; +} + +/** Returns a pointer to the printer object. */ +inline InfoDisplay::CInfoDisplay* const CPointers::infoDisplay() { + return m_pointerCache.infoDisplay; +} + + +#endif diff --git a/bibletime/util/cresmgr.cpp b/bibletime/util/cresmgr.cpp new file mode 100644 index 0000000..8defb77 --- /dev/null +++ b/bibletime/util/cresmgr.cpp @@ -0,0 +1,1198 @@ +/********* +* +* This file is part of BibleTime's source code, http://www.bibletime.info/. +* +* Copyright 1999-2006 by the BibleTime developers. +* The BibleTime source code is licensed under the GNU General Public License version 2.0. +* +**********/ + + + +//own includes +#include "cresmgr.h" + +#include "backend/cswordbackend.h" + +//KDE includes +#include <kglobal.h> +#include <klocale.h> + +namespace CResMgr { + namespace modules { + namespace bible { + const QString icon_unlocked = "bt_bible"; + const QString icon_locked = "bt_bible_locked"; + const QString icon_add = "bt_bible_add"; + } + namespace commentary { + const QString icon_unlocked = "bt_commentary"; + const QString icon_locked = "bt_commentary_locked"; + const QString icon_add = "bt_commentary_add"; + } + namespace lexicon { + const QString icon_unlocked = "bt_lexicon"; + const QString icon_locked = "bt_lexicon_locked"; + const QString icon_add = "bt_lexicon_add"; + } + namespace book { + const QString icon_unlocked = "bt_book"; + const QString icon_locked = "bt_book_locked"; + const QString icon_add = "bt_book_add"; + } + } + + namespace mainMenu { //Main menu + namespace file { //Main menu->File + namespace print { //a standard action + QString tooltip; + + } + namespace quit { //a standard action + QString tooltip; + + } + } + + namespace view { //Main menu->View + namespace showMainIndex { + QString tooltip; + + const QString icon = "view_sidetree"; + const KShortcut accel = Qt::Key_F9; + const char* actionName = "viewMainIndex_action"; + } + namespace showInfoDisplay { + QString tooltip; + + const QString icon = "view_sidetree"; + const KShortcut accel = Qt::Key_F8; + const char* actionName = "viewInfoDisplay_action"; + } + namespace showToolBar { //a standard action + QString tooltip; + + } + } + + namespace mainIndex { //Main menu->Settings + namespace search { + QString tooltip; + + const QString icon = "find"; + const KShortcut accel = Qt::CTRL + Qt::Key_O; + const char* actionName = "mainindex_search_action"; + } + namespace searchdefaultbible { + QString tooltip; + + const QString icon = "find"; + const KShortcut accel = Qt::CTRL + Qt::ALT + Qt::Key_F; + const char* actionName = "mainindex_searchdefaultbible_action"; + } + } + + namespace window { //Main menu->Window + namespace loadProfile { + QString tooltip; + + const QString icon = "view_sidetree"; + const char* actionName = "windowLoadProfile_action"; + } + namespace saveProfile { + QString tooltip; + + const QString icon = "view_sidetree"; + const char* actionName = "windowSaveProfile_action"; + } + namespace saveToNewProfile { + QString tooltip; + + const QString icon = "view_sidetree"; + const KShortcut accel = Qt::CTRL + Qt::ALT + Qt::Key_S; + const char* actionName = "windowSaveToNewProfile_action"; + } + namespace deleteProfile { + QString tooltip; + + const QString icon = "view_sidetree"; + const char* actionName = "windowDeleteProfile_action"; + } + namespace showFullscreen { + QString tooltip; + + const QString icon = "window_fullscreen"; + const KShortcut accel = Qt::CTRL + Qt::SHIFT + Qt::Key_F; + const char* actionName = "windowFullscreen_action"; + } + namespace arrangementMode { + QString tooltip; + + const QString icon = "bt_cascade_auto"; + const KShortcut accel = KKeySequence(); + const char* actionName = "windowArrangementMode_action"; + + namespace manual { + QString tooltip; + + const QString icon = "bt_tile"; + const KShortcut accel = Qt::CTRL + Qt::ALT + Qt::Key_M; + const char* actionName = "windowArrangementManual_action"; + } + namespace autoTileHorizontal { + QString tooltip; + + const QString icon = "bt_tile_auto"; + const KShortcut accel = Qt::CTRL + Qt::ALT + Qt::Key_H; + const char* actionName = "windowAutoTileHorizontal_action"; + } + namespace autoTileVertical { + QString tooltip; + + const QString icon = "bt_tile_auto"; + const KShortcut accel = Qt::CTRL + Qt::ALT + Qt::Key_G; + const char* actionName = "windowAutoTileVertical_action"; + } + namespace autoCascade { + QString tooltip; + + const QString icon = "bt_cascade_auto"; + const KShortcut accel = Qt::CTRL + Qt::ALT + Qt::Key_J; + const char* actionName = "windowAutoCascade_action"; + } + } + namespace tileHorizontal { + QString tooltip; + + const QString icon = "bt_tile"; + const KShortcut accel = Qt::CTRL + Qt::Key_H; + const char* actionName = "windowTileHorizontal_action"; + } + namespace tileVertical { + QString tooltip; + + const QString icon = "bt_tile"; + const KShortcut accel = Qt::CTRL + Qt::Key_G; + const char* actionName = "windowTileVertical_action"; + } + namespace cascade { + QString tooltip; + + const QString icon = "bt_cascade"; + const KShortcut accel = Qt::CTRL + Qt::Key_J; + const char* actionName = "windowCascade_action"; + } + namespace closeAll { + QString tooltip; + + const QString icon = "fileclose"; + const KShortcut accel = Qt::CTRL + Qt::ALT + Qt::Key_W; + const char* actionName = "windowCloseAll_action"; + } + } + + namespace settings { //Main menu->Settings + namespace editToolBar { // available as KStdAction + QString tooltip; + + } + namespace optionsDialog { // available as KStdAction + QString tooltip; + + } + namespace swordSetupDialog { + QString tooltip; + + const QString icon = "bt_swordconfig"; + const KShortcut accel = Qt::Key_F4; + const char* actionName = "options_sword_setup"; + } + + } + + namespace help { //Main menu->Help + namespace handbook { + QString tooltip; + + const QString icon = "contents"; + const KShortcut accel = Qt::Key_F1; + const char* actionName = "helpHandbook_action"; + } + namespace bibleStudyHowTo { + QString tooltip; + + const QString icon = "contents"; + const KShortcut accel = Qt::Key_F2; + const char* actionName = "helpHowTo_action"; + } + namespace bugreport { // available as KStdAction + QString tooltip; + + } + namespace dailyTip { + QString tooltip; + + const QString icon = "idea"; + const KShortcut accel = Qt::Key_F3; + const char* actionName = "helpDailyTip_action"; + } + namespace aboutBibleTime { // available as KStdAction + QString tooltip; + + } + namespace aboutKDE { // available as KStdAction + QString tooltip; + + } + } + } //end of main menu + + namespace searchdialog { + const QString icon = "find"; + + namespace searchButton { + QString tooltip; + + } + namespace cancelSearchButton { + QString tooltip; + + } + + namespace options { + namespace moduleChooserButton { + QString tooltip; + + } + namespace searchedText { + QString tooltip; + + } + namespace searchType { + namespace multipleWords_and { + QString tooltip; + + } + namespace multipleWords_or { + QString tooltip; + + } + namespace exactMatch { + QString tooltip; + + } + namespace regExp { + QString tooltip; + + } + } + + namespace searchOptions { + namespace caseSensitive { + QString tooltip; + + } + } + namespace chooseScope { + QString tooltip; + + } + namespace scopeEditor { + namespace rangeList { + QString tooltip; + + } + namespace nameEdit { + QString tooltip; + + } + namespace editRange { + QString tooltip; + + } + namespace parsedResult { + QString tooltip; + + } + namespace addNewRange { + QString tooltip; + + } + namespace deleteCurrentRange { + QString tooltip; + + } + + } + } + namespace result { + namespace moduleList { + QString tooltip; + + + namespace copyMenu { + const QString icon = "editcopy"; + } + namespace saveMenu { + const QString icon = "filesave"; + } + namespace printMenu { + const QString icon = "fileprint"; + } + } + namespace foundItems { + QString tooltip; + + + namespace copyMenu { + const QString icon = "editcopy"; + } + namespace saveMenu { + const QString icon = "filesave"; + } + namespace printMenu { + const QString icon = "fileprint"; + } + } + namespace textPreview { + QString tooltip; + + } + } + } + + namespace workspace {} + + namespace displaywindows { +/* namespace transliteration { + const QString icon = "bt_displaytranslit"; + }*/ + namespace displaySettings { + const QString icon = "bt_displayconfig"; + } + + namespace general { + namespace scrollButton { + QString tooltip; + } + + namespace search { + QString tooltip; + + const QString icon = "find"; + const KShortcut accel = Qt::CTRL + Qt::Key_L; + const char* actionName = "window_search_action"; + } + + namespace backInHistory { + QString tooltip; + + const QString icon = "previous"; + const KShortcut accel = Qt::ALT + Qt::Key_Left; + const char* actionName = "window_history_back_action"; + } + namespace forwardInHistory { + QString tooltip; + + const QString icon = "next"; + const KShortcut accel = Qt::ALT + Qt::Key_Right; + const char* actionName = "window_history_forward_action"; + } + namespace findStrongs { + QString tooltip; + + const QString icon = "bt_findstrongs"; + const KShortcut accel = KShortcut(0); + const char* actionName = "window_find_strongs_action"; + } + + } + namespace bibleWindow { + namespace bookList { + QString tooltip; + + } + namespace nextBook { + QString tooltip; + + const KShortcut accel = Qt::CTRL + Qt::Key_Y; + } + namespace previousBook { + QString tooltip; + + const KShortcut accel = Qt::CTRL + Qt::SHIFT + Qt::Key_Y; + } + + namespace chapterList { + QString tooltip; + } + namespace nextChapter { + QString tooltip; + const KShortcut accel = Qt::CTRL + Qt::Key_X; + } + namespace previousChapter { + QString tooltip; + const KShortcut accel = Qt::CTRL + Qt::SHIFT + Qt::Key_X; + } + namespace verseList { + QString tooltip; + } + namespace nextVerse { + QString tooltip; + const KShortcut accel = Qt::CTRL + Qt::Key_V; + } + namespace previousVerse { + QString tooltip; + const KShortcut accel = Qt::CTRL + Qt::SHIFT + Qt::Key_V; + } + + namespace copyMenu { + const QString icon = "editcopy"; + } + namespace saveMenu { + const QString icon = "filesave"; + } + namespace printMenu { + const QString icon = "fileprint"; + } + } + namespace commentaryWindow { + namespace syncWindow { + QString tooltip; + const QString icon = "bt_sync"; + const KShortcut accel = KKeySequence(); + const char* actionName = "commentary_syncWindow"; + } + } + namespace lexiconWindow { + namespace entryList { + QString tooltip; + } + namespace nextEntry { + QString tooltip; + const KShortcut accel = Qt::CTRL + Qt::Key_V; + } + namespace previousEntry { + QString tooltip; + const KShortcut accel = Qt::CTRL + Qt::SHIFT + Qt::Key_V; + } + + namespace copyMenu { + const QString icon = "editcopy"; + } + namespace saveMenu { + const QString icon = "filesave"; + } + namespace printMenu { + const QString icon = "fileprint"; + } + } + namespace bookWindow { + namespace toggleTree { + const QString icon = "view_sidetree"; + const KShortcut accel = KKeySequence(); + } + } + + namespace writeWindow { + namespace saveText { + QString tooltip; + + const QString icon = "filesave"; + const KShortcut accel = KKeySequence(); + const char* actionName = "writeWindow_saveText"; + } + namespace restoreText { + QString tooltip; + + const QString icon = "undo"; + const KShortcut accel = KKeySequence(); + const char* actionName = "writeWindow_restoreText"; + } + namespace deleteEntry { + QString tooltip; + + const QString icon = "editdelete"; + const KShortcut accel = KKeySequence(); + const char* actionName = "writeWindow_deleteEntry"; + } + + //formatting buttons + namespace boldText { + QString tooltip; + + const QString icon = "text_bold"; + const KShortcut accel = KKeySequence(); + const char* actionName = "writeWindow_boldText"; + } + namespace italicText { + QString tooltip; + + const QString icon = "text_italic"; + const KShortcut accel = KKeySequence(); + const char* actionName = "writeWindow_italicText"; + } + namespace underlinedText { + QString tooltip; + + const QString icon = "text_under"; + const KShortcut accel = KKeySequence(); + const char* actionName = "writeWindow_underlineText"; + } + + namespace alignLeft { + QString tooltip; + + const QString icon = "text_left"; + const KShortcut accel = KKeySequence(); + const char* actionName = "writeWindow_alignLeft"; + } + namespace alignCenter { + QString tooltip; + + const QString icon = "text_center"; + const KShortcut accel = KKeySequence(); + const char* actionName = "writeWindow_alignCenter"; + } + namespace alignRight { + QString tooltip; + + const QString icon = "rightjust"; + const KShortcut accel = KKeySequence(); + const char* actionName = "writeWindow_alignRight"; + } + namespace alignJustify { + QString tooltip; + + const QString icon = "text_block"; + const KShortcut accel = KKeySequence(); + const char* actionName = "writeWindow_alignJustify"; + } + + namespace fontFamily { + QString tooltip; + + const KShortcut accel = KKeySequence(); + const char* actionName = "writeWindow_fontFamily"; + } + namespace fontSize { + QString tooltip; + + const KShortcut accel = KKeySequence(); + const char* actionName = "writeWindow_fontSize"; + } + namespace fontColor { + QString tooltip; + } + } + } + + namespace settings { + namespace startup { + const QString icon = "bt_startconfig"; + namespace dailyTip { + QString tooltip; + } + namespace showLogo { + QString tooltip; + } + namespace restoreWorkingArea { + QString tooltip; + } + } + namespace fonts { + const QString icon = "fonts"; + + namespace typeChooser { + QString tooltip; + } + } + namespace profiles { + const QString icon = "view_sidetree"; + + namespace list { + QString tooltip; + } + namespace createNew { + QString tooltip; + } + namespace deleteCurrent { + QString tooltip; + } + namespace renameCurrent { + QString tooltip; + } + } + namespace sword { + const QString icon = "bt_swordconfig"; + + namespace general { + namespace language { + QString tooltip; + } + } + namespace modules { + namespace bible { + QString tooltip; + } + namespace commentary { + QString tooltip; + } + namespace lexicon { + QString tooltip; + + } + namespace dailyDevotional { + QString tooltip; + } + namespace hebrewStrongs { + QString tooltip; + } + namespace greekStrongs { + QString tooltip; + } + namespace hebrewMorph { + QString tooltip; + } + namespace greekMorph { + QString tooltip; + } + } + } + namespace keys { + const QString icon = "key_bindings"; + } + } + + namespace mainIndex { //Main menu->Settings + namespace search { + QString tooltip; + + const QString icon = "find"; + const KShortcut accel = Qt::CTRL + Qt::ALT + Qt::Key_M; + const char* actionName = "GMsearch_action"; + } + namespace newFolder { + const QString icon = "folder_new"; + } + namespace changeFolder { + const QString icon = "folder"; + } + namespace openedFolder { + const QString icon = "folder_open"; + } + namespace closedFolder { + const QString icon = "folder"; + } + + namespace bookmark { + const QString icon = "bookmark"; + } + namespace changeBookmark { + const QString icon = "bookmark"; + } + namespace importBookmarks { + const QString icon = "bookmark"; + } + namespace exportBookmarks { + const QString icon = "bookmark"; + } + namespace printBookmarks { + const QString icon = "fileprint"; + } + namespace deleteItems { + const QString icon = "filedelete"; + } + + namespace editModuleMenu { + const QString icon = "pencil"; + } + namespace editModulePlain { + const QString icon = "pencil"; + } + namespace editModuleHTML { + const QString icon = "pencil"; + } + + namespace unlockModule { + const QString icon = "unlock"; + } + namespace aboutModule { + const QString icon = "info"; + } + } +} + + + +namespace CResMgr { + void init_i18n() { + using namespace CResMgr; + { + using namespace mainMenu; + { + using namespace file; + { + using namespace print; + tooltip = i18n ("Open the printer dialog of BibleTime, where you can edit the print queue, assign styles to the items and print them.") ; + } + { + using namespace quit; + tooltip = i18n ("Close BibleTime and save the settings.") ; + } + + { + using namespace view; + { + using namespace showMainIndex; + tooltip = i18n ("Show or hide the bookshelf.") ; + } + { + using namespace showToolBar; + tooltip = i18n ("Toggle the main toolbar view.") ; + } + } + + { + using namespace mainMenu::mainIndex; + { + using namespace search; + tooltip = i18n ("Open the search dialog to search in all works that are currently open.") ; + } + { + using namespace searchdefaultbible; + tooltip = i18n ("Open the search dialog to search in the standard Bible.") ; + } + }; + + { + using namespace window; + { + using namespace loadProfile; + tooltip = i18n ("Restore a saved BibleTime session.") ; + } + { + using namespace saveProfile; + tooltip = i18n ("Save current BibleTime session so that it can be reused later.") ; + } + { + using namespace saveToNewProfile; + tooltip = i18n ("Create and save a new session.") ; + } + { + using namespace deleteProfile; + tooltip = i18n ("Delete a BibleTime session.") ; + } + { + using namespace showFullscreen; + tooltip = i18n ("Toggle fullscreen mode of the main window.") ; + } + { + using namespace tileVertical; + tooltip = i18n ("Vertically tile the open windows.") ; + } + { + using namespace tileHorizontal; + tooltip = i18n ("Horizontally tile the open windows.") ; + } + { + using namespace cascade; + tooltip = i18n ("Cascade the open windows.") ; + } + { + { + using namespace arrangementMode; + tooltip = i18n ("Choose the way that is used to arrange the windows.") ; + } + { + using namespace arrangementMode::autoTileVertical; + tooltip = i18n ("Automatically tile the open windows vertically.") ; + } + { + using namespace arrangementMode::autoTileHorizontal; + tooltip = i18n ("Automatically tile the open windows horizontally.") ; + } + { + using namespace arrangementMode::autoCascade; + tooltip = i18n ("Automatically cascade the open windows.") ; + } + } + { + using namespace closeAll; + tooltip = i18n ("Close all open windows.") ; + } + } + + { + using namespace mainMenu::settings; + { + using namespace editToolBar; + tooltip = i18n ("Open BibleTime's toolbar editor.") ; + } + { + using namespace optionsDialog; + tooltip = i18n ("Open the dialog to set most of BibleTime's preferences.") ; + }; + { + using namespace swordSetupDialog; + tooltip = i18n ("Open the dialog to configure your bookshelf and install/update/remove works.") ; + } + + } + + { + using namespace help; + { + using namespace handbook; + tooltip = i18n ("Open BibleTime's handbook in the KDE helpbrowser.") ; + } + { + using namespace bibleStudyHowTo; + tooltip = i18n ("Open the Bible study HowTo included with BibleTime in the KDE helpbrowser. <BR>This HowTo is an introduction on how to study the Bible in an efficient way.") ; + } + { + using namespace bugreport; + tooltip = i18n ("Send a bugreport to the developers of BibleTime.") ; + } + { + using namespace dailyTip; + tooltip = i18n ("Show a daily tip each time BibleTime starts. <BR>The tips contain important Bible quotations and helpful tips for using BibleTime.") ; + } + { + using namespace aboutBibleTime; + tooltip = i18n ("Show detailed information about BibleTime.") ; + } + { + using namespace aboutKDE; + tooltip = i18n ("Show detailed information about the KDE project.") ; + } + } + } + } + + { + using namespace searchdialog; + { + using namespace searchButton; + tooltip = i18n ("Start to search the text in each of the chosen work(s).") ; + } + { + using namespace cancelSearchButton; + tooltip = i18n ("Stop the active search.") ; + } + + { + using namespace options; + { + using namespace moduleChooserButton; + tooltip = i18n ("Open a dialog to choose work(s) for the search.") ; + } + { + using namespace searchedText; + tooltip = i18n ("Enter the text you want to search in the chosen work(s) here.") ; + } + { + using namespace searchType; + { + using namespace multipleWords_and; + tooltip = i18n ("Treat the search text as multiple words. A text must contain all of the words to match. The order of the words is unimportant.") ; + } + { + using namespace multipleWords_or; + tooltip = i18n ("Treat the search text as multiple words. A text must contain one or more words of to match. The order is unimportant.") ; + } + { + using namespace exactMatch; + tooltip = i18n ("The search text will be used exactly as entered.") ; + } + { + using namespace regExp; + tooltip = i18n ("Treat the search string as a GNU regular expression. The BibleTime handbook contains an introduction to regular expressions.") ; + } + } + + { + using namespace searchOptions; + { + using namespace caseSensitive; + tooltip = i18n ("If you choose this option the search will distinguish between upper and lowercase characters.") ; + } + } + { + using namespace chooseScope; + tooltip = i18n ("Choose a scope from the list. \ +Select the first item to use no scope, the second one is to use each work's last search result as search scope. \ +The others are user defined search scopes."); + } + { + using namespace scopeEditor; + { + using namespace rangeList; + tooltip = i18n ("Select an item from the list to edit the search scope.") ; + } + { + using namespace nameEdit; + tooltip = i18n ("Change the name of the selected search scope.") ; + } + { + using namespace editRange; + tooltip = i18n ("Change the search ranges of the selected search scope item. Have a look at the predefined search scopes to see how search ranges are constructed.") ; + } + { + using namespace parsedResult; + tooltip = i18n ("Contains the search ranges which will be used for the search.") ; + } + { + using namespace addNewRange; + tooltip = i18n ("Add a new search scope. First enter an appropriate name, then edit the search ranges.") ; + } + { + using namespace deleteCurrentRange; + tooltip = i18n ("Deletes the selected search scope. If you close the dialog using Cancel the settings won't be saved.") ; + } + } + } + { + using namespace result; + { + using namespace moduleList; + tooltip = i18n ("The list of works chosen for the search.") ; + } + { + using namespace foundItems; + tooltip = i18n ("This list contains the search result of the selected work.") ; + } + { + using namespace textPreview; + tooltip = i18n ("The text preview of the selected search result item.") ; + } + } + } + + { + using namespace displaywindows; + { + using namespace general; + { + { + using namespace scrollButton; + tooltip = i18n ("This button is useful to scroll through the entries of the list. Press the button and move the mouse to increase or decrease the item.") ; + } + { + using namespace search; + tooltip = i18n ("This button opens the search dialog with the work(s) of this window.") ; + + } + { + using namespace backInHistory; + tooltip = i18n ("Go back one item in the display history.") ; + } + { + using namespace forwardInHistory; + tooltip = i18n ("Go forward one item in the display history.") ; + + } + { + using namespace findStrongs; + tooltip = i18n ("Show all occurences of the Strong number currently under the mouse cursor.") ; + } + } + using namespace bibleWindow; + { + using namespace bookList; + tooltip = i18n ("This list contains the books which are available in this work.") ; + } + { + using namespace nextBook; + tooltip = i18n ("Show the next book of this work.") ; + } + { + using namespace previousBook; + tooltip = i18n ("Show the previous book of this work.") ; + } + { + using namespace chapterList; + tooltip = i18n ("This list contains the chapters which are available in the current book.") ; + } + { + using namespace nextChapter; + tooltip = i18n ("Show the next chapter of the work.") ; + } + { + using namespace previousChapter; + tooltip = i18n ("Show the previous chapter of the work.") ; + } + { + using namespace verseList; + tooltip = i18n ("This list contains the verses which are available in the current chapter.") ; + } + { + using namespace nextVerse; + tooltip = i18n ("In Bible texts, the next verse will be highlighted. In commentaries, the next entry will be shown.") ; + + } + { + using namespace previousVerse; + tooltip = i18n ("In Bible texts, the previous verse will be highlighted. In commentaries, the previous entry will be shown.") ; + } + } + { + using namespace commentaryWindow; + { + using namespace syncWindow; + tooltip = i18n ("Synchronize the displayed entry of this work with the active Bible window.") ; + } + } + { + using namespace lexiconWindow; + { + using namespace entryList; + tooltip = i18n ("This list contains the entries of the current work.") ; + } + { + using namespace nextEntry; + tooltip = i18n ("The next entry of the work will be shown.") ; + } + { + using namespace previousEntry; + tooltip = i18n ("The previous entry of the work will be shown.") ; + } + } + + { + using namespace writeWindow; + { + using namespace saveText; + tooltip = i18n ("Save the curent text into the work. The old text will be overwritten.") ; + } + { + using namespace restoreText; + tooltip = i18n ("Loads the old text from the work and loads it into the edit area. The unsaved text will be lost.") ; + } + { + using namespace deleteEntry; + tooltip = i18n ("Deletes the current entry out of the work. The text will be lost.") ; + } + + //formatting buttons + { + using namespace boldText; + tooltip = i18n ("Toggle bold formatting of the selected text.") ; + } + { + using namespace italicText; + tooltip = i18n ("Toggle italic formatting of the selected text.") ; + } + { + using namespace underlinedText; + tooltip = i18n ("Toggle underlined formatting of the selected text.") ; + } + + { + using namespace alignLeft; + tooltip = i18n ("The text will be aligned on the left side of the page.") ; + } + { + using namespace alignCenter; + tooltip = i18n ("Centers the text horizontally.") ; + } + { + using namespace alignRight; + tooltip = i18n ("Aligns the text on the right side of the page.") ; + } + { + using namespace alignJustify; + tooltip = i18n ("Justifies the text on the page.") ; + } + + { + using namespace fontFamily; + tooltip = i18n ("Choose a new font for the selected text.") ; + } + { using namespace fontSize; + tooltip = i18n ("Choose a new font size for the selected text.") ; + } + { using namespace fontColor; + tooltip = i18n ("Choose a new color for the selected text.") ; + } + } + } + { + using namespace settings; + { + using namespace startup; + { + using namespace dailyTip; + tooltip = i18n ("Activate this box to see a daily tip on startup.") ; + } + { + using namespace showLogo; + tooltip = i18n ("Activate this to see the BibleTime logo on startup.") ; + } + { + using namespace restoreWorkingArea; + tooltip = i18n ("Save the user's session when BibleTime is closed and restore it on the next startup.") ; + } + } + { + using namespace fonts; + { + using namespace typeChooser; + tooltip = i18n ("The font selection below will apply to all texts in this language.") ; + } + } + { + using namespace settings::sword; + { + using namespace general; + { + using namespace language; + tooltip = i18n ("Contains the languages which can be used for the biblical booknames.") ; + } + } + { + using namespace settings::sword::modules; + { + using namespace bible; + tooltip = i18n ("The standard Bible is used when a hyperlink into a Bible is clicked.") ; + } + { + using namespace commentary; + tooltip = i18n ("The standard commentary is used when a hyperlink into a commentary is clicked.") ; + } + { + using namespace lexicon; + tooltip = i18n ("The standard lexicon is used when a hyperlink into a lexicon is clicked.") ; + } + { + using namespace dailyDevotional; + tooltip = i18n ("The standard devotional will be used to display a short start up devotional.") ; + } + { + using namespace hebrewStrongs; + tooltip = i18n ("The standard Hebrew lexicon is used when a hyperlink into a Hebrew lexicon is clicked.") ; + } + { + using namespace greekStrongs; + tooltip = i18n ("The standard Greek lexicon is used when a hyperlink into a Greek lexicon is clicked.") ; + } + { + using namespace hebrewMorph; + tooltip = i18n ("The standard morphological lexicon for Hebrew texts is used when a hyperlink of a morphological tag in a Hebrew text is clicked.") ; + } + { + using namespace greekMorph; + tooltip = i18n ("The standard morphological lexicon for Greek texts is used when a hyperlink of a morphological tag in a Greek text is clicked.") ; + } + } + } + } + { + using namespace mainIndex; + { + using namespace search; + tooltip = i18n ("Opens the search dialog to search in the work(s) that are currently open.") ; + } + } + } +} diff --git a/bibletime/util/cresmgr.h b/bibletime/util/cresmgr.h new file mode 100644 index 0000000..a5e16ab --- /dev/null +++ b/bibletime/util/cresmgr.h @@ -0,0 +1,733 @@ +/********* +* +* This file is part of BibleTime's source code, http://www.bibletime.info/. +* +* Copyright 1999-2006 by the BibleTime developers. +* The BibleTime source code is licensed under the GNU General Public License version 2.0. +* +**********/ + + + +#ifndef CRESMGR_H +#define CRESMGR_H + +//Qt includes +#include <qstring.h> +#include <qkeysequence.h> + +//KDE includes +#include <kshortcut.h> + +/** Provides static functions to easily access the Tooltip texts for all the frontend parts. + * @author The BibleTime team + */ +namespace CResMgr { + void init_i18n(); + + namespace modules { + namespace bible { + extern const QString icon_unlocked; + extern const QString icon_locked; + extern const QString icon_add; + } + namespace commentary { + extern const QString icon_unlocked; + extern const QString icon_locked; + extern const QString icon_add; + }; + namespace lexicon { + extern const QString icon_unlocked; + extern const QString icon_locked; + extern const QString icon_add; + }; + namespace book { + extern const QString icon_unlocked; + extern const QString icon_locked; + extern const QString icon_add; + }; + }; + + namespace mainMenu { //Main menu + namespace file { //Main menu->File + namespace print { //a standard action + extern QString tooltip; + + } + namespace quit { //a standard action + extern QString tooltip; + } + } + + namespace view { //Main menu->View + namespace showMainIndex { + extern QString tooltip; + + extern const QString icon; + extern const KShortcut accel; + extern const char* actionName; + } + namespace showInfoDisplay { + extern QString tooltip; + + extern const QString icon; + extern const KShortcut accel; + extern const char* actionName; + } + namespace showToolBar { //a standard action + extern QString tooltip; + } + } + + namespace mainIndex { //configuration for the main index and the view->search menu + namespace search { + extern QString tooltip; + + extern const QString icon; + extern const KShortcut accel; + extern const char* actionName; + } + namespace searchdefaultbible { + extern QString tooltip; + + extern const QString icon; + extern const KShortcut accel; + extern const char* actionName; + } + } + + namespace window { //Main menu->Window + namespace loadProfile { + extern QString tooltip; + + extern const QString icon; + extern const char* actionName; + } + namespace saveProfile { + extern QString tooltip; + + extern const QString icon; + extern const char* actionName; + } + namespace saveToNewProfile { + extern QString tooltip; + + extern const QString icon; + extern const KShortcut accel; + extern const char* actionName; + } + namespace deleteProfile { + extern QString tooltip; + + extern const QString icon; + extern const char* actionName; + } + namespace showFullscreen { + extern QString tooltip; + + extern const QString icon; + extern const KShortcut accel; + extern const char* actionName; + } + namespace arrangementMode { + extern QString tooltip; + + extern const QString icon; + extern const KShortcut accel; + extern const char* actionName; + + namespace manual { + extern QString tooltip; + + extern const QString icon; + extern const KShortcut accel; + extern const char* actionName; + } + namespace autoTileVertical { + extern QString tooltip; + + extern const QString icon; + extern const KShortcut accel; + extern const char* actionName; + } + namespace autoTileHorizontal { + extern QString tooltip; + + extern const QString icon; + extern const KShortcut accel; + extern const char* actionName; + } + namespace autoCascade { + extern QString tooltip; + + extern const QString icon; + extern const KShortcut accel; + extern const char* actionName; + } + } + namespace tileVertical { + extern QString tooltip; + + extern const QString icon; + extern const KShortcut accel; + extern const char* actionName; + } + namespace tileHorizontal { + extern QString tooltip; + + extern const QString icon; + extern const KShortcut accel; + extern const char* actionName; + } + namespace cascade { + extern QString tooltip; + + extern const QString icon; + extern const KShortcut accel; + extern const char* actionName; + } + namespace closeAll { + extern QString tooltip; + + extern const QString icon; + extern const KShortcut accel; + extern const char* actionName; + } + } + + namespace settings { //Main menu->Settings + namespace editToolBar { // available as KStdAction + extern QString tooltip; + + } + namespace optionsDialog { // available as KStdAction + extern QString tooltip; + + } + namespace swordSetupDialog { + extern QString tooltip; + + extern const QString icon; + extern const KShortcut accel; + extern const char* actionName; + } + } + + namespace help { //Main menu->Help + namespace handbook { + extern QString tooltip; + + extern const QString icon; + extern const KShortcut accel; + extern const char* actionName; + } + namespace bibleStudyHowTo { + extern QString tooltip; + + extern const QString icon; + extern const KShortcut accel; + extern const char* actionName; + } + namespace bugreport { // available as KStdAction + extern QString tooltip; + } + namespace dailyTip { + extern QString tooltip; + + extern const QString icon; + extern const KShortcut accel; + extern const char* actionName; + } + namespace aboutBibleTime { // available as KStdAction + extern QString tooltip; + } + namespace aboutKDE { // available as KStdAction + extern QString tooltip; + } + } + } //end of main menu + + namespace searchdialog { + extern const QString icon; + + namespace searchButton { + extern QString tooltip; + } + namespace cancelSearchButton { + extern QString tooltip; + } + + namespace options { + namespace moduleChooserButton { + extern QString tooltip; + } + namespace searchedText { + extern QString tooltip; + } + namespace searchType { + namespace multipleWords_and { + extern QString tooltip; + } + namespace multipleWords_or { + extern QString tooltip; + } + namespace exactMatch { + extern QString tooltip; + } + namespace regExp { + extern QString tooltip; + } + } + + namespace searchOptions { + namespace caseSensitive { + extern QString tooltip; + } + } + namespace chooseScope { + extern QString tooltip; + } + namespace scopeEditor { + namespace rangeList { + extern QString tooltip; + } + namespace nameEdit { + extern QString tooltip; + } + namespace editRange { + extern QString tooltip; + } + namespace parsedResult { + extern QString tooltip; + } + namespace addNewRange { + extern QString tooltip; + } + namespace deleteCurrentRange { + extern QString tooltip; + } + + } + } + namespace result { + namespace moduleList { + extern QString tooltip; + + namespace copyMenu { + extern const QString icon; + } + namespace saveMenu { + extern const QString icon; + } + namespace printMenu { + extern const QString icon; + } + } + namespace foundItems { + extern QString tooltip; + + namespace copyMenu { + extern const QString icon; + } + namespace saveMenu { + extern const QString icon; + } + namespace printMenu { + extern const QString icon; + } + + } + namespace textPreview { + extern QString tooltip; + } + } + } + +namespace workspace {} + + namespace displaywindows { + namespace transliteration { + extern const QString icon; + } + namespace displaySettings { + extern const QString icon; + } + + namespace general { + namespace scrollButton { + extern QString tooltip; + } + namespace search { + extern QString tooltip; + + extern const QString icon; + extern const KShortcut accel; + extern const char* actionName; + } + + namespace backInHistory { + extern QString tooltip; + + extern const QString icon; + extern const KShortcut accel; + extern const char* actionName; + } + namespace forwardInHistory { + extern QString tooltip; + + extern const QString icon; + extern const KShortcut accel; + extern const char* actionName; + } + + namespace findStrongs { + extern QString tooltip; + + extern const QString icon; + extern const KShortcut accel; + extern const char* actionName; + } + } + + namespace bibleWindow { + namespace bookList { + extern QString tooltip; + + } + namespace nextBook { + extern QString tooltip; + + extern const KShortcut accel; + } + namespace previousBook { + extern QString tooltip; + + extern const KShortcut accel; + } + + namespace chapterList { + extern QString tooltip; + + } + namespace nextChapter { + extern QString tooltip; + + extern const KShortcut accel; + } + namespace previousChapter { + extern QString tooltip; + + extern const KShortcut accel; + } + + namespace verseList { + extern QString tooltip; + + } + namespace nextVerse { + extern QString tooltip; + + extern const KShortcut accel; + } + namespace previousVerse { + extern QString tooltip; + + extern const KShortcut accel; + } + + namespace copyMenu { + extern const QString icon; + } + namespace saveMenu { + extern const QString icon; + } + namespace printMenu { + extern const QString icon; + } + } + namespace commentaryWindow { + namespace syncWindow { + extern const QString icon; + extern QString tooltip; + + extern const KShortcut accel; + extern const char* actionName; + } + + } + + namespace lexiconWindow { + namespace entryList { + extern QString tooltip; + + } + namespace nextEntry { + extern QString tooltip; + + extern const KShortcut accel; + } + namespace previousEntry { + extern QString tooltip; + + extern const KShortcut accel; + } + + namespace copyMenu { + extern const QString icon; + } + namespace saveMenu { + extern const QString icon; + } + namespace printMenu { + extern const QString icon; + } + } + namespace bookWindow { + namespace toggleTree { + extern const QString icon; + extern const KShortcut accel; + } + } + + + namespace writeWindow { + namespace saveText { + extern QString tooltip; + + extern const QString icon; + extern const KShortcut accel; + extern const char* actionName; + } + namespace restoreText { + extern QString tooltip; + + extern const QString icon; + extern const KShortcut accel; + extern const char* actionName; + } + namespace deleteEntry { + extern QString tooltip; + + extern const QString icon; + extern const KShortcut accel; + extern const char* actionName; + } + + //formatting buttons + namespace boldText { + extern QString tooltip; + + extern const QString icon; + extern const KShortcut accel; + extern const char* actionName; + } + namespace italicText { + extern QString tooltip; + + extern const QString icon; + extern const KShortcut accel; + extern const char* actionName; + } + namespace underlinedText { + extern QString tooltip; + + extern const QString icon; + extern const KShortcut accel; + extern const char* actionName; + } + + namespace alignLeft { + extern QString tooltip; + + extern const QString icon; + extern const KShortcut accel; + extern const char* actionName; + } + namespace alignCenter { + extern QString tooltip; + + extern const QString icon; + extern const KShortcut accel; + extern const char* actionName; + } + namespace alignRight { + extern QString tooltip; + + extern const QString icon; + extern const KShortcut accel; + extern const char* actionName; + } + namespace alignJustify { + extern QString tooltip; + + extern const QString icon; + extern const KShortcut accel; + extern const char* actionName; + } + + namespace fontFamily { + extern QString tooltip; + + extern const KShortcut accel; + extern const char* actionName; + } + namespace fontSize { + extern QString tooltip; + + extern const KShortcut accel; + extern const char* actionName; + } + namespace fontColor { + extern QString tooltip; + + } + + } + } + + namespace settings { + namespace startup { + extern const QString icon; + + namespace dailyTip { + extern QString tooltip; + + } + namespace showLogo { + extern QString tooltip; + + } + namespace restoreWorkingArea { + extern QString tooltip; + + } + } + namespace fonts { + extern const QString icon; + + namespace typeChooser { + extern QString tooltip; + + } + } + namespace profiles { + extern const QString icon; + + namespace list { + extern QString tooltip; + + } + namespace createNew { + extern QString tooltip; + + } + namespace deleteCurrent { + extern QString tooltip; + + } + namespace renameCurrent { + extern QString tooltip; + + } + } + namespace sword { + extern const QString icon; + + namespace general { + + namespace language { + extern QString tooltip; + } + } + namespace modules { + namespace bible { + extern QString tooltip; + } + namespace commentary { + extern QString tooltip; + } + namespace lexicon { + extern QString tooltip; + } + namespace dailyDevotional { + extern QString tooltip; + } + namespace hebrewStrongs { + extern QString tooltip; + } + namespace greekStrongs { + extern QString tooltip; + } + namespace hebrewMorph { + extern QString tooltip; + } + namespace greekMorph { + extern QString tooltip; + } + } + } + namespace keys { + extern const QString icon; + } + } + + namespace mainIndex { //configuration for the main index and the view->search menu + namespace search { + extern QString tooltip; + + extern const QString icon; + extern const KShortcut accel; + extern const char* actionName; + } + namespace newFolder { + extern const QString icon; + } + namespace changeFolder { + extern const QString icon; + } + namespace openedFolder { + extern const QString icon; + } + namespace closedFolder { + extern const QString icon; + } + + namespace bookmark { + extern const QString icon; + } + namespace changeBookmark { + extern const QString icon; + } + namespace importBookmarks { + extern const QString icon; + } + namespace exportBookmarks { + extern const QString icon; + } + namespace printBookmarks { + extern const QString icon; + } + namespace deleteItems { + extern const QString icon; + } + + namespace editModuleMenu { + extern const QString icon; + } + namespace editModulePlain { + extern const QString icon; + } + namespace editModuleHTML { + extern const QString icon; + } + + namespace unlockModule { + extern const QString icon; + } + namespace aboutModule { + extern const QString icon; + } + } +} + +#endif diff --git a/bibletime/util/ctoolclass.cpp b/bibletime/util/ctoolclass.cpp new file mode 100644 index 0000000..d00f335 --- /dev/null +++ b/bibletime/util/ctoolclass.cpp @@ -0,0 +1,239 @@ +/********* +* +* This file is part of BibleTime's source code, http://www.bibletime.info/. +* +* Copyright 1999-2006 by the BibleTime developers. +* The BibleTime source code is licensed under the GNU General Public License version 2.0. +* +**********/ + + + +//own includes +#include "ctoolclass.h" + +#include "util/cresmgr.h" +#include "backend/cswordbackend.h" +#include "backend/cswordmoduleinfo.h" + +//QT includes +#include <qlabel.h> +#include <qfile.h> +#include <qfiledialog.h> +#include <qtextstream.h> +#include <qregexp.h> + +//KDE includes +#include <klocale.h> +#include <kglobal.h> +#include <kiconloader.h> +#include <kstandarddirs.h> +#include <kmessagebox.h> +#include <kurl.h> +#include <kfiledialog.h> +#include <kapplication.h> + + +QString CToolClass::locatehtml(const QString &filename) { + QString path = locate("html", KGlobal::locale()->language() + '/' + filename); + if (path.isNull()) + path = locate("html", "default/" + filename); + if (path.isNull()) + path = locate("html", "en/" + filename); + return path; +} + +/** Converts HTML text to plain text */ +QString CToolClass::htmlToText(const QString& html) { + QString newText = html; + // convert some tags we need in code + newText.replace( QRegExp(" "),"#SPACE#" ); + newText.replace( QRegExp("<br/?>\\s*"), "<br/>\n" ); + newText.replace( QRegExp("#SPACE#")," " ); + + QRegExp re("<.+>"); + re.setMinimal(true); + newText.replace( re,"" ); + return newText; +} + +/** Converts text to HTML (\n to <BR>) */ +QString CToolClass::textToHTML(const QString& text) { + QString newText = text; + newText.replace( QRegExp("<BR>\n"),"#NEWLINE#" ); + newText.replace( QRegExp("\n"),"<BR>\n" ); + newText.replace( QRegExp("#NEWLINE#"),"<BR>\n"); + return newText; +} + +/** Creates the file filename and put text into the file. + */ +bool CToolClass::savePlainFile( const QString& filename, const QString& text, const bool& forceOverwrite, const QTextStream::Encoding& fileEncoding) { + QFile saveFile(filename); + bool ret; + + if (saveFile.exists()) { + if (!forceOverwrite && KMessageBox::warningYesNo(0, + QString::fromLatin1("<qt><B>%1</B><BR>%2</qt>") + .arg( i18n("The file already exists.") ) + .arg( i18n("Do you want to overwrite it?") + ) + ) == KMessageBox::No + ) { + return false; + } + else { //either the user chose yes or forceOverwrite is set + saveFile.remove(); + } + }; + + if ( saveFile.open(IO_ReadWrite) ) { + QTextStream textstream( &saveFile ); + textstream.setEncoding(fileEncoding); + textstream << text; + saveFile.close(); + ret = true; + } + else { + KMessageBox::error(0, QString::fromLatin1("<qt>%1<BR><B>%2</B></qt>") + .arg( i18n("The file couldn't be saved.") ) + .arg( i18n("Please check permissions etc."))); + saveFile.close(); + ret = false; + } + return ret; +} + + +/** Returns the icon used for the module given as aparameter. */ +QPixmap CToolClass::getIconForModule( CSwordModuleInfo* module_info ) { + if (!module_info) + return SmallIcon(CResMgr::modules::book::icon_locked, 16); + + if (module_info->category() == CSwordModuleInfo::Cult) { + return SmallIcon("stop.png", 16); + }; + + + QPixmap img; + + switch (module_info->type()) { + case CSwordModuleInfo::Bible: + if (module_info->isLocked()) + img = SmallIcon(CResMgr::modules::bible::icon_locked, 16); + else + img = SmallIcon(CResMgr::modules::bible::icon_unlocked, 16); + break; + + case CSwordModuleInfo::Lexicon: + if (module_info->isLocked()) + img = SmallIcon(CResMgr::modules::lexicon::icon_locked, 16); + else + img = SmallIcon(CResMgr::modules::lexicon::icon_unlocked, 16); + break; + + case CSwordModuleInfo::Commentary: + if (module_info->isLocked()) + img = SmallIcon(CResMgr::modules::commentary::icon_locked, 16); + else + img = SmallIcon(CResMgr::modules::commentary::icon_unlocked, 16); + break; + + case CSwordModuleInfo::GenericBook: + if (module_info->isLocked()) + img = SmallIcon(CResMgr::modules::book::icon_locked, 16); + else + img = SmallIcon(CResMgr::modules::book::icon_unlocked, 16); + break; + + case CSwordModuleInfo::Unknown: //fall though to default + default: + if (module_info->isLocked()) + img = SmallIcon(CResMgr::modules::book::icon_locked, 16); + else + img = SmallIcon(CResMgr::modules::book::icon_unlocked, 16); + break; + } + + + return img; +} + +QLabel* CToolClass::explanationLabel(QWidget* parent, const QString& heading, const QString& text ) { + QLabel* label = new QLabel( QString::fromLatin1("<B>%1</B><BR>%2").arg(heading).arg(text),parent ); + label->setAutoResize(true); + label->setMargin(1); + label->setFrameStyle(QFrame::Box | QFrame::Plain); + return label; +} + +/** No descriptions */ +bool CToolClass::inHTMLTag(int pos, QString & text) { + int i1=text.findRev("<",pos); + int i2=text.findRev(">",pos); + int i3=text.find(">",pos); + int i4=text.find("<",pos); + + + // if ((i1>0) && (i2==-1)) //we're in th first html tag + // i2=i1; // not ncessary, just for explanation + + if ((i3>0) && (i4==-1)) //we're in the last html tag + i4=i3+1; + + // qWarning("%d > %d && %d < %d",i1,i2,i3,i4); + + if ( (i1>i2) && (i3<i4) ) + return true; //yes, we're in a tag + + return false; +} + +QString CToolClass::moduleToolTip(CSwordModuleInfo* module) { + Q_ASSERT(module); + if (!module) { + return QString::null; + } + + QString text; + + text = QString("<b>%1</b> ").arg( module->name() ) + + ((module->category() == CSwordModuleInfo::Cult) ? QString::fromLatin1("<small><b>%1</b></small><br>").arg(i18n("Take care, this work contains cult / questionable material!")) : QString::null); + + text += QString("<small>(") + module->config(CSwordModuleInfo::Description) + QString(")</small><hr>"); + + text += i18n("Language") + QString(": %1<br>").arg( module->language()->translatedName() ); + + if (module->isEncrypted()) { + text += i18n("Unlock key") + QString(": %1<br>") + .arg(!module->config(CSwordModuleInfo::CipherKey).isEmpty() ? module->config(CSwordModuleInfo::CipherKey) : QString("<font COLOR=\"red\">%1</font>").arg(i18n("not set"))); + } + + if (module->hasVersion()) { + text += i18n("Version") + QString(": %1<br>").arg( module->config(CSwordModuleInfo::ModuleVersion) ); + } + + QString options; + unsigned int opts; + for (opts = CSwordModuleInfo::filterTypesMIN; opts <= CSwordModuleInfo::filterTypesMAX; ++opts) { + if (module->has( static_cast<CSwordModuleInfo::FilterTypes>(opts) )) { + if (!options.isEmpty()) { + options += QString::fromLatin1(", "); + } + + options += CSwordBackend::translatedOptionName( + static_cast<CSwordModuleInfo::FilterTypes>(opts) + ); + } + } + + if (!options.isEmpty()) { + text += i18n("Options") + QString::fromLatin1(": <small>") + options + QString("</small>"); + } + + if (text.right(4) == QString::fromLatin1("<br>")) { + text = text.left(text.length()-4); + } + + return text; +} diff --git a/bibletime/util/ctoolclass.h b/bibletime/util/ctoolclass.h new file mode 100644 index 0000000..80d0ae8 --- /dev/null +++ b/bibletime/util/ctoolclass.h @@ -0,0 +1,80 @@ +/********* +* +* This file is part of BibleTime's source code, http://www.bibletime.info/. +* +* Copyright 1999-2006 by the BibleTime developers. +* The BibleTime source code is licensed under the GNU General Public License version 2.0. +* +**********/ + + + +//Qt includes +#include <qstring.h> +#include <qpixmap.h> +#include <qtextstream.h> + + +#ifndef CTOOLCLASS_H +#define CTOOLCLASS_H + + +class CSwordModuleInfo; +class QLabel; + +/** + * Provides some useful functions which would be normally global. + * + * Some methods,that would be normaly global, but I hate global functions :-) + * (the function locateHTML is from Sandy Meier (KDevelop)) + * + * @short A class which contains static members to do small things. + * @author Joachim Ansorg <info@bibletime.info> + */ +class CToolClass { +public: + /** + * @return The path of the HTML file "filename". This function searches only in $KDEDIR. + * @author Sandy Meier of the KDevelop team. + */ + static QString locatehtml(const QString &filename); + /** + * Converts HTML text to plain text. + * This function converts some HTML tags in text (e.g. <BR> to \n) + * @return The text withput HTML tags and with converted <BR> to \n + * @author Joachim Ansorg + */ + static QString htmlToText(const QString&); + /** + * Converts text to HTML converting some text commands into HTML tags (e.g. \n to <BR>) + * @return The HTML formatted text we got after changing \n to <BR> + * @author Joachim Ansorg + */ + static QString textToHTML(const QString&); + /** + * Creates the file filename and put the text of parameter "text" into the file. + * @return True if saving was sucessful, otherwise false + * @author Joachim Ansorg + */ + static bool savePlainFile( const QString& filename, const QString& text, const bool& forceOverwrite = false, const QTextStream::Encoding& fileEncoding = QTextStream::Locale); + /** + * Returns the icon used for the module given as aparameter. + */ + static QPixmap getIconForModule( CSwordModuleInfo* ); + /** Returns a label to explain difficult things of dialogs. + * This function returns a label with heading "heading" and explanation "text". This label should be used to + * explain difficult things of the GUI, e.g. in the optionsdialog. + */ + static QLabel* explanationLabel(QWidget* parent, const QString& heading, const QString& text ); + /** + * Returns true if the character at position "pos" of text is inside an HTML tag. Returns false if it's not inside an HTML tag. + */ + static bool inHTMLTag(int pos, QString & text); + /** Return the module's tooltip text + * @param module The module required for the toolip + * @return The tooltip text for the passed module + */ + static QString moduleToolTip(CSwordModuleInfo* module); +}; + +#endif diff --git a/bibletime/util/directoryutil.cpp b/bibletime/util/directoryutil.cpp new file mode 100644 index 0000000..c55ca96 --- /dev/null +++ b/bibletime/util/directoryutil.cpp @@ -0,0 +1,111 @@ +// +// C++ Implementation: directoryutil +// +// Description: +// +// +// Author: The BibleTime team <info@bibletime.info>, (C) 2006 +// +// Copyright: See COPYING file that comes with this distribution +// +// + +#include "directoryutil.h" + +//Qt includes +#include <qdir.h> + +namespace util { + +namespace filesystem { + +void DirectoryUtil::removeRecursive(const QString& dir) { + qWarning("removeRecursive(%s)", dir.latin1()); + if (dir == QString::null) { + return; + } + + QDir d(dir); + if (!d.exists()) { + return; + } + + QFileInfo *fi = 0; + + //remove all files in this dir + d.setFilter( QDir::Files | QDir::Hidden | QDir::NoSymLinks ); + + const QFileInfoList *fileList = d.entryInfoList(); + QFileInfoListIterator it_file( *fileList ); + while ( (fi = it_file.current()) != 0 ) { + ++it_file; + + qDebug("Removing %s", fi->absFilePath().latin1() ); + d.remove( fi->fileName() ) ; + } + + //remove all subdirs recursively + d.setFilter( QDir::Dirs | QDir::NoSymLinks ); + const QFileInfoList *dirList = d.entryInfoList(); + QFileInfoListIterator it_dir( *dirList ); + + while ( (fi = it_dir.current()) != 0 ) { + ++it_dir; + + if ( !fi->isDir() || fi->fileName() == "." || fi->fileName() == ".." ) { + continue; + } + + qDebug("Removing dir %s", fi->absFilePath().latin1() ); + //d.remove( fi->fileName() ) ; + + removeRecursive( fi->absFilePath() ); + } + + d.rmdir(dir); +} + +/** Returns the size of the directory including the size of all it's files and it's subdirs. + */ +unsigned long DirectoryUtil::getDirSizeRecursive(const QString& dir) { + qWarning("Getting size for %s", dir.latin1()); + + QDir d(dir); + if (!d.exists()) { + return 0; + } + + d.setFilter(QDir::Files); + + unsigned long size = 0; + + const QFileInfoList* infoList = d.entryInfoList(); + QFileInfoListIterator it(*infoList); + QFileInfo* info = 0; + while ((info = it.current()) != 0) { + ++it; + + size += info->size(); + } + + d.setFilter(QDir::Dirs); + const QFileInfoList* dirInfoList = d.entryInfoList(); + QFileInfoListIterator it_dir(*dirInfoList); + while ((info = it_dir.current()) != 0) { + ++it_dir; + + if ( !info->isDir() || info->fileName() == "." || info->fileName() == ".." ) { + continue; + } + + size += getDirSizeRecursive( info->absFilePath() ); + } + + return size; +} + + +} //end of namespace util::filesystem + +} //end of namespace util + diff --git a/bibletime/util/directoryutil.h b/bibletime/util/directoryutil.h new file mode 100644 index 0000000..68a6e88 --- /dev/null +++ b/bibletime/util/directoryutil.h @@ -0,0 +1,55 @@ +// +// C++ Interface: directoryutil +// +// Description: +// +// +// Author: The BibleTime team <info@bibletime.info>, (C) 2006 +// +// Copyright: See COPYING file that comes with this distribution +// +// +#ifndef UTIL_FILESDIRECTORYUTIL_H +#define UTIL_FILESDIRECTORYUTIL_H + +#include <qstring.h> + +namespace util { + +namespace filesystem { + +/** + * Tools for working with directories. + * @author The BibleTime team <info@bibletime.info> +*/ +class DirectoryUtil { +private: + DirectoryUtil() {}; + ~DirectoryUtil() {}; + +public: + /** Removes the given dir with all it's files and subdirs. + * + * TODO: Check if it's suitable for huge dir trees, as it holds a QDir object + * for each of it at the same time in the deepest recursion. + * For really deep dir tree this may lead to a stack overflow. + */ + static void removeRecursive(const QString& dir); + + /** Returns the size of the directory including the size of all it's files + * and it's subdirs. + * + * TODO: Check if it's suitable for huge dir trees, as it holds a QDir object + * for each of it at the same time in the deepest recursion. + * For really deep dir tree this may lead to a stack overflow. + * + * @return The size of the dir in bytes + */ + static unsigned long getDirSizeRecursive(const QString& dir); +}; + +} + +} + +#endif diff --git a/bibletime/util/scoped_resource.h b/bibletime/util/scoped_resource.h new file mode 100644 index 0000000..2032038 --- /dev/null +++ b/bibletime/util/scoped_resource.h @@ -0,0 +1,181 @@ +/********* +* +* This file is part of BibleTime's source code, http://www.bibletime.info/. +* +* Copyright 1999-2006 by the BibleTime developers. +* The BibleTime source code is licensed under the GNU General Public License version 2.0. +* +**********/ + + + +#ifndef SCOPED_RESOURCE_H_INCLUDED +#define SCOPED_RESOURCE_H_INCLUDED + +/** +* The util namespace should take all classes which are of a generic type, +* used to perform common tasks which are not BibleTime-specific. See +* @ref scoped_resource for an example. +*/ +namespace util { + /** + * A class template, scoped_resource, designed to + * implement the Resource Acquisition Is Initialization (RAII) approach + * to resource management. scoped_resource is designed to be used when + * a resource is initialized at the beginning or middle of a scope, + * and released at the end of the scope. The template argument + * ReleasePolicy is a functor which takes an argument of the + * type of the resource, and releases it. + * + * Usage example, for working with files: + * + * @code + * struct close_file { void operator(int fd) const {close(fd);} }; + * ... + * { + * const scoped_resource<int,close_file> file(open("file.txt",O_RDONLY)); + * read(file, buf, 1000); + * } // file is automatically closed here + * @endcode + * + * Note that scoped_resource has an explicit constructor, and prohibits + * copy-construction, and thus the initialization syntax, rather than + * the assignment syntax must be used when initializing. + * + * i.e. using scoped_resource<int,close_file> file = open("file.txt",O_RDONLY); + * in the above example is illegal. + * + */ + template<typename T,typename ReleasePolicy> + class scoped_resource { + T resource; + ReleasePolicy release; + + //prohibited operations + scoped_resource(const scoped_resource&); + scoped_resource& operator=(const scoped_resource&); +public: + typedef T resource_type; + typedef ReleasePolicy release_type; + + /** + * Constructor + * + * @ param res This is the resource to be managed + * @ param rel This is the functor to release the object + */ + explicit scoped_resource(resource_type res,release_type rel=release_type()) +: resource(res), release(rel) {} + + /** + * The destructor is the main point in this class. It takes care of proper + * deletion of the resource, using the provided release policy. + */ + ~scoped_resource() { + release(resource); + } + + /** + * This operator makes sure you can access and use the scoped_resource + * just like you were using the resource itself. + * + * @ret the underlying resource + */ + operator resource_type() const { + return resource; + } + + /** + * This function provides explicit access to the resource. Its behaviour + * is identical to operator resource_type() + * + * @ret the underlying resource + */ + resource_type get + () const { + return resource; + } + + /** + * This function provides convenient direct access to the -> operator + * if the underlying resource is a pointer. Only call this function + * if resource_type is a pointer type. + */ + resource_type operator->() const { + return resource; + } + + }; + + /** + * A helper policy for scoped_ptr. + * It will call the delete operator on a pointer, and assign the pointer to 0 + */ + struct delete_item { + template<typename T> + void operator()(T*& p) const { + delete p; + p = 0; + } + }; + /** + * A helper policy for scoped_array. + * It will call the delete[] operator on a pointer, and assign the pointer to 0 + */ + struct delete_array { + template<typename T> + void operator()(T*& p) const { + delete [] p; + p = 0; + } + }; + + /** + * A class which implements an approximation of + * template<typename T> + * typedef scoped_resource<T*,delete_item> scoped_ptr<T>; + * + * It is a convenient synonym for a common usage of @ref scoped_resource. + * See scoped_resource for more details on how this class behaves. + * + * Usage example: + * @code + * { + * const scoped_ptr<Object> ptr(new Object); + * ...use ptr as you would a normal Object*... + * } // ptr is automatically deleted here + * @endcode + * + * NOTE: use this class only to manage a single object, *never* an array. + * Use scoped_array to manage arrays. This distinction is because you + * may call delete only on objects allocated with new, delete[] only + * on objects allocated with new[]. + */ + template<typename T> +struct scoped_ptr : public scoped_resource<T*,delete_item> { +explicit scoped_ptr(T* p) : scoped_resource<T*,delete_item>(p) {} + } + ; + + /** + * This class has identical behaviour to @ref scoped_ptr, except it manages + * heap-allocated arrays instead of heap-allocated single objects + * + * Usage example: + * @code + * { + * const scoped_array<char> ptr(new char[n]); + * ...use ptr as you would a normal char*... + * } // ptr is automatically deleted here + * @endcode + * + */ + template<typename T> +struct scoped_array : public scoped_resource<T*,delete_array> { +explicit scoped_array(T* p) : scoped_resource<T*,delete_array>(p) {} + } + ; + +} + +#endif |