~ubuntu-branches/ubuntu/quantal/kde4libs/quantal

« back to all changes in this revision

Viewing changes to .pc/kubuntu_64_rosetta_translation.diff/kdecore/kernel/kaboutdata.cpp

  • Committer: Package Import Robot
  • Author(s): Felix Geyer, Philip Muškovac, Jonathan Thomas, Felix Geyer
  • Date: 2011-05-29 17:19:55 UTC
  • mfrom: (1.14.5 upstream) (0.1.19 sid)
  • Revision ID: package-import@ubuntu.com-20110529171955-nodep1593tuwyu6k
Tags: 4:4.6.3-1ubuntu1
[ Philip Muškovac]
* Drop kubuntu_83_fix_solid_network_status.diff
* Update Vcs links as the branch is owned by kubuntu-packagers now

[ Jonathan Thomas ]
* Drop kubuntu_06_user_disk_mounting. We no longer compile the hal
  backend, so this patch is useless.

[ Felix Geyer ]
* Merge from Debian unstable, remaining changes:
  - no build-dep on libaspell-dev
  - no build-dep on libfam-dev
  - kdelibs5-data: don't install kspell_aspell.desktop and
    usr/lib/kde4/kspell_aspell.so
  - kdelibs5-dev: don't install preparetips
  - Pass -DKDESU_USE_SUDO_DEFAULT=true to configure
  - dh_fixperms: exclude /usr/lib/kde4/libexec/fileshareset
  - set export KUBUNTU_DESKTOP_POT=kdelibs
  - don't apply use_dejavu_as_default_font.diff
  - don't apply kconf_update_migrate_from_kde3_icon_theme.diff
    - kdelibs5-data.install: drop usr/share/kde4/apps/kconf_update/kdeui.upd
  - don't build depend on libglu1-mesa-dev, not needed due to
    kubuntu_no_direct_gl_usage.diff
  - Add kdelibs5-data.links: link from /usr/share/doc/kde4 to kde for
    backwards compatible with old docs location
  - Keep the kdelibs5 transitional package
  - kdelibs5-dev.install: install ksambasharedata.h
  - kdelibs5-plugins: recommend ttf-dejavu-core instead of ttf-dejavu to save
    CD space.
* Add Breaks in addition to Replaces for moving files between packages.
* Drop no longer needed Breaks and Replaces.
* Completely drop kubuntu_51_launchpad_integration.diff and
  kubuntu_68_remove_applet_confirmation.diff.
  + Also drop the launchpad and kubuntu icons.
* Remove sequence numbers from kubuntu patches.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * This file is part of the KDE Libraries
3
 
 * Copyright (C) 2000 Espen Sand (espen@kde.org)
4
 
 * Copyright (C) 2006 Nicolas GOUTTE <goutte@kde.org>
5
 
 * Copyright (C) 2008 Friedrich W. H. Kossebau <kossebau@kde.org>
6
 
 * Copyright (C) 2010 Teo Mrnjavac <teo@kde.org>
7
 
 *
8
 
 * This library is free software; you can redistribute it and/or
9
 
 * modify it under the terms of the GNU Library General Public
10
 
 * License as published by the Free Software Foundation; either
11
 
 * version 2 of the License, or (at your option) any later version.
12
 
 *
13
 
 * This library is distributed in the hope that it will be useful,
14
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16
 
 * Library General Public License for more details.
17
 
 *
18
 
 * You should have received a copy of the GNU Library General Public License
19
 
 * along with this library; see the file COPYING.LIB.  If not, write to
20
 
 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21
 
 * Boston, MA 02110-1301, USA.
22
 
 *
23
 
 */
24
 
 
25
 
#include "kaboutdata.h"
26
 
 
27
 
#include "kstandarddirs.h"
28
 
#include "klocalizedstring.h"
29
 
 
30
 
#include <QtCore/QFile>
31
 
#include <QtCore/QTextIStream>
32
 
#include <QtCore/QSharedData>
33
 
#include <QtCore/QVariant>
34
 
#include <QtCore/QList>
35
 
#include <QHash>
36
 
 
37
 
// -----------------------------------------------------------------------------
38
 
// Design notes:
39
 
//
40
 
// These classes deal with a lot of text, some of which needs to be
41
 
// marked for translation. Since at the time when these object and calls are
42
 
// made the translation catalogs are usually still not initialized, the
43
 
// translation has to be delayed. This is achieved by using KLocalizedString
44
 
// for translatable strings. KLocalizedStrings are produced by ki18n* calls,
45
 
// instead of the more usuall i18n* calls which produce QString by trying to
46
 
// translate immediately.
47
 
//
48
 
// All the non-translatable string arguments to methods are taken QByteArray,
49
 
// all the translatable are KLocalizedString. The getter methods always return
50
 
// proper QString: the non-translatable strings supplied by the code are
51
 
// treated with QString::fromUtf8(), those coming from the outside with
52
 
// QTextCodec::toUnicode(), and translatable strings are finalized to QStrings
53
 
// at the point of getter calls (i.e. delayed translation).
54
 
// -----------------------------------------------------------------------------
55
 
 
56
 
class KAboutPerson::Private
57
 
