2014-11-13 01:04:59 +02:00
|
|
|
/* This file is part of the KDE libraries
|
|
|
|
Copyright (C) 2010 Teo Mrnjavac <teo@kde.org>
|
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Lesser General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2.1 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Lesser General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
|
|
License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "kaboutapplicationpersonmodel_p.h"
|
|
|
|
|
|
|
|
|
|
|
|
#include <kdebug.h>
|
|
|
|
#include <kaboutdata.h>
|
|
|
|
|
|
|
|
namespace KDEPrivate
|
|
|
|
{
|
|
|
|
|
|
|
|
KAboutApplicationPersonModel::KAboutApplicationPersonModel( const QList< KAboutPerson > &personList,
|
|
|
|
QObject *parent )
|
|
|
|
: QAbstractListModel( parent )
|
|
|
|
, m_personList( personList )
|
|
|
|
{
|
2015-09-30 10:37:53 +03:00
|
|
|
foreach( const KAboutPerson person, personList )
|
2014-11-13 01:04:59 +02:00
|
|
|
{
|
|
|
|
KAboutApplicationPersonProfile profile =
|
|
|
|
KAboutApplicationPersonProfile( person.name(),
|
|
|
|
person.task(),
|
2021-03-19 02:24:49 +02:00
|
|
|
person.emailAddress());
|
2014-11-13 01:04:59 +02:00
|
|
|
profile.setHomepage( person.webAddress() );
|
|
|
|
m_profileList.append( profile );
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
int KAboutApplicationPersonModel::rowCount( const QModelIndex &parent ) const
|
|
|
|
{
|
|
|
|
Q_UNUSED( parent )
|
|
|
|
return m_personList.count();
|
|
|
|
}
|
|
|
|
|
|
|
|
QVariant KAboutApplicationPersonModel::data( const QModelIndex &index, int role ) const
|
|
|
|
{
|
|
|
|
if( !index.isValid() ) {
|
|
|
|
kWarning()<<"ERROR: invalid index";
|
|
|
|
return QVariant();
|
|
|
|
}
|
|
|
|
if( index.row() >= rowCount() ) {
|
|
|
|
kWarning()<<"ERROR: index out of bounds";
|
|
|
|
return QVariant();
|
|
|
|
}
|
|
|
|
if( role == Qt::DisplayRole ) {
|
|
|
|
// kDebug() << "Spitting data for name " << m_profileList.at( index.row() ).name();
|
|
|
|
QVariant var;
|
|
|
|
var.setValue( m_profileList.at( index.row() ) );
|
|
|
|
return var;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return QVariant();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Qt::ItemFlags KAboutApplicationPersonModel::flags( const QModelIndex &index ) const
|
|
|
|
{
|
|
|
|
if( index.isValid() )
|
|
|
|
return Qt::ItemIsEnabled;
|
|
|
|
return QAbstractListModel::flags( index ) | Qt::ItemIsEditable;
|
|
|
|
}
|
|
|
|
|
|
|
|
} //namespace KDEPrivate
|
|
|
|
|
2015-02-27 07:40:26 +00:00
|
|
|
#include "moc_kaboutapplicationpersonmodel_p.cpp"
|