Eneboo - Documentación para desarrolladores
src/lrelease/metatranslator.h
Ir a la documentación de este archivo.
00001 /**********************************************************************
00002 ** Copyright (C) 2000-2005 Trolltech AS.  All rights reserved.
00003 **
00004 ** This file is part of Qt Linguist.
00005 **
00006 ** This file may be distributed and/or modified under the terms of the
00007 ** GNU General Public License version 2 as published by the Free Software
00008 ** Foundation and appearing in the file LICENSE.GPL included in the
00009 ** packaging of this file.
00010 **
00011 ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
00012 ** licenses may use this file in accordance with the Qt Commercial License
00013 ** Agreement provided with the Software.
00014 **
00015 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00016 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00017 **
00018 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
00019 ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
00020 **   information about Qt Commercial License Agreements.
00021 **
00022 ** Contact info@trolltech.com if any conditions of this licensing are
00023 ** not clear to you.
00024 **
00025 **********************************************************************/
00026 
00027 #ifndef METATRANSLATOR_H
00028 #define METATRANSLATOR_H
00029 
00030 #include <qmap.h>
00031 #include <qstring.h>
00032 #include <qtranslator.h>
00033 #include <qvaluelist.h>
00034 
00035 class QTextCodec;
00036 
00037 class MetaTranslatorMessage : public QTranslatorMessage {
00038 public:
00039   enum Type { Unfinished, Finished, Obsolete };
00040 
00041   MetaTranslatorMessage();
00042   MetaTranslatorMessage( const char *context, const char *sourceText,
00043                          const char *comment,
00044                          const QString& translation = QString::null,
00045                          bool utf8 = FALSE, Type type = Unfinished );
00046   MetaTranslatorMessage( const MetaTranslatorMessage& m );
00047 
00048   MetaTranslatorMessage& operator=( const MetaTranslatorMessage& m );
00049 
00050   void setType( Type nt ) {
00051     ty = nt;
00052   }
00053   Type type() const {
00054     return ty;
00055   }
00056   bool utf8() const {
00057     return utfeight;
00058   }
00059 
00060   bool operator==( const MetaTranslatorMessage& m ) const;
00061   bool operator!=( const MetaTranslatorMessage& m ) const {
00062     return !operator==( m );
00063   }
00064   bool operator<( const MetaTranslatorMessage& m ) const;
00065   bool operator<=( const MetaTranslatorMessage& m ) {
00066     return !operator>( m );
00067   }
00068   bool operator>( const MetaTranslatorMessage& m ) const {
00069     return this->operator<( m );
00070   }
00071   bool operator>=( const MetaTranslatorMessage& m ) const {
00072     return !operator<( m );
00073   }
00074 
00075 private:
00076   bool utfeight;
00077   Type ty;
00078 };
00079 
00080 class MetaTranslator {
00081 public:
00082   MetaTranslator();
00083   MetaTranslator( const MetaTranslator& tor );
00084 
00085   MetaTranslator& operator=( const MetaTranslator& tor );
00086 
00087   void clear();
00088   bool load( const QString& filename );
00089   bool save( const QString& filename ) const;
00090   bool release( const QString& filename, bool verbose = FALSE,
00091                 QTranslator::SaveMode mode = QTranslator::Stripped ) const;
00092 
00093   bool contains( const char *context, const char *sourceText,
00094                  const char *comment ) const;
00095   void insert( const MetaTranslatorMessage& m );
00096 
00097   void stripObsoleteMessages();
00098   void stripEmptyContexts();
00099 
00100   void setCodec( const char *name );
00101   QString toUnicode( const char *str, bool utf8 ) const;
00102 
00103   QValueList<MetaTranslatorMessage> messages() const;
00104   QValueList<MetaTranslatorMessage> translatedMessages() const;
00105 
00106 private:
00107   typedef QMap<MetaTranslatorMessage, int> TMM;
00108   typedef QMap<int, MetaTranslatorMessage> TMMInv;
00109 
00110   TMM mm;
00111   QCString codecName;
00112   QTextCodec *codec;
00113 };
00114 
00115 /*
00116   This is a quick hack. The proper way to handle this would be
00117   to extend MetaTranslator's interface.
00118 */
00119 #define ContextComment "QT_LINGUIST_INTERNAL_CONTEXT_COMMENT"
00120 
00121 #endif
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'