# kdecore Library API Documentation

Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Source Files

# kaboutdata.cpp

    00001 /*
    00002  * This file is part of the KDE Libraries
    00003  * Copyright (C) 2000 Espen Sand (espen@kde.org)
    00004  *
    00005  * This library is free software; you can redistribute it and/or
    00006  * modify it under the terms of the GNU Library General Public
    00007  * License as published by the Free Software Foundation; either
    00008  * version 2 of the License, or (at your option) any later version.
    00009  *
    00010  * This library is distributed in the hope that it will be useful,
    00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00013  * Library General Public License for more details.
    00014  *
    00015  * You should have received a copy of the GNU Library General Public License
    00016  * along with this library; see the file COPYING.LIB.  If not, write to
    00017  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    00018  * Boston, MA 02111-1307, USA.
    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 };
    00084
    00085
    00086
    00087 KAboutData::KAboutData( const char *appName,
    00088                         const char *programName,
    00089                         const char *version,
    00090                         const char *shortDescription,
    00091                         int licenseType,
    00092                         const char *copyrightStatement,
    00093                         const char *text,
    00094                         const char *homePageAddress,
    00095                         const char *bugsEmailAddress
    00096                         ) :
    00097   mProgramName( programName ),
    00098   mVersion( version ),
    00099   mShortDescription( shortDescription ),
    00100   mLicenseKey( licenseType ),
    00101   mCopyrightStatement( copyrightStatement ),
    00102   mOtherText( text ),
    00103   mHomepageAddress( homePageAddress ),
    00104   mBugEmailAddress( bugsEmailAddress )
    00105 {
    00106    d = new KAboutDataPrivate;
    00107
    00108    if( appName ) {
    00109      const char *p = strrchr(appName, '/');
    00110      if( p )
    00111          mAppName = p+1;
    00112      else
    00113          mAppName = appName;
    00114    } else
    00115      mAppName = 0;
    00116 }
    00117
    00118 KAboutData::~KAboutData()
    00119 {
    00120     delete d;
    00121 }
    00122
    00123 void
    00124 KAboutData::addAuthor( const char *name, const char *task,
    00125                     const char *emailAddress, const char *webAddress )
    00126 {
    00127   mAuthorList.append(KAboutPerson(name,task,emailAddress,webAddress));
    00128 }
    00129
    00130 void
    00131 KAboutData::addCredit( const char *name, const char *task,
    00132                     const char *emailAddress, const char *webAddress )
    00133 {
    00134   mCreditList.append(KAboutPerson(name,task,emailAddress,webAddress));
    00135 }
    00136
    00137 void
    00138 KAboutData::setTranslator( const char *name, const char *emailAddress)
    00139 {
    00140   d->translatorName=name;
    00141   d->translatorEmail=emailAddress;
    00142 }
    00143
    00144 void
    00145 KAboutData::setLicenseText( const char *licenseText )
    00146 {
    00147   mLicenseText = licenseText;
    00148   mLicenseKey = License_Custom;
    00149 }
    00150
    00151 void
    00152 KAboutData::setLicenseTextFile( const QString &file )
    00153 {
    00154   mLicenseText = qstrdup(QFile::encodeName(file));
    00155   mLicenseKey = License_File;
    00156 }
    00157
    00158
    00159 const char *
    00160 KAboutData::appName() const
    00161 {
    00162    return mAppName;
    00163 }
    00164
    00165 QString
    00166 KAboutData::programName() const
    00167 {
    00168    if (mProgramName && *mProgramName)
    00169       return i18n(mProgramName);
    00170    else
    00171       return QString::null;
    00172 }
    00173
    00174 QString
    00175 KAboutData::version() const
    00176 {
    00177    return QString::fromLatin1(mVersion);
    00178 }
    00179
    00180 QString
    00181 KAboutData::shortDescription() const
    00182 {
    00183    if (mShortDescription && *mShortDescription)
    00184       return i18n(mShortDescription);
    00185    else
    00186       return QString::null;
    00187 }
    00188
    00189 QString
    00190 KAboutData::homepage() const
    00191 {
    00192    return QString::fromLatin1(mHomepageAddress);
    00193 }
    00194
    00195 QString
    00196 KAboutData::bugAddress() const
    00197 {
    00198    return QString::fromLatin1(mBugEmailAddress);
    00199 }
    00200
    00201 const QValueList<KAboutPerson>
    00202 KAboutData::authors() const
    00203 {
    00204    return mAuthorList;
    00205 }
    00206
    00207 const QValueList<KAboutPerson>
    00208 KAboutData::credits() const
    00209 {
    00210    return mCreditList;
    00211 }
    00212
    00213 const QValueList<KAboutTranslator>
    00214 KAboutData::translators() const
    00215 {
    00216     QValueList<KAboutTranslator> personList;
    00217
    00218     if(d->translatorName == 0)
    00219         return personList;
    00220
    00221     QStringList nameList;
    00222     QStringList emailList;
    00223
    00224     QString names = i18n(d->translatorName);
    00225     if(names != QString::fromUtf8(d->translatorName))
    00226     {
    00227         nameList = QStringList::split(',',names);
    00228     }
    00229
    00230
    00231     if(d->translatorEmail)
    00232     {
    00233         QString emails = i18n(d->translatorEmail);
    00234
    00235         if(emails != QString::fromUtf8(d->translatorEmail))
    00236         {
    00237             emailList = QStringList::split(',',emails,true);
    00238         }
    00239     }
    00240
    00241
    00242     QStringList::Iterator nit;
    00243     QStringList::Iterator eit=emailList.begin();
    00244
    00245     for(nit = nameList.begin(); nit != nameList.end(); ++nit)
    00246     {
    00247         QString email;
    00248         if(eit != emailList.end())
    00249         {
    00250             email=*eit;
    00251             ++eit;
    00252         }
    00253
    00254         QString name=*nit;
    00255
    00256         personList.append(KAboutTranslator( name, email));
    00257     }
    00258
    00259     return personList;
    00260 }
    00261
    00262 QString
    00263 KAboutData::aboutTranslationTeam()
    00264 {
    00265     return i18n("replace this with information about your translation team",
    00266             "<p>KDE is translated into many languages thanks to the work "
    00267             "of the translation teams all over the world.</p>"
    00268             "<p>For more information on KDE internationalization "
    00269             "visit http://i18n.kde.org</p>");
    00270 }
    00271
    00272 QString
    00273 KAboutData::otherText() const
    00274 {
    00275    if (mOtherText && *mOtherText)
    00276       return i18n(mOtherText);
    00277    else
    00278       return QString::null;
    00279 }
    00280
    00281
    00282 QString
    00283 KAboutData::license() const
    00284 {
    00285   QString l;
    00286   QString f;
    00287   switch ( mLicenseKey )
    00288   {
    00289     case License_File:
    00290        f = QFile::decodeName(mLicenseText);
    00291        break;
    00292     case License_GPL_V2:
    00293        l = "GPL v2";
    00294        f = locate("data", "LICENSES/GPL_V2");
    00295        break;
    00296     case License_LGPL_V2:
    00297        l = "LGPL v2";
    00298        f = locate("data", "LICENSES/LGPL_V2");
    00299        break;
    00300     case License_BSD:
    00301        l = "BSD License";
    00302        f = locate("data", "LICENSES/BSD");
    00303        break;
    00304     case License_Artistic:
    00305        l = "Artistic License";
    00306        f = locate("data", "LICENSES/ARTISTIC");
    00307        break;
    00308     case License_QPL_V1_0:
    00309        l = "QPL v1.0";
    00310        f = locate("data", "LICENSES/QPL_V1.0");
    00311        break;
    00312     case License_Custom:
    00313        if (mLicenseText && *mLicenseText)
    00314           return( i18n(mLicenseText) );
    00315        // fall through
    00316     default:
    00317        return i18n("No licensing terms for this program have been specified.\n"
    00318                    "Please check the documentation or the source for any\n"
    00319                    "licensing terms.\n");
    00320       }
    00321
    00322   QString result;
    00323   if (!l.isEmpty())
    00324      result = i18n("This program is distributed under the terms of the %1.").arg( l );
    00325
    00326   if (!f.isEmpty())
    00327   {
    00328      QFile file(f);
    00329      if (file.open(IO_ReadOnly))
    00330      {
    00331         result += '\n';
    00332         result += '\n';
    00333         QTextStream str(&file);
    00334         result += str.read();
    00335      }
    00336   }
    00337
    00338   return result;
    00339 }
    00340
    00341 QString
    00342 KAboutData::copyrightStatement() const
    00343 {
    00344   if (mCopyrightStatement && *mCopyrightStatement)
    00345      return i18n(mCopyrightStatement);
    00346   else
    00347      return QString::null;
    00348 }

This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Jan 28 12:46:18 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001