{
58
 
public:
59
 
   KLocalizedString _name;
60
 
   KLocalizedString _task;
61
 
   QString _emailAddress;
62
 
   QString _webAddress;
63
 
   QString _ocsUsername;
64
 
 
65
 
   QString _nameNoop;
66
 
};
67
 
 
68
 
KAboutPerson::KAboutPerson( const KLocalizedString &_name,
69
 
                            const KLocalizedString &_task,
70
 
                            const QByteArray &_emailAddress,
71
 
                            const QByteArray &_webAddress )
72
 
  : d(new Private)
73
 
{
74
 
   d->_name = _name;
75
 
   d->_task = _task;
76
 
   d->_emailAddress = QString::fromUtf8(_emailAddress);
77
 
   d->_webAddress = QString::fromUtf8(_webAddress);
78
 
}
79
 
 
80
 
KAboutPerson::KAboutPerson( const KLocalizedString &_name,
81
 
                            const KLocalizedString &_task,
82
 
                            const QByteArray &_emailAddress,
83
 
                            const QByteArray &_webAddress,
84
 
                            const QByteArray &_ocsUsername )
85
 
  : d(new Private)
86
 
{
87
 
   d->_name = _name;
88
 
   d->_task = _task;
89
 
   d->_emailAddress = QString::fromUtf8(_emailAddress);
90
 
   d->_webAddress = QString::fromUtf8(_webAddress);
91
 
   d->_ocsUsername = QString::fromUtf8( _ocsUsername );
92
 
}
93
 
 
94
 
KAboutPerson::KAboutPerson( const QString &_name, const QString &_email )
95
 
  : d(new Private)
96
 
{
97
 
   d->_nameNoop = _name;
98
 
   d->_emailAddress = _email;
99
 
}
100
 
 
101
 
KAboutPerson::KAboutPerson(const KAboutPerson& other): d(new Private)
102
 
{
103
 
    *d = *other.d;
104
 
}
105
 
 
106
 
KAboutPerson::~KAboutPerson()
107
 
{
108
 
   delete d;
109
 
}
110
 
 
111
 
QString KAboutPerson::name() const
112
 
{
113
 
   if (!d->_nameNoop.isEmpty())
114
 
      return d->_nameNoop;
115
 
   return d->_name.toString();
116
 
}
117
 
 
118
 
QString KAboutPerson::task() const
119
 
{
120
 
   if (!d->_task.isEmpty())
121
 
      return d->_task.toString();
122
 
   return QString();
123
 
}
124
 
 
125
 
QString KAboutPerson::emailAddress() const
126
 
{
127
 
   return d->_emailAddress;
128
 
}
129
 
 
130
 
 
131
 
QString KAboutPerson::webAddress() const
132
 
{
133
 
   return d->_webAddress;
134
 
}
135
 
 
136
 
QString KAboutPerson::ocsUsername() const
137
 
{
138
 
    return d->_ocsUsername;
139
 
}
140
 
 
141
 
KAboutPerson &KAboutPerson::operator=(const KAboutPerson& other)
142
 
{
143
 
   *d = *other.d;
144
 
   return *this;
145
 
}
146
 
 
147
 
 
148
 
 
149
 
class KAboutLicense::Private : public QSharedData
150
 
{
151
 
public:
152
 
    Private( enum KAboutData::LicenseKey licenseType, const KAboutData *aboutData );
153
 
    Private( const QString &pathToFile, const KAboutData *aboutData );
154
 
    Private( const KLocalizedString &licenseText, const KAboutData *aboutData );
155
 
    Private( const Private& other);
156
 
public:
157
 
    enum KAboutData::LicenseKey  _licenseKey;
158
 
    KLocalizedString             _licenseText;
159
 
    QString                      _pathToLicenseTextFile;
160
 
    // needed for access to the possibly changing copyrightStatement()
161
 
    const KAboutData *           _aboutData;
162
 
};
163
 
 
164
 
KAboutLicense::Private::Private( enum KAboutData::LicenseKey licenseType, const KAboutData *aboutData )
165
 
  : QSharedData(),
166
 
    _licenseKey( licenseType ),
167
 
    _aboutData( aboutData )
168
 
{
169
 
}
170
 
 
171
 
KAboutLicense::Private::Private( const QString &pathToFile, const KAboutData *aboutData )
172
 
  : QSharedData(),
173
 
    _licenseKey( KAboutData::License_File ),
174
 
    _pathToLicenseTextFile( pathToFile ),
175
 
    _aboutData( aboutData )
176
 
{
177
 
}
178
 
 
179
 
KAboutLicense::Private::Private( const KLocalizedString &licenseText, const KAboutData *aboutData )
180
 
  : QSharedData(),
181
 
    _licenseKey( KAboutData::License_Custom ),
182
 
    _licenseText( licenseText ),
183
 
    _aboutData( aboutData )
184
 
{
185
 
}
186
 
 
187
 
KAboutLicense::Private::Private(const KAboutLicense::Private& other)
188
 
  : QSharedData(other),
189
 
    _licenseKey( other._licenseKey ),
190
 
    _licenseText( other._licenseText ),
191
 
    _pathToLicenseTextFile( other._pathToLicenseTextFile ),
192
 
    _aboutData( other._aboutData )
193
 
{}
194
 
 
195
 
 
196
 
