~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to src/plugins/codecs/cn/main.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-08-24 04:09:09 UTC
  • Revision ID: james.westby@ubuntu.com-20050824040909-xmxe9jfr4a0w5671
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/****************************************************************************
 
2
**
 
3
** Copyright (C) 1992-2005 Trolltech AS. All rights reserved.
 
4
**
 
5
** This file is part of the internationalization module of the Qt Toolkit.
 
6
**
 
7
** This file may be distributed under the terms of the Q Public License
 
8
** as defined by Trolltech AS of Norway and appearing in the file
 
9
** LICENSE.QPL included in the packaging of this file.
 
10
**
 
11
** This file may be distributed and/or modified under the terms of the
 
12
** GNU General Public License version 2 as published by the Free Software
 
13
** Foundation and appearing in the file LICENSE.GPL included in the
 
14
** packaging of this file.
 
15
**
 
16
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
 
17
**   information about Qt Commercial License Agreements.
 
18
** See http://www.trolltech.com/qpl/ for QPL licensing information.
 
19
** See http://www.trolltech.com/gpl/ for GPL licensing information.
 
20
**
 
21
** Contact info@trolltech.com if any conditions of this licensing are
 
22
** not clear to you.
 
23
**
 
24
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
 
25
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 
26
**
 
27
****************************************************************************/
 
28
 
 
29
#include <qtextcodecplugin.h>
 
30
#include <qtextcodec.h>
 
31
#include <qlist.h>
 
32
 
 
33
#include "qgb18030codec.h"
 
34
 
 
35
 
 
36
class CNTextCodecs : public QTextCodecPlugin
 
37
{
 
38
public:
 
39
    CNTextCodecs() {}
 
40
 
 
41
    QList<QByteArray> names() const;
 
42
    QList<QByteArray> aliases() const;
 
43
    QList<int> mibEnums() const;
 
44
 
 
45
    QTextCodec *createForMib(int);
 
46
    QTextCodec *createForName(const QByteArray &);
 
47
};
 
48
 
 
49
QList<QByteArray> CNTextCodecs::names() const
 
50
{
 
51
    QList<QByteArray> list;
 
52
    list += QGb18030Codec::_name();
 
53
    list += QGbkCodec::_name();
 
54
    list += QGb2312Codec::_name();
 
55
#ifdef Q_WS_X11
 
56
    list += QFontGb2312Codec::_name();
 
57
    list += QFontGbkCodec::_name();
 
58
#endif
 
59
    return list;
 
60
}
 
61
 
 
62
QList<QByteArray> CNTextCodecs::aliases() const
 
63
{
 
64
    QList<QByteArray> list;
 
65
    list += QGb18030Codec::_aliases();
 
66
    list += QGbkCodec::_aliases();
 
67
    list += QGb2312Codec::_aliases();
 
68
#ifdef Q_WS_X11
 
69
    list += QFontGb2312Codec::_aliases();
 
70
    list += QFontGbkCodec::_aliases();
 
71
#endif
 
72
    return list;
 
73
}
 
74
 
 
75
QList<int> CNTextCodecs::mibEnums() const
 
76
{
 
77
    QList<int> list;
 
78
    list += QGb18030Codec::_mibEnum();
 
79
    list += QGbkCodec::_mibEnum();
 
80
    list += QGb2312Codec::_mibEnum();
 
81
#ifdef Q_WS_X11
 
82
    list += QFontGb2312Codec::_mibEnum();
 
83
    list += QFontGbkCodec::_mibEnum();
 
84
#endif
 
85
    return list;
 
86
}
 
87
 
 
88
QTextCodec *CNTextCodecs::createForMib(int mib)
 
89
{
 
90
    if (mib == QGb18030Codec::_mibEnum())
 
91
        return new QGb18030Codec;
 
92
    if (mib == QGbkCodec::_mibEnum())
 
93
        return new QGbkCodec;
 
94
    if (mib == QGb2312Codec::_mibEnum())
 
95
        return new QGb2312Codec;
 
96
#ifdef Q_WS_X11
 
97
    if (mib == QFontGbkCodec::_mibEnum())
 
98
        return new QFontGbkCodec;
 
99
    if (mib == QFontGb2312Codec::_mibEnum())
 
100
        return new QFontGb2312Codec;
 
101
#endif
 
102
    return 0;
 
103
}
 
104
 
 
105
 
 
106
QTextCodec *CNTextCodecs::createForName(const QByteArray &name)
 
107
{
 
108
    if (name == QGb18030Codec::_name() || QGb18030Codec::_aliases().contains(name))
 
109
        return new QGb18030Codec;
 
110
    if (name == QGbkCodec::_name() || QGbkCodec::_aliases().contains(name))
 
111
        return new QGbkCodec;
 
112
    if (name == QGb2312Codec::_name() || QGb2312Codec::_aliases().contains(name))
 
113
        return new QGb2312Codec;
 
114
#ifdef Q_WS_X11
 
115
    if (name == QFontGbkCodec::_name() || QFontGbkCodec::_aliases().contains(name))
 
116
        return new QFontGbkCodec;
 
117
    if (name == QFontGb2312Codec::_name() || QFontGb2312Codec::_aliases().contains(name))
 
118
        return new QFontGb2312Codec;
 
119
#endif
 
120
    return 0;
 
121
}
 
122
 
 
123
 
 
124
Q_EXPORT_PLUGIN(CNTextCodecs);