SIP4 python bindings for TQt
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.

96 lines
2.7KB

  1. /**********************************************************************
  2. ** Copyright (C) 2000 Trolltech AS. All rights reserved.
  3. **
  4. ** metatranslator.h
  5. **
  6. ** This file is part of TQt Linguist.
  7. **
  8. ** See the file LICENSE included in the distribution for the usage
  9. ** and distribution terms.
  10. **
  11. ** The file is provided AS IS with NO WARRANTY OF ANY KIND,
  12. ** INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR
  13. ** A PARTICULAR PURPOSE.
  14. **
  15. **********************************************************************/
  16. #ifndef METATRANSLATOR_H
  17. #define METATRANSLATOR_H
  18. #include <qmap.h>
  19. #include <qstring.h>
  20. #include <qtranslator.h>
  21. #include <qvaluelist.h>
  22. class TQTextCodec;
  23. class MetaTranslatorMessage : public TQTranslatorMessage
  24. {
  25. public:
  26. enum Type { Unfinished, Finished, Obsolete };
  27. MetaTranslatorMessage();
  28. MetaTranslatorMessage( const char *context, const char *sourceText,
  29. const char *comment,
  30. const TQString& translation = TQString::null,
  31. bool utf8 = FALSE, Type type = Unfinished );
  32. MetaTranslatorMessage( const MetaTranslatorMessage& m );
  33. MetaTranslatorMessage& operator=( const MetaTranslatorMessage& m );
  34. void setType( Type nt ) { ty = nt; }
  35. Type type() const { return ty; }
  36. bool utf8() const { return utfeight; }
  37. bool operator==( const MetaTranslatorMessage& m ) const;
  38. bool operator!=( const MetaTranslatorMessage& m ) const
  39. { return !operator==( m ); }
  40. bool operator<( const MetaTranslatorMessage& m ) const;
  41. bool operator<=( const MetaTranslatorMessage& m )
  42. { return !operator>( m ); }
  43. bool operator>( const MetaTranslatorMessage& m ) const
  44. { return this->operator<( m ); }
  45. bool operator>=( const MetaTranslatorMessage& m ) const
  46. { return !operator<( m ); }
  47. private:
  48. bool utfeight;
  49. Type ty;
  50. };
  51. class MetaTranslator
  52. {
  53. public:
  54. MetaTranslator();
  55. MetaTranslator( const MetaTranslator& tor );
  56. MetaTranslator& operator=( const MetaTranslator& tor );
  57. bool load( const TQString& filename );
  58. bool save( const TQString& filename ) const;
  59. bool release( const TQString& filename, bool verbose = FALSE ) const;
  60. bool contains( const char *context, const char *sourceText,
  61. const char *comment ) const;
  62. void insert( const MetaTranslatorMessage& m );
  63. void stripObsoleteMessages();
  64. void stripEmptyContexts();
  65. void setCodec( const char *name );
  66. TQString toUnicode( const char *str, bool utf8 ) const;
  67. TQValueList<MetaTranslatorMessage> messages() const;
  68. TQValueList<MetaTranslatorMessage> translatedMessages() const;
  69. private:
  70. typedef TQMap<MetaTranslatorMessage, int> TMM;
  71. typedef TQMap<int, MetaTranslatorMessage> TMMInv;
  72. TMM mm;
  73. TQCString codecName;
  74. TQTextCodec *codec;
  75. };
  76. #endif