KAboutLicense::KAboutLicense( enum KAboutData::LicenseKey licenseType, const KAboutData *aboutData )
197
 
  : d(new Private(licenseType,aboutData))
198
 
{
199
 
}
200
 
 
201
 
KAboutLicense::KAboutLicense( const QString &pathToFile, const KAboutData *aboutData )
202
 
  : d(new Private(pathToFile,aboutData))
203
 
{
204
 
}
205
 
 
206
 
KAboutLicense::KAboutLicense( const KLocalizedString &licenseText, const KAboutData *aboutData )
207
 
  : d(new Private(licenseText,aboutData))
208
 
{
209
 
}
210
 
 
211
 
KAboutLicense::KAboutLicense(const KAboutLicense& other)
212
 
  : d(other.d)
213
 
{
214
 
}
215
 
 
216
 
KAboutLicense::~KAboutLicense()
217
 
{}
218
 
 
219
 
QString KAboutLicense::text() const
220
 
{
221
 
    QString result;
222
 
 
223
 
    const QString lineFeed = QString::fromLatin1( "\n\n" );
224
 
 
225
 
    if (d->_aboutData && !d->_aboutData->copyrightStatement().isEmpty()) {
226
 
        result = d->_aboutData->copyrightStatement() + lineFeed;
227
 
    }
228
 
 
229
 
    bool knownLicense = false;
230
 
    QString pathToFile;
231
 
    switch ( d->_licenseKey )
232
 
    {
233
 
    case KAboutData::License_File:
234
 
        pathToFile = d->_pathToLicenseTextFile;
235
 
        break;
236
 
    case KAboutData::License_GPL_V2:
237
 
        knownLicense = true;
238
 
        pathToFile = KStandardDirs::locate("data", QString::fromLatin1("LICENSES/GPL_V2"));
239
 
        break;
240
 
    case KAboutData::License_LGPL_V2:
241
 
        knownLicense = true;
242
 
        pathToFile = KStandardDirs::locate("data", QString::fromLatin1("LICENSES/LGPL_V2"));
243
 
        break;
244
 
    case KAboutData::License_BSD:
245
 
        knownLicense = true;
246
 
        pathToFile = KStandardDirs::locate("data", QString::fromLatin1("LICENSES/BSD"));
247
 
        break;
248
 
    case KAboutData::License_Artistic:
249
 
        knownLicense = true;
250
 
        pathToFile = KStandardDirs::locate("data", QString::fromLatin1("LICENSES/ARTISTIC"));
251
 
        break;
252
 
    case KAboutData::License_QPL_V1_0:
253
 
        knownLicense = true;
254
 
        pathToFile = KStandardDirs::locate("data", QString::fromLatin1("LICENSES/QPL_V1.0"));
255
 
        break;
256
 
    case KAboutData::License_GPL_V3:
257
 
        knownLicense = true;
258
 
        pathToFile = KStandardDirs::locate("data", QString::fromLatin1("LICENSES/GPL_V3"));
259
 
        break;
260
 
    case KAboutData::License_LGPL_V3:
261
 
        knownLicense = true;
262
 
        pathToFile = KStandardDirs::locate("data", QString::fromLatin1("LICENSES/LGPL_V3"));
263
 
        break;
264
 
    case KAboutData::License_Custom:
265
 
        if (!d->_licenseText.isEmpty()) {
266
 
            result = d->_licenseText.toString();
267
 
            break;
268
 
        }
269
 
        // fall through
270
 
    default:
271
 
        result += i18n("No licensing terms for this program have been specified.\n"
272
 
                       "Please check the documentation or the source for any\n"
273
 
                       "licensing terms.\n");
274
 
    }
275
 
 
276
 
    if (knownLicense) {
277
 
        result += i18n("This program is distributed under the terms of the %1.", name(KAboutData::ShortName));
278
 
        if (!pathToFile.isEmpty()) {
279
 
            result += lineFeed;
280
 
        }
281
 
    }
282
 
 
283
 
    if (!pathToFile.isEmpty()) {
284
 
        QFile file(pathToFile);
285
 
        if (file.open(QIODevice::ReadOnly)) {
286
 
            QTextStream str(&file);
287
 
            result += str.readAll();
288
 
        }
289
 
    }
290
 
 
291
 
    return result;
292
 
}
293
 
 
294
 
 
295
 
QString KAboutLicense::name(KAboutData::NameFormat formatName) const
296
 
