akonadi
20 #include "agenttypemodel.h"
21 #include "agenttype.h"
22 #include "agentmanager.h"
24 #include <QtCore/QStringList>
25 #include <QtGui/QIcon>
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() )
91 if ( index.row() < 0 || index.row() >= d->mTypes.count() )
94 const AgentType &type = d->mTypes[ index.row() ];
100 case Qt::DecorationRole:
106 var.setValue( type );
128 QModelIndex AgentTypeModel::index(
int row,
int column,
const QModelIndex& )
const
130 if ( row < 0 || row >= d->mTypes.count() )
131 return QModelIndex();
134 return QModelIndex();
136 return createIndex( row, column, 0 );
139 QModelIndex AgentTypeModel::parent(
const QModelIndex& )
const
141 return QModelIndex();
144 Qt::ItemFlags AgentTypeModel::flags(
const QModelIndex& index)
const
146 if ( !index.isValid() || index.row() < 0 || index.row() >= d->mTypes.count() )
147 return QAbstractItemModel::flags( index );
149 const AgentType &type = d->mTypes[ index.row() ];
150 if ( type.
capabilities().contains( QLatin1String(
"Unique" ) ) &&
153 return QAbstractItemModel::flags( index ) & ~(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
155 return QAbstractItemModel::flags(index);
158 #include "agenttypemodel.moc"
This file is part of the KDE documentation.
Documentation copyright © 1996-2012 The KDE developers.
Generated on Tue Dec 11 2012 12:14:29 by
doxygen 1.8.1.2 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.