diff options
-rw-r--r-- | tdecore/tdeaboutdata.cpp | 149 | ||||
-rw-r--r-- | tdecore/tdeaboutdata.h | 106 |
2 files changed, 108 insertions, 147 deletions
diff --git a/tdecore/tdeaboutdata.cpp b/tdecore/tdeaboutdata.cpp index 3a147842a..2e58ed283 100644 --- a/tdecore/tdeaboutdata.cpp +++ b/tdecore/tdeaboutdata.cpp @@ -34,10 +34,7 @@ TDEAboutPerson::name() const TQString TDEAboutPerson::task() const { - if (mTask && *mTask) - return i18n(mTask); - else - return TQString::null; + return i18n(mTask); } TQString @@ -77,76 +74,66 @@ public: TDEAboutDataPrivate() : translatorName("_: NAME OF TRANSLATORS\nYour names") , translatorEmail("_: EMAIL OF TRANSLATORS\nYour emails") - , productName(0) - , programLogo(0) , customAuthorTextEnabled(false) - , mTranslatedProgramName( 0 ) {} - ~TDEAboutDataPrivate() - { - delete programLogo; - delete[] mTranslatedProgramName; - } - const char *translatorName; - const char *translatorEmail; - const char *productName; - TQImage* programLogo; + + TQCString translatorName; + TQCString translatorEmail; + TQCString productName; + TQImage programLogo; TQString customAuthorPlainText, customAuthorRichText; bool customAuthorTextEnabled; - const char *mTranslatedProgramName; + TQCString mTranslatedProgramName; }; -const char *TDEAboutData::defaultBugTracker = "http://bugs.trinitydesktop.org"; - -TDEAboutData::TDEAboutData( const char *appName, - const char *programName, - const char *version, - const char *shortDescription, - int licenseType, - const char *copyrightStatement, - const char *text, - const char *homePageAddress, - const char *bugsEmailAddress - ) : - mProgramName( programName ), - mVersion( version ), - mShortDescription( shortDescription ), - mLicenseKey( licenseType ), - mCopyrightStatement( copyrightStatement ), - mOtherText( text ), - mHomepageAddress( homePageAddress ), - mBugEmailAddress( (bugsEmailAddress!=0)?bugsEmailAddress:defaultBugTracker ), - mLicenseText (0) -{ - d = new TDEAboutDataPrivate; - - if( appName ) { - const char *p = strrchr(appName, '/'); - if( p ) - mAppName = p+1; - else - mAppName = appName; - } else - mAppName = 0; +TQCString TDEAboutData::defaultBugTracker = "http://bugs.trinitydesktop.org"; + +TDEAboutData::TDEAboutData(const char *appName, + const char *programName, + const char *version, + const char *shortDescription, + int licenseType, + const char *copyrightStatement, + const char *text, + const char *homePageAddress, + const char *bugsEmailAddress) + : mProgramName( programName ), + mVersion( version ), + mShortDescription( shortDescription ), + mLicenseKey( licenseType ), + mCopyrightStatement( copyrightStatement ), + mOtherText( text ), + mHomepageAddress( homePageAddress ), + mBugEmailAddress( (bugsEmailAddress != nullptr) ? TQCString(bugsEmailAddress) : TQCString(defaultBugTracker) ), + mLicenseText() +{ + d = new TDEAboutDataPrivate; + + if( appName ) { + const char *p = strrchr(appName, '/'); + if( p ) + mAppName = p+1; + else + mAppName = appName; + } else + mAppName = TQCString(); } TDEAboutData::~TDEAboutData() { - if (mLicenseKey == License_File) - delete [] mLicenseText; delete d; } void TDEAboutData::addAuthor( const char *name, const char *task, - const char *emailAddress, const char *webAddress ) + const char *emailAddress, const char *webAddress ) { mAuthorList.append(TDEAboutPerson(name,task,emailAddress,webAddress)); } void TDEAboutData::addCredit( const char *name, const char *task, - const char *emailAddress, const char *webAddress ) + const char *emailAddress, const char *webAddress ) { mCreditList.append(TDEAboutPerson(name,task,emailAddress,webAddress)); } @@ -242,28 +229,25 @@ TDEAboutData::appName() const const char * TDEAboutData::productName() const { - if (d->productName) - return d->productName; - else - return appName(); + if (!d->productName.isEmpty()) + return d->productName; + else + return appName(); } TQString TDEAboutData::programName() const { - if (mProgramName && *mProgramName) - return i18n(mProgramName); - else - return TQString::null; + return i18n(mProgramName); } const char* TDEAboutData::internalProgramName() const { - if (d->mTranslatedProgramName) - return d->mTranslatedProgramName; - else - return mProgramName; + if (!d->mTranslatedProgramName.isEmpty()) + return d->mTranslatedProgramName; + else + return mProgramName; } // TDECrash should call as few things as possible and should avoid e.g. malloc() @@ -272,8 +256,7 @@ TDEAboutData::internalProgramName() const void TDEAboutData::translateInternalProgramName() const { - delete[] d->mTranslatedProgramName; - d->mTranslatedProgramName = 0; + d->mTranslatedProgramName = TQCString(); if( TDEGlobal::locale() ) d->mTranslatedProgramName = tqstrdup( programName().utf8()); } @@ -281,16 +264,13 @@ TDEAboutData::translateInternalProgramName() const TQImage TDEAboutData::programLogo() const { - return d->programLogo ? (*d->programLogo) : TQImage(); + return d->programLogo; } void TDEAboutData::setProgramLogo(const TQImage& image) { - if (!d->programLogo) - d->programLogo = new TQImage( image ); - else - *d->programLogo = image; + d->programLogo = image; } TQString @@ -302,10 +282,7 @@ TDEAboutData::version() const TQString TDEAboutData::shortDescription() const { - if (mShortDescription && *mShortDescription) - return i18n(mShortDescription); - else - return TQString::null; + return i18n(mShortDescription); } TQString @@ -337,7 +314,7 @@ TDEAboutData::translators() const { TQValueList<TDEAboutTranslator> personList; - if(d->translatorName == 0) + if(d->translatorName.isEmpty()) return personList; TQStringList nameList; @@ -350,7 +327,7 @@ TDEAboutData::translators() const } - if(d->translatorEmail) + if(!d->translatorEmail.isEmpty()) { TQString emails = i18n(d->translatorEmail); @@ -397,10 +374,7 @@ TDEAboutData::aboutTranslationTeam() TQString TDEAboutData::otherText() const { - if (mOtherText && *mOtherText) - return i18n(mOtherText); - else - return TQString::null; + return i18n(mOtherText); } @@ -447,7 +421,7 @@ TDEAboutData::license() const f = locate("data", "LICENSES/QPL_V1.0"); break; case License_Custom: - if (mLicenseText && *mLicenseText) + if (!mLicenseText.isEmpty()) return( i18n(mLicenseText) ); // fall through default: @@ -478,10 +452,7 @@ TDEAboutData::license() const TQString TDEAboutData::copyrightStatement() const { - if (mCopyrightStatement && *mCopyrightStatement) - return i18n(mCopyrightStatement); - else - return TQString::null; + return i18n(mCopyrightStatement); } TQString @@ -501,7 +472,7 @@ TDEAboutData::customAuthorTextEnabled() const { return d->customAuthorTextEnabled; } - + void TDEAboutData::setCustomAuthorText(const TQString &plainText, const TQString &richText) { @@ -510,7 +481,7 @@ TDEAboutData::setCustomAuthorText(const TQString &plainText, const TQString &ric d->customAuthorTextEnabled = true; } - + void TDEAboutData::unsetCustomAuthorText() { diff --git a/tdecore/tdeaboutdata.h b/tdecore/tdeaboutdata.h index 06f193f75..50a520f3a 100644 --- a/tdecore/tdeaboutdata.h +++ b/tdecore/tdeaboutdata.h @@ -27,7 +27,6 @@ #ifndef _TDEABOUTDATA_H_ #define _TDEABOUTDATA_H_ -class TDEAboutPersonPrivate; class TDEAboutDataPrivate; /** @@ -67,19 +66,14 @@ public: * * @param webAddress Home page of the person. */ - TDEAboutPerson( const char *name, const char *task, - const char *emailAddress, const char *webAddress ) + TDEAboutPerson(const char *name = nullptr, const char *task = nullptr, + const char *emailAddress = nullptr, const char *webAddress = nullptr) { mName = name; mTask = task; mEmailAddress = emailAddress; mWebAddress = webAddress; } - /** - * @internal - * Don't use. Required by QValueList - */ - TDEAboutPerson() {} /** * The person's name @@ -109,16 +103,13 @@ public: */ TQString webAddress() const; -private: - const char *mName; - const char *mTask; - const char *mEmailAddress; - const char *mWebAddress; - - TDEAboutPersonPrivate *d; +protected: + TQCString mName; + TQCString mTask; + TQCString mEmailAddress; + TQCString mWebAddress; }; -class TDEAboutTranslatorPrivate; /** * This structure is used to store information about a translator. * It can store the translator's name and an email address. @@ -161,7 +152,6 @@ public: private: TQString mName; TQString mEmail; - TDEAboutTranslatorPrivate* d; }; @@ -237,16 +227,16 @@ class TDECORE_EXPORT TDEAboutData * This defaults to the trinitydesktop.org bug system. * */ - TDEAboutData( const char *appName, - const char *programName, - const char *version, - const char *shortDescription = 0, - int licenseType = License_Unknown, - const char *copyrightStatement = 0, - const char *text = 0, - const char *homePageAddress = 0, - const char *bugsEmailAddress = 0 - ); + TDEAboutData(const char *appName, + const char *programName, + const char *version, + const char *shortDescription = nullptr, + int licenseType = License_Unknown, + const char *copyrightStatement = nullptr, + const char *text = nullptr, + const char *homePageAddress = nullptr, + const char *bugsEmailAddress = nullptr + ); ~TDEAboutData(); @@ -270,9 +260,9 @@ class TDECORE_EXPORT TDEAboutData * */ void addAuthor( const char *name, - const char *task=0, - const char *emailAddress=0, - const char *webAddress=0 ); + const char *task=0, + const char *emailAddress=0, + const char *webAddress=0 ); /** * Defines a person that deserves credit. You can call this function @@ -295,8 +285,8 @@ class TDECORE_EXPORT TDEAboutData */ void addCredit( const char *name, const char *task=0, - const char *emailAddress=0, - const char *webAddress=0 ); + const char *emailAddress=0, + const char *webAddress=0 ); /** * Sets the name of the translator of the gui. Since this depends @@ -354,7 +344,7 @@ class TDECORE_EXPORT TDEAboutData * @param appName The application name. Example: "kate". */ void setAppName( const char *appName ); - + /** * Defines the displayable program name string. * @@ -367,7 +357,7 @@ class TDECORE_EXPORT TDEAboutData /** * Defines the program logo. - * Use this if you need to have application logo + * Use this if you need to have application logo * in AboutData other than application icon. * * @param image logo image. @@ -382,7 +372,7 @@ class TDECORE_EXPORT TDEAboutData * @param version The program version. */ void setVersion( const char* version ); - + /** * Defines a short description of what the program does. * @@ -391,14 +381,14 @@ class TDECORE_EXPORT TDEAboutData * with syntax highlithing support."). */ void setShortDescription( const char *shortDescription ); - + /** * Defines the license identifier. * * @param licenseKey The license identifier. */ void setLicense( LicenseKey licenseKey); - + /** * Defines the copyright statement to show when displaying the license. * @@ -408,7 +398,7 @@ class TDECORE_EXPORT TDEAboutData * is not used. */ void setCopyrightStatement( const char *copyrightStatement ); - + /** * Defines the additional text to show in the about dialog. * @@ -417,7 +407,7 @@ class TDECORE_EXPORT TDEAboutData * should be marked for translation. */ void setOtherText( const char *otherText ); - + /** * Defines the program homepage. * @@ -426,7 +416,7 @@ class TDECORE_EXPORT TDEAboutData * is correct, "kate-editor.org" is not. */ void setHomepage( const char *homepage ); - + /** * Defines the address where bug reports should be sent. * @@ -434,7 +424,7 @@ class TDECORE_EXPORT TDEAboutData * This defaults to the kde.org bug system. */ void setBugAddress( const char *bugAddress ); - + /** * Defines the product name wich will be used in the KBugReport dialog. * By default it's the appName, but you can overwrite it here to provide @@ -455,7 +445,7 @@ class TDECORE_EXPORT TDEAboutData * Returns the application's product name, which will be used in KBugReport * dialog. By default it returns appName(), otherwise the one which is set * with setProductName() - * + * * @return the product name. */ const char *productName() const; @@ -476,8 +466,8 @@ class TDECORE_EXPORT TDEAboutData void translateInternalProgramName() const; /** - * Returns the program logo image. - * @return the program logo data or null image if there is + * Returns the program logo image. + * @return the program logo data or null image if there is * no custom application logo defined. * @since 3.4 */ @@ -513,7 +503,7 @@ class TDECORE_EXPORT TDEAboutData * @return the email address where to report bugs. */ TQString bugAddress() const; - + /** * @internal */ @@ -590,7 +580,7 @@ class TDECORE_EXPORT TDEAboutData * authors. */ bool customAuthorTextEnabled() const; - + /** * Sets the custom text displayed around the list of authors instead * of the default message telling users to send bug reports to bugAddress(). @@ -602,28 +592,28 @@ class TDECORE_EXPORT TDEAboutData * all. Call unsetCustomAuthorText() to revert to the default mesage. */ void setCustomAuthorText(const TQString &plainText, const TQString &richText); - + /** * Clears any custom text displayed around the list of authors and falls * back to the default message telling users to send bug reports to * bugAddress(). */ void unsetCustomAuthorText(); - + private: - const char *mAppName; - const char *mProgramName; - const char *mVersion; - const char *mShortDescription; + TQCString mAppName; + TQCString mProgramName; + TQCString mVersion; + TQCString mShortDescription; int mLicenseKey; - const char *mCopyrightStatement; - const char *mOtherText; - const char *mHomepageAddress; - const char *mBugEmailAddress; + TQCString mCopyrightStatement; + TQCString mOtherText; + TQCString mHomepageAddress; + TQCString mBugEmailAddress; TQValueList<TDEAboutPerson> mAuthorList; TQValueList<TDEAboutPerson> mCreditList; - const char *mLicenseText; - static const char *defaultBugTracker; + TQCString mLicenseText; + static TQCString defaultBugTracker; TDEAboutDataPrivate *d; }; |