akonadi
entitytreemodel.cpp
61 EntityTreeModel::EntityTreeModel(ChangeRecorder *monitor, EntityTreeModelPrivate *d, QObject *parent)
139 //We have to use the same session as the monitor, so the monitor can fetch the collection afterwards
255 const HeaderGroup headerGroup = static_cast<HeaderGroup>((role / static_cast<int>(TerminalUserRole)));
314 return d->m_pendingCollectionRetrieveJobs.contains(collection.id()) ? FetchingState : IdleState;
428 if (rights & (Collection::CanCreateCollection | Collection::CanCreateItem | Collection::CanLinkItem)) {
433 // dragging is always possible, even for read-only objects, but they can only be copied, not moved.
459 // dragging is always possible, even for read-only objects, but they can only be copied, not moved.
474 // TODO: Should this return the mimetypes that the items provide? Allow dragging a contact from here for example.
478 bool EntityTreeModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
551 kDebug() << "unwanted collection" << mimeChecker.wantedMimeTypes() << collection.contentMimeTypes();
560 KMessageBox::error(0, i18n("The target collection '%1' contains already\na collection with name '%2'.",
675 const int row = d->indexOf<Node::Collection>(d->m_childEntities.value(collection.parentCollection().id()), collection.id());
730 QVariant EntityTreeModel::entityHeaderData(int section, Qt::Orientation orientation, int role, HeaderGroup headerGroup) const
750 const HeaderGroup headerGroup = static_cast<HeaderGroup>((role / static_cast<int>(TerminalUserRole)));
854 EntityDisplayAttribute *eda = collection.attribute<EntityDisplayAttribute>(Entity::AddIfMissing);
877 EntityDisplayAttribute *displayAttribute = item.attribute<EntityDisplayAttribute>(Entity::AddIfMissing);
977 bool EntityTreeModel::entityMatch(const Item &item, const QVariant &value, Qt::MatchFlags flags) const
985 bool EntityTreeModel::entityMatch(const Collection &collection, const QVariant &value, Qt::MatchFlags flags) const
993 QModelIndexList EntityTreeModel::match(const QModelIndex &start, int role, const QVariant &value, int hits, Qt::MatchFlags flags) const
1134 disconnect(d->m_monitor, SIGNAL(itemMoved(Akonadi::Item,Akonadi::Collection,Akonadi::Collection)),
1198 this, SLOT(monitoredCollectionMoved(Akonadi::Collection,Akonadi::Collection,Akonadi::Collection)));
1213 static QPair<QList<const QAbstractProxyModel *>, const EntityTreeModel *> proxiesAndModel(const QAbstractItemModel *model)
1228 static QModelIndex proxiedIndex(const QModelIndex &idx, QList<const QAbstractProxyModel *> proxyChain)
1238 QModelIndex EntityTreeModel::modelIndexForCollection(const QAbstractItemModel *model, const Collection &collection)
1240 QPair<QList<const QAbstractProxyModel *>, const EntityTreeModel *> pair = proxiesAndModel(model);
1247 QModelIndexList EntityTreeModel::modelIndexesForItem(const QAbstractItemModel *model, const Item &item)
1249 QPair<QList<const QAbstractProxyModel *>, const EntityTreeModel *> pair = proxiesAndModel(model);
void setAllMonitored(bool monitored=true)
Sets whether all items shall be monitored.
Definition: monitor.cpp:186
virtual bool entityMatch(const Item &item, const QVariant &value, Qt::MatchFlags flags) const
Reimplement this in a subclass to return true if item matches value with flags in the AmazingCompleti...
Definition: entitytreemodel.cpp:977
Job that modifies a collection in the Akonadi storage.
Definition: collectionmodifyjob.h:82
qlonglong toLongLong(bool *ok) const
void setIncludeRootCollection(bool include)
Sets whether the root collection shall be provided by the model.
Definition: entitytreemodel.cpp:1154
Parts available in the model for the item.
Definition: entitytreemodel.h:343
bool systemEntitiesShown() const
Returns true if internal system entities are shown, and false otherwise.
Definition: entitytreemodel.cpp:143
Session * session() const
Returns the Session used by the monitor to communicate with Akonadi.
Definition: monitor.cpp:365
QString iconName() const
Returns the icon name of the icon returned by icon().
Definition: entitydisplayattribute.cpp:67
Returns the number of unread items in a collection.
Definition: entitytreemodel.h:350
QString displayName() const
Returns the display name (EntityDisplayAttribute::displayName()) if set, and Collection::name() other...
Definition: collection.cpp:86
virtual QVariant entityData(const Item &item, int column, int role=Qt::DisplayRole) const
Provided for convenience of subclasses.
Definition: entitytreemodel.cpp:173
Last role for user extensions. Don't use a role beyond this or headerData will break.
Definition: entitytreemodel.h:356
Provides statistics information of a Collection.
Definition: collectionstatistics.h:69
Returns the FetchState of a particular item.
Definition: entitytreemodel.h:351
QModelIndex indexForCollection(const Collection &collection) const
Returns the model index for the given collection.
Fetches collections, but does not put them in the model. This can be used to create a list of items i...
Definition: entitytreemodel.h:531
void setCollectionMonitored(const Collection &collection, bool monitored=true)
Sets whether the specified collection shall be monitored for changes.
Definition: monitor.cpp:66
virtual bool hasFormat(const QString &mimeType) const
ItemPopulationStrategy
Describes how the model should populated its items.
Definition: entitytreemodel.h:408
int indexOf(const QList< Node * > &nodes, Entity::Id id) const
Returns the index of the node in list with the id id.
Definition: entitytreemodel_p.h:178
QString displayName() const
Returns the name that should be used for display.
Definition: entitydisplayattribute.cpp:52
Do not include items in the model.
Definition: entitytreemodel.h:409
const T & at(int i) const
bool contains(const QString &str, Qt::CaseSensitivity cs) const
typedef MatchFlags
T value() const
Can create new subcollections in this collection.
Definition: collection.h:92
KJob * pasteUriList(const QMimeData *mimeData, const Collection &collection, Qt::DropAction action, Session *session=0)
URI list paste/drop.
Definition: pastehelper.cpp:307
Helper for checking MIME types of Collections and Items.
Definition: mimetypechecker.h:109
void setCollectionsMonitored(const Akonadi::Collection::List &collections)
Monitors the specified collections and resets the model.
Definition: entitytreemodel.cpp:114
virtual bool insertRows(int row, int count, const QModelIndex &parent)
qint64 internalId() const
void setCollectionMonitored(const Akonadi::Collection &col, bool monitored=true)
Adds or removes a specific collection from the monitored set without resetting the model...
Definition: entitytreemodel.cpp:127
virtual QVariant entityHeaderData(int section, Qt::Orientation orientation, int role, HeaderGroup headerGroup) const
Reimplement this to provide different header data.
Definition: entitytreemodel.cpp:730
bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *method)
There is no fetch of items in this collection in progress.
Definition: entitytreemodel.h:375
bool isCollectionPopulated(Akonadi::Collection::Id) const
Returns whether the collection has been populated.
Definition: entitytreemodel.cpp:965
void setName(const QString &name)
Sets the i18n'ed name of the collection.
Definition: collection.cpp:93
int size() const
Returns the progress of synchronization in percent for a particular collection.
Definition: entitytreemodel.h:352
Header information for a collection-only tree.
Definition: entitytreemodel.h:385
HeaderGroup
Describes what header information the model shall return.
Definition: entitytreemodel.h:383
Fetch items only when requested (using canFetchMore/fetchMore)
Definition: entitytreemodel.h:411
virtual QModelIndexList match(const QModelIndex &start, int role, const QVariant &value, int hits, QFlags< Qt::MatchFlag > flags) const
Returns whether a Collection has been populated, i.e. whether its items have been fetched...
Definition: entitytreemodel.h:353
Attribute * attribute(const QByteArray &name) const
Returns the attribute of the given type name if available, 0 otherwise.
Definition: entity.cpp:167
bool isValid() const
Collection::List collectionsMonitored() const
Returns the list of collections being monitored.
Definition: monitor.cpp:273
void setCollectionFetchStrategy(CollectionFetchStrategy strategy)
Sets the collection fetch strategy of the model.
Definition: entitytreemodel.cpp:1182
QString number(int n, int base)
Can create links to existing items in this virtual collection.
Definition: collection.h:94
Collection parentCollection() const
Returns the parent collection of this object.
Definition: entity.cpp:185
ItemPopulationStrategy itemPopulationStrategy() const
Returns the item population strategy of the model.
Definition: entitytreemodel.cpp:1148
Role used to implement amazing completion.
Definition: entitytreemodel.h:340
QModelIndexList indexesForItem(const Item &item) const
Returns the model indexes for the given item.
bool isEmpty() const
QStringList wantedMimeTypes() const
Returns the list of wanted MIME types this instance checks against.
Definition: mimetypechecker.cpp:52
int row() const
void setBackgroundColor(const QColor &color)
Sets the backgroundColor to color.
Definition: entitydisplayattribute.cpp:162
virtual bool removeColumns(int column, int count, const QModelIndex &parent)
Akonadi::CollectionFetchScope::ListFilter listFilter() const
Returns the currently used listfilter.
Definition: entitytreemodel.cpp:99
Can create new items in this collection.
Definition: collection.h:89
void * internalPointer() const
The parent collection of the entity.
Definition: entitytreemodel.h:341
QString rootCollectionDisplayName() const
Returns the display name of the root collection.
Definition: entitytreemodel.cpp:1176
void setDisplayName(const QString &name)
Sets the name that should be used for display.
Definition: entitydisplayattribute.cpp:57
QModelIndex parent() const
void fetchCollection(bool enable)
Enables automatic fetching of changed collections from the Akonadi storage.
Definition: monitor.cpp:219
bool isFullyPopulated() const
Returns whether the model is fully populated.
Definition: entitytreemodel.cpp:971
virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const
void setListFilter(Akonadi::CollectionFetchScope::ListFilter filter)
Sets the currently used listfilter.
Definition: entitytreemodel.cpp:105
Retrieve items immediately when their parent is in the model. This is the default.
Definition: entitytreemodel.h:410
bool isWantedCollection(const Collection &collection) const
Checks whether a given collection has one of the wanted MIME types.
Definition: mimetypechecker.cpp:86
Rights rights() const
Returns the rights the user has on the collection.
Definition: collection.cpp:99
static QModelIndex modelIndexForCollection(const QAbstractItemModel *model, const Collection &collection)
Returns a QModelIndex in model which points to collection.
Definition: entitytreemodel.cpp:1238
void setRootCollectionDisplayName(const QString &name)
Sets the display name of the root collection of the model.
Definition: entitytreemodel.cpp:1168
QModelIndex createIndex(int row, int column, void *ptr) const
No filtering, retrieve all collections.
Definition: collectionfetchscope.h:133
void setItemPopulationStrategy(ItemPopulationStrategy strategy)
Sets the item population strategy of the model.
Definition: entitytreemodel.cpp:1121
virtual bool insertColumns(int column, int count, const QModelIndex &parent)
Returns original name for collection.
Definition: entitytreemodel.h:354
QVariant fromValue(const T &value)
virtual bool removeRows(int row, int count, const QModelIndex &parent)
Fetches nothing. This creates an empty model.
Definition: entitytreemodel.h:528
Header information for a list of items.
Definition: entitytreemodel.h:386
QColor backgroundColor() const
Returns the backgroundColor or an invalid color if none is set.
Definition: entitydisplayattribute.cpp:157
Parts available in the Akonadi server for the item.
Definition: entitytreemodel.h:344
void setWantedMimeTypes(const QStringList &mimeTypes)
Sets the list of wanted MIME types this instance checks against.
Definition: mimetypechecker.cpp:57
QAbstractItemModel * sourceModel() const
QStringList childCollectionNames(const Collection &collection) const
Returns the list of names of the child collections of collection.
CollectionFetchStrategy collectionFetchStrategy() const
Returns the collection fetch strategy of the model.
Definition: entitytreemodel.cpp:1207
QVariant data(int role) const
void setShowSystemEntities(bool show)
Some Entities are hidden in the model, but exist for internal purposes, for example, custom object directories in groupware resources.
Definition: entitytreemodel.cpp:149
typedef DropActions
bool isWantedItem(const Item &item) const
Checks whether a given item has one of the wanted MIME types.
Definition: mimetypechecker.cpp:72
bool hasAttribute(const QByteArray &name) const
Returns true if the entity has an attribute of the given type name, false otherwise.
Definition: entity.cpp:148
A model for collections and items together.
Definition: entitytreemodel.h:318
Job that modifies an existing item in the Akonadi storage.
Definition: itemmodifyjob.h:97
There is a fetch of items in this collection in progress.
Definition: entitytreemodel.h:376
int column() const
bool toBool() const
qint64 unreadCount() const
Returns the number of unread items in this collection or -1 if this information is not available...
Definition: collectionstatistics.cpp:77
QStringList contentMimeTypes() const
Returns a list of possible content mimetypes, e.g.
Definition: collection.cpp:115
virtual bool setData(const QModelIndex &index, const QVariant &value, int role)
bool isCollectionTreeFetched() const
Returns whether the collection tree has been fetched at initialisation.
Definition: entitytreemodel.cpp:958
bool isValid() const
virtual Qt::ItemFlags flags(const QModelIndex &index) const
void prepend(const T &value)
Only retrieve enabled collections, ignoring the local preference. This is the same as setIncludeUnsub...
Definition: collectionfetchscope.h:137
static QModelIndexList modelIndexesForItem(const QAbstractItemModel *model, const Item &item)
Returns a QModelIndex in model which points to item.
Definition: entitytreemodel.cpp:1247
virtual QModelIndexList match(const QModelIndex &start, int role, const QVariant &value, int hits=1, Qt::MatchFlags flags=Qt::MatchFlags(Qt::MatchStartsWith|Qt::MatchWrap)) const
Reimplemented to handle the AmazingCompletionRole.
Definition: entitytreemodel.cpp:993
const_iterator constEnd() const
The akonadi:/ Url of the entity as a string. Item urls will contain the mimetype. ...
Definition: entitytreemodel.h:349
const_iterator constBegin() const
CollectionFetchStrategy
Describes what collections shall be fetched by and represent in the model.
Definition: entitytreemodel.h:527
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QObject * parent() const
AKONADI_DEPRECATED bool includeUnsubscribed() const
Returns whether unsubscribed entities will be included in the listing.
Definition: entitytreemodel.cpp:85
static Collection fromUrl(const KUrl &url)
Creates a collection from the given url.
Definition: collection.cpp:172
void setReferenced(bool referenced)
Sets a collection to be referenced.
Definition: collection.cpp:338
QString toString() const
CollectionStatistics statistics() const
Returns the collection statistics of the collection.
Definition: collection.cpp:238
bool includeRootCollection() const
Returns whether the root collection is provided by the model.
Definition: entitytreemodel.cpp:1162
Attribute that stores the properties that are used to display an entity.
Definition: entitydisplayattribute.h:39
AKONADI_DEPRECATED void setIncludeUnsubscribed(bool show)
Sets whether unsubscribed entities will be included in the listing.
Definition: entitytreemodel.cpp:90
bool isValid() const
void setCollectionReferenced(const Akonadi::Collection &col, bool referenced=true)
References a collection and starts to monitor it.
Definition: entitytreemodel.cpp:133
typedef ItemFlags
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:38:03 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:38:03 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.