20#include "agenttypemodel.h"
22#include "agentmanager.h"
24#include <QtCore/QStringList>
32class AgentTypeModel::Private
44 void typeAdded(
const AgentType &agentType);
45 void typeRemoved(
const AgentType &agentType);
48void AgentTypeModel::Private::typeAdded(
const AgentType &agentType)
50 mTypes.append(agentType);
52 emit mParent->layoutChanged();
55void AgentTypeModel::Private::typeRemoved(
const AgentType &agentType)
57 mTypes.removeAll(agentType);
59 emit mParent->layoutChanged();
63 : QAbstractItemModel(parent)
64 , d(new Private(this))
77int AgentTypeModel::columnCount(
const QModelIndex &)
const
82int AgentTypeModel::rowCount(
const QModelIndex &)
const
84 return d->mTypes.count();
87QVariant AgentTypeModel::data(
const QModelIndex &index,
int role)
const
89 if (!index.isValid()) {
93 if (index.row() < 0 || index.row() >= d->mTypes.count()) {
97 const AgentType &type = d->mTypes[index.row()];
100 case Qt::DisplayRole:
103 case Qt::DecorationRole:
113 return type.identifier();
116 return type.description();
119 return type.mimeTypes();
122 return type.capabilities();
130QModelIndex 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);
143QModelIndex AgentTypeModel::parent(
const QModelIndex &)
const
145 return QModelIndex();
148Qt::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"
AgentType::List types() const
Returns the list of all available agent types.
static AgentManager * self()
Returns the global instance of the agent manager.
Provides a data model for agent types.
virtual ~AgentTypeModel()
Destroys the agent type model.
AgentTypeModel(QObject *parent=0)
Creates a new agent type model.
@ MimeTypesRole
A list of supported mimetypes.
@ TypeRole
The agent type itself.
@ IdentifierRole
The identifier of the agent type.
@ DescriptionRole
A description of the agent type.
@ CapabilitiesRole
A list of supported capabilities.
A representation of an agent type.
QList< AgentType > List
Describes a list of agent types.
FreeBusyManager::Singleton.