From kde-commits Thu Sep 30 23:26:12 2010 From: Allen Winter Date: Thu, 30 Sep 2010 23:26:12 +0000 To: kde-commits Subject: KDE/kdepimlibs/kcalutils Message-Id: <20100930232614.23B09AC891 () svn ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=128588921730570 SVN commit 1181417 by winterz: forward port: SVN commit 1181412 by winterz: refactor: new method displayViewFormatPerson() to make a generic Person link kolab/issue4483 SVN commit 1181415 by winterz: gee.. displayViewLinkPerson() and displayViewFormatPerson().. and they do almost the same thing. make them one. M +14 -39 incidenceformatter.cpp --- trunk/KDE/kdepimlibs/kcalutils/incidenceformatter.cpp #1181416:1181417 @@ -271,17 +271,14 @@ *******************************************************************/ //@cond PRIVATE -static QString displayViewLinkPerson( const QString &email, const QString &name, - const QString &uid, Attendee::PartStat status ) +static QString displayViewFormatPerson( const QString &email, const QString &name, + const QString &uid, const QString &iconPath ) { // Search for new print name or uid, if needed. QPair s = searchNameAndUid( email, name, uid ); const QString printName = s.first; const QString printUid = s.second; - // Get the icon corresponding to the attendee participation status. - const QString iconPath = attendeeStatusIconPath( status ); - QString personString; if ( !iconPath.isEmpty() ) { personString += "" + " "; @@ -303,36 +300,12 @@ return personString; } -static QString displayViewFormatOrganizer( const QString &email, const QString &name ) +static QString displayViewFormatPerson( const QString &email, const QString &name, + const QString &uid, Attendee::PartStat status ) { - // Search for new print name or uid, if needed. - QPair s = searchNameAndUid( email, name, QString() ); - const QString printName = s.first; - const QString printUid = s.second; - - // Get the icon for organizer - const QString iconPath = - KIconLoader::global()->iconPath( "meeting-organizer", KIconLoader::Small ); - - QString personString; - personString += "" + " "; - - // Make the uid link - if ( !printUid.isEmpty() ) { - personString += htmlAddUidLink( email, printName, printUid ); - } else { - // No UID, just show some text - personString += ( printName.isEmpty() ? email : printName ); + return displayViewFormatPerson( email, name, uid, attendeeStatusIconPath( status ) ); } - // Make the mailto link - if ( !email.isEmpty() ) { - personString += " " + htmlAddMailtoLink( email, printName ); - } - - return personString; -} - static QString displayViewFormatAttendeeRoleList( Incidence::Ptr incidence, Attendee::Role role ) { QString tmpStr; @@ -349,7 +322,7 @@ // skip attendee that is also the organizer continue; } - tmpStr += displayViewLinkPerson( a->email(), a->name(), a->uid(), a->status() ); + tmpStr += displayViewFormatPerson( a->email(), a->name(), a->uid(), a->status() ); if ( !a->delegator().isEmpty() ) { tmpStr += i18n( " (delegated by %1)", a->delegator() ); } @@ -373,11 +346,15 @@ if ( attendeeCount > 1 || ( attendeeCount == 1 && incidence->organizer()->email() != incidence->attendees().first()->email() ) ) { + + QPair s = searchNameAndUid( incidence->organizer()->email(), + incidence->organizer()->name(), + QString() ); tmpStr += ""; tmpStr += "" + i18n( "Organizer:" ) + ""; - tmpStr += "" + - displayViewFormatOrganizer( incidence->organizer()->email(), - incidence->organizer()->name() ) + + const QString iconPath = KIconLoader::global()->iconPath( "organizer", KIconLoader::Small ); + tmpStr += "" + displayViewFormatPerson( incidence->organizer()->email(), + s.first, s.second, iconPath ) + ""; tmpStr += ""; } @@ -477,9 +454,7 @@ QString name_1 = event->customProperty( "KABC", "NAME-1" ); QString email_1= event->customProperty( "KABC", "EMAIL-1" ); - //TODO: add a birthday cake icon. Make a displayViewLinkBirthdayPerson(email,name,uid) - QString tmpStr = displayViewLinkPerson( email_1, name_1, uid_1, Attendee::None ); - + QString tmpStr = displayViewFormatPerson( email_1, name_1, uid_1, QString() ); return tmpStr; }