kaboutdata.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include <kaboutdata.h>
00024 #include <kstandarddirs.h>
00025 #include <qfile.h>
00026 #include <qtextstream.h>
00027
00028 QString
00029 KAboutPerson::name() const
00030 {
00031 return QString::fromUtf8(mName);
00032 }
00033
00034 QString
00035 KAboutPerson::task() const
00036 {
00037 if (mTask && *mTask)
00038 return i18n(mTask);
00039 else
00040 return QString::null;
00041 }
00042
00043 QString
00044 KAboutPerson::emailAddress() const
00045 {
00046 return QString::fromUtf8(mEmailAddress);
00047 }
00048
00049
00050 QString
00051 KAboutPerson::webAddress() const
00052 {
00053 return QString::fromUtf8(mWebAddress);
00054 }
00055
00056
00057 KAboutTranslator::KAboutTranslator(const QString & name,
00058 const QString & emailAddress)
00059 {
00060 mName=name;
00061 mEmail=emailAddress;
00062 }
00063
00064 QString KAboutTranslator::name() const
00065 {
00066 return mName;
00067 }
00068
00069 QString KAboutTranslator::emailAddress() const
00070 {
00071 return mEmail;
00072 }
00073
00074 class KAboutDataPrivate
00075 {
00076 public:
00077 KAboutDataPrivate()
00078 : translatorName("_: NAME OF TRANSLATORS\nYour names")
00079 , translatorEmail("_: EMAIL OF TRANSLATORS\nYour emails")
00080 {};
00081 const char *translatorName;
00082 const char *translatorEmail;
00083 const char *productName;
00084 };
00085
00086
00087
00088 KAboutData::KAboutData( const char *appName,
00089 const char *programName,
00090 const char *version,
00091 const char *shortDescription,
00092 int licenseType,
00093 const char *copyrightStatement,
00094 const char *text,
00095 const char *homePageAddress,
00096 const char *bugsEmailAddress
00097 ) :
00098 mProgramName( programName ),
00099 mVersion( version ),
00100 mShortDescription( shortDescription ),
00101 mLicenseKey( licenseType ),
00102 mCopyrightStatement( copyrightStatement ),
00103 mOtherText( text ),
00104 mHomepageAddress( homePageAddress ),
00105 mBugEmailAddress( bugsEmailAddress ),
00106 mLicenseText (0)
00107 {
00108 d = new KAboutDataPrivate;
00109 d->productName = 0;
00110
00111 if( appName ) {
00112 const char *p = strrchr(appName, '/');
00113 if( p )
00114 mAppName = p+1;
00115 else
00116 mAppName = appName;
00117 } else
00118 mAppName = 0;
00119 }
00120
00121 KAboutData::~KAboutData()
00122 {
00123 if (mLicenseKey == License_File)
00124 delete [] mLicenseText;
00125 delete d;
00126 }
00127
00128 void
00129 KAboutData::addAuthor( const char *name, const char *task,
00130 const char *emailAddress, const char *webAddress )
00131 {
00132 mAuthorList.append(KAboutPerson(name,task,emailAddress,webAddress));
00133 }
00134
00135 void
00136 KAboutData::addCredit( const char *name, const char *task,
00137 const char *emailAddress, const char *webAddress )
00138 {
00139 mCreditList.append(KAboutPerson(name,task,emailAddress,webAddress));
00140 }
00141
00142 void
00143 KAboutData::setTranslator( const char *name, const char *emailAddress)
00144 {
00145 d->translatorName=name;
00146 d->translatorEmail=emailAddress;
00147 }
00148
00149 void
00150 KAboutData::setLicenseText( const char *licenseText )
00151 {
00152 mLicenseText = licenseText;
00153 mLicenseKey = License_Custom;
00154 }
00155
00156 void
00157 KAboutData::setLicenseTextFile( const QString &file )
00158 {
00159 mLicenseText = qstrdup(QFile::encodeName(file));
00160 mLicenseKey = License_File;
00161 }
00162
00163 void
00164 KAboutData::setAppName( const char *appName )
00165 {
00166 mAppName = appName;
00167 }
00168
00169 void
00170 KAboutData::setProgramName( const char* programName )
00171 {
00172 mProgramName = programName;
00173 }
00174
00175 void
00176 KAboutData::setVersion( const char* version )
00177 {
00178 mVersion = version;
00179 }
00180
00181 void
00182 KAboutData::setShortDescription( const char *shortDescription )
00183 {
00184 mShortDescription = shortDescription;
00185 }
00186
00187 void
00188 KAboutData::setLicense( LicenseKey licenseKey)
00189 {
00190 mLicenseKey = licenseKey;
00191 }
00192
00193 void
00194 KAboutData::setCopyrightStatement( const char *copyrightStatement )
00195 {
00196 mCopyrightStatement = copyrightStatement;
00197 }
00198
00199 void
00200 KAboutData::setOtherText( const char *otherText )
00201 {
00202 mOtherText = otherText;
00203 }
00204
00205 void
00206 KAboutData::setHomepage( const char *homepage )
00207 {
00208 mHomepageAddress = homepage;
00209 }
00210
00211 void
00212 KAboutData::setBugAddress( const char *bugAddress )
00213 {
00214 mBugEmailAddress = bugAddress;
00215 }
00216
00217 void
00218 KAboutData::setProductName( const char *productName )
00219 {
00220 d->productName = productName;
00221 }
00222
00223 const char *
00224 KAboutData::appName() const
00225 {
00226 return mAppName;
00227 }
00228
00229 const char *
00230 KAboutData::productName() const
00231 {
00232 if (d->productName)
00233 return d->productName;
00234 else
00235 return appName();
00236 }
00237
00238 QString
00239 KAboutData::programName() const
00240 {
00241 if (mProgramName && *mProgramName)
00242 return i18n(mProgramName);
00243 else
00244 return QString::null;
00245 }
00246
00247 QString
00248 KAboutData::version() const
00249 {
00250 return QString::fromLatin1(mVersion);
00251 }
00252
00253 QString
00254 KAboutData::shortDescription() const
00255 {
00256 if (mShortDescription && *mShortDescription)
00257 return i18n(mShortDescription);
00258 else
00259 return QString::null;
00260 }
00261
00262 QString
00263 KAboutData::homepage() const
00264 {
00265 return QString::fromLatin1(mHomepageAddress);
00266 }
00267
00268 QString
00269 KAboutData::bugAddress() const
00270 {
00271 return QString::fromLatin1(mBugEmailAddress);
00272 }
00273
00274 const QValueList<KAboutPerson>
00275 KAboutData::authors() const
00276 {
00277 return mAuthorList;
00278 }
00279
00280 const QValueList<KAboutPerson>
00281 KAboutData::credits() const
00282 {
00283 return mCreditList;
00284 }
00285
00286 const QValueList<KAboutTranslator>
00287 KAboutData::translators() const
00288 {
00289 QValueList<KAboutTranslator> personList;
00290
00291 if(d->translatorName == 0)
00292 return personList;
00293
00294 QStringList nameList;
00295 QStringList emailList;
00296
00297 QString names = i18n(d->translatorName);
00298 if(names != QString::fromUtf8(d->translatorName))
00299 {
00300 nameList = QStringList::split(',',names);
00301 }
00302
00303
00304 if(d->translatorEmail)
00305 {
00306 QString emails = i18n(d->translatorEmail);
00307
00308 if(emails != QString::fromUtf8(d->translatorEmail))
00309 {
00310 emailList = QStringList::split(',',emails,true);
00311 }
00312 }
00313
00314
00315 QStringList::Iterator nit;
00316 QStringList::Iterator eit=emailList.begin();
00317
00318 for(nit = nameList.begin(); nit != nameList.end(); ++nit)
00319 {
00320 QString email;
00321 if(eit != emailList.end())
00322 {
00323 email=*eit;
00324 ++eit;
00325 }
00326
00327 QString name=*nit;
00328
00329 personList.append(KAboutTranslator( name, email));
00330 }
00331
00332 return personList;
00333 }
00334
00335 QString
00336 KAboutData::aboutTranslationTeam()
00337 {
00338 return i18n("replace this with information about your translation team",
00339 "<p>KDE is translated into many languages thanks to the work "
00340 "of the translation teams all over the world.</p>"
00341 "<p>For more information on KDE internationalization "
00342 "visit http://i18n.kde.org</p>");
00343 }
00344
00345 QString
00346 KAboutData::otherText() const
00347 {
00348 if (mOtherText && *mOtherText)
00349 return i18n(mOtherText);
00350 else
00351 return QString::null;
00352 }
00353
00354
00355 QString
00356 KAboutData::license() const
00357 {
00358 QString result;
00359 if (!copyrightStatement().isEmpty())
00360 result = copyrightStatement() + "\n\n";
00361
00362 QString l;
00363 QString f;
00364 switch ( mLicenseKey )
00365 {
00366 case License_File:
00367 f = QFile::decodeName(mLicenseText);
00368 break;
00369 case License_GPL_V2:
00370 l = "GPL v2";
00371 f = locate("data", "LICENSES/GPL_V2");
00372 break;
00373 case License_LGPL_V2:
00374 l = "LGPL v2";
00375 f = locate("data", "LICENSES/LGPL_V2");
00376 break;
00377 case License_BSD:
00378 l = "BSD License";
00379 f = locate("data", "LICENSES/BSD");
00380 break;
00381 case License_Artistic:
00382 l = "Artistic License";
00383 f = locate("data", "LICENSES/ARTISTIC");
00384 break;
00385 case License_QPL_V1_0:
00386 l = "QPL v1.0";
00387 f = locate("data", "LICENSES/QPL_V1.0");
00388 break;
00389 case License_Custom:
00390 if (mLicenseText && *mLicenseText)
00391 return( i18n(mLicenseText) );
00392
00393 default:
00394 result += i18n("No licensing terms for this program have been specified.\n"
00395 "Please check the documentation or the source for any\n"
00396 "licensing terms.\n");
00397 return result;
00398 }
00399
00400 if (!l.isEmpty())
00401 result += i18n("This program is distributed under the terms of the %1.").arg( l );
00402
00403 if (!f.isEmpty())
00404 {
00405 QFile file(f);
00406 if (file.open(IO_ReadOnly))
00407 {
00408 result += '\n';
00409 result += '\n';
00410 QTextStream str(&file);
00411 result += str.read();
00412 }
00413 }
00414
00415 return result;
00416 }
00417
00418 QString
00419 KAboutData::copyrightStatement() const
00420 {
00421 if (mCopyrightStatement && *mCopyrightStatement)
00422 return i18n(mCopyrightStatement);
00423 else
00424 return QString::null;
00425 }
This file is part of the documentation for kdecore Library Version 3.3.2.