{
297
 
    QString licenseShort;
298
 
    QString licenseFull;
299
 
 
300
 
    switch (d->_licenseKey) {
301
 
    case KAboutData::License_GPL_V2:
302
 
        licenseShort = i18nc("@item license (short name)","GPL v2");
303
 
        licenseFull = i18nc("@item license","GNU General Public License Version 2");
304
 
        break;
305
 
    case KAboutData::License_LGPL_V2:
306
 
        licenseShort = i18nc("@item license (short name)","LGPL v2");
307
 
        licenseFull = i18nc("@item license","GNU Lesser General Public License Version 2");
308
 
        break;
309
 
    case KAboutData::License_BSD:
310
 
        licenseShort = i18nc("@item license (short name)","BSD License");
311
 
        licenseFull = i18nc("@item license","BSD License");
312
 
        break;
313
 
    case KAboutData::License_Artistic:
314
 
        licenseShort = i18nc("@item license (short name)","Artistic License");
315
 
        licenseFull = i18nc("@item license","Artistic License");
316
 
        break;
317
 
    case KAboutData::License_QPL_V1_0:
318
 
        licenseShort = i18nc("@item license (short name)","QPL v1.0");
319
 
        licenseFull = i18nc("@item license","Q Public License");
320
 
        break;
321
 
    case KAboutData::License_GPL_V3:
322
 
        licenseShort = i18nc("@item license (short name)","GPL v3");
323
 
        licenseFull = i18nc("@item license","GNU General Public License Version 3");
324
 
        break;
325
 
    case KAboutData::License_LGPL_V3:
326
 
        licenseShort = i18nc("@item license (short name)","LGPL v3");
327
 
        licenseFull = i18nc("@item license","GNU Lesser General Public License Version 3");
328
 
        break;
329
 
    case KAboutData::License_Custom:
330
 
    case KAboutData::License_File:
331
 
        licenseShort = licenseFull = i18nc("@item license","Custom");
332
 
        break;
333
 
    default:
334
 
        licenseShort = licenseFull = i18nc("@item license","Not specified");
335
 
    }
336
 
 
337
 
    const QString result =
338
 
        (formatName == KAboutData::ShortName ) ? licenseShort :
339
 
        (formatName == KAboutData::FullName ) ?  licenseFull :
340
 
                                                 QString();
341
 
 
342
 
    return result;
343
 
}
344
 
 
345
 
 
346
 
KAboutLicense &KAboutLicense::operator=(const KAboutLicense& other)
347
 
{
348
 
   d = other.d;
349
 
   return *this;
350
 
}
351
 
 
352
 
KAboutData::LicenseKey KAboutLicense::key() const
353
 
{
354
 
    return d->_licenseKey;
355
 
}
356
 
 
357
 
KAboutLicense KAboutLicense::byKeyword(const QString &rawKeyword)
358
 
{
359
 
    // Setup keyword->enum dictionary on first call.
360
 
    // Use normalized keywords, by the algorithm below.
361
 
    static QHash<QByteArray, KAboutData::LicenseKey> ldict;
362
 
    if (ldict.isEmpty()) {
363
 
        ldict.insert("gpl", KAboutData::License_GPL);
364
 
        ldict.insert("gplv2", KAboutData::License_GPL_V2);
365
 
        ldict.insert("gplv2+", KAboutData::License_GPL_V2);
366
 
        ldict.insert("lgpl", KAboutData::License_LGPL);
367
 
        ldict.insert("lgplv2", KAboutData::License_LGPL_V2);
368
 
        ldict.insert("lgplv2+", KAboutData::License_LGPL_V2);
369
 
        ldict.insert("bsd", KAboutData::License_BSD);
370
 
        ldict.insert("artistic", KAboutData::License_Artistic);
371
 
        ldict.insert("qpl", KAboutData::License_QPL);
372
 
        ldict.insert("qplv1", KAboutData::License_QPL_V1_0);
373
 
        ldict.insert("qplv10", KAboutData::License_QPL_V1_0);
374
 
        ldict.insert("gplv3", KAboutData::License_GPL_V3);
375
 
        ldict.insert("gplv3+", KAboutData::License_GPL_V3);
376
 
        ldict.insert("lgplv3", KAboutData::License_LGPL_V3);
377
 
        ldict.insert("lgplv3+", KAboutData::License_LGPL_V3);
378
 
    }
379
 
 
380
 
    // Normalize keyword.
381
 
    QString keyword = rawKeyword;
382
 
    keyword = keyword.toLower();
383
 
    keyword.remove(QLatin1Char(' '));
384
 
    keyword.remove(QLatin1Char('.'));
385
 
 
386
 
    KAboutData::LicenseKey license = ldict.value(keyword.toLatin1(),
387
 
                                                 KAboutData::License_Custom);
388
 
    return KAboutLicense(license, 0);
389
 
}
390
 
 
391
 
 
392
 
class KAboutData::Private
393
 
{
394
 
public:
395
 
    Private()
396
 
        : customAuthorTextEnabled(false)
397
 
        {}
398
 
    QByteArray _appName;
399
 
    KLocalizedString _programName;
400
 
    KLocalizedString _shortDescription;
401
 
    QByteArray _catalogName;
402
 
    KLocalizedString _copyrightStatement;
403
 
    KLocalizedString _otherText;
404
 
    QString _homepageAddress;
405
 
    QList<KAboutPerson> _authorList;
406
 
    QList<KAboutPerson> _creditList;
407
 
    QList<KAboutLicense> _licenseList;
408
 
    KLocalizedString translatorName;
409
 
    KLocalizedString translatorEmail;
410
 
    QString productName;
411
 
    QString programIconName;
412
 
    QVariant programLogo;
413
 
    KLocalizedString customAuthorPlainText, customAuthorRichText;
414
 
    bool customAuthorTextEnabled;
415
 
 
416
 
    QString organizationDomain;
417
 
    QByteArray _ocsProviderUrl;
418
 
 
419
 
    // Everything dr.konqi needs, we store as utf-8, so we
420
 
    // can just give it a pointer, w/o any allocations.
421
 
    QByteArray _translatedProgramName; // ### I don't see it ever being translated, and I did not change that
422
 
    QByteArray _version;
423
 
    QByteArray _bugEmailAddress;
424
 
};
425
 
 
426
 
 
427
 
