20 #include "agenttypemodel.h"
21 #include "agenttype.h"
22 #include "agentmanager.h"
24 #include <QtCore/QStringList>
27 using namespace Akonadi;
32 class AgentTypeModel::Private
44 void typeAdded(
const AgentType &agentType );
45 void typeRemoved(
const AgentType &agentType );
48 void AgentTypeModel::Private::typeAdded(
const AgentType &agentType )
50 mTypes.append( agentType );
52 emit mParent->layoutChanged();
55 void AgentTypeModel::Private::typeRemoved(
const AgentType &agentType )
57 mTypes.removeAll( agentType );
59 emit mParent->layoutChanged();
63 : QAbstractItemModel( parent ), d( new Private( this ) )
76 int AgentTypeModel::columnCount(
const QModelIndex& )
const
81 int AgentTypeModel::rowCount(
const QModelIndex& )
const
83 return d->mTypes.count();
86 QVariant AgentTypeModel::data(
const QModelIndex &index,
int role )
const
88 if ( !index.isValid() ) {
92 if ( index.row() < 0 || index.row() >= d->mTypes.count() ) {
96 const AgentType &type = d->mTypes[ index.row() ];
102 case Qt::DecorationRole:
108 var.setValue( type );
130 QModelIndex AgentTypeModel::index(
int row,
int column,
const QModelIndex& )
const
132 if ( row < 0 || row >= d->mTypes.count() ) {
133 return QModelIndex();
137 return QModelIndex();
140 return createIndex( row, column);
143 QModelIndex AgentTypeModel::parent(
const QModelIndex& )
const
145 return QModelIndex();
148 Qt::ItemFlags AgentTypeModel::flags(
const QModelIndex& index)
const
150 if ( !index.isValid() || index.row() < 0 || index.row() >= d->mTypes.count() ) {
151 return QAbstractItemModel::flags( index );
154 const AgentType &type = d->mTypes[ index.row() ];
155 if ( type.
capabilities().contains( QLatin1String(
"Unique" ) ) &&
157 return QAbstractItemModel::flags( index ) & ~( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
159 return QAbstractItemModel::flags( index );
162 #include "moc_agenttypemodel.cpp"
QIcon icon() const
Returns the icon of the agent type.
QString description() const
Returns the description of the agent type.
QString name() const
Returns the i18n'ed name of the agent type.
QString identifier() const
Returns the unique identifier of the agent type.
A representation of an agent type.
QStringList mimeTypes() const
Returns the list of supported mime types of the agent type.
AgentInstance instance(const QString &identifier) const
Returns the agent instance with the given identifier or an invalid agent instance if the identifier d...
QList< AgentType > List
Describes a list of agent types.
The identifier of the agent type.
QStringList capabilities() const
Returns the list of supported capabilities of the agent type.
A description of the agent type.
AgentTypeModel(QObject *parent=0)
Creates a new agent type model.
Provides a data model for agent types.
virtual ~AgentTypeModel()
Destroys the agent type model.
AgentType::List types() const
Returns the list of all available agent types.
static AgentManager * self()
Returns the global instance of the agent manager.
A list of supported capabilities.
A list of supported mimetypes.