• Skip to content
  • Skip to link menu
KDE 4.2 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 }
00473 
00474 KAboutData&
00475 KAboutData::operator=(const KAboutData& other)
00476 {
00477     *d = *other.d;
00478     return *this;
00479 }
00480 
00481 KAboutData &
00482 KAboutData::addAuthor( const KLocalizedString &name,
00483                        const KLocalizedString &task,
00484                        const QByteArray &emailAddress,
00485                        const QByteArray &webAddress )
00486 {
00487   d->_authorList.append(KAboutPerson(name,task,emailAddress,webAddress));
00488   return *this;
00489 }
00490 
00491 KAboutData &
00492 KAboutData::addCredit( const KLocalizedString &name,
00493                        const KLocalizedString &task,
00494                        const QByteArray &emailAddress,
00495                        const QByteArray &webAddress )
00496 {
00497   d->_creditList.append(KAboutPerson(name,task,emailAddress,webAddress));
00498   return *this;
00499 }
00500 
00501 KAboutData &
00502 KAboutData::setTranslator( const KLocalizedString& name,
00503                            const KLocalizedString& emailAddress )
00504 {
00505   d->translatorName = name;
00506   d->translatorEmail = emailAddress;
00507   return *this;
00508 }
00509 
00510 KAboutData &
00511 KAboutData::setLicenseText( const KLocalizedString &licenseText )
00512 {
00513     d->_licenseList[0] = KAboutLicense(licenseText,this);
00514     return *this;
00515 }
00516 
00517 KAboutData &
00518 KAboutData::addLicenseText( const KLocalizedString &licenseText )
00519 {
00520     // if the default license is unknown, overwrite instead of append
00521     KAboutLicense &firstLicense = d->_licenseList[0];
00522     if (d->_licenseList.count() == 1 && firstLicense.d->_licenseKey == License_Unknown) {
00523         firstLicense = KAboutLicense(licenseText,this);
00524     } else {
00525         d->_licenseList.append(KAboutLicense(licenseText,this));
00526     }
00527     return *this;
00528 }
00529 
00530 KAboutData &
00531 KAboutData::setLicenseTextFile( const QString &pathToFile )
00532 {
00533     d->_licenseList[0] = KAboutLicense(pathToFile,this);
00534     return *this;
00535 }
00536 
00537 KAboutData &
00538 KAboutData::addLicenseTextFile( const QString &pathToFile )
00539 {
00540     // if the default license is unknown, overwrite instead of append
00541     KAboutLicense &firstLicense = d->_licenseList[0];
00542     if (d->_licenseList.count() == 1 && firstLicense.d->_licenseKey == License_Unknown) {
00543         firstLicense = KAboutLicense(pathToFile,this);
00544     } else {
00545         d->_licenseList.append(KAboutLicense(pathToFile,this));
00546     }
00547     return *this;
00548 }
00549 
00550 KAboutData &
00551 KAboutData::setAppName( const QByteArray &_appName )
00552 {
00553   d->_appName = QString::fromUtf8(_appName);
00554   return *this;
00555 }
00556 
00557 KAboutData &
00558 KAboutData::setProgramName( const KLocalizedString &_programName )
00559 {
00560   d->_programName = _programName;
00561   translateInternalProgramName();
00562   return *this;
00563 }
00564 
00565 KAboutData &
00566 KAboutData::setVersion( const QByteArray &_version )
00567 {
00568   d->_version = _version;
00569   return *this;
00570 }
00571 
00572 KAboutData &
00573 KAboutData::setShortDescription( const KLocalizedString &_shortDescription )
00574 {
00575   d->_shortDescription = _shortDescription;
00576   return *this;
00577 }
00578 
00579 KAboutData &
00580 KAboutData::setCatalogName( const QByteArray &_catalogName )
00581 {
00582   d->_catalogName = _catalogName;
00583   return *this;
00584 }
00585 
00586 KAboutData &
00587 KAboutData::setLicense( LicenseKey licenseKey)
00588 {
00589     d->_licenseList[0] = KAboutLicense(licenseKey,this);
00590     return *this;
00591 }
00592 
00593 KAboutData &
00594 KAboutData::addLicense( LicenseKey licenseKey)
00595 {
00596     // if the default license is unknown, overwrite instead of append
00597     KAboutLicense &firstLicense = d->_licenseList[0];
00598     if (d->_licenseList.count() == 1 && firstLicense.d->_licenseKey == License_Unknown) {
00599         firstLicense = KAboutLicense(licenseKey,this);
00600     } else {
00601         d->_licenseList.append(KAboutLicense(licenseKey,this));
00602     }
00603     return *this;
00604 }
00605 
00606 KAboutData &
00607 KAboutData::setCopyrightStatement( const KLocalizedString &_copyrightStatement )
00608 {
00609   d->_copyrightStatement = _copyrightStatement;
00610   return *this;
00611 }
00612 
00613 KAboutData &
00614 KAboutData::setOtherText( const KLocalizedString &_otherText )
00615 {
00616   d->_otherText = _otherText;
00617   return *this;
00618 }
00619 
00620 KAboutData &
00621 KAboutData::setHomepage( const QByteArray &_homepage )
00622 {
00623   d->_homepageAddress = QString::fromUtf8(_homepage);
00624   return *this;
00625 }
00626 
00627 KAboutData &
00628 KAboutData::setBugAddress( const QByteArray &_bugAddress )
00629 {
00630   d->_bugEmailAddress = _bugAddress;
00631   return *this;
00632 }
00633 
00634 KAboutData &
00635 KAboutData::setOrganizationDomain( const QByteArray &domain )
00636 {
00637   d->organizationDomain = QString::fromUtf8(domain);
00638   return *this;
00639 }
00640 
00641 KAboutData &
00642 KAboutData::setProductName( const QByteArray &_productName )
00643 {
00644   d->productName = QString::fromUtf8(_productName);
00645   return *this;
00646 }
00647 
00648 QString
00649 KAboutData::appName() const
00650 {
00651    return d->_appName;
00652 }
00653 
00654 QString
00655 KAboutData::productName() const
00656 {
00657    if (!d->productName.isEmpty())
00658       return d->productName;
00659    return appName();
00660 }
00661 
00662 QString
00663 KAboutData::programName() const
00664 {
00665    if (!d->_programName.isEmpty())
00666       return d->_programName.toString();
00667    return QString();
00668 }
00669 
00673 const char*
00674 KAboutData::internalProgramName() const
00675 {
00676    return d->_translatedProgramName.constData();
00677 }
00678 
00683 void
00684 KAboutData::translateInternalProgramName() const
00685 {
00686   d->_translatedProgramName.clear();
00687   if( KGlobal::locale())
00688       d->_translatedProgramName = programName().toUtf8();
00689 }
00690 
00691 QString
00692 KAboutData::programIconName() const
00693 {
00694     return d->programIconName.isEmpty() ? appName() : d->programIconName;
00695 }
00696 
00697 KAboutData &
00698 KAboutData::setProgramIconName( const QString &iconName )
00699 {
00700     d->programIconName = iconName;
00701     return *this;
00702 }
00703 
00704 QVariant
00705 KAboutData::programLogo() const
00706 {
00707     return d->programLogo;
00708 }
00709 
00710 KAboutData &
00711 KAboutData::setProgramLogo(const QVariant& image)
00712 {
00713     d->programLogo = image ;
00714     return *this;
00715 }
00716 
00717 QString
00718 KAboutData::version() const
00719 {
00720    return QString::fromUtf8(d->_version);
00721 }
00722 
00726 const char*
00727 KAboutData::internalVersion() const
00728 {
00729    return d->_version.constData();
00730 }
00731 
00732 QString
00733 KAboutData::shortDescription() const
00734 {
00735    if (!d->_shortDescription.isEmpty())
00736       return d->_shortDescription.toString();
00737    return QString();
00738 }
00739 
00740 QString
00741 KAboutData::catalogName() const
00742 {
00743    if (!d->_catalogName.isEmpty())
00744       return d->_catalogName;
00745    // Fallback to appname for catalog name if empty.
00746    return d->_appName;
00747 }
00748 
00749 QString
00750 KAboutData::homepage() const
00751 {
00752    return d->_homepageAddress;
00753 }
00754 
00755 QString
00756 KAboutData::bugAddress() const
00757 {
00758    return QString::fromUtf8(d->_bugEmailAddress);
00759 }
00760 
00761 QString
00762 KAboutData::organizationDomain() const
00763 {
00764     return d->organizationDomain;
00765 }
00766 
00767 
00771 const char*
00772 KAboutData::internalBugAddress() const
00773 {
00774    if (d->_bugEmailAddress.isEmpty())
00775       return 0;
00776    return d->_bugEmailAddress.constData();
00777 }
00778 
00779 QList<KAboutPerson>
00780 KAboutData::authors() const
00781 {
00782    return d->_authorList;
00783 }
00784 
00785 QList<KAboutPerson>
00786 KAboutData::credits() const
00787 {
00788    return d->_creditList;
00789 }
00790 
00791 #define NAME_OF_TRANSLATORS "Your names"
00792 #define EMAIL_OF_TRANSLATORS "Your emails"
00793 QList<KAboutPerson>
00794 KAboutData::translators() const
00795 {
00796     QList<KAboutPerson> personList;
00797 
00798     QString translatorName;
00799     if (!d->translatorName.isEmpty()) {
00800         translatorName = d->translatorName.toString();
00801     }
00802     else {
00803         translatorName = i18nc("NAME OF TRANSLATORS", NAME_OF_TRANSLATORS);
00804     }
00805 
00806     QString translatorEmail;
00807     if (!d->translatorEmail.isEmpty()) {
00808         translatorEmail = d->translatorEmail.toString();
00809     }
00810     else {
00811         translatorEmail = i18nc("EMAIL OF TRANSLATORS", EMAIL_OF_TRANSLATORS);
00812     }
00813 
00814     if ( translatorName.isEmpty() || translatorName == QString::fromUtf8( NAME_OF_TRANSLATORS ) )
00815         return personList;
00816 
00817     const QStringList nameList ( translatorName.split( ',' ) );
00818 
00819     QStringList emailList;
00820     if( !translatorEmail.isEmpty() && translatorEmail != QString::fromUtf8( EMAIL_OF_TRANSLATORS ) )
00821     {
00822        emailList = translatorEmail.split( ',', QString::KeepEmptyParts );
00823     }
00824 
00825     QStringList::const_iterator nit;
00826     QStringList::const_iterator eit = emailList.constBegin();
00827 
00828     for( nit = nameList.constBegin(); nit != nameList.constEnd(); ++nit )
00829     {
00830         QString email;
00831         if ( eit != emailList.constEnd() )
00832         {
00833             email = *eit;
00834             ++eit;
00835         }
00836 
00837         personList.append( KAboutPerson( (*nit).trimmed(), email.trimmed() ) );
00838     }
00839 
00840     return personList;
00841 }
00842 
00843 QString
00844 KAboutData::aboutTranslationTeam()
00845 {
00846     return i18nc("replace this with information about your translation team",
00847             "<p>KDE is translated into many languages thanks to the work "
00848             "of the translation teams all over the world.</p>"
00849             "<p>For more information on KDE internationalization "
00850             "visit <a href=\"http://l10n.kde.org\">http://l10n.kde.org</a></p>"
00851             );
00852 }
00853 
00854 QString
00855 KAboutData::otherText() const
00856 {
00857    if (!d->_otherText.isEmpty())
00858       return d->_otherText.toString();
00859    return QString();
00860 }
00861 
00862 QString
00863 KAboutData::license() const
00864 {
00865     return d->_licenseList.at(0).text();
00866 }
00867 
00868 QString
00869 KAboutData::licenseName(NameFormat formatName) const
00870 {
00871     return d->_licenseList.at(0).name(formatName);
00872 }
00873 
00874 QList<KAboutLicense>
00875 KAboutData::licenses() const
00876 {
00877     return d->_licenseList;
00878 }
00879 
00880 QString
00881 KAboutData::copyrightStatement() const
00882 {
00883   if (!d->_copyrightStatement.isEmpty())
00884     return d->_copyrightStatement.toString();
00885   return QString();
00886 }
00887 
00888 QString
00889 KAboutData::customAuthorPlainText() const
00890 {
00891   if (!d->customAuthorPlainText.isEmpty())
00892     return d->customAuthorPlainText.toString();
00893   return QString();
00894 }
00895 
00896 QString
00897 KAboutData::customAuthorRichText() const
00898 {
00899   if (!d->customAuthorRichText.isEmpty())
00900     return d->customAuthorRichText.toString();
00901   return QString();
00902 }
00903 
00904 bool
00905 KAboutData::customAuthorTextEnabled() const
00906 {
00907   return d->customAuthorTextEnabled;
00908 }
00909 
00910 KAboutData &
00911 KAboutData::setCustomAuthorText(const KLocalizedString &plainText,
00912                                 const KLocalizedString &richText)
00913 {
00914   d->customAuthorPlainText = plainText;
00915   d->customAuthorRichText = richText;
00916 
00917   d->customAuthorTextEnabled = true;
00918 
00919   return *this;
00920 }
00921 
00922 KAboutData &
00923 KAboutData::unsetCustomAuthorText()
00924 {
00925   d->customAuthorPlainText = KLocalizedString();
00926   d->customAuthorRichText = KLocalizedString();
00927 
00928   d->customAuthorTextEnabled = false;
00929 
00930   return *this;
00931 }
00932 

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
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.7
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