Git commit 20f59466923fe3bf1fd0ed5aa4eac85795591c3e by Frank Osterfeld. Committed on 04/03/2012 at 19:41. Pushed by osterfeld into branch 'akregator_port'. Port author listing in formatted article M +37 -0 krss/item.cpp M +2 -0 krss/item.h http://commits.kde.org/kdepimlibs/20f59466923fe3bf1fd0ed5aa4eac85795591c3e diff --git a/krss/item.cpp b/krss/item.cpp index 7bd9077..3672942 100644 --- a/krss/item.cpp +++ b/krss/item.cpp @@ -30,6 +30,9 @@ #include = #include +#include + +#include = #include = @@ -203,6 +206,40 @@ QList Item::authors() const return d->akonadiItem.payload().authors(); } = +static QString authorAsHtml( const Person& p ) { + const QString name =3D Qt::escape( p.name() ); + const QString email =3D Qt::escape( p.email() ); + + if (!email.isEmpty()) { + if (!name.isEmpty()) + return QString::fromLatin1("%2").a= rg( email, name ); + else + return QString::fromLatin1("%1").a= rg( email ); + } + + const QString uri =3D Qt::escape( p.uri() ); + if (!name.isEmpty()) { + if (!uri.isEmpty()) + return QString::fromLatin1("%2").arg( uri= , name ); + else + return Qt::escape( name ); + } + + if ( !uri.isEmpty() ) + return QString::fromLatin1( "%1" ).arg( uri ); + return QString(); + +} + +QString Item::authorsAsHtml() const +{ + const QList authors =3D d->akonadiItem.payload().auth= ors(); + QStringList formatted; + Q_FOREACH( const Person& i, authors ) + formatted +=3D authorAsHtml( i ); + return formatted.join( i18nc("separator for listing multiple authors",= ", ") ); +} + void Item::setAuthors( const QList& authors ) { RssItem payload =3D d->akonadiItem.payload(); diff --git a/krss/item.h b/krss/item.h index 86b55fa..7027607 100644 --- a/krss/item.h +++ b/krss/item.h @@ -192,6 +192,8 @@ public: QList authors() const; void setAuthors( const QList& authors ); = + QString authorsAsHtml() const; + /** * returns the language used in the item's content *