home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / qt3_emx.zip / include / qtranslator.h < prev    next >
C/C++ Source or Header  |  2001-10-11  |  5KB  |  158 lines

  1. /****************************************************************************
  2. ** $Id:  qt/qtranslator.h   3.0.0   edited Aug 14 10:51 $
  3. **
  4. ** Definition of the translator class
  5. **
  6. ** Created : 980906
  7. **
  8. ** Copyright (C) 1998-99 by Trolltech AS.  All rights reserved.
  9. **
  10. ** This file is part of the kernel module of the Qt GUI Toolkit.
  11. **
  12. ** This file may be distributed under the terms of the Q Public License
  13. ** as defined by Trolltech AS of Norway and appearing in the file
  14. ** LICENSE.QPL included in the packaging of this file.
  15. **
  16. ** This file may be distributed and/or modified under the terms of the
  17. ** GNU General Public License version 2 as published by the Free Software
  18. ** Foundation and appearing in the file LICENSE.GPL included in the
  19. ** packaging of this file.
  20. **
  21. ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
  22. ** licenses may use this file in accordance with the Qt Commercial License
  23. ** Agreement provided with the Software.
  24. **
  25. ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
  26. ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  27. **
  28. ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
  29. **   information about Qt Commercial License Agreements.
  30. ** See http://www.trolltech.com/qpl/ for QPL licensing information.
  31. ** See http://www.trolltech.com/gpl/ for GPL licensing information.
  32. **
  33. ** Contact info@trolltech.com if any conditions of this licensing are
  34. ** not clear to you.
  35. **
  36. **********************************************************************/
  37.  
  38.  
  39. #ifndef QTRANSLATOR_H
  40. #define QTRANSLATOR_H
  41.  
  42. #ifndef QT_H
  43. #include "qobject.h"
  44. #include "qvaluelist.h"
  45. #endif // QT_H
  46.  
  47. #ifndef QT_NO_TRANSLATION
  48.  
  49. class QTranslatorPrivate;
  50.  
  51. class Q_EXPORT QTranslatorMessage
  52. {
  53. public:
  54.     QTranslatorMessage();
  55.     QTranslatorMessage( const char * context,
  56.             const char * sourceText,
  57.             const char * comment,
  58.             const QString& translation = QString::null );
  59.     QTranslatorMessage( QDataStream & );
  60.     QTranslatorMessage( const QTranslatorMessage & m );
  61.  
  62.     QTranslatorMessage & operator=( const QTranslatorMessage & m );
  63.  
  64.     uint hash() const { return h; }
  65.     const char *context() const { return cx; }
  66.     const char *sourceText() const { return st; }
  67.     const char *comment() const { return cm; }
  68.  
  69.     void setTranslation( const QString & translation ) { tn = translation; }
  70.     QString translation() const { return tn; }
  71.  
  72.     enum Prefix { NoPrefix, Hash, HashContext, HashContextSourceText,
  73.           HashContextSourceTextComment };
  74.     void write( QDataStream & s, bool strip = FALSE,
  75.         Prefix prefix = HashContextSourceTextComment ) const;
  76.     Prefix commonPrefix( const QTranslatorMessage& ) const;
  77.  
  78.     bool operator==( const QTranslatorMessage& m ) const;
  79.     bool operator!=( const QTranslatorMessage& m ) const
  80.     { return !operator==( m ); }
  81.     bool operator<( const QTranslatorMessage& m ) const;
  82.     bool operator<=( const QTranslatorMessage& m ) const
  83.     { return !operator>( m ); }
  84.     bool operator>( const QTranslatorMessage& m ) const
  85.     { return this->operator<( m ); }
  86.     bool operator>=( const QTranslatorMessage& m ) const
  87.     { return !operator<( m ); }
  88.  
  89. private:
  90.     uint h;
  91.     QCString cx;
  92.     QCString st;
  93.     QCString cm;
  94.     QString tn;
  95.  
  96.     enum Tag { Tag_End = 1, Tag_SourceText16, Tag_Translation, Tag_Context16,
  97.            Tag_Hash, Tag_SourceText, Tag_Context, Tag_Comment,
  98.            Tag_Obsolete1 };
  99. };
  100.  
  101.  
  102. class Q_EXPORT QTranslator: public QObject
  103. {
  104.     Q_OBJECT
  105. public:
  106.     QTranslator( QObject * parent, const char * name = 0 );
  107.     ~QTranslator();
  108.  
  109. #ifndef QT_NO_COMPAT
  110.     QString find( const char *context, const char *sourceText, const char * comment = 0 ) const {
  111.     return findMessage( context, sourceText, comment ).translation();
  112.     }
  113. #endif
  114.     virtual QTranslatorMessage findMessage( const char *, const char *,
  115.                     const char * ) const;
  116.  
  117.     bool load( const QString & filename,
  118.            const QString & directory = QString::null,
  119.            const QString & search_delimiters = QString::null,
  120.            const QString & suffix = QString::null );
  121.  
  122.     void clear();
  123.  
  124. #ifndef QT_NO_TRANSLATION_BUILDER
  125.     enum SaveMode { Everything, Stripped };
  126.  
  127.     bool save( const QString & filename, SaveMode mode = Everything );
  128.  
  129.     void insert( const QTranslatorMessage& );
  130.     void insert( const char *context, const char *sourceText, const QString &translation ) {
  131.     insert( QTranslatorMessage(context, sourceText, "", translation) );
  132.     }
  133.     void remove( const QTranslatorMessage& );
  134.     void remove( const char *context, const char *sourceText ) {
  135.     remove( QTranslatorMessage(context, sourceText, "") );
  136.     }
  137.     bool contains( const char *, const char *, const char * comment = 0 ) const;
  138.  
  139.     void squeeze( SaveMode = Everything );
  140.     void unsqueeze();
  141.  
  142.     QValueList<QTranslatorMessage> messages() const;
  143. #endif
  144.  
  145. private:
  146.     QTranslatorPrivate * d;
  147.  
  148. private:    // Disabled copy constructor and operator=
  149. #if defined(Q_DISABLE_COPY)
  150.     QTranslator( const QTranslator & );
  151.     QTranslator &operator=( const QTranslator & );
  152. #endif
  153. };
  154.  
  155. #endif // QT_NO_TRANSLATION
  156.  
  157. #endif
  158.