KAboutData::KAboutData( const QByteArray &_appName,
428
 
                        const QByteArray &_catalogName,
429
 
                        const KLocalizedString &_programName,
430
 
                        const QByteArray &_version,
431
 
                        const KLocalizedString &_shortDescription,
432
 
                        enum LicenseKey licenseType,
433
 
                        const KLocalizedString &_copyrightStatement,
434
 
                        const KLocalizedString &text,
435
 
                        const QByteArray &homePageAddress,
436
 
                        const QByteArray &bugsEmailAddress
437
 
                      )
438
 
  : d(new Private)
439
 
{
440
 
    d->_appName = _appName;
441
 
    int p = d->_appName.indexOf('/');
442
 
    if (p >= 0) {
443
 
        d->_appName = d->_appName.mid(p + 1);
444
 
    }
445
 
 
446
 
    d->_catalogName = _catalogName;
447
 
    d->_programName = _programName;
448
 
    if (!d->_programName.isEmpty()) // KComponentData("klauncher") gives empty program name
449
 
        d->_translatedProgramName = _programName.toString(0).toUtf8();
450
 
    d->_version = _version;
451
 
    d->_shortDescription = _shortDescription;
452
 
    d->_licenseList.append(KAboutLicense(licenseType,this));
453
 
    d->_copyrightStatement = _copyrightStatement;
454
 
    d->_otherText = text;
455
 
    d->_homepageAddress = QString::fromLatin1(homePageAddress);
456
 
    d->_bugEmailAddress = bugsEmailAddress;
457
 
 
458
 
    if (d->_homepageAddress.contains(QLatin1String("http://"))) {
459
 
        const int dot = d->_homepageAddress.indexOf(QLatin1Char('.'));
460
 
        if (dot >= 0) {
461
 
            d->organizationDomain = d->_homepageAddress.mid(dot + 1);
462
 
            const int slash = d->organizationDomain.indexOf(QLatin1Char('/'));
463
 
            if (slash >= 0)
464
 
                d->organizationDomain.truncate(slash);
465
 
        }
466
 
        else {
467
 
            d->organizationDomain = QString::fromLatin1("kde.org");
468
 
        }
469
 
    }
470
 
    else {
471
 
        d->organizationDomain = QString::fromLatin1("kde.org");
472
 
    }
473
 
}
474
 
 
475
 
KAboutData::~KAboutData()
476
 
{
477
 
    delete d;
478
 
}
479
 
 
480
 
KAboutData::KAboutData(const KAboutData& other): d(new Private)
481
 
{
482
 
    *d = *other.d;
483
 
    QList<KAboutLicense>::iterator it = d->_licenseList.begin(), itEnd = d->_licenseList.end();
484
 
    for ( ; it != itEnd; ++it) {
485
 
        KAboutLicense& al = *it;
486
 
        al.d.detach();
487
 
        al.d->_aboutData = this;
488
 
    }
489
 
}
490
 
 
491
 
KAboutData &KAboutData::operator=(const KAboutData& other)
492
 
{
493
 
    if (this != &other) {
494
 
        *d = *other.d;
495
 
        QList<KAboutLicense>::iterator it = d->_licenseList.begin(), itEnd = d->_licenseList.end();
496
 
        for ( ; it != itEnd; ++it) {
497
 
            KAboutLicense& al = *it;
498
 
            al.d.detach();
499
 
            al.d->_aboutData = this;
500
 
        }
501
 
    }
502
 
    return *this;
503
 
}
504
 
 
505
 
KAboutData &KAboutData::addAuthor( const KLocalizedString &name,
506
 
                                   const KLocalizedString &task,
507
 
                                   const QByteArray &emailAddress,
508
 
                                   const QByteArray &webAddress )
509
 
{
510
 
  d->_authorList.append(KAboutPerson(name,task,emailAddress,webAddress));
511
 
  return *this;
512
 
}
513
 
 
514
 
KAboutData &KAboutData::addAuthor( const KLocalizedString &name,
515
 
                                   const KLocalizedString &task,
516
 
                                   const QByteArray &emailAddress,
517
 
                                   const QByteArray &webAddress,
518
 
                                   const QByteArray &ocsUsername )
519
 
{
520
 
  d->_authorList.append(KAboutPerson(name,task,emailAddress,webAddress,ocsUsername));
521
 
  return *this;
522
 
}
523
 
 
524
 
KAboutData &KAboutData::addCredit( const KLocalizedString &name,
525
 
                                   const KLocalizedString &task,
526
 
                                   const QByteArray &emailAddress,
527
 
                                   const QByteArray &webAddress )
528
 
{
529
 
  d->_creditList.append(KAboutPerson(name,task,emailAddress,webAddress));
530
 
  return *this;
531
 
}
532
 
 
533
 
KAboutData &KAboutData::addCredit( const KLocalizedString &name,
534
 
                                   const KLocalizedString &task,
535
 
                                   const QByteArray &emailAddress,
536
 
                                   const QByteArray &webAddress,
537
 
                                   const QByteArray &ocsUsername )
538
 
{
539
 
  d->_creditList.append(KAboutPerson(name,task,emailAddress,webAddress,ocsUsername));
540
 
  return *this;
541
 
}
542
 
 
543
 
KAboutData &KAboutData::setTranslator( const KLocalizedString& name,
544
 
                                       const KLocalizedString& emailAddress )
545
 
{
546
 
  d->translatorName = name;
547
 
  d->translatorEmail = emailAddress;
548
 
  return *this;
549
 
}
550
 
 
551
 
KAboutData &KAboutData::setLicenseText( const KLocalizedString &licenseText )
552
 
{
553
 
    d->_licenseList[0] = KAboutLicense(licenseText,this);
554
 
    return *this;
555
 
}
556
 
 
557
 
KAboutData &KAboutData::addLicenseText( const KLocalizedString &licenseText )
558
 
{
559
 
    // if the default license is unknown, overwrite instead of append
560
 
    KAboutLicense &firstLicense = d->_licenseList[0];
561
 
    if (d->_licenseList.count() == 1 && firstLicense.d->_licenseKey == License_Unknown) {
562
 
        firstLicense = KAboutLicense(licenseText,this);
563
 
    } else {
564
 
        d->_licenseList.append(KAboutLicense(licenseText,this));
565
 
    }
566
 
    return *this;
567
 
}
568
 
 
569
 
KAboutData &KAboutData::setLicenseTextFile( const QString &pathToFile )
570
 
{
571
 
    d->_licenseList[0] = KAboutLicense(pathToFile,this);
572
 
    return *this;
573
 
}
574
 
 
575
 
KAboutData &KAboutData::addLicenseTextFile( const QString &pathToFile )
576
 
{
577
 
    // if the default license is unknown, overwrite instead of append
578
 
    KAboutLicense &firstLicense = d->_licenseList[0];
579
 
    if (d->_licenseList.count() == 1 && firstLicense.d->_licenseKey == License_Unknown) {
580
 
        firstLicense = KAboutLicense(pathToFile,this);
581
 
    } else {
582
 
        d->_licenseList.append(KAboutLicense(pathToFile,this));
583
 
    }
584
 
    return *this;
585
 
}
586
 
 
587
 
KAboutData &KAboutData::setAppName( const QByteArray &_appName )
588
 
{
589
 
  d->_appName = _appName;
590
 
  return *this;
591
 
}
592
 
 
593
 
KAboutData &KAboutData::setProgramName( const KLocalizedString &_programName )
594
 
{
595
 
  d->_programName = _programName;
596
 
  translateInternalProgramName();
597
 
  return *this;
598
 
}
599
 
 
600
 
KAboutData &KAboutData::setOcsProvider(const QByteArray &_ocsProviderUrl )
601
 
{
602
 
    d->_ocsProviderUrl = _ocsProviderUrl;
603
 
    return *this;
604
 
}
605
 
 
606
 
KAboutData &KAboutData::setVersion( const QByteArray &_version )
607
 
{
608
 
  d->_version = _version;
609
 
  return *this;
610
 
}
611
 
 
612
 
KAboutData &KAboutData::setShortDescription( const KLocalizedString &_shortDescription )
613
 
{
614
 
  d->_shortDescription = _shortDescription;
615
 
  return *this;
616
 
}
617
 
 
618
 
KAboutData &KAboutData::setCatalogName( const QByteArray &_catalogName )
619
 
{
620
 
  d->_catalogName = _catalogName;
621
 
  return *this;
622
 
}
623
 
 
624
 
KAboutData &KAboutData::setLicense( LicenseKey licenseKey)
625
 
{
626
 
    d->_licenseList[0] = KAboutLicense(licenseKey,this);
627
 
    return *this;
628
 
}
629
 
 
630
 
KAboutData &KAboutData::addLicense( LicenseKey licenseKey)
631
 
{
632
 
    // if the default license is unknown, overwrite instead of append
633
 
    KAboutLicense &firstLicense = d->_licenseList[0];
634
 
    if (d->_licenseList.count() == 1 && firstLicense.d->_licenseKey == License_Unknown) {
635
 
        firstLicense = KAboutLicense(licenseKey,this);
636
 
    } else {
637
 
        d->_licenseList.append(KAboutLicense(licenseKey,this));
638
 
    }
639
 
    return *this;
640
 
}
641
 
 
642
 
KAboutData &KAboutData::setCopyrightStatement( const KLocalizedString &_copyrightStatement )
643
 
{
644
 
  d->_copyrightStatement = _copyrightStatement;
645
 
  return *this;
646
 
}
647
 
 
648
 
KAboutData &KAboutData::setOtherText( const KLocalizedString &_otherText )
649
 
{
650
 
  d->_otherText = _otherText;
651
 
  return *this;
652
 
}
653
 
 
654
 
KAboutData &KAboutData::setHomepage( const QByteArray &_homepage )
655
 
{
656
 
  d->_homepageAddress = QString::fromLatin1(_homepage);
657
 
  return *this;
658
 
}
659
 
 
660
 
KAboutData &KAboutData::setBugAddress( const QByteArray &_bugAddress )
661
 
{
662
 
  d->_bugEmailAddress = _bugAddress;
663
 
  return *this;
664
 
}
665
 
 
666
 
KAboutData &KAboutData::setOrganizationDomain( const QByteArray &domain )
667
 
