kdecore: format and indent

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2023-08-10 20:47:11 +03:00
parent d181c8678c
commit ab05f3c60d
2 changed files with 416 additions and 463 deletions

View file

@ -30,7 +30,6 @@
#include <QtCore/QFile> #include <QtCore/QFile>
#include <QtCore/QTextStream> #include <QtCore/QTextStream>
#include <QtCore/QSharedData> #include <QtCore/QSharedData>
#include <QtCore/QVariant>
#include <QtCore/QList> #include <QtCore/QList>
#include <QHash> #include <QHash>
@ -56,55 +55,58 @@
class KAboutPerson::Private class KAboutPerson::Private
{ {
public: public:
KLocalizedString _name; KLocalizedString _name;
KLocalizedString _task; KLocalizedString _task;
QString _emailAddress; QString _emailAddress;
QString _webAddress; QString _webAddress;
QString _nameNoop; QString _nameNoop;
}; };
KAboutPerson::KAboutPerson( const KLocalizedString &_name, KAboutPerson::KAboutPerson(const KLocalizedString &_name,
const KLocalizedString &_task, const KLocalizedString &_task,
const QByteArray &_emailAddress, const QByteArray &_emailAddress,
const QByteArray &_webAddress ) const QByteArray &_webAddress)
: d(new Private) : d(new Private)
{ {
d->_name = _name; d->_name = _name;
d->_task = _task; d->_task = _task;
d->_emailAddress = QString::fromUtf8(_emailAddress); d->_emailAddress = QString::fromUtf8(_emailAddress);
d->_webAddress = QString::fromUtf8(_webAddress); d->_webAddress = QString::fromUtf8(_webAddress);
} }
KAboutPerson::KAboutPerson( const QString &_name, const QString &_email ) KAboutPerson::KAboutPerson(const QString &_name, const QString &_email)
: d(new Private) : d(new Private())
{ {
d->_nameNoop = _name; d->_nameNoop = _name;
d->_emailAddress = _email; d->_emailAddress = _email;
} }
KAboutPerson::KAboutPerson(const KAboutPerson& other): d(new Private) KAboutPerson::KAboutPerson(const KAboutPerson &other)
: d(new Private())
{ {
*d = *other.d; *d = *other.d;
} }
KAboutPerson::~KAboutPerson() KAboutPerson::~KAboutPerson()
{ {
delete d; delete d;
} }
QString KAboutPerson::name() const QString KAboutPerson::name() const
{ {
if (!d->_nameNoop.isEmpty()) if (!d->_nameNoop.isEmpty()) {
return d->_nameNoop; return d->_nameNoop;
return d->_name.toString(); }
return d->_name.toString();
} }
QString KAboutPerson::task() const QString KAboutPerson::task() const
{ {
if (!d->_task.isEmpty()) if (!d->_task.isEmpty()) {
return d->_task.toString(); return d->_task.toString();
return QString(); }
return QString();
} }
QString KAboutPerson::emailAddress() const QString KAboutPerson::emailAddress() const
@ -112,16 +114,15 @@ QString KAboutPerson::emailAddress() const
return d->_emailAddress; return d->_emailAddress;
} }
QString KAboutPerson::webAddress() const QString KAboutPerson::webAddress() const
{ {
return d->_webAddress; return d->_webAddress;
} }
KAboutPerson &KAboutPerson::operator=(const KAboutPerson& other) KAboutPerson &KAboutPerson::operator=(const KAboutPerson &other)
{ {
*d = *other.d; *d = *other.d;
return *this; return *this;
} }
@ -129,36 +130,35 @@ KAboutPerson &KAboutPerson::operator=(const KAboutPerson& other)
class KAboutLicense::Private : public QSharedData class KAboutLicense::Private : public QSharedData
{ {
public: public:
Private( enum KAboutData::LicenseKey licenseType, const KAboutData *aboutData ); Private(enum KAboutData::LicenseKey licenseType, const KAboutData *aboutData);
Private( const Private& other); Private(const Private &other);
public: public:
enum KAboutData::LicenseKey _licenseKey; enum KAboutData::LicenseKey _licenseKey;
// needed for access to the possibly changing copyrightStatement() // needed for access to the possibly changing copyrightStatement()
const KAboutData * _aboutData; const KAboutData * _aboutData;
}; };
KAboutLicense::Private::Private( enum KAboutData::LicenseKey licenseType, const KAboutData *aboutData ) KAboutLicense::Private::Private(enum KAboutData::LicenseKey licenseType, const KAboutData *aboutData)
: QSharedData(), : QSharedData(),
_licenseKey( licenseType ), _licenseKey(licenseType),
_aboutData( aboutData ) _aboutData(aboutData)
{ {
} }
KAboutLicense::Private::Private(const KAboutLicense::Private& other) KAboutLicense::Private::Private(const KAboutLicense::Private &other)
: QSharedData(other), : QSharedData(other),
_licenseKey( other._licenseKey ), _licenseKey(other._licenseKey),
_aboutData( other._aboutData ) _aboutData(other._aboutData)
{ {
} }
KAboutLicense::KAboutLicense(enum KAboutData::LicenseKey licenseType, const KAboutData *aboutData)
KAboutLicense::KAboutLicense( enum KAboutData::LicenseKey licenseType, const KAboutData *aboutData ) : d(new Private(licenseType, aboutData))
: d(new Private(licenseType,aboutData))
{ {
} }
KAboutLicense::KAboutLicense(const KAboutLicense& other) KAboutLicense::KAboutLicense(const KAboutLicense &other)
: d(other.d) : d(other.d)
{ {
} }
@ -170,7 +170,7 @@ QString KAboutLicense::text() const
{ {
QString result; QString result;
const QString lineFeed = QString::fromLatin1( "\n\n" ); const QString lineFeed = QString::fromLatin1("\n\n");
if (d->_aboutData && !d->_aboutData->copyrightStatement().isEmpty()) { if (d->_aboutData && !d->_aboutData->copyrightStatement().isEmpty()) {
result = d->_aboutData->copyrightStatement() + lineFeed; result = d->_aboutData->copyrightStatement() + lineFeed;
@ -178,37 +178,45 @@ QString KAboutLicense::text() const
bool knownLicense = false; bool knownLicense = false;
QString pathToFile; QString pathToFile;
switch ( d->_licenseKey ) switch (d->_licenseKey) {
{ case KAboutData::License_GPL_V2: {
case KAboutData::License_GPL_V2: knownLicense = true;
knownLicense = true; pathToFile = KStandardDirs::locate("data", QString::fromLatin1("LICENSES/GPL_V2"));
pathToFile = KStandardDirs::locate("data", QString::fromLatin1("LICENSES/GPL_V2")); break;
break; }
case KAboutData::License_LGPL_V2: case KAboutData::License_LGPL_V2: {
knownLicense = true; knownLicense = true;
pathToFile = KStandardDirs::locate("data", QString::fromLatin1("LICENSES/LGPL_V2")); pathToFile = KStandardDirs::locate("data", QString::fromLatin1("LICENSES/LGPL_V2"));
break; break;
case KAboutData::License_BSD: }
knownLicense = true; case KAboutData::License_BSD: {
pathToFile = KStandardDirs::locate("data", QString::fromLatin1("LICENSES/BSD")); knownLicense = true;
break; pathToFile = KStandardDirs::locate("data", QString::fromLatin1("LICENSES/BSD"));
case KAboutData::License_Artistic: break;
knownLicense = true; }
pathToFile = KStandardDirs::locate("data", QString::fromLatin1("LICENSES/ARTISTIC")); case KAboutData::License_Artistic: {
break; knownLicense = true;
case KAboutData::License_GPL_V3: pathToFile = KStandardDirs::locate("data", QString::fromLatin1("LICENSES/ARTISTIC"));
knownLicense = true; break;
pathToFile = KStandardDirs::locate("data", QString::fromLatin1("LICENSES/GPL_V3")); }
break; case KAboutData::License_GPL_V3: {
case KAboutData::License_LGPL_V3: knownLicense = true;
knownLicense = true; pathToFile = KStandardDirs::locate("data", QString::fromLatin1("LICENSES/GPL_V3"));
pathToFile = KStandardDirs::locate("data", QString::fromLatin1("LICENSES/LGPL_V3")); break;
break; }
default: case KAboutData::License_LGPL_V3: {
result += i18n("No licensing terms for this program have been specified.\n" knownLicense = true;
"Please check the documentation or the source for any\n" pathToFile = KStandardDirs::locate("data", QString::fromLatin1("LICENSES/LGPL_V3"));
"licensing terms.\n"); break;
break; }
default: {
result += i18n(
"No licensing terms for this program have been specified.\n"
"Please check the documentation or the source for any\n"
"licensing terms.\n"
);
break;
}
} }
if (knownLicense) { if (knownLicense) {
@ -236,48 +244,55 @@ QString KAboutLicense::name(KAboutData::NameFormat formatName) const
QString licenseFull; QString licenseFull;
switch (d->_licenseKey) { switch (d->_licenseKey) {
case KAboutData::License_GPL_V2: case KAboutData::License_GPL_V2: {
licenseShort = i18nc("@item license (short name)","GPL v2"); licenseShort = i18nc("@item license (short name)","GPL v2");
licenseFull = i18nc("@item license","GNU General Public License Version 2"); licenseFull = i18nc("@item license", "GNU General Public License Version 2");
break; break;
case KAboutData::License_LGPL_V2: }
licenseShort = i18nc("@item license (short name)","LGPL v2"); case KAboutData::License_LGPL_V2: {
licenseFull = i18nc("@item license","GNU Lesser General Public License Version 2"); licenseShort = i18nc("@item license (short name)","LGPL v2");
break; licenseFull = i18nc("@item license", "GNU Lesser General Public License Version 2");
case KAboutData::License_BSD: break;
licenseShort = i18nc("@item license (short name)","BSD License"); }
licenseFull = i18nc("@item license","BSD License"); case KAboutData::License_BSD: {
break; licenseShort = i18nc("@item license (short name)","BSD License");
case KAboutData::License_Artistic: licenseFull = i18nc("@item license", "BSD License");
licenseShort = i18nc("@item license (short name)","Artistic License"); break;
licenseFull = i18nc("@item license","Artistic License"); }
break; case KAboutData::License_Artistic: {
case KAboutData::License_GPL_V3: licenseShort = i18nc("@item license (short name)","Artistic License");
licenseShort = i18nc("@item license (short name)","GPL v3"); licenseFull = i18nc("@item license", "Artistic License");
licenseFull = i18nc("@item license","GNU General Public License Version 3"); break;
break; }
case KAboutData::License_LGPL_V3: case KAboutData::License_GPL_V3: {
licenseShort = i18nc("@item license (short name)","LGPL v3"); licenseShort = i18nc("@item license (short name)","GPL v3");
licenseFull = i18nc("@item license","GNU Lesser General Public License Version 3"); licenseFull = i18nc("@item license", "GNU General Public License Version 3");
break; break;
default: }
licenseShort = licenseFull = i18nc("@item license","Not specified"); case KAboutData::License_LGPL_V3: {
break; licenseShort = i18nc("@item license (short name)","LGPL v3");
licenseFull = i18nc("@item license","GNU Lesser General Public License Version 3");
break;
}
default: {
licenseShort = licenseFull = i18nc("@item license", "Not specified");
break;
}
} }
const QString result = if (formatName == KAboutData::ShortName) {
(formatName == KAboutData::ShortName ) ? licenseShort : return licenseShort;
(formatName == KAboutData::FullName ) ? licenseFull : } else if (formatName == KAboutData::FullName) {
QString(); return licenseFull;
}
return result; return QString();
} }
KAboutLicense &KAboutLicense::operator=(const KAboutLicense& other) KAboutLicense &KAboutLicense::operator=(const KAboutLicense &other)
{ {
d = other.d; d = other.d;
return *this; return *this;
} }
KAboutData::LicenseKey KAboutLicense::key() const KAboutData::LicenseKey KAboutLicense::key() const
@ -311,9 +326,8 @@ KAboutLicense KAboutLicense::byKeyword(const QString &rawKeyword)
keyword.remove(QLatin1Char(' ')); keyword.remove(QLatin1Char(' '));
keyword.remove(QLatin1Char('.')); keyword.remove(QLatin1Char('.'));
KAboutData::LicenseKey license = ldict.value(keyword.toLatin1(), KAboutData::LicenseKey license = ldict.value(keyword.toLatin1(), KAboutData::License_Unknown);
KAboutData::License_Unknown); return KAboutLicense(license, nullptr);
return KAboutLicense(license, 0);
} }
@ -338,15 +352,14 @@ public:
}; };
KAboutData::KAboutData( const QByteArray &_appName, KAboutData::KAboutData(const QByteArray &_appName,
const QByteArray &_catalogName, const QByteArray &_catalogName,
const KLocalizedString &_programName, const KLocalizedString &_programName,
const QByteArray &_version, const QByteArray &_version,
const KLocalizedString &_shortDescription, const KLocalizedString &_shortDescription,
enum LicenseKey licenseType, enum LicenseKey licenseType,
const KLocalizedString &_copyrightStatement const KLocalizedString &_copyrightStatement)
) : d(new Private())
: d(new Private)
{ {
d->_appName = _appName; d->_appName = _appName;
int p = d->_appName.indexOf('/'); int p = d->_appName.indexOf('/');
@ -358,7 +371,7 @@ KAboutData::KAboutData( const QByteArray &_appName,
d->_programName = _programName; d->_programName = _programName;
d->_version = _version; d->_version = _version;
d->_shortDescription = _shortDescription; d->_shortDescription = _shortDescription;
d->_licenseList.append(KAboutLicense(licenseType,this)); d->_licenseList.append(KAboutLicense(licenseType, this));
d->_copyrightStatement = _copyrightStatement; d->_copyrightStatement = _copyrightStatement;
d->_homepageAddress = QString::fromLatin1(KDE_HOME_URL); d->_homepageAddress = QString::fromLatin1(KDE_HOME_URL);
d->_bugEmailAddress = QByteArray(KDE_BUG_REPORT_EMAIL); d->_bugEmailAddress = QByteArray(KDE_BUG_REPORT_EMAIL);
@ -370,7 +383,8 @@ KAboutData::~KAboutData()
delete d; delete d;
} }
KAboutData::KAboutData(const KAboutData& other): d(new Private) KAboutData::KAboutData(const KAboutData& other)
: d(new Private())
{ {
*d = *other.d; *d = *other.d;
QList<KAboutLicense>::iterator it = d->_licenseList.begin(), itEnd = d->_licenseList.end(); QList<KAboutLicense>::iterator it = d->_licenseList.begin(), itEnd = d->_licenseList.end();
@ -395,114 +409,115 @@ KAboutData &KAboutData::operator=(const KAboutData& other)
return *this; return *this;
} }
KAboutData &KAboutData::addAuthor( const KLocalizedString &name, KAboutData &KAboutData::addAuthor(const KLocalizedString &name,
const KLocalizedString &task, const KLocalizedString &task,
const QByteArray &emailAddress, const QByteArray &emailAddress,
const QByteArray &webAddress ) const QByteArray &webAddress)
{ {
d->_authorList.append(KAboutPerson(name,task,emailAddress,webAddress)); d->_authorList.append(KAboutPerson(name, task, emailAddress, webAddress));
return *this;
}
KAboutData &KAboutData::addCredit( const KLocalizedString &name,
const KLocalizedString &task,
const QByteArray &emailAddress,
const QByteArray &webAddress )
{
d->_creditList.append(KAboutPerson(name,task,emailAddress,webAddress));
return *this;
}
KAboutData &KAboutData::setTranslator( const KLocalizedString& name,
const KLocalizedString& emailAddress )
{
d->translatorName = name;
d->translatorEmail = emailAddress;
return *this;
}
KAboutData &KAboutData::setAppName( const QByteArray &_appName )
{
d->_appName = _appName;
return *this;
}
KAboutData &KAboutData::setProgramName( const KLocalizedString &_programName )
{
d->_programName = _programName;
return *this;
}
KAboutData &KAboutData::setVersion( const QByteArray &_version )
{
d->_version = _version;
return *this;
}
KAboutData &KAboutData::setShortDescription( const KLocalizedString &_shortDescription )
{
d->_shortDescription = _shortDescription;
return *this;
}
KAboutData &KAboutData::setCatalogName( const QByteArray &_catalogName )
{
d->_catalogName = _catalogName;
return *this;
}
KAboutData &KAboutData::setLicense( LicenseKey licenseKey)
{
d->_licenseList[0] = KAboutLicense(licenseKey,this);
return *this; return *this;
} }
KAboutData &KAboutData::addLicense( LicenseKey licenseKey) KAboutData &KAboutData::addCredit(const KLocalizedString &name,
const KLocalizedString &task,
const QByteArray &emailAddress,
const QByteArray &webAddress)
{
d->_creditList.append(KAboutPerson(name, task, emailAddress, webAddress));
return *this;
}
KAboutData &KAboutData::setTranslator( const KLocalizedString &name,
const KLocalizedString &emailAddress)
{
d->translatorName = name;
d->translatorEmail = emailAddress;
return *this;
}
KAboutData &KAboutData::setAppName(const QByteArray &_appName)
{
d->_appName = _appName;
return *this;
}
KAboutData &KAboutData::setProgramName(const KLocalizedString &_programName)
{
d->_programName = _programName;
return *this;
}
KAboutData &KAboutData::setVersion(const QByteArray &_version)
{
d->_version = _version;
return *this;
}
KAboutData &KAboutData::setShortDescription(const KLocalizedString &_shortDescription)
{
d->_shortDescription = _shortDescription;
return *this;
}
KAboutData &KAboutData::setCatalogName(const QByteArray &_catalogName)
{
d->_catalogName = _catalogName;
return *this;
}
KAboutData &KAboutData::setLicense(LicenseKey licenseKey)
{
d->_licenseList[0] = KAboutLicense(licenseKey, this);
return *this;
}
KAboutData &KAboutData::addLicense(LicenseKey licenseKey)
{ {
// if the default license is unknown, overwrite instead of append // if the default license is unknown, overwrite instead of append
KAboutLicense &firstLicense = d->_licenseList[0]; KAboutLicense &firstLicense = d->_licenseList[0];
if (d->_licenseList.count() == 1 && firstLicense.d->_licenseKey == License_Unknown) { if (d->_licenseList.count() == 1 && firstLicense.d->_licenseKey == License_Unknown) {
firstLicense = KAboutLicense(licenseKey,this); firstLicense = KAboutLicense(licenseKey,this);
} else { } else {
d->_licenseList.append(KAboutLicense(licenseKey,this)); d->_licenseList.append(KAboutLicense(licenseKey, this));
} }
return *this; return *this;
} }
KAboutData &KAboutData::setCopyrightStatement( const KLocalizedString &_copyrightStatement ) KAboutData &KAboutData::setCopyrightStatement(const KLocalizedString &_copyrightStatement)
{ {
d->_copyrightStatement = _copyrightStatement; d->_copyrightStatement = _copyrightStatement;
return *this; return *this;
} }
KAboutData &KAboutData::setHomepage( const QByteArray &_homepage ) KAboutData &KAboutData::setHomepage(const QByteArray &_homepage)
{ {
d->_homepageAddress = QString::fromLatin1(_homepage); d->_homepageAddress = QString::fromLatin1(_homepage);
return *this; return *this;
} }
KAboutData &KAboutData::setBugAddress( const QByteArray &_bugAddress ) KAboutData &KAboutData::setBugAddress(const QByteArray &_bugAddress)
{ {
d->_bugEmailAddress = _bugAddress; d->_bugEmailAddress = _bugAddress;
return *this; return *this;
} }
KAboutData &KAboutData::setOrganizationDomain( const QByteArray &domain ) KAboutData &KAboutData::setOrganizationDomain(const QByteArray &domain)
{ {
d->organizationDomain = QString::fromLatin1(domain); d->organizationDomain = QString::fromLatin1(domain);
return *this; return *this;
} }
QString KAboutData::appName() const QString KAboutData::appName() const
{ {
return QString::fromUtf8(d->_appName); return QString::fromUtf8(d->_appName);
} }
QString KAboutData::programName() const QString KAboutData::programName() const
{ {
if (!d->_programName.isEmpty()) if (!d->_programName.isEmpty()) {
return d->_programName.toString(); return d->_programName.toString();
return QString(); }
return QString();
} }
QString KAboutData::programIconName() const QString KAboutData::programIconName() const
@ -510,7 +525,7 @@ QString KAboutData::programIconName() const
return d->programIconName.isEmpty() ? appName() : d->programIconName; return d->programIconName.isEmpty() ? appName() : d->programIconName;
} }
KAboutData &KAboutData::setProgramIconName( const QString &iconName ) KAboutData &KAboutData::setProgramIconName(const QString &iconName)
{ {
d->programIconName = iconName; d->programIconName = iconName;
return *this; return *this;
@ -518,32 +533,34 @@ KAboutData &KAboutData::setProgramIconName( const QString &iconName )
QString KAboutData::version() const QString KAboutData::version() const
{ {
return QString::fromUtf8(d->_version); return QString::fromUtf8(d->_version);
} }
QString KAboutData::shortDescription() const QString KAboutData::shortDescription() const
{ {
if (!d->_shortDescription.isEmpty()) if (!d->_shortDescription.isEmpty()) {
return d->_shortDescription.toString(); return d->_shortDescription.toString();
return QString(); }
return QString();
} }
QString KAboutData::catalogName() const QString KAboutData::catalogName() const
{ {
if (!d->_catalogName.isEmpty()) if (!d->_catalogName.isEmpty()) {
return QString::fromUtf8(d->_catalogName); return QString::fromUtf8(d->_catalogName);
// Fallback to appname for catalog name if empty. }
return QString::fromUtf8(d->_appName); // Fallback to appname for catalog name if empty.
return QString::fromUtf8(d->_appName);
} }
QString KAboutData::homepage() const QString KAboutData::homepage() const
{ {
return d->_homepageAddress; return d->_homepageAddress;
} }
QString KAboutData::bugAddress() const QString KAboutData::bugAddress() const
{ {
return QString::fromUtf8(d->_bugEmailAddress); return QString::fromUtf8(d->_bugEmailAddress);
} }
QString KAboutData::organizationDomain() const QString KAboutData::organizationDomain() const
@ -553,12 +570,12 @@ QString KAboutData::organizationDomain() const
QList<KAboutPerson> KAboutData::authors() const QList<KAboutPerson> KAboutData::authors() const
{ {
return d->_authorList; return d->_authorList;
} }
QList<KAboutPerson> KAboutData::credits() const QList<KAboutPerson> KAboutData::credits() const
{ {
return d->_creditList; return d->_creditList;
} }
#define NAME_OF_TRANSLATORS "Your names" #define NAME_OF_TRANSLATORS "Your names"
@ -580,42 +597,37 @@ QList<KAboutPerson> KAboutData::translators() const
QString translatorName; QString translatorName;
if (!d->translatorName.isEmpty()) { if (!d->translatorName.isEmpty()) {
translatorName = d->translatorName.toString(); translatorName = d->translatorName.toString();
} } else {
else {
translatorName = ki18nc("NAME OF TRANSLATORS", NAME_OF_TRANSLATORS).toString(tmpLocale); translatorName = ki18nc("NAME OF TRANSLATORS", NAME_OF_TRANSLATORS).toString(tmpLocale);
} }
QString translatorEmail; QString translatorEmail;
if (!d->translatorEmail.isEmpty()) { if (!d->translatorEmail.isEmpty()) {
translatorEmail = d->translatorEmail.toString(); translatorEmail = d->translatorEmail.toString();
} } else {
else {
translatorEmail = ki18nc("EMAIL OF TRANSLATORS", EMAIL_OF_TRANSLATORS).toString(tmpLocale); translatorEmail = ki18nc("EMAIL OF TRANSLATORS", EMAIL_OF_TRANSLATORS).toString(tmpLocale);
} }
delete tmpLocale; delete tmpLocale;
if ( translatorName.isEmpty() || translatorName == QString::fromUtf8( NAME_OF_TRANSLATORS ) ) if (translatorName.isEmpty() || translatorName == QString::fromUtf8(NAME_OF_TRANSLATORS)) {
return personList; return personList;
}
const QStringList nameList(translatorName.split(QString(QLatin1Char(',')))); const QStringList nameList(translatorName.split(QString(QLatin1Char(','))));
QStringList emailList; QStringList emailList;
if( !translatorEmail.isEmpty() && translatorEmail != QString::fromUtf8( EMAIL_OF_TRANSLATORS ) ) if (!translatorEmail.isEmpty() && translatorEmail != QString::fromUtf8(EMAIL_OF_TRANSLATORS)) {
{ emailList = translatorEmail.split(QString(QLatin1Char(',')), QString::KeepEmptyParts);
emailList = translatorEmail.split(QString(QLatin1Char(',')), QString::KeepEmptyParts);
} }
foreach ( const QString &nit, nameList ) foreach (const QString &nit, nameList) {
{
// overkill? // overkill?
QString email; QString email;
foreach (const QString &eit, emailList ) foreach (const QString &eit, emailList) {
{
email = eit; email = eit;
} }
personList.append(KAboutPerson(nit.trimmed(), email.trimmed()));
personList.append( KAboutPerson( nit.trimmed(), email.trimmed() ) );
} }
return personList; return personList;
@ -637,7 +649,7 @@ QString KAboutData::license() const
return d->_licenseList.at(0).text(); return d->_licenseList.at(0).text();
} }
QString KAboutData::licenseName( NameFormat formatName ) const QString KAboutData::licenseName(NameFormat formatName) const
{ {
return d->_licenseList.at(0).name(formatName); return d->_licenseList.at(0).name(formatName);
} }
@ -649,7 +661,8 @@ QList<KAboutLicense> KAboutData::licenses() const
QString KAboutData::copyrightStatement() const QString KAboutData::copyrightStatement() const
{ {
if (!d->_copyrightStatement.isEmpty()) if (!d->_copyrightStatement.isEmpty()) {
return d->_copyrightStatement.toString(); return d->_copyrightStatement.toString();
return QString(); }
return QString();
} }

View file

@ -29,19 +29,17 @@
#include <kglobalsettings.h> #include <kglobalsettings.h>
class KAboutData; class KAboutData;
class KAboutLicense;
/** /**
* This class is used to store information about a person or developer. * This class is used to store information about a person or developer. It can store the person's
* It can store the person's name, a task, an email address and a * name, a task, an email address and a link to a home page. This class is intended for use in the
* link to a home page. This class is intended for use in the * KAboutData class, but it can be used elsewhere as well. Normally you should at least define the
* KAboutData class, but it can be used elsewhere as well. * person's name. KAboutData methods KAboutData::authors() and KAboutData::credits() return lists
* Normally you should at least define the person's name. * of KAboutPerson data objects which you can examine.
* Creating a KAboutPerson object by yourself is relatively useless,
* but the KAboutData methods KAboutData::authors() and KAboutData::credits()
* return lists of KAboutPerson data objects which you can examine.
* *
* Example usage within a main(), retrieving the list of people involved * Example usage within a main(), retrieving the list of people involved with a program and
* with a program and re-using data from one of them: * re-using data from one of them:
* *
* @code * @code
* KAboutData about("khello", "khello", ki18n("KHello"), "0.1", * KAboutData about("khello", "khello", ki18n("KHello"), "0.1",
@ -58,8 +56,6 @@ class KAboutData;
* calls are used to produce KLocalizedStrings, which can delay the translation * calls are used to produce KLocalizedStrings, which can delay the translation
* lookup. This is necessary because the translation catalogs are usually not * lookup. This is necessary because the translation catalogs are usually not
* yet initialized at the point where KAboutData is constructed. * yet initialized at the point where KAboutData is constructed.
*
* @bc KDE4
*/ */
class KDECORE_EXPORT KAboutPerson class KDECORE_EXPORT KAboutPerson
{ {
@ -69,58 +65,53 @@ public:
* Convenience constructor * Convenience constructor
* *
* @param name The name of the person. * @param name The name of the person.
*
* @param task The task of this person. * @param task The task of this person.
*
* @param emailAddress The email address of the person. * @param emailAddress The email address of the person.
*
* @param webAddress Home page of the person. * @param webAddress Home page of the person.
*/ */
explicit KAboutPerson( const KLocalizedString &name, explicit KAboutPerson(const KLocalizedString &name,
const KLocalizedString &task = KLocalizedString(), const KLocalizedString &task = KLocalizedString(),
const QByteArray &emailAddress = QByteArray(), const QByteArray &emailAddress = QByteArray(),
const QByteArray &webAddress = QByteArray() ); const QByteArray &webAddress = QByteArray());
/** /**
* Copy constructor. Performs a deep copy. * Copy constructor. Performs a deep copy.
* @param other object to copy * @param other object to copy
*/ */
KAboutPerson(const KAboutPerson& other); KAboutPerson(const KAboutPerson &other);
~KAboutPerson(); ~KAboutPerson();
/** /**
* Assignment operator. Performs a deep copy. * Assignment operator. Performs a deep copy.
* @param other object to copy * @param other object to copy
*/ */
KAboutPerson& operator=(const KAboutPerson& other); KAboutPerson& operator=(const KAboutPerson &other);
/** /**
* The person's name * The person's name
* @return the person's name (can be QString(), if it has been * @return the person's name (can be QString(), if it has been constructed with an empty name)
* constructed with an empty name)
*/ */
QString name() const; QString name() const;
/** /**
* The person's task * The person's task
* @return the person's task (can be QString(), if it has been * @return the person's task (can be QString(), if it has been constructed with an empty task)
* constructed with an empty task)
*/ */
QString task() const; QString task() const;
/** /**
* The person's email address * The person's email address
* @return the person's email address (can be QString(), if it has been * @return the person's email address (can be QString(), if it has been constructed with an
* constructed with an empty email) * empty email)
*/ */
QString emailAddress() const; QString emailAddress() const;
/** /**
* The home page or a relevant link * The home page or a relevant link
* @return the persons home page (can be QString(), if it has been * @return the persons home page (can be QString(), if it has been constructed with an empty
* constructed with an empty home page) * home page)
*/ */
QString webAddress() const; QString webAddress() const;
@ -128,207 +119,170 @@ private:
/** /**
* @internal Used by KAboutData to construct translator data. * @internal Used by KAboutData to construct translator data.
*/ */
explicit KAboutPerson( const QString &name, const QString &email ); explicit KAboutPerson(const QString &name, const QString &email);
class Private; class Private;
Private *const d; Private *const d;
}; };
class KAboutLicense;
// KDE5: refactor together with KComponentData.
// Like changing all property names which contain Program or App.
/** /**
* This class is used to store information about a program. It can store * This class is used to store information about a program. It can store such values as version
* such values as version number, program name, home page, email address * number, program name, home page, email address for bug reporting, multiple authors and
* for bug reporting, multiple authors and contributors * contributors (using KAboutPerson), license and copyright information.
* (using KAboutPerson), license and copyright information.
* *
* Currently, the values set here are shown by the "About" box (see * Currently, the values set here are shown by the "About" box (see KAboutDialog), and by the help
* KAboutDialog), and by the help shown on command line (see KCmdLineArgs). * shown on command line (see KCmdLineArgs). They are also used for the icon and the name of the
* They are also used for the icon and the name of the program's windows. * program's windows.
* *
* @note Instead of the more usual i18n calls, for translatable text the ki18n * @note Instead of the more usual i18n calls, for translatable text the ki18n calls are used to
* calls are used to produce KLocalizedStrings, which can delay the translation * produce KLocalizedStrings, which can delay the translation lookup. This is necessary because the
* lookup. This is necessary because the translation catalogs are usually not * translation catalogs are usually not yet initialized at the point where KAboutData is
* yet initialized at the point where KAboutData is constructed. * constructed.
* *
* @short Holds information needed by the "About" box and other * @short Holds information needed by the "About" box and other classes.
* classes.
* @author Espen Sand (espen@kde.org), David Faure (faure@kde.org) * @author Espen Sand (espen@kde.org), David Faure (faure@kde.org)
*/ */
class KDECORE_EXPORT KAboutData class KDECORE_EXPORT KAboutData
{ {
public: public:
/** /**
* Describes the license of the software. * Describes the license of the software.
*/ */
enum LicenseKey // KDE5: move to KAboutLicense, cut License_ prefix enum LicenseKey // KDE5: move to KAboutLicense
{ {
License_Unknown = 0, License_Unknown = 0,
License_GPL = 1, License_GPL = 1,
License_GPL_V2 = 1, License_GPL_V2 = 1,
License_LGPL = 2, License_LGPL = 2,
License_LGPL_V2 = 2, License_LGPL_V2 = 2,
License_BSD = 3, License_BSD = 3,
License_Artistic = 4, License_Artistic = 4,
License_GPL_V3 = 5, License_GPL_V3 = 5,
License_LGPL_V3 = 6 License_LGPL_V3 = 6
}; };
/** /**
* Format of the license name. * Format of the license name.
*/ */
enum NameFormat // KDE5: move to KAboutLicense enum NameFormat // KDE5: move to KAboutLicense
{ {
ShortName, ShortName,
FullName FullName
}; };
public:
/** /**
* Constructor. * Constructor.
* *
* @param appName The program name used internally. Example: "kedit" * @param appName The program name used internally. Example: "kedit"
* * @param catalogName The translation catalog name; if null or empty, the @p appName will be
* @param catalogName The translation catalog name; if null or empty, the * used. You may want the catalog name to differ from program name, for example, when
* @p appName will be used. You may want the catalog name to * you want to group translations of several smaller utilities under the same catalog.
* differ from program name, for example, when you want to group * @param programName A displayable program name string. This string should be marked for
* translations of several smaller utilities under the same catalog. * translation. Example: ki18n("KEdit")
*
* @param programName A displayable program name string. This string
* should be marked for translation. Example: ki18n("KEdit")
*
* @param version The program version string. * @param version The program version string.
* * @param shortDescription A short description of what the program does. This string should be
* @param shortDescription A short description of what the program does. * marked for translation. Example: ki18n("A simple text editor.")
* This string should be marked for translation.
* Example: ki18n("A simple text editor.")
*
* @param licenseType The license identifier. * @param licenseType The license identifier.
*
* @param copyrightStatement A copyright statement, that can look like this: * @param copyrightStatement A copyright statement, that can look like this:
* ki18n("Copyright (C) 1999-2000 Name"). The string specified here is * ki18n("Copyright (C) 1999-2000 Name"). The string specified here is taken verbatim,
* taken verbatim; the author information from addAuthor is not used. * the author information from addAuthor is not used.
*/ */
KAboutData( const QByteArray &appName, KAboutData(const QByteArray &appName,
const QByteArray &catalogName, const QByteArray &catalogName,
const KLocalizedString &programName, const KLocalizedString &programName,
const QByteArray &version, const QByteArray &version,
const KLocalizedString &shortDescription = KLocalizedString(), const KLocalizedString &shortDescription = KLocalizedString(),
enum LicenseKey licenseType = License_Unknown, enum LicenseKey licenseType = License_Unknown,
const KLocalizedString &copyrightStatement = KLocalizedString() const KLocalizedString &copyrightStatement = KLocalizedString());
);
/** /**
* Copy constructor. Performs a deep copy. * Copy constructor. Performs a deep copy.
* @param other object to copy * @param other object to copy
*/ */
KAboutData(const KAboutData& other); KAboutData(const KAboutData &other);
/** /**
* Assignment operator. Performs a deep copy. * Assignment operator. Performs a deep copy.
* @param other object to copy * @param other object to copy
*/ */
KAboutData& operator=(const KAboutData& other); KAboutData& operator=(const KAboutData &other);
~KAboutData(); ~KAboutData();
/** /**
* Defines an author. * Defines an author.
* *
* You can call this function as many times as you need. Each entry is * You can call this function as many times as you need. Each entry is appended to a list. The
* appended to a list. The person in the first entry is assumed to be * person in the first entry is assumed to be the leader of the project.
* the leader of the project.
*
* @param name The developer's name. It should be marked for translation
* like this: ki18n("Developer Name")
*
* @param task What the person is responsible for. This text can contain
* newlines. It should be marked for translation like this:
* ki18n("Task description..."). Can be left empty.
*
* @param emailAddress An Email address where the person can be reached.
* Can be left empty.
*
* @param webAddress The person's homepage or a relevant link.
* Start the address with "http://". "http://some.domain" is
* correct, "some.domain" is not. Can be left empty.
* *
* @param name The developer's name. It should be marked for translation like this:
* ki18n("Developer Name")
* @param task What the person is responsible for. This text can contain newlines. It should be
* marked for translation like this: ki18n("Task description..."). Can be left empty.
* @param emailAddress An Email address where the person can be reached. Can be left empty.
* @param webAddress The person's homepage or a relevant link. Start the address with
* "http://". "http://some.domain" is correct, "some.domain" is not. Can be left empty.
*/ */
KAboutData &addAuthor( const KLocalizedString &name, KAboutData& addAuthor(const KLocalizedString &name,
const KLocalizedString &task = KLocalizedString(), const KLocalizedString &task = KLocalizedString(),
const QByteArray &emailAddress = QByteArray(), const QByteArray &emailAddress = QByteArray(),
const QByteArray &webAddress = QByteArray() ); const QByteArray &webAddress = QByteArray());
/** /**
* Defines a person that deserves credit. * Defines a person that deserves credit.
* *
* You can call this function as many times as you need. Each entry * You can call this function as many times as you need. Each entry is appended to a list.
* is appended to a list.
*
* @param name The person's name. It should be marked for translation
* like this: ki18n("Contributor Name")
*
* @param task What the person has done to deserve the honor. The
* text can contain newlines. It should be marked for
* translation like this: ki18n("Task description...")
* Can be left empty.
*
* @param emailAddress An email address when the person can be reached.
* Can be left empty.
*
* @param webAddress The person's homepage or a relevant link.
* Start the address with "http://". "http://some.domain" is
* is correct, "some.domain" is not. Can be left empty.
* *
* @param name The person's name. It should be marked for translation like this:
* ki18n("Contributor Name")
* @param task What the person has done to deserve the honor. The text can contain newlines.
* It should be marked for translation like this: ki18n("Task description..."). Can be
* left empty.
* @param emailAddress An email address when the person can be reached. Can be left empty.
* @param webAddress The person's homepage or a relevant link. Start the address with
* "http://". "http://some.domain" is correct, "some.domain" is not. Can be left empty.
*/ */
KAboutData &addCredit( const KLocalizedString &name, KAboutData& addCredit(const KLocalizedString &name,
const KLocalizedString &task = KLocalizedString(), const KLocalizedString &task = KLocalizedString(),
const QByteArray &emailAddress = QByteArray(), const QByteArray &emailAddress = QByteArray(),
const QByteArray &webAddress = QByteArray() ); const QByteArray &webAddress = QByteArray());
/** /**
* @brief Sets the name(s) of the translator(s) of the GUI. * @brief Sets the name(s) of the translator(s) of the GUI.
* *
* Since this depends on the language, just use a dummy text marked for * Since this depends on the language, just use a dummy text marked for translation. The
* translation. * canonical use is:
*
* The canonical use is:
* *
* \code * \code
* setTranslator(ki18nc("NAME OF TRANSLATORS", "Your names"), * setTranslator(ki18nc("NAME OF TRANSLATORS", "Your names"),
* ki18nc("EMAIL OF TRANSLATORS", "Your emails")); * ki18nc("EMAIL OF TRANSLATORS", "Your emails"));
* \endcode * \endcode
* *
* The translator can then translate this dummy text with his name * The translator can then translate this dummy text with his name or with a list of names
* or with a list of names separated with ",". * separated with ",". If there is no translation or the application is used with the default
* If there is no translation or the application is used with the * language, this function call is ignored.
* default language, this function call is ignored.
* *
* @param name the name(s) of the translator(s) * @param name the name(s) of the translator(s)
* @param emailAddress the email address(es) of the translator(s) * @param emailAddress the email address(es) of the translator(s)
* @see KAboutTranslator * @see KAboutTranslator
*/ */
KAboutData &setTranslator( const KLocalizedString& name, KAboutData& setTranslator(const KLocalizedString &name,
const KLocalizedString& emailAddress ); const KLocalizedString &emailAddress);
/** /**
* Defines the program name used internally. * Defines the program name used internally.
* *
* @param appName The application name. Example: "kate". * @param appName The application name. Example: "kate".
*/ */
KAboutData &setAppName( const QByteArray &appName ); KAboutData& setAppName(const QByteArray &appName);
/** /**
* Defines the displayable program name string. * Defines the displayable program name string.
* *
* @param programName The program name. This string should be * @param programName The program name. This string should be marked for translation. Example:
* marked for translation. * ki18n("Advanced Text Editor").
* Example: ki18n("Advanced Text Editor").
*/ */
KAboutData &setProgramName( const KLocalizedString &programName ); KAboutData &setProgramName(const KLocalizedString &programName);
/** /**
* Defines the program icon. * Defines the program icon.
@ -340,30 +294,30 @@ class KDECORE_EXPORT KAboutData
* @see programIconName() * @see programIconName()
* @since 4.1 * @since 4.1
*/ */
KAboutData &setProgramIconName( const QString &iconName ); KAboutData& setProgramIconName(const QString &iconName);
/** /**
* Defines the program version string. * Defines the program version string.
* *
* @param version The program version. * @param version The program version.
*/ */
KAboutData &setVersion( const QByteArray &version ); KAboutData& setVersion(const QByteArray &version);
/** /**
* Defines a short description of what the program does. * Defines a short description of what the program does.
* *
* @param shortDescription The program description. This string should * @param shortDescription The program description. This string should be marked for
* be marked for translation. Example: ki18n("An advanced text * translation. Example: ki18n("An advanced text editor with syntax highlighting
* editor with syntax highlighting support."). * support.").
*/ */
KAboutData &setShortDescription( const KLocalizedString &shortDescription ); KAboutData& setShortDescription(const KLocalizedString &shortDescription);
/** /**
* Defines the translation catalog that the program uses. * Defines the translation catalog that the program uses.
* *
* @param catalogName The translation catalog name. * @param catalogName The translation catalog name.
*/ */
KAboutData &setCatalogName( const QByteArray &catalogName ); KAboutData& setCatalogName(const QByteArray &catalogName);
/** /**
* Defines the license identifier. * Defines the license identifier.
@ -371,63 +325,61 @@ class KDECORE_EXPORT KAboutData
* @param licenseKey The license identifier. * @param licenseKey The license identifier.
* @see addLicense * @see addLicense
*/ */
KAboutData &setLicense( LicenseKey licenseKey ); KAboutData& setLicense(LicenseKey licenseKey);
/** /**
* Adds a license identifier. * Adds a license identifier.
* *
* If there is only one unknown license set, e.g. by using the default * If there is only one unknown license set, e.g. by using the default parameter in the
* parameter in the constructor, that one is replaced. * constructor, that one is replaced.
* *
* @param licenseKey The license identifier. * @param licenseKey The license identifier.
* @since 4.1 * @since 4.1
*/ */
KAboutData &addLicense( LicenseKey licenseKey ); KAboutData& addLicense(LicenseKey licenseKey);
/** /**
* Defines the copyright statement to show when displaying the license. * Defines the copyright statement to show when displaying the license.
* *
* @param copyrightStatement A copyright statement, that can look like * @param copyrightStatement A copyright statement, that can look like this:
* this: ki18n("Copyright (C) 1999-2000 Name"). The string specified here is * ki18n("Copyright (C) 1999-2000 Name"). The string specified here is taken verbatim,
* taken verbatim; the author information from addAuthor is not used. * the author information from addAuthor is not used.
*/ */
KAboutData &setCopyrightStatement( const KLocalizedString &copyrightStatement ); KAboutData& setCopyrightStatement(const KLocalizedString &copyrightStatement);
/** /**
* Defines the program homepage. * Defines the program homepage.
* *
* @param homepage The program homepage string. * @param homepage The program homepage string. Start the address with "http://".
* Start the address with "http://". "http://kate.kde.org" * "http://kate.kde.org" is correct but "kate.kde.org" is not. This defaults to the KDE
* is correct but "kate.kde.org" is not. * homepage address.
*/ */
KAboutData &setHomepage( const QByteArray &homepage ); KAboutData& setHomepage(const QByteArray &homepage);
/** /**
* Defines the address where bug reports should be sent. * Defines the address where bug reports should be sent.
* *
* @param bugAddress The bug report email address string. * @param bugAddress The bug report email address string. This defaults to the KDE bug system
* This defaults to the kde.org bug system. * address.
*/ */
KAboutData &setBugAddress( const QByteArray &bugAddress ); KAboutData &setBugAddress(const QByteArray &bugAddress);
/** /**
* Defines the Internet domain of the organization that wrote this application. * Defines the Internet domain of the organization that wrote this application. The domain is
* The domain is set to kde.org by default, or the domain of the homePageAddress constructor argument, * set to kde.org by default, or the domain of the homePageAddress constructor argument, if
* if set. * set.
* *
* Make sure to call setOrganizationDomain if your product is developed out of the * Make sure to call setOrganizationDomain if your product is developed out of the kde.org
* kde.org version-control system. * version-control system.
* *
* Used by the automatic registration to D-Bus done by KApplication and KUniqueApplication. * Used by the automatic registration to D-Bus done by KApplication and KUniqueApplication.
* *
* IMPORTANT: if the organization domain is set, the .desktop file that describes your * IMPORTANT: if the organization domain is set, the .desktop file that describes your
* application should have an entry like X-DBUS-ServiceName=reversed_domain.kmyapp * application should have an entry like X-DBUS-ServiceName=reversed_domain.kmyapp.
* For instance kwrite passes "http://www.kate-editor.org" as the homePageAddress so it needs
* X-DBUS-ServiceName=org.kate-editor.kwrite in its kwrite.desktop file.
* *
* @param domain the domain name, for instance kde.org, koffice.org, kdevelop.org, etc. * @param domain the domain name, for instance kde.org, koffice.org, kdevelop.org, etc.
*/ */
KAboutData &setOrganizationDomain( const QByteArray &domain ); KAboutData& setOrganizationDomain(const QByteArray &domain);
/** /**
* Returns the application's internal name. * Returns the application's internal name.
@ -451,9 +403,8 @@ class KDECORE_EXPORT KAboutData
/** /**
* Returns the program's icon name. * Returns the program's icon name.
* *
* The default value is appName(). * The default value is appName(). Use setProgramIconName() if you need to have an icon whose
* Use setProgramIconName() if you need to have an icon * name is different from the internal application name.
* whose name is different from the internal application name.
* *
* @return the program's icon name. * @return the program's icon name.
* @see setProgramIconName() * @see setProgramIconName()
@ -469,8 +420,7 @@ class KDECORE_EXPORT KAboutData
/** /**
* Returns a short, translated description. * Returns a short, translated description.
* @return the short description (translated). Can be * @return the short description (translated). Can be QString() if not set.
* QString() if not set.
*/ */
QString shortDescription() const; QString shortDescription() const;
@ -482,8 +432,7 @@ class KDECORE_EXPORT KAboutData
/** /**
* Returns the application homepage. * Returns the application homepage.
* @return the application homepage URL. Can be QString() if * @return the application homepage URL. Can be QString() if not set.
* not set.
*/ */
QString homepage() const; QString homepage() const;
@ -518,12 +467,11 @@ class KDECORE_EXPORT KAboutData
static QString aboutTranslationTeam(); static QString aboutTranslationTeam();
/** /**
* Returns the license. If the licenseType argument of the constructor has been * Returns the license. If the licenseType argument of the constructor has been used, any text
* used, any text defined by setLicenseText is ignored, * defined by setLicenseText is ignored, and the standard text for the chosen license will be
* and the standard text for the chosen license will be returned. * returned.
* *
* @return The license text. * @return The license text.
*
* @deprecated There could be multiple licenses, use licenses() instead. * @deprecated There could be multiple licenses, use licenses() instead.
*/ */
QString license() const; QString license() const;
@ -532,7 +480,6 @@ class KDECORE_EXPORT KAboutData
* Returns the license name. * Returns the license name.
* *
* @return The license name as a string. * @return The license name as a string.
*
* @deprecated There could be multiple licenses, use licenses() instead. * @deprecated There could be multiple licenses, use licenses() instead.
*/ */
QString licenseName(NameFormat formatName) const; QString licenseName(NameFormat formatName) const;
@ -551,8 +498,7 @@ class KDECORE_EXPORT KAboutData
*/ */
QString copyrightStatement() const; QString copyrightStatement() const;
private: private:
class Private; class Private;
Private *const d; Private *const d;
}; };
@ -560,18 +506,17 @@ class KDECORE_EXPORT KAboutData
/** /**
* This class is used to store information about a license. * This class is used to store information about a license.
* The license can be one of some predefined, one given as text or one
* that can be loaded from a file. This class is used in the KAboutData class.
* Explicitly creating a KAboutLicense object is not possible.
* If the license is wanted for a KDE component having KAboutData object,
* use KAboutData::licenses() to get the licenses for that component.
* If the license is for a non-code resource and given by a keyword
* (e.g. in .desktop files), try using KAboutLicense::byKeyword().
* *
* @note Instead of the more usual i18n calls, for translatable text the ki18n * The license can be one of the predefined or unknown. This class is used in the KAboutData class.
* calls are used to produce KLocalizedStrings, which can delay the translation * Explicitly creating a KAboutLicense object is not possible. If the license is wanted for a KDE
* lookup. This is necessary because the translation catalogs are usually not * component having KAboutData object, use KAboutData::licenses() to get the licenses for that
* yet initialized at the point where KAboutData is constructed. * component. If the license is for a non-code resource and given by a keyword (e.g. in .desktop
* files), try using KAboutLicense::byKeyword().
*
* @note Instead of the more usual i18n calls, for translatable text the ki18n calls are used to
* produce KLocalizedStrings, which can delay the translation lookup. This is necessary because the
* translation catalogs are usually not yet initialized at the point where KAboutData is
* constructed.
*/ */
class KDECORE_EXPORT KAboutLicense class KDECORE_EXPORT KAboutLicense
{ {
@ -581,7 +526,7 @@ public:
* Copy constructor. Performs a deep copy. * Copy constructor. Performs a deep copy.
* @param other object to copy * @param other object to copy
*/ */
KAboutLicense(const KAboutLicense& other); KAboutLicense(const KAboutLicense &other);
~KAboutLicense(); ~KAboutLicense();
@ -589,13 +534,12 @@ public:
* Assignment operator. Performs a deep copy. * Assignment operator. Performs a deep copy.
* @param other object to copy * @param other object to copy
*/ */
KAboutLicense& operator=(const KAboutLicense& other); KAboutLicense& operator=(const KAboutLicense &other);
/** /**
* Returns the full license text. If the licenseType argument of the * Returns the full license text. If the licenseType argument of the constructor has been used
* constructor has been used and the standard text for the chosen * and the standard text for the chosen license will be returned.
* license will be returned.
* *
* @return The license text. * @return The license text.
*/ */
@ -619,21 +563,18 @@ public:
/** /**
* Fetch a known license by a keyword. * Fetch a known license by a keyword.
* *
* Frequently the license data is provided by a terse keyword-like string, * Frequently the license data is provided by a terse keyword-like string, e.g. by a field in a
* e.g. by a field in a .desktop file. Using this method, an application * .desktop file. Using this method, an application can get hold of a proper KAboutLicense
* can get hold of a proper KAboutLicense object, providing that the * object, providing that the license is one of the several known to KDE, and use it to present
* license is one of the several known to KDE, and use it to present
* more human-readable information to the user. * more human-readable information to the user.
* *
* Keywords are matched by stripping all whitespace and lowercasing. * Keywords are matched by stripping all whitespace and lowercasing. The known keywords
* The known keywords correspond to the KAboutData::LicenseKey enumeration, * correspond to the KAboutData::LicenseKey enumeration, e.g. any of "LGPLV3", "LGPLv3",
* e.g. any of "LGPLV3", "LGPLv3", "LGPL v3" would match License_LGPL_V3. * "LGPL v3" would match License_LGPL_V3. If there is no match for the keyword, an invalid
* If there is no match for the keyword, an invalid license object is * license object is returned (KAboutData::License_Unknown).
* returned (KAboutData::License_Unknown).
* *
* @param keyword The license keyword. * @param keyword The license keyword.
* @return The license object. * @return The license object.
*
* @see KAboutData::LicenseKey * @see KAboutData::LicenseKey
* @since 4.1 * @since 4.1
*/ */
@ -643,11 +584,10 @@ private:
/** /**
* @internal Used by KAboutData to construct a predefined license. * @internal Used by KAboutData to construct a predefined license.
*/ */
explicit KAboutLicense( enum KAboutData::LicenseKey licenseType, const KAboutData *aboutData ); explicit KAboutLicense(enum KAboutData::LicenseKey licenseType, const KAboutData *aboutData);
class Private; class Private;
QSharedDataPointer<Private> d; QSharedDataPointer<Private> d;
}; };
#endif #endif // KABOUTDATA_H