author | zautrix <zautrix> | 2004-06-26 19:01:18 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-06-26 19:01:18 (UTC) |
commit | b9aad1f15dc600e4dbe4c62d3fcced6363188ba3 (patch) (unidiff) | |
tree | 2c3d4004fb21c72cba65793859f9bcd8ffd3a49c /microkde/kdecore/kcatalogue.cpp | |
download | kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.zip kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.tar.gz kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.tar.bz2 |
Initial revision
Diffstat (limited to 'microkde/kdecore/kcatalogue.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | microkde/kdecore/kcatalogue.cpp | 131 |
1 files changed, 131 insertions, 0 deletions
diff --git a/microkde/kdecore/kcatalogue.cpp b/microkde/kdecore/kcatalogue.cpp new file mode 100644 index 0000000..97ac326 --- a/dev/null +++ b/microkde/kdecore/kcatalogue.cpp | |||
@@ -0,0 +1,131 @@ | |||
1 | /* This file is part of the KDE libraries | ||
2 | Copyright (c) 2001 Hans Petter Bieker <bieker@kde.org> | ||
3 | |||
4 | This library is free software; you can redistribute it and/or | ||
5 | modify it under the terms of the GNU Library General Public | ||
6 | License as published by the Free Software Foundation; either | ||
7 | version 2 of the License, or (at your option) any later version. | ||
8 | |||
9 | This library is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | Library General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU Library General Public License | ||
15 | along with this library; see the file COPYING.LIB. If not, write to | ||
16 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
17 | Boston, MA 02111-1307, USA. | ||
18 | */ | ||
19 | |||
20 | //US #include <config.h> | ||
21 | |||
22 | #include <qfile.h> | ||
23 | |||
24 | #include <kdebug.h> | ||
25 | |||
26 | #include "kcatalogue.h" | ||
27 | |||
28 | char *k_nl_find_msg(struct kde_loaded_l10nfile *domain_file, | ||
29 | const char *msgid); | ||
30 | void k_nl_unload_domain (struct loaded_domain *domain); | ||
31 | |||
32 | #ifndef KDE_USE_FINAL // with --enable-final, we're getting this from libintl.cpp | ||
33 | struct kde_loaded_l10nfile | ||
34 | { | ||
35 | const char *filename; | ||
36 | int decided; | ||
37 | |||
38 | const void *data; | ||
39 | |||
40 | kde_loaded_l10nfile() : filename(0), decided(0), data(0) {} | ||
41 | }; | ||
42 | #endif | ||
43 | |||
44 | class KCataloguePrivate | ||
45 | { | ||
46 | public: | ||
47 | QString name; | ||
48 | |||
49 | kde_loaded_l10nfile domain; | ||
50 | }; | ||
51 | |||
52 | KCatalogue::KCatalogue(const QString & name) | ||
53 | : d( new KCataloguePrivate ) | ||
54 | { | ||
55 | d->name = name; | ||
56 | } | ||
57 | |||
58 | KCatalogue::KCatalogue(const KCatalogue & rhs) | ||
59 | : d( new KCataloguePrivate ) | ||
60 | { | ||
61 | *this = rhs; | ||
62 | } | ||
63 | |||
64 | KCatalogue & KCatalogue::operator=(const KCatalogue & rhs) | ||
65 | { | ||
66 | d->name = rhs.d->name; | ||
67 | setFileName( rhs.fileName() ); | ||
68 | |||
69 | return *this; | ||
70 | } | ||
71 | |||
72 | KCatalogue::~KCatalogue() | ||
73 | { | ||
74 | doUnload(); | ||
75 | |||
76 | delete d; | ||
77 | } | ||
78 | |||
79 | QString KCatalogue::name() const | ||
80 | { | ||
81 | return d->name; | ||
82 | } | ||
83 | |||
84 | void KCatalogue::setFileName( const QString & fileName ) | ||
85 | { | ||
86 | // nothing to do if the file name is already the same | ||
87 | if ( this->fileName() == fileName ) return; | ||
88 | |||
89 | doUnload(); | ||
90 | |||
91 | QCString newFileName = QFile::encodeName( fileName ); | ||
92 | |||
93 | if ( !fileName.isEmpty() ) | ||
94 | { | ||
95 | // set file name | ||
96 | char *filename = new char[ newFileName.length() + 1 ]; | ||
97 | ::qstrcpy( filename, newFileName ); | ||
98 | d->domain.filename = filename; | ||
99 | } | ||
100 | } | ||
101 | |||
102 | QString KCatalogue::fileName() const | ||
103 | { | ||
104 | return QFile::decodeName( d->domain.filename ); | ||
105 | } | ||
106 | |||
107 | const char * KCatalogue::translate(const char * msgid) const | ||
108 | { | ||
109 | qDebug("KCatalogue::translate has to be fixed %s",msgid ); | ||
110 | //US return ::k_nl_find_msg( &d->domain, msgid ); | ||
111 | return msgid; | ||
112 | |||
113 | } | ||
114 | |||
115 | void KCatalogue::doUnload() | ||
116 | { | ||
117 | // use gettext's unloader | ||
118 | if ( d->domain.data ) | ||
119 | { | ||
120 | //US ::k_nl_unload_domain( (struct loaded_domain *)d->domain.data ); | ||
121 | qDebug("KCatalogue::doUnload has to be fixed" ); | ||
122 | |||
123 | } | ||
124 | d->domain.data = 0; | ||
125 | |||
126 | // free name | ||
127 | delete [] const_cast<char *>(d->domain.filename); | ||
128 | d->domain.filename = 0; | ||
129 | |||
130 | d->domain.decided = 0; | ||
131 | } | ||