{
668
 
  d->organizationDomain = QString::fromLatin1(domain);
669
 
  return *this;
670
 
}
671
 
 
672
 
KAboutData &KAboutData::setProductName( const QByteArray &_productName )
673
 
{
674
 
  d->productName = QString::fromUtf8(_productName);
675
 
  return *this;
676
 
}
677
 
 
678
 
QString KAboutData::appName() const
679
 
{
680
 
  return QString::fromUtf8(d->_appName);
681
 
}
682
 
 
683
 
QString KAboutData::productName() const
684
 
{
685
 
   if (!d->productName.isEmpty())
686
 
      return d->productName;
687
 
   return appName();
688
 
}
689
 
 
690
 
QString KAboutData::programName() const
691
 
{
692
 
   if (!d->_programName.isEmpty())
693
 
      return d->_programName.toString();
694
 
   return QString();
695
 
}
696
 
 
697
 
/// @internal
698
 
/// Return the program name. It is always pre-allocated.
699
 
/// Needed for KCrash in particular.
700
 
const char* KAboutData::internalProgramName() const
701
 
{
702
 
   return d->_translatedProgramName.constData();
703
 
}
704
 
 
705
 
/// @internal
706
 
/// KCrash should call as few things as possible and should avoid e.g. malloc()
707
 
/// because it may deadlock. Since i18n() needs it, when KLocale is available
708
 
/// the i18n() call will be done here in advance.
709
 
void KAboutData::translateInternalProgramName() const
710
 
{
711
 
  d->_translatedProgramName.clear();
712
 
  if( KGlobal::locale())
713
 
      d->_translatedProgramName = programName().toUtf8();
714
 
}
715
 
 
716
 
QString KAboutData::programIconName() const
717
 
{
718
 
    return d->programIconName.isEmpty() ? appName() : d->programIconName;
719
 
}
720
 
 
721
 
KAboutData &KAboutData::setProgramIconName( const QString &iconName )
722
 
{
723
 
    d->programIconName = iconName;
724
 
    return *this;
725
 
}
726
 
 
727
 
QVariant KAboutData::programLogo() const
728
 
{
729
 
    return d->programLogo;
730
 
}
731
 
 
732
 
KAboutData &KAboutData::setProgramLogo(const QVariant& image)
733
 
{
734
 
    d->programLogo = image ;
735
 
    return *this;
736
 
}
737
 
 
738
 
QString KAboutData::ocsProviderUrl() const
739
 
{
740
 
    if( !d->_ocsProviderUrl.isEmpty() )
741
 
        return QString::fromUtf8( d->_ocsProviderUrl );
742
 
    return QString();
743
 
}
744
 
 
745
 
QString KAboutData::version() const
746
 
{
747
 
   return QString::fromUtf8(d->_version);
748
 
}
749
 
 
750
 
/// @internal
751
 
/// Return the untranslated and uninterpreted (to UTF8) string
752
 
/// for the version information. Used in particular for KCrash.
753
 
const char* KAboutData::internalVersion() const
754
 
{
755
 
   return d->_version.constData();
756
 
}
757
 
 
758
 
QString KAboutData::shortDescription() const
759
 
{
760
 
   if (!d->_shortDescription.isEmpty())
761
 
      return d->_shortDescription.toString();
762
 
   return QString();
763
 
}
764
 
 
765
 
QString KAboutData::catalogName() const
766
 
{
767
 
   if (!d->_catalogName.isEmpty())
768
 
     return QString::fromUtf8(d->_catalogName);
769
 
   // Fallback to appname for catalog name if empty.
770
 
   return QString::fromUtf8(d->_appName);
771
 
}
772
 
 
773
 
QString KAboutData::homepage() const
774
 
{
775
 
   return d->_homepageAddress;
776
 
}
777
 
 
778
 
QString KAboutData::bugAddress() const
779
 
{
780
 
   return QString::fromUtf8(d->_bugEmailAddress);
781
 
}
782
 
 
783
 
QString KAboutData::organizationDomain() const
784
 
{
785
 
    return d->organizationDomain;
786
 
}
787
 
 
788
 
 
789
 
/// @internal
790
 
/// Return the untranslated and uninterpreted (to UTF8) string
791
 
/// for the bug mail address. Used in particular for KCrash.
792
 
const char* KAboutData::internalBugAddress() const
793
 
{
794
 
   if (d->_bugEmailAddress.isEmpty())
795
 
      return 0;
796
 
   return d->_bugEmailAddress.constData();
797
 
}
798
 
 
799
 
QList<KAboutPerson> KAboutData::authors() const
800
 
{
801
 
   return d->_authorList;
802
 
}
803
 
 
804
 
QList<KAboutPerson> KAboutData::credits() const
805
 
{
806
 
   return d->_creditList;
807
 
}
808
 
 
809
 
#define NAME_OF_TRANSLATORS "Your names"
810
 
#define EMAIL_OF_TRANSLATORS "Your emails"
811
 
QList<KAboutPerson> KAboutData::translators() const
812
 
