Eneboo - Documentación para desarrolladores
src/qt/include/qtranslator.h
Ir a la documentación de este archivo.
00001 /****************************************************************************
00002 ** $Id: qt/qtranslator.h   3.3.8   edited Jan 11 14:46 $
00003 **
00004 ** Definition of the translator class
00005 **
00006 ** Created : 980906
00007 **
00008 ** Copyright (C) 1998-2007 Trolltech ASA.  All rights reserved.
00009 **
00010 ** This file is part of the kernel module of the Qt GUI Toolkit.
00011 **
00012 ** This file may be distributed under the terms of the Q Public License
00013 ** as defined by Trolltech ASA of Norway and appearing in the file
00014 ** LICENSE.QPL included in the packaging of this file.
00015 **
00016 ** This file may be distributed and/or modified under the terms of the
00017 ** GNU General Public License version 2 as published by the Free Software
00018 ** Foundation and appearing in the file LICENSE.GPL included in the
00019 ** packaging of this file.
00020 **
00021 ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
00022 ** licenses may use this file in accordance with the Qt Commercial License
00023 ** Agreement provided with the Software.
00024 **
00025 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00026 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00027 **
00028 ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
00029 **   information about Qt Commercial License Agreements.
00030 ** See http://www.trolltech.com/qpl/ for QPL licensing information.
00031 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
00032 **
00033 ** Contact info@trolltech.com if any conditions of this licensing are
00034 ** not clear to you.
00035 **
00036 **********************************************************************/
00037 
00038 
00039 #ifndef QTRANSLATOR_H
00040 #define QTRANSLATOR_H
00041 
00042 #ifndef QT_H
00043 #include "qobject.h"
00044 #include "qvaluelist.h"
00045 #endif // QT_H
00046 
00047 #ifndef QT_NO_TRANSLATION
00048 
00049 class QTranslatorPrivate;
00050 
00051 class Q_EXPORT QTranslatorMessage
00052 {
00053 public:
00054     QTranslatorMessage();
00055     QTranslatorMessage( const char * context,
00056                         const char * sourceText,
00057                         const char * comment,
00058                         const QString& translation = QString::null );
00059     QTranslatorMessage( QDataStream & );
00060     QTranslatorMessage( const QTranslatorMessage & m );
00061 
00062     QTranslatorMessage & operator=( const QTranslatorMessage & m );
00063 
00064     uint hash() const { return h; }
00065     const char *context() const { return cx; }
00066     const char *sourceText() const { return st; }
00067     const char *comment() const { return cm; }
00068 
00069     void setTranslation( const QString & translation ) { tn = translation; }
00070     QString translation() const { return tn; }
00071 
00072     enum Prefix { NoPrefix, Hash, HashContext, HashContextSourceText,
00073                   HashContextSourceTextComment };
00074     void write( QDataStream & s, bool strip = FALSE,
00075                 Prefix prefix = HashContextSourceTextComment ) const;
00076     Prefix commonPrefix( const QTranslatorMessage& ) const;
00077 
00078     bool operator==( const QTranslatorMessage& m ) const;
00079     bool operator!=( const QTranslatorMessage& m ) const
00080     { return !operator==( m ); }
00081     bool operator<( const QTranslatorMessage& m ) const;
00082     bool operator<=( const QTranslatorMessage& m ) const
00083     { return !m.operator<( *this ); }
00084     bool operator>( const QTranslatorMessage& m ) const
00085     { return m.operator<( *this ); }
00086     bool operator>=( const QTranslatorMessage& m ) const
00087     { return !operator<( m ); }
00088 
00089 private:
00090     uint h;
00091     QCString cx;
00092     QCString st;
00093     QCString cm;
00094     QString tn;
00095 
00096     enum Tag { Tag_End = 1, Tag_SourceText16, Tag_Translation, Tag_Context16,
00097                Tag_Hash, Tag_SourceText, Tag_Context, Tag_Comment,
00098                Tag_Obsolete1 };
00099 };
00100 
00101 
00102 class Q_EXPORT QTranslator: public QObject
00103 {
00104     Q_OBJECT
00105 public:
00106     QTranslator( QObject * parent = 0, const char * name = 0 );
00107     ~QTranslator();
00108 
00109 #ifndef QT_NO_COMPAT
00110     QString find( const char *context, const char *sourceText, const char * comment = 0 ) const {
00111         return findMessage( context, sourceText, comment ).translation();
00112     }
00113 #endif
00114     virtual QTranslatorMessage findMessage( const char *, const char *,
00115                                             const char * = 0 ) const;
00116 
00117     bool load( const QString & filename,
00118                const QString & directory = QString::null,
00119                const QString & search_delimiters = QString::null,
00120                const QString & suffix = QString::null );
00121     bool load( const uchar *data, int len ) {
00122         clear();
00123         return do_load( data, len );
00124     }
00125 
00126     void clear();
00127 
00128 #ifndef QT_NO_TRANSLATION_BUILDER
00129     enum SaveMode { Everything, Stripped };
00130 
00131     bool save( const QString & filename, SaveMode mode = Everything );
00132 
00133     void insert( const QTranslatorMessage& );
00134     void insert( const char *context, const char *sourceText, const QString &translation ) {
00135         insert( QTranslatorMessage(context, sourceText, "", translation) );
00136     }
00137     void remove( const QTranslatorMessage& );
00138     void remove( const char *context, const char *sourceText ) {
00139         remove( QTranslatorMessage(context, sourceText, "") );
00140     }
00141     bool contains( const char *, const char *, const char * comment = 0 ) const;
00142 
00143     void squeeze( SaveMode = Everything );
00144     void unsqueeze();
00145 
00146     QValueList<QTranslatorMessage> messages() const;
00147 #endif
00148 
00149     bool isEmpty() const;
00150 
00151 private:
00152 #if defined(Q_DISABLE_COPY)
00153     QTranslator( const QTranslator & );
00154     QTranslator &operator=( const QTranslator & );
00155 #endif
00156 
00157     bool do_load( const uchar *data, int len );
00158 
00159     QTranslatorPrivate * d;
00160 };
00161 
00162 #endif // QT_NO_TRANSLATION
00163 
00164 #endif
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'