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

« back to all changes in this revision

Viewing changes to src/plugins/codecs/jp/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 <qstringlist.h>
 
32
 
 
33
#include "qeucjpcodec.h"
 
34
#include "qjiscodec.h"
 
35
#include "qsjiscodec.h"
 
36
#ifdef Q_WS_X11
 
37
#include "qfontjpcodec.h"
 
38
#endif
 
39
 
 
40
class JPTextCodecs : public QTextCodecPlugin
 
41
{
 
42
public:
 
43
    JPTextCodecs() {}
 
44
 
 
45
    QList<QByteArray> names() const;
 
46
    QList<QByteArray> aliases() const;
 
47
    QList<int> mibEnums() const;
 
48
 
 
49
    QTextCodec *createForMib(int);
 
50
    QTextCodec *createForName(const QByteArray &);
 
51
};
 
52
 
 
53
QList<QByteArray> JPTextCodecs::names() const
 
54
{
 
55
    QList<QByteArray> list;
 
56
    list += QEucJpCodec::_name();
 
57
    list += QJisCodec::_name();
 
58
    list += QSjisCodec::_name();
 
59
#ifdef Q_WS_X11
 
60
    list += QFontJis0201Codec::_name();
 
61
    list += QFontJis0208Codec::_name();
 
62
#endif
 
63
    return list;
 
64
}
 
65
 
 
66
QList<QByteArray> JPTextCodecs::aliases() const
 
67
{
 
68
    QList<QByteArray> list;
 
69
    list += QEucJpCodec::_aliases();
 
70
    list += QJisCodec::_aliases();
 
71
    list += QSjisCodec::_aliases();
 
72
#ifdef Q_WS_X11
 
73
    list += QFontJis0201Codec::_aliases();
 
74
    list += QFontJis0208Codec::_aliases();
 
75
#endif
 
76
    return list;
 
77
}
 
78
 
 
79
QList<int> JPTextCodecs::mibEnums() const
 
80
{
 
81
    QList<int> list;
 
82
    list += QEucJpCodec::_mibEnum();
 
83
    list += QJisCodec::_mibEnum();
 
84
    list += QSjisCodec::_mibEnum();
 
85
#ifdef Q_WS_X11
 
86
    list += QFontJis0201Codec::_mibEnum();
 
87
    list += QFontJis0208Codec::_mibEnum();
 
88
#endif
 
89
    return list;
 
90
}
 
91
 
 
92
QTextCodec *JPTextCodecs::createForMib(int mib)
 
93
{
 
94
    if (mib == QEucJpCodec::_mibEnum())
 
95
        return new QEucJpCodec;
 
96
    if (mib == QJisCodec::_mibEnum())
 
97
        return new QJisCodec;
 
98
    if (mib == QSjisCodec::_mibEnum())
 
99
        return new QSjisCodec;
 
100
#ifdef Q_WS_X11
 
101
    if (mib == QFontJis0208Codec::_mibEnum())
 
102
        return new QFontJis0208Codec;
 
103
    if (mib == QFontJis0201Codec::_mibEnum())
 
104
        return new QFontJis0201Codec;
 
105
#endif
 
106
    return 0;
 
107
}
 
108
 
 
109
 
 
110
QTextCodec *JPTextCodecs::createForName(const QByteArray &name)
 
111
{
 
112
    if (name == QEucJpCodec::_name() || QEucJpCodec::_aliases().contains(name))
 
113
        return new QEucJpCodec;
 
114
    if (name == QJisCodec::_name() || QJisCodec::_aliases().contains(name))
 
115
        return new QJisCodec;
 
116
    if (name == QSjisCodec::_name() || QSjisCodec::_aliases().contains(name))
 
117
        return new QSjisCodec;
 
118
#ifdef Q_WS_X11
 
119
    if (name == QFontJis0208Codec::_name() || QFontJis0208Codec::_aliases().contains(name))
 
120
        return new QFontJis0208Codec;
 
121
    if (name == QFontJis0201Codec::_name() || QFontJis0201Codec::_aliases().contains(name))
 
122
        return new QFontJis0201Codec;
 
123
#endif
 
124
    return 0;
 
125
}
 
126
 
 
127
 
 
128
Q_EXPORT_PLUGIN(JPTextCodecs);