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

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
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.6.1
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