{
813
 
    QList<KAboutPerson> personList;
814
 
 
815
 
    KLocale *tmpLocale = NULL;
816
 
    if (KGlobal::locale()) {
817
 
        // There could be many catalogs loaded into the global locale,
818
 
        // e.g. in systemsettings. The tmp locale is needed to make sure we
819
 
        // use the translators name from this aboutdata's catalog, rather than
820
 
        // from any other loaded catalog.
821
 
        tmpLocale = new KLocale(*KGlobal::locale());
822
 
        tmpLocale->setActiveCatalog(catalogName());
823
 
    }
824
 
 
825
 
    QString translatorName;
826
 
    if (!d->translatorName.isEmpty()) {
827
 
        translatorName = d->translatorName.toString();
828
 
    }
829
 
    else {
830
 
        translatorName = ki18nc("NAME OF TRANSLATORS", NAME_OF_TRANSLATORS).toString(tmpLocale);
831
 
    }
832
 
 
833
 
    QString translatorEmail;
834
 
    if (!d->translatorEmail.isEmpty()) {
835
 
        translatorEmail = d->translatorEmail.toString();
836
 
    }
837
 
    else {
838
 
        translatorEmail = ki18nc("EMAIL OF TRANSLATORS", EMAIL_OF_TRANSLATORS).toString(tmpLocale);
839
 
    }
840
 
 
841
 
    delete tmpLocale;
842
 
 
843
 
    if ( translatorName.isEmpty() || translatorName == QString::fromUtf8( NAME_OF_TRANSLATORS ) )
844
 
        return personList;
845
 
 
846
 
    const QStringList nameList(translatorName.split(QString(QLatin1Char(','))));
847
 
 
848
 
    QStringList emailList;
849
 
    if( !translatorEmail.isEmpty() && translatorEmail != QString::fromUtf8( EMAIL_OF_TRANSLATORS ) )
850
 
    {
851
 
       emailList = translatorEmail.split(QString(QLatin1Char(',')), QString::KeepEmptyParts);
852
 
    }
853
 
 
854
 
    QStringList::const_iterator nit;
855
 
    QStringList::const_iterator eit = emailList.constBegin();
856
 
 
857
 
    for( nit = nameList.constBegin(); nit != nameList.constEnd(); ++nit )
858
 
    {
859
 
        QString email;
860
 
        if ( eit != emailList.constEnd() )
861
 
        {
862
 
            email = *eit;
863
 
            ++eit;
864
 
        }
865
 
 
866
 
        personList.append( KAboutPerson( (*nit).trimmed(), email.trimmed() ) );
867
 
    }
868
 
 
869
 
    return personList;
870
 
}
871
 
 
872
 
QString KAboutData::aboutTranslationTeam()
873
 
{
874
 
    return i18nc("replace this with information about your translation team",
875
 
            "<p>KDE is translated into many languages thanks to the work "
876
 
            "of the translation teams all over the world.</p>"
877
 
            "<p>For more information on KDE internationalization "
878
 
            "visit <a href=\"http://l10n.kde.org\">http://l10n.kde.org</a></p>"
879
 
            );
880
 
}
881
 
 
882
 
QString KAboutData::otherText() const
883
 
{
884
 
   if (!d->_otherText.isEmpty())
885
 
      return d->_otherText.toString();
886
 
   return QString();
887
 
}
888
 
 
889
 
QString KAboutData::license() const
890
 
{
891
 
    return d->_licenseList.at(0).text();
892
 
}
893
 
 
894
 
QString KAboutData::licenseName( NameFormat formatName ) const
895
 
{
896
 
    return d->_licenseList.at(0).name(formatName);
897
 
}
898
 
 
899
 
QList<KAboutLicense> KAboutData::licenses() const
900
 
{
901
 
    return d->_licenseList;
902
 
}
903
 
 
904
 
QString KAboutData::copyrightStatement() const
905
 
{
906
 
  if (!d->_copyrightStatement.isEmpty())
907
 
    return d->_copyrightStatement.toString();
908
 
  return QString();
909
 
}
910
 
 
911
 
QString KAboutData::customAuthorPlainText() const
912
 
{
913
 
  if (!d->customAuthorPlainText.isEmpty())
914
 
    return d->customAuthorPlainText.toString();
915
 
  return QString();
916
 
}
917
 
 
918
 
QString KAboutData::customAuthorRichText() const
919
 
{
920
 
  if (!d->customAuthorRichText.isEmpty())
921
 
    return d->customAuthorRichText.toString();
922
 
  return QString();
923
 
}
924
 
 
925
 
bool KAboutData::customAuthorTextEnabled() const
926
 
{
927
 
  return d->customAuthorTextEnabled;
928
 
}
929
 
 
930
 
KAboutData &KAboutData::setCustomAuthorText( const KLocalizedString &plainText,
931
 
                                             const KLocalizedString &richText )
932
 
{
933
 
  d->customAuthorPlainText = plainText;
934
 
  d->customAuthorRichText = richText;
935
 
 
936
 
  d->customAuthorTextEnabled = true;
937
 
 
938
 
  return *this;
939
 
}
940
 
 
941
 
KAboutData &KAboutData::unsetCustomAuthorText()
942
 
{
943
 
  d->customAuthorPlainText = KLocalizedString();
944
 
  d->customAuthorRichText = KLocalizedString();
945
 
 
946
 
  d->customAuthorTextEnabled = false;
947
 
 
948
 
  return *this;
949
 
}
950