24 #include <tqptrdict.h>
25 #include <tqwindowdefs.h>
27 #include <tdeglobal.h>
28 #include <tdelocale.h>
39 TQMap<TQString,TQString> mNameMap;
42 static TQPtrDict<EntryPrivate> *d_ptr = 0;
44 static EntryPrivate *d(
const Entry *e)
48 d_ptr =
new TQPtrDict<EntryPrivate>();
49 d_ptr->setAutoDelete(
true);
51 EntryPrivate *ret = d_ptr->find((
void*)e);
54 ret =
new EntryPrivate();
55 d_ptr->replace((
void*)e, ret);
62 return d(
this)->mEmail;
67 d(
this)->mEmail = email;
72 if ( d(
this)->mNameMap.isEmpty() )
return TQString::null;
74 if ( !d(
this)->mNameMap[ lang ].isEmpty() )
return d(
this)->mNameMap[ lang ];
76 TQStringList
langs = TDEGlobal::locale()->languageList();
77 for(TQStringList::Iterator it = langs.begin(); it != langs.end(); ++it)
78 if( !d(
this)->mNameMap[ *it ].isEmpty() )
return d(
this)->mNameMap[ *it ];
80 if ( !d(
this)->mNameMap[ TQString::null ].isEmpty() )
return d(
this)->mNameMap[ TQString::null ];
81 else return *(mSummaryMap.begin());
86 d(
this)->mNameMap.insert( lang, name );
88 if ( mLangs.find( lang ) == mLangs.end() ) mLangs.append( lang );
94 mRelease( 0 ), mReleaseDate( TQDate::currentDate() ), mRating( 0 ),
99 Entry::Entry(
const TQDomElement &e ) :
100 mRelease( 0 ), mRating( 0 ), mDownloads( 0 )
102 parseDomElement( e );
109 EntryPrivate *p = d_ptr->find(
this);
113 if (d_ptr->isEmpty())
168 mSummaryMap.insert( lang, text );
170 if ( mLangs.find( lang ) == mLangs.end() ) mLangs.append( lang );
175 if ( mSummaryMap.isEmpty() )
return TQString::null;
177 if ( !mSummaryMap[ lang ].isEmpty() )
return mSummaryMap[ lang ];
179 TQStringList
langs = TDEGlobal::locale()->languageList();
180 for(TQStringList::Iterator it = langs.begin(); it != langs.end(); ++it)
181 if( !mSummaryMap[ *it ].isEmpty() )
return mSummaryMap[ *it ];
183 if ( !mSummaryMap[ TQString::null ].isEmpty() )
return mSummaryMap[ TQString::null ];
184 else return *(mSummaryMap.begin());
223 mPayloadMap.insert( lang, url );
225 if ( mLangs.find( lang ) == mLangs.end() ) mLangs.append( lang );
230 KURL
payload = mPayloadMap[ lang ];
231 if ( payload.isEmpty() ) {
232 TQStringList
langs = TDEGlobal::locale()->languageList();
233 for(TQStringList::Iterator it = langs.begin(); it != langs.end(); ++it)
234 if( !mPayloadMap[ *it ].isEmpty() )
return mPayloadMap[ *it ];
236 if ( payload.isEmpty() ) payload = mPayloadMap [ TQString::null ];
237 if ( payload.isEmpty() && !mPayloadMap.isEmpty() ) {
238 payload = *(mPayloadMap.begin());
246 mPreviewMap.insert( lang, url );
248 if ( mLangs.find( lang ) == mLangs.end() ) mLangs.append( lang );
253 KURL
preview = mPreviewMap[ lang ];
254 if ( preview.isEmpty() ) {
255 TQStringList
langs = TDEGlobal::locale()->languageList();
256 for(TQStringList::Iterator it = langs.begin(); it != langs.end(); ++it)
257 if( !mPreviewMap[ *it ].isEmpty() )
return mPreviewMap[ *it ];
259 if ( preview.isEmpty() ) preview = mPreviewMap [ TQString::null ];
260 if ( preview.isEmpty() && !mPreviewMap.isEmpty() ) {
261 preview = *(mPreviewMap.begin());
308 void Entry::parseDomElement(
const TQDomElement &element )
310 if ( element.tagName() !=
"content" )
return;
311 mType = element.attribute(
"type");
315 for( n = element.firstChild(); !n.isNull(); n = n.nextSibling() ) {
316 TQDomElement e = n.toElement();
317 if ( e.tagName() ==
"name" )
319 setName( e.text().stripWhiteSpace(), lang );
320 setName( e.text().stripWhiteSpace() );
322 if ( e.tagName() ==
"personid" ) {
328 if ( e.tagName() ==
"licence" )
setLicence( e.text().stripWhiteSpace() );
329 if ( e.tagName() ==
"description" ) {
330 setSummary( e.text().stripWhiteSpace(), lang );
332 if ( e.tagName() ==
"version" )
setVersion( e.text().stripWhiteSpace() );
334 if ( e.tagName() ==
"created" ) {
335 TQDate date = TQT_TQDATE_OBJECT(TQDate::fromString( e.text().stripWhiteSpace(), Qt::ISODate ));
338 if ( e.tagName() ==
"smallpreviewpic1" ) {
339 setPreview( KURL( e.text().stripWhiteSpace() ), lang );
341 if ( e.tagName() ==
"downloadlink1" ) {
342 setPayload( KURL( e.text().stripWhiteSpace() ), lang );
344 if ( e.tagName() ==
"score" )
setRating( e.text().toInt() );
345 if ( e.tagName() ==
"downloads" )
setDownloads( e.text().toInt() );
350 TQDomElement Entry::createDomElement( TQDomDocument &doc,
351 TQDomElement &parent )
353 TQDomElement entry = doc.createElement(
"content" );
354 entry.setAttribute(
"type", mType);
355 parent.appendChild( entry );
357 addElement( doc, entry,
"language",
langs().first() );
359 addElement( doc, entry,
"name",
name() );
360 addElement( doc, entry,
"personid",
author() );
362 addElement( doc, entry,
"licence",
license() );
363 addElement( doc, entry,
"version",
version() );
365 addElement( doc, entry,
"score", TQString::number(
rating() ) );
366 addElement( doc, entry,
"downloads", TQString::number(
downloads() ) );
368 addElement( doc, entry,
"created",
371 addElement( doc, entry,
"description",
summary() );
372 addElement( doc, entry,
"preview",
preview().url() );
373 addElement( doc, entry,
"payload",
payload().url() );
378 TQDomElement Entry::addElement( TQDomDocument &doc, TQDomElement &parent,
379 const TQString &tag,
const TQString &value )
381 TQDomElement n = doc.createElement( tag );
382 n.appendChild( doc.createTextNode( value ) );
383 parent.appendChild( n );
int downloads()
Retrieve the download count for the object, which has been determined by its hosting sites and thus m...
TQString authorEmail() const
Retrieve the author's email address of the object.
int rating()
Retrieve the rating for the object, which has been determined by its users and thus might change over...
void setRelease(int)
Sets the release number, which is increased for feature-equal objects with the same version number...
KURL preview(const TQString &lang=TQString::null) const
Retrieve the file name of an image containing a preview of the object.
TDENewStuff data entry container.
int release() const
Retrieve the release number of the object.
TQString license() const
Retrieve the license name of the object.
void setAuthor(const TQString &)
Sets the full name of the object's author.
TQString type() const
Retrieve the type of the data object.
void setDownloads(int)
Sets the number of downloads.
void setReleaseDate(const TQDate &)
Sets the release date.
void setVersion(const TQString &)
Sets the version number.
TQStringList langs()
Return the list of languages this object supports.
TQString fullName()
Return the full name for the meta information.
TQString author() const
Retrieve the author's name of the object.
void setType(const TQString &)
Sets the application type, e.g.
TQString name() const
Retrieve the name of the data object.
void setPreview(const KURL &, const TQString &lang=TQString::null)
Sets the object's preview file, if available.
TQString summary(const TQString &lang=TQString::null) const
Retrieve a short description about the object.
void setAuthorEmail(const TQString &)
Sets the email address of the object's author.
void setRating(int)
Sets the rating between 0 (worst) and 10 (best).
KURL payload(const TQString &lang=TQString::null) const
Retrieve the file name of the object.
TQDate releaseDate() const
Retrieve the date of the object's publication.
Handles security releated issues, like signing, verifying.
void setSummary(const TQString &, const TQString &lang=TQString::null)
Sets a short description on what the object is all about.
TQString version() const
Retrieve the version string of the object.
void setName(const TQString &)
Sets the (unique) name for this data object.
void setLicence(const TQString &)
Sets the license (abbreviation) applicable to the object.
void setPayload(const KURL &, const TQString &lang=TQString::null)
Sets the object's file.