• Skip to content
  • Skip to link menu
KDE 4.6 API Reference
  • KDE API Reference
  • kdelibs
  • KDE Home
  • Contact Us
 

KDECore

kaboutdata.cpp

Go to the documentation of this file.
00001 /*
00002  * This file is part of the KDE Libraries
00003  * Copyright (C) 2000 Espen Sand (espen@kde.org)
00004  * Copyright (C) 2006 Nicolas GOUTTE <goutte@kde.org>
00005  * Copyright (C) 2008 Friedrich W. H. Kossebau <kossebau@kde.org>
00006  * Copyright (C) 2010 Teo Mrnjavac <teo@kde.org>
00007  *
00008  * This library is free software; you can redistribute it and/or
00009  * modify it under the terms of the GNU Library General Public
00010  * License as published by the Free Software Foundation; either
00011  * version 2 of the License, or (at your option) any later version.
00012  *
00013  * This library is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016  * Library General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU Library General Public License
00019  * along with this library; see the file COPYING.LIB.  If not, write to
00020  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00021  * Boston, MA 02110-1301, USA.
00022  *
00023  */
00024 
00025 #include "kaboutdata.h"
00026 
00027 #include "kstandarddirs.h"
00028 #include "klocalizedstring.h"
00029 
00030 #include <QtCore/QFile>
00031 #include <QtCore/QTextIStream>
00032 #include <QtCore/QSharedData>
00033 #include <QtCore/QVariant>
00034 #include <QtCore/QList>
00035 #include <QHash>
00036 
00037 // -----------------------------------------------------------------------------
00038 // Design notes:
00039 //
00040 // These classes deal with a lot of text, some of which needs to be
00041 // marked for translation. Since at the time when these object and calls are
00042 // made the translation catalogs are usually still not initialized, the
00043 // translation has to be delayed. This is achieved by using KLocalizedString
00044 // for translatable strings. KLocalizedStrings are produced by ki18n* calls,
00045 // instead of the more usuall i18n* calls which produce QString by trying to
00046 // translate immediately.
00047 //
00048 // All the non-translatable string arguments to methods are taken QByteArray,
00049 // all the translatable are KLocalizedString. The getter methods always return
00050 // proper QString: the non-translatable strings supplied by the code are
00051 // treated with QString::fromUtf8(), those coming from the outside with
00052 // QTextCodec::toUnicode(), and translatable strings are finalized to QStrings
00053 // at the point of getter calls (i.e. delayed translation).
00054 // -----------------------------------------------------------------------------
00055 
00056 class KAboutPerson::Private
00057 {
00058 public:
00059    KLocalizedString _name;
00060    KLocalizedString _task;
00061    QString _emailAddress;
00062    QString _webAddress;
00063    QString _ocsUsername;
00064 
00065    QString _nameNoop;
00066 };
00067 
00068 KAboutPerson::KAboutPerson( const KLocalizedString &_name,
00069                             const KLocalizedString &_task,
00070                             const QByteArray &_emailAddress,
00071                             const QByteArray &_webAddress )
00072   : d(new Private)
00073 {
00074    d->_name = _name;
00075    d->_task = _task;
00076    d->_emailAddress = QString::fromUtf8(_emailAddress);
00077    d->_webAddress = QString::fromUtf8(_webAddress);
00078 }
00079 
00080 KAboutPerson::KAboutPerson( const KLocalizedString &_name,
00081                             const KLocalizedString &_task,
00082                             const QByteArray &_emailAddress,
00083                             const QByteArray &_webAddress,
00084                             const QByteArray &_ocsUsername )
00085   : d(new Private)
00086 {
00087    d->_name = _name;
00088    d->_task = _task;
00089    d->_emailAddress = QString::fromUtf8(_emailAddress);
00090    d->_webAddress = QString::fromUtf8(_webAddress);
00091    d->_ocsUsername = QString::fromUtf8( _ocsUsername );
00092 }
00093 
00094 KAboutPerson::KAboutPerson( const QString &_name, const QString &_email )
00095   : d(new Private)
00096 {
00097    d->_nameNoop = _name;
00098    d->_emailAddress = _email;
00099 }
00100 
00101 KAboutPerson::KAboutPerson(const KAboutPerson& other): d(new Private)
00102 {
00103     *d = *other.d;
00104 }
00105 
00106 KAboutPerson::~KAboutPerson()
00107 {
00108    delete d;
00109 }
00110 
00111 QString KAboutPerson::name() const
00112 {
00113    if (!d->_nameNoop.isEmpty())
00114       return d->_nameNoop;
00115    return d->_name.toString();
00116 }
00117 
00118 QString KAboutPerson::task() const
00119 {
00120    if (!d->_task.isEmpty())
00121       return d->_task.toString();
00122    return QString();
00123 }
00124 
00125 QString KAboutPerson::emailAddress() const
00126 {
00127    return d->_emailAddress;
00128 }
00129 
00130 
00131 QString KAboutPerson::webAddress() const
00132 {
00133    return d->_webAddress;
00134 }
00135 
00136 QString KAboutPerson::ocsUsername() const
00137 {
00138     return d->_ocsUsername;
00139 }
00140 
00141 KAboutPerson &KAboutPerson::operator=(const KAboutPerson& other)
00142 {
00143    *d = *other.d;
00144    return *this;
00145 }
00146 
00147 
00148 
00149 class KAboutLicense::Private : public QSharedData
00150 {
00151 public:
00152     Private( enum KAboutData::LicenseKey licenseType, const KAboutData *aboutData );
00153     Private( const QString &pathToFile, const KAboutData *aboutData );
00154     Private( const KLocalizedString &licenseText, const KAboutData *aboutData );
00155     Private( const Private& other);
00156 public:
00157     enum KAboutData::LicenseKey  _licenseKey;
00158     KLocalizedString             _licenseText;
00159     QString                      _pathToLicenseTextFile;
00160     // needed for access to the possibly changing copyrightStatement()
00161     const KAboutData *           _aboutData;
00162 };
00163 
00164 KAboutLicense::Private::Private( enum KAboutData::LicenseKey licenseType, const KAboutData *aboutData )
00165   : QSharedData(),
00166     _licenseKey( licenseType ),
00167     _aboutData( aboutData )
00168 {
00169 }
00170 
00171 KAboutLicense::Private::Private( const QString &pathToFile, const KAboutData *aboutData )
00172   : QSharedData(),
00173     _licenseKey( KAboutData::License_File ),
00174     _pathToLicenseTextFile( pathToFile ),
00175     _aboutData( aboutData )
00176 {
00177 }
00178 
00179 KAboutLicense::Private::Private( const KLocalizedString &licenseText, const KAboutData *aboutData )
00180   : QSharedData(),
00181     _licenseKey( KAboutData::License_Custom ),
00182     _licenseText( licenseText ),
00183     _aboutData( aboutData )
00184 {
00185 }
00186 
00187 KAboutLicense::Private::Private(const KAboutLicense::Private& other)
00188   : QSharedData(other),
00189     _licenseKey( other._licenseKey ),
00190     _licenseText( other._licenseText ),
00191     _pathToLicenseTextFile( other._pathToLicenseTextFile ),
00192     _aboutData( other._aboutData )
00193 {}
00194 
00195 
00196 KAboutLicense::KAboutLicense( enum KAboutData::LicenseKey licenseType, const KAboutData *aboutData )
00197   : d(new Private(licenseType,aboutData))
00198 {
00199 }
00200 
00201 KAboutLicense::KAboutLicense( const QString &pathToFile, const KAboutData *aboutData )
00202   : d(new Private(pathToFile,aboutData))
00203 {
00204 }
00205 
00206 KAboutLicense::KAboutLicense( const KLocalizedString &licenseText, const KAboutData *aboutData )
00207   : d(new Private(licenseText,aboutData))
00208 {
00209 }
00210 
00211 KAboutLicense::KAboutLicense(const KAboutLicense& other)
00212   : d(other.d)
00213 {
00214 }
00215 
00216 KAboutLicense::~KAboutLicense()
00217 {}
00218 
00219 QString KAboutLicense::text() const
00220 {
00221     QString result;
00222 
00223     const QString lineFeed = QString::fromLatin1( "\n\n" );
00224 
00225     if (d->_aboutData && !d->_aboutData->copyrightStatement().isEmpty()) {
00226         result = d->_aboutData->copyrightStatement() + lineFeed;
00227     }
00228 
00229     bool knownLicense = false;
00230     QString pathToFile;
00231     switch ( d->_licenseKey )
00232     {
00233     case KAboutData::License_File:
00234         pathToFile = d->_pathToLicenseTextFile;
00235         break;
00236     case KAboutData::License_GPL_V2:
00237         knownLicense = true;
00238         pathToFile = KStandardDirs::locate("data", QString::fromLatin1("LICENSES/GPL_V2"));
00239         break;
00240     case KAboutData::License_LGPL_V2:
00241         knownLicense = true;
00242         pathToFile = KStandardDirs::locate("data", QString::fromLatin1("LICENSES/LGPL_V2"));
00243         break;
00244     case KAboutData::License_BSD:
00245         knownLicense = true;
00246         pathToFile = KStandardDirs::locate("data", QString::fromLatin1("LICENSES/BSD"));
00247         break;
00248     case KAboutData::License_Artistic:
00249         knownLicense = true;
00250         pathToFile = KStandardDirs::locate("data", QString::fromLatin1("LICENSES/ARTISTIC"));
00251         break;
00252     case KAboutData::License_QPL_V1_0:
00253         knownLicense = true;
00254         pathToFile = KStandardDirs::locate("data", QString::fromLatin1("LICENSES/QPL_V1.0"));
00255         break;
00256     case KAboutData::License_GPL_V3:
00257         knownLicense = true;
00258         pathToFile = KStandardDirs::locate("data", QString::fromLatin1("LICENSES/GPL_V3"));
00259         break;
00260     case KAboutData::License_LGPL_V3:
00261         knownLicense = true;
00262         pathToFile = KStandardDirs::locate("data", QString::fromLatin1("LICENSES/LGPL_V3"));
00263         break;
00264     case KAboutData::License_Custom:
00265         if (!d->_licenseText.isEmpty()) {
00266             result = d->_licenseText.toString();
00267             break;
00268         }
00269         // fall through
00270     default:
00271         result += i18n("No licensing terms for this program have been specified.\n"
00272                        "Please check the documentation or the source for any\n"
00273                        "licensing terms.\n");
00274     }
00275 
00276     if (knownLicense) {
00277         result += i18n("This program is distributed under the terms of the %1.", name(KAboutData::ShortName));
00278         if (!pathToFile.isEmpty()) {
00279             result += lineFeed;
00280         }
00281     }
00282 
00283     if (!pathToFile.isEmpty()) {
00284         QFile file(pathToFile);
00285         if (file.open(QIODevice::ReadOnly)) {
00286             QTextStream str(&file);
00287             result += str.readAll();
00288         }
00289     }
00290 
00291     return result;
00292 }
00293 
00294 
00295 QString KAboutLicense::name(KAboutData::NameFormat formatName) const
00296 {
00297     QString licenseShort;
00298     QString licenseFull;
00299 
00300     switch (d->_licenseKey) {
00301     case KAboutData::License_GPL_V2:
00302         licenseShort = i18nc("@item license (short name)","GPL v2");
00303         licenseFull = i18nc("@item license","GNU General Public License Version 2");
00304         break;
00305     case KAboutData::License_LGPL_V2:
00306         licenseShort = i18nc("@item license (short name)","LGPL v2");
00307         licenseFull = i18nc("@item license","GNU Lesser General Public License Version 2");
00308         break;
00309     case KAboutData::License_BSD:
00310         licenseShort = i18nc("@item license (short name)","BSD License");
00311         licenseFull = i18nc("@item license","BSD License");
00312         break;
00313     case KAboutData::License_Artistic:
00314         licenseShort = i18nc("@item license (short name)","Artistic License");
00315         licenseFull = i18nc("@item license","Artistic License");
00316         break;
00317     case KAboutData::License_QPL_V1_0:
00318         licenseShort = i18nc("@item license (short name)","QPL v1.0");
00319         licenseFull = i18nc("@item license","Q Public License");
00320         break;
00321     case KAboutData::License_GPL_V3:
00322         licenseShort = i18nc("@item license (short name)","GPL v3");
00323         licenseFull = i18nc("@item license","GNU General Public License Version 3");
00324         break;
00325     case KAboutData::License_LGPL_V3:
00326         licenseShort = i18nc("@item license (short name)","LGPL v3");
00327         licenseFull = i18nc("@item license","GNU Lesser General Public License Version 3");
00328         break;
00329     case KAboutData::License_Custom:
00330     case KAboutData::License_File:
00331         licenseShort = licenseFull = i18nc("@item license","Custom");
00332         break;
00333     default:
00334         licenseShort = licenseFull = i18nc("@item license","Not specified");
00335     }
00336 
00337     const QString result =
00338         (formatName == KAboutData::ShortName ) ? licenseShort :
00339         (formatName == KAboutData::FullName ) ?  licenseFull :
00340                                                  QString();
00341 
00342     return result;
00343 }
00344 
00345 
00346 KAboutLicense &KAboutLicense::operator=(const KAboutLicense& other)
00347 {
00348    d = other.d;
00349    return *this;
00350 }
00351 
00352 KAboutData::LicenseKey KAboutLicense::key() const
00353 {
00354     return d->_licenseKey;
00355 }
00356 
00357 KAboutLicense KAboutLicense::byKeyword(const QString &rawKeyword)
00358 {
00359     // Setup keyword->enum dictionary on first call.
00360     // Use normalized keywords, by the algorithm below.
00361     static QHash<QByteArray, KAboutData::LicenseKey> ldict;
00362     if (ldict.isEmpty()) {
00363         ldict.insert("gpl", KAboutData::License_GPL);
00364         ldict.insert("gplv2", KAboutData::License_GPL_V2);
00365         ldict.insert("gplv2+", KAboutData::License_GPL_V2);
00366         ldict.insert("lgpl", KAboutData::License_LGPL);
00367         ldict.insert("lgplv2", KAboutData::License_LGPL_V2);
00368         ldict.insert("lgplv2+", KAboutData::License_LGPL_V2);
00369         ldict.insert("bsd", KAboutData::License_BSD);
00370         ldict.insert("artistic", KAboutData::License_Artistic);
00371         ldict.insert("qpl", KAboutData::License_QPL);
00372         ldict.insert("qplv1", KAboutData::License_QPL_V1_0);
00373         ldict.insert("qplv10", KAboutData::License_QPL_V1_0);
00374         ldict.insert("gplv3", KAboutData::License_GPL_V3);
00375         ldict.insert("gplv3+", KAboutData::License_GPL_V3);
00376         ldict.insert("lgplv3", KAboutData::License_LGPL_V3);
00377         ldict.insert("lgplv3+", KAboutData::License_LGPL_V3);
00378     }
00379 
00380     // Normalize keyword.
00381     QString keyword = rawKeyword;
00382     keyword = keyword.toLower();
00383     keyword.remove(QLatin1Char(' '));
00384     keyword.remove(QLatin1Char('.'));
00385 
00386     KAboutData::LicenseKey license = ldict.value(keyword.toLatin1(),
00387                                                  KAboutData::License_Custom);
00388     return KAboutLicense(license, 0);
00389 }
00390 
00391 
00392 class KAboutData::Private
00393 {
00394 public:
00395     Private()
00396         : customAuthorTextEnabled(false)
00397         {}
00398     QByteArray _appName;
00399     KLocalizedString _programName;
00400     KLocalizedString _shortDescription;
00401     QByteArray _catalogName;
00402     KLocalizedString _copyrightStatement;
00403     KLocalizedString _otherText;
00404     QString _homepageAddress;
00405     QList<KAboutPerson> _authorList;
00406     QList<KAboutPerson> _creditList;
00407     QList<KAboutLicense> _licenseList;
00408     KLocalizedString translatorName;
00409     KLocalizedString translatorEmail;
00410     QString productName;
00411     QString programIconName;
00412     QVariant programLogo;
00413     KLocalizedString customAuthorPlainText, customAuthorRichText;
00414     bool customAuthorTextEnabled;
00415 
00416     QString organizationDomain;
00417     QByteArray _ocsProviderUrl;
00418 
00419     // Everything dr.konqi needs, we store as utf-8, so we
00420     // can just give it a pointer, w/o any allocations.
00421     QByteArray _translatedProgramName; // ### I don't see it ever being translated, and I did not change that
00422     QByteArray _version;
00423     QByteArray _bugEmailAddress;
00424 };
00425 
00426 
00427 KAboutData::KAboutData( const QByteArray &_appName,
00428                         const QByteArray &_catalogName,
00429                         const KLocalizedString &_programName,
00430                         const QByteArray &_version,
00431                         const KLocalizedString &_shortDescription,
00432                         enum LicenseKey licenseType,
00433                         const KLocalizedString &_copyrightStatement,
00434                         const KLocalizedString &text,
00435                         const QByteArray &homePageAddress,
00436                         const QByteArray &bugsEmailAddress
00437                       )
00438   : d(new Private)
00439 {
00440     d->_appName = _appName;
00441     int p = d->_appName.indexOf('/');
00442     if (p >= 0) {
00443         d->_appName = d->_appName.mid(p + 1);
00444     }
00445 
00446     d->_catalogName = _catalogName;
00447     d->_programName = _programName;
00448     if (!d->_programName.isEmpty()) // KComponentData("klauncher") gives empty program name
00449         d->_translatedProgramName = _programName.toString(0).toUtf8();
00450     d->_version = _version;
00451     d->_shortDescription = _shortDescription;
00452     d->_licenseList.append(KAboutLicense(licenseType,this));
00453     d->_copyrightStatement = _copyrightStatement;
00454     d->_otherText = text;
00455     d->_homepageAddress = QString::fromLatin1(homePageAddress);
00456     d->_bugEmailAddress = bugsEmailAddress;
00457 
00458     if (d->_homepageAddress.contains(QLatin1String("http://"))) {
00459         const int dot = d->_homepageAddress.indexOf(QLatin1Char('.'));
00460         if (dot >= 0) {
00461             d->organizationDomain = d->_homepageAddress.mid(dot + 1);
00462             const int slash = d->organizationDomain.indexOf(QLatin1Char('/'));
00463             if (slash >= 0)
00464                 d->organizationDomain.truncate(slash);
00465         }
00466         else {
00467             d->organizationDomain = QString::fromLatin1("kde.org");
00468         }
00469     }
00470     else {
00471         d->organizationDomain = QString::fromLatin1("kde.org");
00472     }
00473 }
00474 
00475 KAboutData::~KAboutData()
00476 {
00477     delete d;
00478 }
00479 
00480 KAboutData::KAboutData(const KAboutData& other): d(new Private)
00481 {
00482     *d = *other.d;
00483     QList<KAboutLicense>::iterator it = d->_licenseList.begin(), itEnd = d->_licenseList.end();
00484     for ( ; it != itEnd; ++it) {
00485         KAboutLicense& al = *it;
00486         al.d.detach();
00487         al.d->_aboutData = this;
00488     }
00489 }
00490 
00491 KAboutData &KAboutData::operator=(const KAboutData& other)
00492 {
00493     if (this != &other) {
00494         *d = *other.d;
00495         QList<KAboutLicense>::iterator it = d->_licenseList.begin(), itEnd = d->_licenseList.end();
00496         for ( ; it != itEnd; ++it) {
00497             KAboutLicense& al = *it;
00498             al.d.detach();
00499             al.d->_aboutData = this;
00500         }
00501     }
00502     return *this;
00503 }
00504 
00505 KAboutData &KAboutData::addAuthor( const KLocalizedString &name,
00506                                    const KLocalizedString &task,
00507                                    const QByteArray &emailAddress,
00508                                    const QByteArray &webAddress )
00509 {
00510   d->_authorList.append(KAboutPerson(name,task,emailAddress,webAddress));
00511   return *this;
00512 }
00513 
00514 KAboutData &KAboutData::addAuthor( const KLocalizedString &name,
00515                                    const KLocalizedString &task,
00516                                    const QByteArray &emailAddress,
00517                                    const QByteArray &webAddress,
00518                                    const QByteArray &ocsUsername )
00519 {
00520   d->_authorList.append(KAboutPerson(name,task,emailAddress,webAddress,ocsUsername));
00521   return *this;
00522 }
00523 
00524 KAboutData &KAboutData::addCredit( const KLocalizedString &name,
00525                                    const KLocalizedString &task,
00526                                    const QByteArray &emailAddress,
00527                                    const QByteArray &webAddress )
00528 {
00529   d->_creditList.append(KAboutPerson(name,task,emailAddress,webAddress));
00530   return *this;
00531 }
00532 
00533 KAboutData &KAboutData::addCredit( const KLocalizedString &name,
00534                                    const KLocalizedString &task,
00535                                    const QByteArray &emailAddress,
00536                                    const QByteArray &webAddress,
00537                                    const QByteArray &ocsUsername )
00538 {
00539   d->_creditList.append(KAboutPerson(name,task,emailAddress,webAddress,ocsUsername));
00540   return *this;
00541 }
00542 
00543 KAboutData &KAboutData::setTranslator( const KLocalizedString& name,
00544                                        const KLocalizedString& emailAddress )
00545 {
00546   d->translatorName = name;
00547   d->translatorEmail = emailAddress;
00548   return *this;
00549 }
00550 
00551 KAboutData &KAboutData::setLicenseText( const KLocalizedString &licenseText )
00552 {
00553     d->_licenseList[0] = KAboutLicense(licenseText,this);
00554     return *this;
00555 }
00556 
00557 KAboutData &KAboutData::addLicenseText( const KLocalizedString &licenseText )
00558 {
00559     // if the default license is unknown, overwrite instead of append
00560     KAboutLicense &firstLicense = d->_licenseList[0];
00561     if (d->_licenseList.count() == 1 && firstLicense.d->_licenseKey == License_Unknown) {
00562         firstLicense = KAboutLicense(licenseText,this);
00563     } else {
00564         d->_licenseList.append(KAboutLicense(licenseText,this));
00565     }
00566     return *this;
00567 }
00568 
00569 KAboutData &KAboutData::setLicenseTextFile( const QString &pathToFile )
00570 {
00571     d->_licenseList[0] = KAboutLicense(pathToFile,this);
00572     return *this;
00573 }
00574 
00575 KAboutData &KAboutData::addLicenseTextFile( const QString &pathToFile )
00576 {
00577     // if the default license is unknown, overwrite instead of append
00578     KAboutLicense &firstLicense = d->_licenseList[0];
00579     if (d->_licenseList.count() == 1 && firstLicense.d->_licenseKey == License_Unknown) {
00580         firstLicense = KAboutLicense(pathToFile,this);
00581     } else {
00582         d->_licenseList.append(KAboutLicense(pathToFile,this));
00583     }
00584     return *this;
00585 }
00586 
00587 KAboutData &KAboutData::setAppName( const QByteArray &_appName )
00588 {
00589   d->_appName = _appName;
00590   return *this;
00591 }
00592 
00593 KAboutData &KAboutData::setProgramName( const KLocalizedString &_programName )
00594 {
00595   d->_programName = _programName;
00596   translateInternalProgramName();
00597   return *this;
00598 }
00599 
00600 KAboutData &KAboutData::setOcsProvider(const QByteArray &_ocsProviderUrl )
00601 {
00602     d->_ocsProviderUrl = _ocsProviderUrl;
00603     return *this;
00604 }
00605 
00606 KAboutData &KAboutData::setVersion( const QByteArray &_version )
00607 {
00608   d->_version = _version;
00609   return *this;
00610 }
00611 
00612 KAboutData &KAboutData::setShortDescription( const KLocalizedString &_shortDescription )
00613 {
00614   d->_shortDescription = _shortDescription;
00615   return *this;
00616 }
00617 
00618 KAboutData &KAboutData::setCatalogName( const QByteArray &_catalogName )
00619 {
00620   d->_catalogName = _catalogName;
00621   return *this;
00622 }
00623 
00624 KAboutData &KAboutData::setLicense( LicenseKey licenseKey)
00625 {
00626     d->_licenseList[0] = KAboutLicense(licenseKey,this);
00627     return *this;
00628 }
00629 
00630 KAboutData &KAboutData::addLicense( LicenseKey licenseKey)
00631 {
00632     // if the default license is unknown, overwrite instead of append
00633     KAboutLicense &firstLicense = d->_licenseList[0];
00634     if (d->_licenseList.count() == 1 && firstLicense.d->_licenseKey == License_Unknown) {
00635         firstLicense = KAboutLicense(licenseKey,this);
00636     } else {
00637         d->_licenseList.append(KAboutLicense(licenseKey,this));
00638     }
00639     return *this;
00640 }
00641 
00642 KAboutData &KAboutData::setCopyrightStatement( const KLocalizedString &_copyrightStatement )
00643 {
00644   d->_copyrightStatement = _copyrightStatement;
00645   return *this;
00646 }
00647 
00648 KAboutData &KAboutData::setOtherText( const KLocalizedString &_otherText )
00649 {
00650   d->_otherText = _otherText;
00651   return *this;
00652 }
00653 
00654 KAboutData &KAboutData::setHomepage( const QByteArray &_homepage )
00655 {
00656   d->_homepageAddress = QString::fromLatin1(_homepage);
00657   return *this;
00658 }
00659 
00660 KAboutData &KAboutData::setBugAddress( const QByteArray &_bugAddress )
00661 {
00662   d->_bugEmailAddress = _bugAddress;
00663   return *this;
00664 }
00665 
00666 KAboutData &KAboutData::setOrganizationDomain( const QByteArray &domain )
00667 {
00668   d->organizationDomain = QString::fromLatin1(domain);
00669   return *this;
00670 }
00671 
00672 KAboutData &KAboutData::setProductName( const QByteArray &_productName )
00673 {
00674   d->productName = QString::fromUtf8(_productName);
00675   return *this;
00676 }
00677 
00678 QString KAboutData::appName() const
00679 {
00680   return QString::fromUtf8(d->_appName);
00681 }
00682 
00683 QString KAboutData::productName() const
00684 {
00685    if (!d->productName.isEmpty())
00686       return d->productName;
00687    return appName();
00688 }
00689 
00690 QString KAboutData::programName() const
00691 {
00692    if (!d->_programName.isEmpty())
00693       return d->_programName.toString();
00694    return QString();
00695 }
00696 
00700 const char* KAboutData::internalProgramName() const
00701 {
00702    return d->_translatedProgramName.constData();
00703 }
00704 
00709 void KAboutData::translateInternalProgramName() const
00710 {
00711   d->_translatedProgramName.clear();
00712   if( KGlobal::locale())
00713       d->_translatedProgramName = programName().toUtf8();
00714 }
00715 
00716 QString KAboutData::programIconName() const
00717 {
00718     return d->programIconName.isEmpty() ? appName() : d->programIconName;
00719 }
00720 
00721 KAboutData &KAboutData::setProgramIconName( const QString &iconName )
00722 {
00723     d->programIconName = iconName;
00724     return *this;
00725 }
00726 
00727 QVariant KAboutData::programLogo() const
00728 {
00729     return d->programLogo;
00730 }
00731 
00732 KAboutData &KAboutData::setProgramLogo(const QVariant& image)
00733 {
00734     d->programLogo = image ;
00735     return *this;
00736 }
00737 
00738 QString KAboutData::ocsProviderUrl() const
00739 {
00740     if( !d->_ocsProviderUrl.isEmpty() )
00741         return QString::fromUtf8( d->_ocsProviderUrl );
00742     return QString();
00743 }
00744 
00745 QString KAboutData::version() const
00746 {
00747    return QString::fromUtf8(d->_version);
00748 }
00749 
00753 const char* KAboutData::internalVersion() const
00754 {
00755    return d->_version.constData();
00756 }
00757 
00758 QString KAboutData::shortDescription() const
00759 {
00760    if (!d->_shortDescription.isEmpty())
00761       return d->_shortDescription.toString();
00762    return QString();
00763 }
00764 
00765 QString KAboutData::catalogName() const
00766 {
00767    if (!d->_catalogName.isEmpty())
00768      return QString::fromUtf8(d->_catalogName);
00769    // Fallback to appname for catalog name if empty.
00770    return QString::fromUtf8(d->_appName);
00771 }
00772 
00773 QString KAboutData::homepage() const
00774 {
00775    return d->_homepageAddress;
00776 }
00777 
00778 QString KAboutData::bugAddress() const
00779 {
00780    return QString::fromUtf8(d->_bugEmailAddress);
00781 }
00782 
00783 QString KAboutData::organizationDomain() const
00784 {
00785     return d->organizationDomain;
00786 }
00787 
00788 
00792 const char* KAboutData::internalBugAddress() const
00793 {
00794    if (d->_bugEmailAddress.isEmpty())
00795       return 0;
00796    return d->_bugEmailAddress.constData();
00797 }
00798 
00799 QList<KAboutPerson> KAboutData::authors() const
00800 {
00801    return d->_authorList;
00802 }
00803 
00804 QList<KAboutPerson> KAboutData::credits() const
00805 {
00806    return d->_creditList;
00807 }
00808 
00809 #define NAME_OF_TRANSLATORS "Your names"
00810 #define EMAIL_OF_TRANSLATORS "Your emails"
00811 QList<KAboutPerson> KAboutData::translators() const
00812 {
00813     QList<KAboutPerson> personList;
00814 
00815     KLocale *tmpLocale = NULL;
00816     if (KGlobal::locale()) {
00817         // There could be many catalogs loaded into the global locale,
00818         // e.g. in systemsettings. The tmp locale is needed to make sure we
00819         // use the translators name from this aboutdata's catalog, rather than
00820         // from any other loaded catalog.
00821         tmpLocale = new KLocale(*KGlobal::locale());
00822         tmpLocale->setActiveCatalog(catalogName());
00823     }
00824 
00825     QString translatorName;
00826     if (!d->translatorName.isEmpty()) {
00827         translatorName = d->translatorName.toString();
00828     }
00829     else {
00830         translatorName = ki18nc("NAME OF TRANSLATORS", NAME_OF_TRANSLATORS).toString(tmpLocale);
00831     }
00832 
00833     QString translatorEmail;
00834     if (!d->translatorEmail.isEmpty()) {
00835         translatorEmail = d->translatorEmail.toString();
00836     }
00837     else {
00838         translatorEmail = ki18nc("EMAIL OF TRANSLATORS", EMAIL_OF_TRANSLATORS).toString(tmpLocale);
00839     }
00840 
00841     delete tmpLocale;
00842 
00843     if ( translatorName.isEmpty() || translatorName == QString::fromUtf8( NAME_OF_TRANSLATORS ) )
00844         return personList;
00845 
00846     const QStringList nameList(translatorName.split(QString(QLatin1Char(','))));
00847 
00848     QStringList emailList;
00849     if( !translatorEmail.isEmpty() && translatorEmail != QString::fromUtf8( EMAIL_OF_TRANSLATORS ) )
00850     {
00851        emailList = translatorEmail.split(QString(QLatin1Char(',')), QString::KeepEmptyParts);
00852     }
00853 
00854     QStringList::const_iterator nit;
00855     QStringList::const_iterator eit = emailList.constBegin();
00856 
00857     for( nit = nameList.constBegin(); nit != nameList.constEnd(); ++nit )
00858     {
00859         QString email;
00860         if ( eit != emailList.constEnd() )
00861         {
00862             email = *eit;
00863             ++eit;
00864         }
00865 
00866         personList.append( KAboutPerson( (*nit).trimmed(), email.trimmed() ) );
00867     }
00868 
00869     return personList;
00870 }
00871 
00872 QString KAboutData::aboutTranslationTeam()
00873 {
00874     return i18nc("replace this with information about your translation team",
00875             "<p>KDE is translated into many languages thanks to the work "
00876             "of the translation teams all over the world.</p>"
00877             "<p>For more information on KDE internationalization "
00878             "visit <a href=\"http://l10n.kde.org\">http://l10n.kde.org</a></p>"
00879             );
00880 }
00881 
00882 QString KAboutData::otherText() const
00883 {
00884    if (!d->_otherText.isEmpty())
00885       return d->_otherText.toString();
00886    return QString();
00887 }
00888 
00889 QString KAboutData::license() const
00890 {
00891     return d->_licenseList.at(0).text();
00892 }
00893 
00894 QString KAboutData::licenseName( NameFormat formatName ) const
00895 {
00896     return d->_licenseList.at(0).name(formatName);
00897 }
00898 
00899 QList<KAboutLicense> KAboutData::licenses() const
00900 {
00901     return d->_licenseList;
00902 }
00903 
00904 QString KAboutData::copyrightStatement() const
00905 {
00906   if (!d->_copyrightStatement.isEmpty())
00907     return d->_copyrightStatement.toString();
00908   return QString();
00909 }
00910 
00911 QString KAboutData::customAuthorPlainText() const
00912 {
00913   if (!d->customAuthorPlainText.isEmpty())
00914     return d->customAuthorPlainText.toString();
00915   return QString();
00916 }
00917 
00918 QString KAboutData::customAuthorRichText() const
00919 {
00920   if (!d->customAuthorRichText.isEmpty())
00921     return d->customAuthorRichText.toString();
00922   return QString();
00923 }
00924 
00925 bool KAboutData::customAuthorTextEnabled() const
00926 {
00927   return d->customAuthorTextEnabled;
00928 }
00929 
00930 KAboutData &KAboutData::setCustomAuthorText( const KLocalizedString &plainText,
00931                                              const KLocalizedString &richText )
00932 {
00933   d->customAuthorPlainText = plainText;
00934   d->customAuthorRichText = richText;
00935 
00936   d->customAuthorTextEnabled = true;
00937 
00938   return *this;
00939 }
00940 
00941 KAboutData &KAboutData::unsetCustomAuthorText()
00942 {
00943   d->customAuthorPlainText = KLocalizedString();
00944   d->customAuthorRichText = KLocalizedString();
00945 
00946   d->customAuthorTextEnabled = false;
00947 
00948   return *this;
00949 }
00950 

KDECore

Skip menu "KDECore"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.7.3
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal