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.

creferencemanager.h 4.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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 CREFERENCEMANAGER_H
  10. #define CREFERENCEMANAGER_H
  11. //Qt includes
  12. #include <tqstring.h>
  13. #include "cswordmoduleinfo.h"
  14. /** Contains static functions to work with referneces used for Drag & Drop and for hyperlinks used in our
  15. * rendered HTML code.
  16. * @author The BibleTime team
  17. */
  18. class CReferenceManager {
  19. public:
  20. enum Type {
  21. Bible, /**< Bibles */
  22. Commentary, /**< Commentary */
  23. Lexicon, /**< Lexicon */
  24. GenericBook, /**< Generic Book */
  25. MorphHebrew, /**< Module for hebrew morphology*/
  26. MorphGreek, /**< Module for greek morphology */
  27. StrongsHebrew, /**< Module for hebrew strongs */
  28. StrongsGreek, /**< Module for greek strongs */
  29. Unknown /**< Unknown */
  30. };
  31. /** Turn a hyperlink into module, key and type.
  32. * Decodes the given hyperlink into module, key and type.
  33. * @param hyperlink The hyperlink to decode
  34. * @param module The string which will contain the module name after decoding
  35. * @param key The string which will contain the key after decoding
  36. * @param type The type param will contain the reference type after decoding
  37. */
  38. static const bool decodeHyperlink( const TQString& hyperlink, TQString& module, TQString& key, Type& type);
  39. /**
  40. * Returns a hyperlink used to be imbedded in the display windows.
  41. * At the moment the format is sword://module/key
  42. * @param module The module which is used to encode the hyperlink
  43. * @param key The key which is used to encode the hyperlink
  44. * @param type The type which is used to encode the hyperlink
  45. * @return The encoded hyperlink
  46. */
  47. static const TQString encodeHyperlink( const TQString module, const TQString key, const Type type);
  48. /**
  49. * Puts a module Name and a Reference together in the 'draggable' form
  50. * (module)reference
  51. * @param module The name of the module
  52. * @param reference The key reference as text
  53. * @return The encoded reference using module and reference
  54. * @author Martin Gruner
  55. */
  56. static const TQString encodeReference(const TQString &module, const TQString &reference);
  57. /**
  58. * decodes a 'draggable' reference into a modulename and a reference
  59. * @author Martin Gruner
  60. */
  61. static void decodeReference(TQString &dragreference, TQString &module, TQString &reference);
  62. /**
  63. * Returns true if the parameter is a hyperlink.
  64. * @param hyperlink The string which is tested
  65. * @return True if the passed string is a hyperlink
  66. */
  67. static const bool isHyperlink( const TQString& hyperlink );
  68. /**
  69. * Returns the preferred module name for the given type.
  70. * @param type The type which is used to find the module
  71. * @return The default module name for the passed type
  72. */
  73. static const TQString preferredModule( const Type type );
  74. /**
  75. * Returns the type of the passed module type
  76. * @param type The CSwordModuleInfo module typpe
  77. * @return The ReferenceManager type
  78. */
  79. static CReferenceManager::Type typeFromModule( const CSwordModuleInfo::ModuleType type );
  80. struct ParseOptions {
  81. TQString refDestinationModule;
  82. TQString refBase; /* only valid for verse based destination modules*/
  83. TQString sourceLanguage; /* only valid for verse based destination modules*/
  84. TQString destinationLanguage; /* only valid for verse based destination modules*/
  85. ParseOptions() {
  86. destinationLanguage = "en";
  87. };
  88. };
  89. /** Parses the given verse references using the given language and the module.
  90. * @param moduleName The name of the module to use. Required for the language checking before parsing the key.
  91. * @param ref The verse reference.
  92. * @param lang The language of the verse reference
  93. * @param newLang The language of the reference, which will be returned. For example: If BibleTime using an english environment parses a spanish ref (lang=es) the returned ref should be in english (newLang=en), because his english standard module only understands en.
  94. */
  95. static const TQString parseVerseReference( const TQString& ref, const ParseOptions& options);
  96. };
  97. #endif