Eneboo - Documentación para desarrolladores
src/qt/tools/linguist/shared/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 {
00039 public:
00040     enum Type { Unfinished, Finished, Obsolete };
00041 
00042     MetaTranslatorMessage();
00043     MetaTranslatorMessage( const char *context, const char *sourceText,
00044                            const char *comment,
00045                            const QString& translation = QString::null,
00046                            bool utf8 = FALSE, Type type = Unfinished );
00047     MetaTranslatorMessage( const MetaTranslatorMessage& m );
00048 
00049     MetaTranslatorMessage& operator=( const MetaTranslatorMessage& m );
00050 
00051     void setType( Type nt ) { ty = nt; }
00052     Type type() const { return ty; }
00053     bool utf8() const { return utfeight; }
00054 
00055     bool operator==( const MetaTranslatorMessage& m ) const;
00056     bool operator!=( const MetaTranslatorMessage& m ) const
00057     { return !operator==( m ); }
00058     bool operator<( const MetaTranslatorMessage& m ) const;
00059     bool operator<=( const MetaTranslatorMessage& m )
00060     { return !operator>( m ); }
00061     bool operator>( const MetaTranslatorMessage& m ) const
00062     { return this->operator<( m ); }
00063     bool operator>=( const MetaTranslatorMessage& m ) const
00064     { return !operator<( m ); }
00065 
00066 private:
00067     bool utfeight;
00068     Type ty;
00069 };
00070 
00071 class MetaTranslator
00072 {
00073 public:
00074     MetaTranslator();
00075     MetaTranslator( const MetaTranslator& tor );
00076 
00077     MetaTranslator& operator=( const MetaTranslator& tor );
00078 
00079     void clear();
00080     bool load( const QString& filename );
00081     bool save( const QString& filename ) const;
00082     bool release( const QString& filename, bool verbose = FALSE,
00083                   QTranslator::SaveMode mode = QTranslator::Stripped ) const;
00084 
00085     bool contains( const char *context, const char *sourceText,
00086                    const char *comment ) const;
00087     void insert( const MetaTranslatorMessage& m );
00088 
00089     void stripObsoleteMessages();
00090     void stripEmptyContexts();
00091 
00092     void setCodec( const char *name );
00093     QString toUnicode( const char *str, bool utf8 ) const;
00094 
00095     QValueList<MetaTranslatorMessage> messages() const;
00096     QValueList<MetaTranslatorMessage> translatedMessages() const;
00097 
00098 private:
00099     typedef QMap<MetaTranslatorMessage, int> TMM;
00100     typedef QMap<int, MetaTranslatorMessage> TMMInv;
00101 
00102     TMM mm;
00103     QCString codecName;
00104     QTextCodec *codec;
00105 };
00106 
00107 /*
00108   This is a quick hack. The proper way to handle this would be
00109   to extend MetaTranslator's interface.
00110 */
00111 #define ContextComment "QT_LINGUIST_INTERNAL_CONTEXT_COMMENT"
00112 
00113 #endif
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'