mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-23 18:32:49 +00:00
generic: remove unused OCS features
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
f17c006588
commit
4b18326ae5
7 changed files with 13 additions and 592 deletions
|
@ -60,7 +60,6 @@ public:
|
|||
KLocalizedString _task;
|
||||
QString _emailAddress;
|
||||
QString _webAddress;
|
||||
QString _ocsUsername;
|
||||
|
||||
QString _nameNoop;
|
||||
};
|
||||
|
@ -77,20 +76,6 @@ KAboutPerson::KAboutPerson( const KLocalizedString &_name,
|
|||
d->_webAddress = QString::fromUtf8(_webAddress);
|
||||
}
|
||||
|
||||
KAboutPerson::KAboutPerson( const KLocalizedString &_name,
|
||||
const KLocalizedString &_task,
|
||||
const QByteArray &_emailAddress,
|
||||
const QByteArray &_webAddress,
|
||||
const QByteArray &_ocsUsername )
|
||||
: d(new Private)
|
||||
{
|
||||
d->_name = _name;
|
||||
d->_task = _task;
|
||||
d->_emailAddress = QString::fromUtf8(_emailAddress);
|
||||
d->_webAddress = QString::fromUtf8(_webAddress);
|
||||
d->_ocsUsername = QString::fromUtf8( _ocsUsername );
|
||||
}
|
||||
|
||||
KAboutPerson::KAboutPerson( const QString &_name, const QString &_email )
|
||||
: d(new Private)
|
||||
{
|
||||
|
@ -133,11 +118,6 @@ QString KAboutPerson::webAddress() const
|
|||
return d->_webAddress;
|
||||
}
|
||||
|
||||
QString KAboutPerson::ocsUsername() const
|
||||
{
|
||||
return d->_ocsUsername;
|
||||
}
|
||||
|
||||
KAboutPerson &KAboutPerson::operator=(const KAboutPerson& other)
|
||||
{
|
||||
*d = *other.d;
|
||||
|
@ -413,7 +393,6 @@ public:
|
|||
bool customAuthorTextEnabled;
|
||||
|
||||
QString organizationDomain;
|
||||
QByteArray _ocsProviderUrl;
|
||||
|
||||
// Everything dr.konqi needs, we store as utf-8, so we
|
||||
// can just give it a pointer, w/o any allocations.
|
||||
|
@ -510,16 +489,6 @@ KAboutData &KAboutData::addAuthor( const KLocalizedString &name,
|
|||
return *this;
|
||||
}
|
||||
|
||||
KAboutData &KAboutData::addAuthor( const KLocalizedString &name,
|
||||
const KLocalizedString &task,
|
||||
const QByteArray &emailAddress,
|
||||
const QByteArray &webAddress,
|
||||
const QByteArray &ocsUsername )
|
||||
{
|
||||
d->_authorList.append(KAboutPerson(name,task,emailAddress,webAddress,ocsUsername));
|
||||
return *this;
|
||||
}
|
||||
|
||||
KAboutData &KAboutData::addCredit( const KLocalizedString &name,
|
||||
const KLocalizedString &task,
|
||||
const QByteArray &emailAddress,
|
||||
|
@ -529,16 +498,6 @@ KAboutData &KAboutData::addCredit( const KLocalizedString &name,
|
|||
return *this;
|
||||
}
|
||||
|
||||
KAboutData &KAboutData::addCredit( const KLocalizedString &name,
|
||||
const KLocalizedString &task,
|
||||
const QByteArray &emailAddress,
|
||||
const QByteArray &webAddress,
|
||||
const QByteArray &ocsUsername )
|
||||
{
|
||||
d->_creditList.append(KAboutPerson(name,task,emailAddress,webAddress,ocsUsername));
|
||||
return *this;
|
||||
}
|
||||
|
||||
KAboutData &KAboutData::setTranslator( const KLocalizedString& name,
|
||||
const KLocalizedString& emailAddress )
|
||||
{
|
||||
|
@ -596,12 +555,6 @@ KAboutData &KAboutData::setProgramName( const KLocalizedString &_programName )
|
|||
return *this;
|
||||
}
|
||||
|
||||
KAboutData &KAboutData::setOcsProvider(const QByteArray &_ocsProviderUrl )
|
||||
{
|
||||
d->_ocsProviderUrl = _ocsProviderUrl;
|
||||
return *this;
|
||||
}
|
||||
|
||||
KAboutData &KAboutData::setVersion( const QByteArray &_version )
|
||||
{
|
||||
d->_version = _version;
|
||||
|
@ -721,13 +674,6 @@ KAboutData &KAboutData::setProgramLogo(const QVariant& image)
|
|||
return *this;
|
||||
}
|
||||
|
||||
QString KAboutData::ocsProviderUrl() const
|
||||
{
|
||||
if( !d->_ocsProviderUrl.isEmpty() )
|
||||
return QString::fromUtf8( d->_ocsProviderUrl );
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString KAboutData::version() const
|
||||
{
|
||||
return QString::fromUtf8(d->_version);
|
||||
|
|
|
@ -83,25 +83,6 @@ public:
|
|||
const QByteArray &emailAddress = QByteArray(),
|
||||
const QByteArray &webAddress = QByteArray() );
|
||||
|
||||
/**
|
||||
* Convenience constructor with Open Collaboration Services data
|
||||
*
|
||||
* @param name The name of the person.
|
||||
*
|
||||
* @param task The task of this person.
|
||||
*
|
||||
* @param emailAddress The email address of the person.
|
||||
*
|
||||
* @param webAddress Home page of the person.
|
||||
*
|
||||
* @param ocsUsername Open Collaboration Services username of the person.
|
||||
*/
|
||||
explicit KAboutPerson( const KLocalizedString &name,
|
||||
const KLocalizedString &task,
|
||||
const QByteArray &emailAddress,
|
||||
const QByteArray &webAddress,
|
||||
const QByteArray &ocsUsername ); //KDE5: merge into main ctor
|
||||
|
||||
/**
|
||||
* Copy constructor. Performs a deep copy.
|
||||
* @param other object to copy
|
||||
|
@ -145,13 +126,6 @@ public:
|
|||
*/
|
||||
QString webAddress() const;
|
||||
|
||||
/**
|
||||
* The person's Open Collaboration Services username
|
||||
* @return the persons OCS username (can be QString(), if it has been
|
||||
* constructed with an empty username)
|
||||
*/
|
||||
QString ocsUsername() const;
|
||||
|
||||
private:
|
||||
/**
|
||||
* @internal Used by KAboutData to construct translator data.
|
||||
|
@ -313,37 +287,6 @@ class KDECORE_EXPORT KAboutData
|
|||
const QByteArray &emailAddress = QByteArray(),
|
||||
const QByteArray &webAddress = QByteArray() );
|
||||
|
||||
/**
|
||||
* Defines an author.
|
||||
*
|
||||
* You can call this function as many times as you need. Each entry is
|
||||
* appended to a list. The person in the first entry is assumed to be
|
||||
* the leader of the project.
|
||||
*
|
||||
* @param name The developer's name. It should be marked for translation
|
||||
* like this: ki18n("Developer Name")
|
||||
*
|
||||
* @param task What the person is responsible for. This text can contain
|
||||
* newlines. It should be marked for translation like this:
|
||||
* ki18n("Task description..."). Can be left empty.
|
||||
*
|
||||
* @param emailAddress An Email address where the person can be reached.
|
||||
* Can be left empty.
|
||||
*
|
||||
* @param webAddress The person's homepage or a relevant link.
|
||||
* Start the address with "http://". "http://some.domain" is
|
||||
* correct, "some.domain" is not. Can be left empty.
|
||||
*
|
||||
* @param ocsUsername The person's Open Collaboration Services username.
|
||||
* The provider can be optionally specified with @see setOcsProvider.
|
||||
*
|
||||
*/
|
||||
KAboutData &addAuthor( const KLocalizedString &name,
|
||||
const KLocalizedString &task,
|
||||
const QByteArray &emailAddress,
|
||||
const QByteArray &webAddress,
|
||||
const QByteArray &ocsUsername ); //KDE5: merge with addAuthor
|
||||
|
||||
/**
|
||||
* Defines a person that deserves credit.
|
||||
*
|
||||
|
@ -371,37 +314,6 @@ class KDECORE_EXPORT KAboutData
|
|||
const QByteArray &emailAddress = QByteArray(),
|
||||
const QByteArray &webAddress = QByteArray() );
|
||||
|
||||
/**
|
||||
* Defines a person that deserves credit.
|
||||
*
|
||||
* You can call this function as many times as you need. Each entry
|
||||
* is appended to a list.
|
||||
*
|
||||
* @param name The person's name. It should be marked for translation
|
||||
* like this: ki18n("Contributor Name")
|
||||
*
|
||||
* @param task What the person has done to deserve the honor. The
|
||||
* text can contain newlines. It should be marked for
|
||||
* translation like this: ki18n("Task description...")
|
||||
* Can be left empty.
|
||||
*
|
||||
* @param emailAddress An email address when the person can be reached.
|
||||
* Can be left empty.
|
||||
*
|
||||
* @param webAddress The person's homepage or a relevant link.
|
||||
* Start the address with "http://". "http://some.domain" is
|
||||
* is correct, "some.domain" is not. Can be left empty.
|
||||
*
|
||||
* @param ocsUsername The person's Open Collaboration Services username.
|
||||
* The provider can be optionally specified with @see setOcsProvider.
|
||||
*
|
||||
*/
|
||||
KAboutData &addCredit( const KLocalizedString &name,
|
||||
const KLocalizedString &task,
|
||||
const QByteArray &emailAddress,
|
||||
const QByteArray &webAddress,
|
||||
const QByteArray &ocsUsername ); //KDE5: merge with addCredit
|
||||
|
||||
/**
|
||||
* @brief Sets the name(s) of the translator(s) of the GUI.
|
||||
*
|
||||
|
@ -519,20 +431,6 @@ class KDECORE_EXPORT KAboutData
|
|||
*/
|
||||
KAboutData &setProgramLogo(const QVariant& image);
|
||||
|
||||
/**
|
||||
* Specifies an Open Collaboration Services provider by URL.
|
||||
* A provider file must be available for the chosen provider.
|
||||
*
|
||||
* Use this if you need to override the default provider.
|
||||
*
|
||||
* If this method is not used, all the KAboutPerson OCS usernames
|
||||
* will be used with the openDesktop.org entry from the default
|
||||
* provider file.
|
||||
*
|
||||
* @param providerUrl The provider URL as defined in the provider file.
|
||||
*/
|
||||
KAboutData &setOcsProvider( const QByteArray &providerUrl );
|
||||
|
||||
/**
|
||||
* Defines the program version string.
|
||||
*
|
||||
|
@ -685,12 +583,6 @@ class KDECORE_EXPORT KAboutData
|
|||
*/
|
||||
QVariant programLogo() const;
|
||||
|
||||
/**
|
||||
* Returns the chosen Open Collaboration Services provider URL.
|
||||
* @return the provider URL.
|
||||
*/
|
||||
QString ocsProviderUrl() const;
|
||||
|
||||
/**
|
||||
* Returns the program's version.
|
||||
* @return the version string.
|
||||
|
|
|
@ -209,7 +209,6 @@ void KAboutApplicationDialog::Private::init( const KAboutData *ad, Options opt )
|
|||
|
||||
KDEPrivate::KAboutApplicationPersonModel *authorModel =
|
||||
new KDEPrivate::KAboutApplicationPersonModel( aboutData->authors(),
|
||||
aboutData->ocsProviderUrl(),
|
||||
authorWidget );
|
||||
|
||||
KDEPrivate::KAboutApplicationPersonListView *authorView =
|
||||
|
@ -236,7 +235,6 @@ void KAboutApplicationDialog::Private::init( const KAboutData *ad, Options opt )
|
|||
|
||||
KDEPrivate::KAboutApplicationPersonModel *creditModel =
|
||||
new KDEPrivate::KAboutApplicationPersonModel( aboutData->credits(),
|
||||
aboutData->ocsProviderUrl(),
|
||||
creditWidget );
|
||||
|
||||
KDEPrivate::KAboutApplicationPersonListView *creditView =
|
||||
|
@ -263,7 +261,6 @@ void KAboutApplicationDialog::Private::init( const KAboutData *ad, Options opt )
|
|||
|
||||
KDEPrivate::KAboutApplicationPersonModel *translatorModel =
|
||||
new KDEPrivate::KAboutApplicationPersonModel( aboutData->translators(),
|
||||
aboutData->ocsProviderUrl(),
|
||||
translatorWidget );
|
||||
|
||||
KDEPrivate::KAboutApplicationPersonListView *translatorView =
|
||||
|
|
|
@ -33,10 +33,7 @@
|
|||
namespace KDEPrivate
|
||||
{
|
||||
|
||||
static const int AVATAR_HEIGHT = 50;
|
||||
static const int AVATAR_WIDTH = 50;
|
||||
static const int MAIN_LINKS_HEIGHT = 32;
|
||||
static const int SOCIAL_LINKS_HEIGHT = 26;
|
||||
static const int MAX_SOCIAL_LINKS = 9;
|
||||
|
||||
KAboutApplicationPersonListDelegate::KAboutApplicationPersonListDelegate(
|
||||
|
@ -66,26 +63,11 @@ QList< QWidget *> KAboutApplicationPersonListDelegate::createItemWidgets() const
|
|||
mainLinks );
|
||||
homepageAction->setVisible( false );
|
||||
mainLinks->addAction( homepageAction );
|
||||
KAction *visitProfileAction = new KAction( KIcon( "get-hot-new-stuff" ), "", mainLinks );
|
||||
visitProfileAction->setVisible( false );
|
||||
mainLinks->addAction( visitProfileAction );
|
||||
|
||||
list.append( mainLinks );
|
||||
|
||||
|
||||
KToolBar *socialLinks = new KToolBar( itemView(), false, false );
|
||||
for( int i = 0; i < MAX_SOCIAL_LINKS; ++i ) {
|
||||
KAction *action = new KAction( KIcon( "applications-internet" ), "", socialLinks );
|
||||
action->setVisible( false );
|
||||
socialLinks->addAction( action );
|
||||
}
|
||||
|
||||
list.append( socialLinks );
|
||||
|
||||
connect( mainLinks, SIGNAL(actionTriggered(QAction*)),
|
||||
this, SLOT(launchUrl(QAction*)) );
|
||||
connect( socialLinks, SIGNAL(actionTriggered(QAction*)),
|
||||
this, SLOT(launchUrl(QAction*)) );
|
||||
|
||||
return list;
|
||||
}
|
||||
|
@ -115,7 +97,7 @@ void KAboutApplicationPersonListDelegate::updateItemWidgets( const QList<QWidget
|
|||
|
||||
label->setText( text );
|
||||
|
||||
//And now we fill in the main links (email + homepage + OCS profile)...
|
||||
//And now we fill in the main links (email + homepage)...
|
||||
KToolBar *mainLinks = qobject_cast< KToolBar * >( widgets.at( MainLinks ) );
|
||||
mainLinks->setIconSize( QSize( 22, 22 ) );
|
||||
mainLinks->setContentsMargins( 0, 0, 0, 0 );
|
||||
|
@ -134,78 +116,19 @@ void KAboutApplicationPersonListDelegate::updateItemWidgets( const QList<QWidget
|
|||
action->setData( profile.homepage().url() );
|
||||
action->setVisible( true );
|
||||
}
|
||||
if( !profile.ocsProfileUrl().isEmpty() ) {
|
||||
action = qobject_cast< KAction * >( mainLinks->actions().at( VisitProfileAction ) );
|
||||
KAboutApplicationPersonModel *model = qobject_cast< KAboutApplicationPersonModel * >( itemView()->model() );
|
||||
action->setToolTip( i18n( "Visit contributor's profile on %1\n%2",
|
||||
model->providerName(),
|
||||
profile.ocsProfileUrl() ) );
|
||||
action->setData( profile.ocsProfileUrl() );
|
||||
action->setVisible( true );
|
||||
}
|
||||
|
||||
mainLinks->resize( QSize( mainLinks->sizeHint().width(), MAIN_LINKS_HEIGHT ) );
|
||||
mainLinks->move( wRect.left(), wRect.top() + label->height() );
|
||||
|
||||
//Finally, the social links...
|
||||
KToolBar *socialLinks = qobject_cast< KToolBar * >( widgets.at( SocialLinks ) );
|
||||
socialLinks->setIconSize( QSize( 16, 16 ) );
|
||||
socialLinks->setContentsMargins( 0, 0, 0, 0 );
|
||||
socialLinks->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
|
||||
|
||||
int currentSocialLinkAction = 0;
|
||||
foreach( const KAboutApplicationPersonProfileOcsLink &link, profile.ocsLinks() ) {
|
||||
if( !profile.homepage().isEmpty() && profile.homepage() == link.url() )
|
||||
continue; //We skip it if it's the same as the homepage from KAboutData
|
||||
|
||||
action = qobject_cast< KAction * >( socialLinks->actions().at( currentSocialLinkAction ) );
|
||||
if( link.type() == KAboutApplicationPersonProfileOcsLink::Other ) {
|
||||
action->setToolTip( i18n( "Visit contributor's page\n%1",
|
||||
link.url().url() ) );
|
||||
}
|
||||
else if( link.type() == KAboutApplicationPersonProfileOcsLink::Blog ) {
|
||||
action->setToolTip( i18n( "Visit contributor's blog\n%1",
|
||||
link.url().url() ) );
|
||||
}
|
||||
else if( link.type() == KAboutApplicationPersonProfileOcsLink::Homepage ) {
|
||||
action->setToolTip( i18n( "Visit contributor's homepage\n%1",
|
||||
link.url().url() ) );
|
||||
}
|
||||
else {
|
||||
action->setToolTip( i18n( "Visit contributor's profile on %1\n%2",
|
||||
link.prettyType(),
|
||||
link.url().url() ) );
|
||||
}
|
||||
action->setIcon( link.icon() );
|
||||
action->setData( link.url().url() );
|
||||
action->setVisible( true );
|
||||
|
||||
++currentSocialLinkAction;
|
||||
if( currentSocialLinkAction > MAX_SOCIAL_LINKS - 1 )
|
||||
break;
|
||||
}
|
||||
|
||||
socialLinks->resize( QSize( socialLinks->sizeHint().width(), SOCIAL_LINKS_HEIGHT ) );
|
||||
socialLinks->move( wRect.left() + mainLinks->width(),
|
||||
wRect.top() + label->height() +
|
||||
( MAIN_LINKS_HEIGHT - SOCIAL_LINKS_HEIGHT ) / 2 );
|
||||
|
||||
itemView()->reset();
|
||||
}
|
||||
|
||||
QSize KAboutApplicationPersonListDelegate::sizeHint( const QStyleOptionViewItem &option,
|
||||
const QModelIndex &index ) const
|
||||
{
|
||||
KAboutApplicationPersonProfile profile = index.data().value< KAboutApplicationPersonProfile >();
|
||||
bool hasAvatar = !profile.avatar().isNull();
|
||||
int height = widgetsRect( option, index ).height();
|
||||
|
||||
int margin = option.fontMetrics.height() / 2;
|
||||
|
||||
int height = hasAvatar ? qMax( widgetsRect( option, index ).height(),
|
||||
AVATAR_HEIGHT + 2*margin )
|
||||
: widgetsRect( option, index ).height();
|
||||
|
||||
QSize metrics( option.fontMetrics.height() * 7, height );
|
||||
return metrics;
|
||||
return QSize( option.fontMetrics.height() * 7, height );
|
||||
}
|
||||
|
||||
void KAboutApplicationPersonListDelegate::paint( QPainter *painter,
|
||||
|
@ -216,28 +139,6 @@ void KAboutApplicationPersonListDelegate::paint( QPainter *painter,
|
|||
|
||||
QStyle *style = QApplication::style();
|
||||
style->drawPrimitive(QStyle::PE_Widget, &option, painter, 0);
|
||||
|
||||
const KAboutApplicationPersonModel * model = qobject_cast< const KAboutApplicationPersonModel * >(index.model());
|
||||
|
||||
if ( model->hasAvatarPixmaps() ) {
|
||||
int height = qMax( widgetsRect( option, index ).height(), AVATAR_HEIGHT + 2*margin );
|
||||
QPoint point( option.rect.left() + 2 * margin,
|
||||
option.rect.top() + ( (height - AVATAR_HEIGHT) / 2) );
|
||||
|
||||
KAboutApplicationPersonProfile profile = index.data().value< KAboutApplicationPersonProfile >();
|
||||
|
||||
if( !profile.avatar().isNull() ) {
|
||||
QPixmap pixmap = profile.avatar();
|
||||
|
||||
point.setX( ( AVATAR_WIDTH - pixmap.width() ) / 2 + 5 );
|
||||
point.setY( option.rect.top() + ( ( height - pixmap.height() ) / 2 ) );
|
||||
painter->drawPixmap( point, pixmap );
|
||||
|
||||
QPoint framePoint( point.x() - 5, point.y() - 5 );
|
||||
QPixmap framePixmap = QPixmap( KStandardDirs::locate( "data", "kdeui/pics/thumb_frame.png" ) );
|
||||
painter->drawPixmap( framePoint, framePixmap.scaled( pixmap.width() + 10, pixmap.height() + 10 ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void KAboutApplicationPersonListDelegate::launchUrl( QAction *action ) const
|
||||
|
@ -274,10 +175,6 @@ QString KAboutApplicationPersonListDelegate::buildTextForProfile( const KAboutAp
|
|||
text += QLatin1String("</i>");
|
||||
}
|
||||
|
||||
if( !profile.location().isEmpty() ) {
|
||||
text += QLatin1String("\n<br>");
|
||||
text += profile.location();
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
|
@ -287,19 +184,10 @@ QRect KAboutApplicationPersonListDelegate::widgetsRect( const QStyleOptionViewIt
|
|||
KAboutApplicationPersonProfile profile = index.data().value< KAboutApplicationPersonProfile >();
|
||||
int margin = option.fontMetrics.height() / 2;
|
||||
|
||||
QRect widgetsRect;
|
||||
if( qobject_cast< const KAboutApplicationPersonModel * >( index.model() )->hasAvatarPixmaps() ) {
|
||||
widgetsRect = QRect( option.rect.left() + AVATAR_WIDTH + 3 * margin,
|
||||
margin/2,
|
||||
option.rect.width() - AVATAR_WIDTH - 4 * margin,
|
||||
0 );
|
||||
}
|
||||
else {
|
||||
widgetsRect = QRect( option.rect.left() + margin,
|
||||
QRect widgetsRect = QRect( option.rect.left() + margin,
|
||||
margin/2,
|
||||
option.rect.width() - 2*margin,
|
||||
0 );
|
||||
}
|
||||
|
||||
int textHeight = heightForString( buildTextForProfile( profile ), widgetsRect.width() - margin, option );
|
||||
widgetsRect.setHeight( textHeight + MAIN_LINKS_HEIGHT + 1.5*margin );
|
||||
|
|
|
@ -56,15 +56,13 @@ private:
|
|||
enum DelegateWidgets
|
||||
{
|
||||
TextLabel = 0,
|
||||
MainLinks,
|
||||
SocialLinks
|
||||
MainLinks
|
||||
};
|
||||
|
||||
enum MainLinkActions
|
||||
{
|
||||
EmailAction = 0,
|
||||
HomepageAction,
|
||||
VisitProfileAction
|
||||
HomepageAction
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -28,31 +28,20 @@ namespace KDEPrivate
|
|||
{
|
||||
|
||||
KAboutApplicationPersonModel::KAboutApplicationPersonModel( const QList< KAboutPerson > &personList,
|
||||
const QString &providerUrl,
|
||||
QObject *parent )
|
||||
: QAbstractListModel( parent )
|
||||
, m_personList( personList )
|
||||
, m_hasAvatarPixmaps( false )
|
||||
, m_providerUrl( providerUrl )
|
||||
{
|
||||
if( m_providerUrl.isEmpty() )
|
||||
m_providerUrl = QString( "https://api.opendesktop.org/v1/" );
|
||||
|
||||
foreach( const KAboutPerson person, personList )
|
||||
{
|
||||
KAboutApplicationPersonProfile profile =
|
||||
KAboutApplicationPersonProfile( person.name(),
|
||||
person.task(),
|
||||
person.emailAddress(),
|
||||
person.ocsUsername() );
|
||||
person.emailAddress());
|
||||
profile.setHomepage( person.webAddress() );
|
||||
m_profileList.append( profile );
|
||||
}
|
||||
|
||||
m_ocsLinkIcons.insert( KAboutApplicationPersonProfileOcsLink::Other, KIcon( "applications-internet").pixmap( 16 ) );
|
||||
m_ocsLinkIcons.insert( KAboutApplicationPersonProfileOcsLink::Blog, KIcon( "applications-internet" ).pixmap( 16 ) );
|
||||
m_ocsLinkIcons.insert( KAboutApplicationPersonProfileOcsLink::Homepage, KIcon( "applications-internet" ).pixmap( 16 ) );
|
||||
|
||||
}
|
||||
|
||||
int KAboutApplicationPersonModel::rowCount( const QModelIndex &parent ) const
|
||||
|
@ -89,160 +78,6 @@ Qt::ItemFlags KAboutApplicationPersonModel::flags( const QModelIndex &index ) co
|
|||
return QAbstractListModel::flags( index ) | Qt::ItemIsEditable;
|
||||
}
|
||||
|
||||
void KAboutApplicationPersonModel::onProvidersLoaded() //SLOT
|
||||
{
|
||||
}
|
||||
|
||||
void KAboutApplicationPersonModel::onPersonJobFinished( Attica::BaseJob *job ) //SLOT
|
||||
{
|
||||
Q_UNUSED( job )
|
||||
}
|
||||
|
||||
void KAboutApplicationPersonModel::onAvatarJobFinished( QNetworkReply *reply ) //SLOT
|
||||
{
|
||||
Q_UNUSED( reply )
|
||||
}
|
||||
|
||||
void KAboutApplicationPersonModel::fetchOcsLinkIcons( int personProfileListIndex )
|
||||
{
|
||||
KAboutApplicationPersonProfile profile = m_profileList.value( personProfileListIndex );
|
||||
QList< KAboutApplicationPersonProfileOcsLink > ocsLinks = profile.ocsLinks();
|
||||
|
||||
KAboutApplicationPersonIconsJob *job =
|
||||
new KAboutApplicationPersonIconsJob( this, personProfileListIndex );
|
||||
connect( job, SIGNAL(finished(KAboutApplicationPersonIconsJob*)),
|
||||
this, SLOT(onOcsLinksJobFinished(KAboutApplicationPersonIconsJob*)) );
|
||||
job->start();
|
||||
}
|
||||
|
||||
void KAboutApplicationPersonModel::onOcsLinksJobFinished( KAboutApplicationPersonIconsJob *job ) //SLOT
|
||||
{
|
||||
int personProfileListIndex = job->personProfileListIndex();
|
||||
KAboutApplicationPersonProfile profile = m_profileList.value( personProfileListIndex );
|
||||
|
||||
profile.setOcsLinks( job->ocsLinks() );
|
||||
|
||||
m_profileList.replace( personProfileListIndex, profile );
|
||||
|
||||
emit dataChanged( index( personProfileListIndex ), index( personProfileListIndex ) );
|
||||
emit layoutChanged();
|
||||
}
|
||||
|
||||
KAboutApplicationPersonProfileOcsLink::Type KAboutApplicationPersonProfileOcsLink::typeFromAttica( const QString &atticaType )
|
||||
{
|
||||
int index = -1;
|
||||
for( int i = 0; i < NUM_ATTICA_LINK_TYPES; ++i ) {
|
||||
if( atticaType == QString( s_personOcsLinkAtticaTypes[i] ) ) {
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if( index == -1 )
|
||||
return Other;
|
||||
else
|
||||
return static_cast< Type >( index );
|
||||
}
|
||||
|
||||
QString KAboutApplicationPersonProfileOcsLink::prettyType() const
|
||||
{
|
||||
//This can't be static like the other lists because of i18n
|
||||
switch( m_type ) {
|
||||
case Other:
|
||||
return i18nc( "A generic social network or homepage link of an unlisted type.", "Other" );
|
||||
case Blog:
|
||||
return i18nc( "A type of link.", "Blog" );
|
||||
case Delicious:
|
||||
return "Delicious";
|
||||
case Digg:
|
||||
return "Digg";
|
||||
case Facebook:
|
||||
return "Facebook";
|
||||
case Homepage:
|
||||
return i18nc( "A type of link.", "Homepage" );
|
||||
case Identica:
|
||||
return "Identi.ca";
|
||||
case LibreFm:
|
||||
return "Libre.fm";
|
||||
case LinkedIn:
|
||||
return "LinkedIn";
|
||||
case MySpace:
|
||||
return "MySpace";
|
||||
case Reddit:
|
||||
return "Reddit";
|
||||
case StackOverflow:
|
||||
return "Stack Overflow";
|
||||
case Twitter:
|
||||
return "Twitter";
|
||||
case Wikipedia:
|
||||
return "Wikipedia";
|
||||
case Xing:
|
||||
return "Xing";
|
||||
case YouTube:
|
||||
return "YouTube";
|
||||
case NUM_ATTICA_LINK_TYPES: // silence compiler warning
|
||||
break;
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
||||
KAboutApplicationPersonIconsJob::KAboutApplicationPersonIconsJob( KAboutApplicationPersonModel *model,
|
||||
int personProfileListIndex )
|
||||
: QObject( model )
|
||||
, m_personProfileListIndex( personProfileListIndex )
|
||||
, m_model( model )
|
||||
{
|
||||
m_manager = new QNetworkAccessManager( this );
|
||||
connect( m_manager, SIGNAL(finished(QNetworkReply*)),
|
||||
this, SLOT(onJobFinished(QNetworkReply*)) );
|
||||
m_ocsLinks = model->m_profileList.value( personProfileListIndex ).ocsLinks();
|
||||
}
|
||||
|
||||
void KAboutApplicationPersonIconsJob::start()
|
||||
{
|
||||
getIcons( 0 );
|
||||
}
|
||||
|
||||
void KAboutApplicationPersonIconsJob::getIcons( int i )
|
||||
{
|
||||
for( QList< KAboutApplicationPersonProfileOcsLink >::iterator it = m_ocsLinks.begin() + i;
|
||||
it != m_ocsLinks.end(); ++it ) {
|
||||
if( m_model->m_ocsLinkIcons.contains( it->type() ) ) {
|
||||
it->setIcon( m_model->m_ocsLinkIcons.value( it->type() ) );
|
||||
}
|
||||
else if( m_model->m_ocsLinkIconUrls.contains( it->type() ) )
|
||||
{
|
||||
QNetworkReply *reply =
|
||||
m_manager->get( QNetworkRequest( QUrl( m_model->m_ocsLinkIconUrls.value( it->type() ) ) ) );
|
||||
reply->setProperty( "linkIndex", i );
|
||||
return;
|
||||
}
|
||||
++i;
|
||||
}
|
||||
emit finished( this );
|
||||
}
|
||||
|
||||
void KAboutApplicationPersonIconsJob::onJobFinished( QNetworkReply *reply ) //SLOT
|
||||
{
|
||||
int i = reply->property( "linkIndex" ).toInt();
|
||||
KAboutApplicationPersonProfileOcsLink::Type type = m_ocsLinks.at( i ).type();
|
||||
|
||||
if( reply->error() != QNetworkReply::NoError ) {
|
||||
kDebug() << "Could not fetch OCS link icon.";
|
||||
reply->deleteLater();
|
||||
getIcons( i + 1 );
|
||||
return;
|
||||
}
|
||||
QByteArray data = reply->readAll();
|
||||
QPixmap pixmap;
|
||||
pixmap.loadFromData( data );
|
||||
|
||||
if( !pixmap.isNull() && !m_model->m_ocsLinkIcons.contains( type ) ) {
|
||||
m_model->m_ocsLinkIcons.insert( type, pixmap );
|
||||
}
|
||||
reply->deleteLater();
|
||||
getIcons( i );
|
||||
}
|
||||
|
||||
} //namespace KDEPrivate
|
||||
|
||||
#include "moc_kaboutapplicationpersonmodel_p.cpp"
|
||||
|
|
|
@ -36,14 +36,12 @@ namespace KDEPrivate
|
|||
{
|
||||
|
||||
class KAboutApplicationPersonProfile;
|
||||
class KAboutApplicationPersonIconsJob;
|
||||
|
||||
class KAboutApplicationPersonModel : public QAbstractListModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
KAboutApplicationPersonModel( const QList< KAboutPerson > &personList,
|
||||
const QString &providerUrl = QString(),
|
||||
QObject *parent = 0 );
|
||||
|
||||
int rowCount( const QModelIndex &parent = QModelIndex() ) const;
|
||||
|
@ -52,93 +50,9 @@ public:
|
|||
|
||||
Qt::ItemFlags flags( const QModelIndex &index ) const;
|
||||
|
||||
bool hasAvatarPixmaps() const { return m_hasAvatarPixmaps; }
|
||||
|
||||
const QString &providerName() const { return m_providerName; }
|
||||
|
||||
private Q_SLOTS:
|
||||
void onProvidersLoaded();
|
||||
void onPersonJobFinished( Attica::BaseJob *job );
|
||||
void onAvatarJobFinished( QNetworkReply *reply );
|
||||
void onOcsLinksJobFinished( KAboutApplicationPersonIconsJob *job );
|
||||
|
||||
private:
|
||||
void fetchOcsLinkIcons( int personProfileListIndex );
|
||||
|
||||
QList< KAboutPerson > m_personList;
|
||||
QList< KAboutApplicationPersonProfile > m_profileList;
|
||||
|
||||
QMap< int, QString > m_ocsLinkIconUrls;
|
||||
QMap< int, QPixmap > m_ocsLinkIcons;
|
||||
|
||||
bool m_hasAvatarPixmaps;
|
||||
|
||||
QString m_providerUrl;
|
||||
QString m_providerName;
|
||||
|
||||
friend class KAboutApplicationPersonIconsJob;
|
||||
};
|
||||
|
||||
//This list must be in sync with the one in KAboutApplicationPersonProfileOcsLink::prettyType()
|
||||
static const char s_personOcsLinkAtticaTypes[][16] = {
|
||||
{ "other" },
|
||||
{ "Blog" },
|
||||
{ "delicious" },
|
||||
{ "Digg" },
|
||||
{ "Facebook" },
|
||||
{ "Homepage" },
|
||||
{ "identi.ca" },
|
||||
{ "libre.fm" },
|
||||
{ "LinkedIn" },
|
||||
{ "MySpace" },
|
||||
{ "Reddit" },
|
||||
{ "StackOverflow" },
|
||||
{ "Twitter" },
|
||||
{ "Wikipedia" },
|
||||
{ "Xing" },
|
||||
{ "YouTube" } };
|
||||
|
||||
class KAboutApplicationPersonProfileOcsLink
|
||||
{
|
||||
public:
|
||||
enum Type
|
||||
{
|
||||
Other = 0,
|
||||
Blog,
|
||||
Delicious,
|
||||
Digg,
|
||||
Facebook,
|
||||
Homepage,
|
||||
Identica,
|
||||
LibreFm,
|
||||
LinkedIn,
|
||||
MySpace,
|
||||
Reddit,
|
||||
StackOverflow,
|
||||
Twitter,
|
||||
Wikipedia,
|
||||
Xing,
|
||||
YouTube,
|
||||
NUM_ATTICA_LINK_TYPES
|
||||
};
|
||||
|
||||
static Type typeFromAttica( const QString &atticaType );
|
||||
|
||||
KAboutApplicationPersonProfileOcsLink( Type type, const KUrl &url )
|
||||
: m_type( type )
|
||||
, m_url( url )
|
||||
{}
|
||||
|
||||
Type type() const { return m_type; }
|
||||
QString prettyType() const;
|
||||
void setIcon( const QIcon &icon ) { m_icon = icon; }
|
||||
const QIcon &icon() const { return m_icon; }
|
||||
const KUrl & url() const { return m_url; }
|
||||
|
||||
private:
|
||||
Type m_type;
|
||||
KUrl m_url;
|
||||
QIcon m_icon;
|
||||
};
|
||||
|
||||
class KAboutApplicationPersonProfile
|
||||
|
@ -148,77 +62,28 @@ public:
|
|||
: m_name()
|
||||
, m_task()
|
||||
, m_email()
|
||||
, m_ocsUsername() {} //needed for QVariant
|
||||
{} //needed for QVariant
|
||||
|
||||
KAboutApplicationPersonProfile( const QString &name,
|
||||
const QString &task,
|
||||
const QString &email,
|
||||
const QString &ocsUsername = QString() )
|
||||
const QString &email)
|
||||
: m_name( name )
|
||||
, m_task( task )
|
||||
, m_email( email )
|
||||
, m_ocsUsername( ocsUsername )
|
||||
{}
|
||||
|
||||
void setHomepage( const KUrl &url ) { m_homepage = url; }
|
||||
void setAvatar( const QPixmap &pixmap ) { m_avatar = pixmap; }
|
||||
void setLocation( const QString &location ) { m_location = location; }
|
||||
void setOcsProfileUrl( const QString &url ) { m_ocsProfileUrl = url; }
|
||||
void addAdditionalString( const QString &string ) { m_additionalStrings << string; }
|
||||
void setOcsLinks( const QList< KAboutApplicationPersonProfileOcsLink > &ocsLinks )
|
||||
{ m_ocsLinks = ocsLinks; }
|
||||
|
||||
const QString & name() const { return m_name; }
|
||||
const QString & task() const { return m_task; }
|
||||
const QString & email() const { return m_email; }
|
||||
const QString & ocsUsername() const { return m_ocsUsername; }
|
||||
const QString & ocsProfileUrl() const { return m_ocsProfileUrl; }
|
||||
const KUrl & homepage() const { return m_homepage; }
|
||||
const QPixmap & avatar() const { return m_avatar; }
|
||||
const QString & location() const { return m_location; }
|
||||
const QStringList & additionalStrings() const { return m_additionalStrings; }
|
||||
const QList< KAboutApplicationPersonProfileOcsLink > & ocsLinks() const { return m_ocsLinks; }
|
||||
|
||||
private:
|
||||
QString m_name;
|
||||
QString m_task;
|
||||
QString m_email;
|
||||
QString m_ocsUsername;
|
||||
QString m_ocsProfileUrl;
|
||||
KUrl m_homepage;
|
||||
QPixmap m_avatar;
|
||||
QString m_location;
|
||||
QStringList m_additionalStrings;
|
||||
QList< KAboutApplicationPersonProfileOcsLink > m_ocsLinks;
|
||||
};
|
||||
|
||||
class KAboutApplicationPersonIconsJob : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
KAboutApplicationPersonIconsJob( KAboutApplicationPersonModel *model,
|
||||
int personProfileListIndex );
|
||||
|
||||
void start();
|
||||
|
||||
int personProfileListIndex() const { return m_personProfileListIndex; }
|
||||
|
||||
const QList< KAboutApplicationPersonProfileOcsLink > & ocsLinks() const { return m_ocsLinks; }
|
||||
|
||||
signals:
|
||||
void finished( KAboutApplicationPersonIconsJob *job);
|
||||
|
||||
private Q_SLOTS:
|
||||
void onJobFinished( QNetworkReply *reply );
|
||||
|
||||
private:
|
||||
void getIcons( int i );
|
||||
|
||||
int m_personProfileListIndex;
|
||||
KAboutApplicationPersonModel *m_model;
|
||||
QList< KAboutApplicationPersonProfileOcsLink > m_ocsLinks;
|
||||
|
||||
QNetworkAccessManager *m_manager;
|
||||
};
|
||||
|
||||
} //namespace KDEPrivate
|
||||
|
|
Loading…
Add table
Reference in a new issue