diff --git a/akonadi/entitytreemodel.cpp b/akonadi/entitytreemodel.cpp deleted file mode 100644 index 64be17d16..000000000 --- a/akonadi/entitytreemodel.cpp +++ /dev/null @@ -1,340 +0,0 @@ -/* - Copyright (c) 2008 Stephen Kelly - - This library is free software; you can redistribute it and/or modify it - under the terms of the GNU Library General Public License as published by - the Free Software Foundation; either version 2 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 Library General Public - License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to the - Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -#include "entitytreemodel.h" -#include "entitytreemodel_p.h" - - -#include -#include -#include -#include -#include - -#include "collection.h" -#include "collectionfetchjob.h" -#include "collectionmodifyjob.h" -#include "collectionmodel_p.h" -// #include "entityaboveattribute.h" -#include "entitydisplayattribute.h" -#include "itemfetchjob.h" -#include "itemfetchscope.h" -#include "itemmodifyjob.h" -#include "monitor.h" -#include "pastehelper.h" - -#include -#include - -#include "kdebug.h" - -using namespace Akonadi; - -EntityTreeModel::EntityTreeModel( const QStringList &mimetypes, QObject *parent ) - : CollectionModel( new EntityTreeModelPrivate( this ), parent ) -{ - Q_D( EntityTreeModel ); - - d->m_mimeTypeFilter = mimetypes; - - connect( this, SIGNAL( rowsInserted( const QModelIndex &, int, int ) ), - SLOT( onRowsInserted( const QModelIndex &, int, int ) ) ); - - connect( d->itemMonitor, SIGNAL( itemAdded( const Akonadi::Item&, const Akonadi::Collection& ) ), - this, SLOT( itemAdded( const Akonadi::Item&, const Akonadi::Collection& ) ) ); - connect( d->itemMonitor, SIGNAL( itemChanged( const Akonadi::Item&, const QSet& ) ), - this, SLOT( itemChanged( const Akonadi::Item&, const QSet& ) ) ); - connect( d->itemMonitor, SIGNAL( itemRemoved( const Akonadi::Item& ) ), - this, SLOT( itemRemoved( const Akonadi::Item& ) ) ); - -} - -EntityTreeModel::~EntityTreeModel() -{ -} - -QVariant EntityTreeModel::data( const QModelIndex & index, int role ) const -{ - Q_D( const EntityTreeModel ); - - if ( isItem( index ) ) { - const Item::Id itemId = index.internalId() * -1; - - switch ( role ) { - case Qt::DisplayRole: - case Qt::EditRole: - if ( d->m_items.value( itemId ).hasAttribute() && - ! d->m_items.value( itemId ).attribute()->displayName().isEmpty() ) - return d->m_items.value( itemId ).attribute()->displayName(); - return d->m_items.value( itemId ).remoteId(); - break; - - case Qt::DecorationRole: - if ( d->m_items.value( itemId ).hasAttribute() && - ! d->m_items.value( itemId ).attribute()->iconName().isEmpty() ) - return d->m_items.value( itemId ).attribute()->icon(); - break; - - case ItemRole: - return QVariant::fromValue( d->m_items.value( itemId ) ); - break; - - case ItemIdRole: - return d->m_items.value( itemId ).id(); - break; - - case MimeTypeRole: - return d->m_items.value( itemId ).mimeType(); - break; - - case RemoteIdRole: - return d->m_items.value( itemId ).remoteId(); - break; - -// case EntityAboveRole: -// if ( d->m_items.value( itemId ).hasAttribute() && -// !d->m_items.value( itemId ).attribute()->entityAbove().isEmpty() ) -// return d->m_items.value( itemId ).attribute()->entityAbove(); -// break; - - default: - break; - } - } - - if ( isCollection( index ) ) { - switch ( role ) { - case MimeTypeRole: - return d->collections.value( index.internalId() ).mimeType(); - break; - - case RemoteIdRole: - return d->collections.value( index.internalId() ).remoteId(); - -// case EntityAboveRole: -// if ( d->collections.value(index.internalId()).hasAttribute() && -// ! d->collections.value(index.internalId()).attribute()->entityAbove().isEmpty() ) -// return d->collections.value(index.internalId()).attribute()->entityAbove(); -// break; - - break; - default: - break; - } - - } - - return CollectionModel::data( index, role ); -} - - -Qt::ItemFlags EntityTreeModel::flags( const QModelIndex & index ) const -{ - Q_D( const EntityTreeModel ); - - if ( isCollection( index ) ) { - return CollectionModel::flags( index ); - } - - Qt::ItemFlags flags = QAbstractItemModel::flags( index ); - - flags = flags | Qt::ItemIsDragEnabled; - - Item item; - if ( index.isValid() ) { - item = d->m_items.value( index.internalId() * -1 ); - Q_ASSERT( item.isValid() ); - } else - return flags | Qt::ItemIsDropEnabled; // HACK Workaround for a probable bug in Qt - - const Collection col( index.parent().internalId() ); - if ( col.isValid() ) { - if ( col.rights() & ( Collection::CanChangeItem | - Collection::CanCreateItem | - Collection::CanDeleteItem | - Collection::CanChangeCollection ) ) { - if ( index.column() == 0 ) - flags = flags | Qt::ItemIsEditable; - - flags = flags | Qt::ItemIsDropEnabled; - } - } - - return flags; -} - - -bool EntityTreeModel::dropMimeData( const QMimeData * data, Qt::DropAction action, int row, int column, const QModelIndex & parent ) -{ - // TODO: Implement this! - - - if ( isCollection( parent ) ) { - // TODO: I might not be able to use this convenience. -// CollectionModel::dropMimeData(data, action, row, column, parent); - } - - const Collection col( parent.internalId() ); - - KJob* job = PasteHelper::paste( data, col, action != Qt::MoveAction ); - // TODO: error handling - return job; -} - -QModelIndex EntityTreeModel::index( int row, int column, const QModelIndex & parent ) const -{ - Q_D( const EntityTreeModel ); - - const Collection::Id parentCollectionId = parent.internalId(); - - if ( row < d->childCollections.value( parentCollectionId ).size() ) { - // We're asked for an index for a collection. - // This will return an invalid index where necessary. - return CollectionModel::index( row, column, parent ); - } - - // Because we already know that index is not a model, skip over all collection indexes. - // For example, if a parent collection has 5 child collections and 4 child items, the - // 7th row of that parent is the 3rd item in the internal list of items (recalling that - // row is zero indexed). offsetRow would be 3 in that case. - const int offsetRow = row - d->childCollections.value( parentCollectionId ).size(); - - const QList list = d->m_itemsInCollection[ parent.internalId()]; - - if ( offsetRow < 0 || offsetRow >= list.size() ) - return QModelIndex(); - if ( !d->m_items.contains( list.at( offsetRow ) ) ) - return QModelIndex(); - - // Note: Items and Collections have unique ids (from separate database tables), but an item and - // an id can both use the same id. This causes problems when trying to determine if an indexForId - // is a collection or an item. To workaround that design limitation, we take advantage of the id - // being a signed uint64. The internalId of the index will be a negative number for items, and - // a positive number for collections. This is only true for internal ids of indexes. Everywhere - // else, the real positive unique id from akonadi is used and conversion must be done, but only - // when dealing with items. - return createIndex( row, column, reinterpret_cast( list.at( offsetRow ) * -1 ) ); -} - -QModelIndex EntityTreeModel::parent( const QModelIndex & index ) const -{ - Q_D( const EntityTreeModel ); - -// if ( !d->m_items.contains( index.internalId() ) ) - if ( isCollection( index ) ) { - const QModelIndex idx = CollectionModel::parent( index ); - return idx; - } - - const Item item = d->m_items.value( index.internalId() * -1 ); - if ( !item.isValid() ) - return QModelIndex(); - - QHashIterator< Collection::Id, QList > iter( d->m_itemsInCollection ); - while ( iter.hasNext() ) { - iter.next(); - if ( iter.value().contains( item.id() ) ) { - return d->indexForId( iter.key() ); // iter.key is the collection we found the item in. - } - } - - return CollectionModel::parent( index ); -} - -int EntityTreeModel::rowCount( const QModelIndex & parent ) const -{ - Q_D( const EntityTreeModel ); - - return d->childEntitiesCount( parent ); -} - -QMimeData *EntityTreeModel::mimeData( const QModelIndexList &indexes ) const -{ - QMimeData *data = new QMimeData(); - KUrl::List urls; - foreach( const QModelIndex &index, indexes ) { - if ( index.column() != 0 ) - continue; - - if ( isCollection( index ) ) { - urls << Collection( index.internalId() ).url(); - } - - if ( isItem( index ) ) { - urls << Item( index.internalId() * -1 ).url(); - } - } - urls.populateMimeData( data ); - - return data; -} - -bool EntityTreeModel::setData( const QModelIndex &index, const QVariant &value, int role ) -{ - Q_D( EntityTreeModel ); - - if ( index.column() == 0 && role == Qt::EditRole ) { - if ( isCollection( index ) ) { - // rename collection - Collection col = d->collections.value( index.internalId() ); - if ( !col.isValid() || value.toString().isEmpty() ) - return false; - - col.setName( value.toString() ); - CollectionModifyJob *job = new CollectionModifyJob( col ); - connect( job, SIGNAL( result( KJob* ) ), SLOT( editDone( KJob* ) ) ); - return true; - } - if ( isItem( index ) ) { - Item item = d->m_items.value( index.internalId() * -1 ); - if ( !item.isValid() || value.toString().isEmpty() ) - return false; - -// if ( item.hasAttribute< EntityDisplayAttribute >() ) -// { - EntityDisplayAttribute *displayAttribute = item.attribute( Entity::AddIfMissing ); - displayAttribute->setDisplayName( value.toString() ); -// } - - ItemModifyJob *job = new ItemModifyJob( item ); - connect( job, SIGNAL( result( KJob* ) ), SLOT( editDone( KJob* ) ) ); - return true; - } - } - - return QAbstractItemModel::setData( index, value, role ); -} - -bool EntityTreeModel::isItem( const QModelIndex &index ) const -{ - if ( index.internalId() < 0 ) - return true; - else - return false; -} - -bool EntityTreeModel::isCollection( const QModelIndex &index ) const -{ - if ( index.internalId() > 0 ) - return true; - else - return false; -} - -#include "entitytreemodel.moc" diff --git a/akonadi/entitytreemodel.h b/akonadi/entitytreemodel.h deleted file mode 100644 index c1a0e26af..000000000 --- a/akonadi/entitytreemodel.h +++ /dev/null @@ -1,132 +0,0 @@ -/* - Copyright (c) 2008 Stephen Kelly - - This library is free software; you can redistribute it and/or modify it - under the terms of the GNU Library General Public License as published by - the Free Software Foundation; either version 2 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 Library General Public - License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to the - Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -#ifndef AKONADI_ENTITYTREEMODEL_H -#define AKONADI_ENTITYTREEMODEL_H - -#include "akonadi_export.h" - -#include "collectionmodel.h" - -// #include - -class QStringList; - -namespace Akonadi -{ - -class Collection; -class Item; - -class EntityTreeModelPrivate; - -/** - * @short A model for collections and items together. - * - * This class provides the interface of QAbstractItemModel for the - * collection and item tree of the Akonadi storage. - * - * Child elements of a collection consist of the child collections - * followed by the items. This arrangement can be modified using a proxy model. - * - * @code - * - * EntityTreeModel *model = new EntityTreeModel( this, QStringList() << FooMimeType << BarMimeType ); - * - * QTreeView *view = new QTreeView( this ); - * view->setModel( model ); - * - * @endcode - * - * Only collections and items matching @p mimeTypes will be shown. This way, - * retrieving every item in Akonadi is avoided. - * - * @author Stephen Kelly - * @since 4.2 - * @todo Implement dropMimeData. Currently just a stub. - * @todo Also need to implement a new view to use this. - * @todo Implement itemMoved. - */ -class AKONADI_EXPORT EntityTreeModel : public CollectionModel -{ - Q_OBJECT - - public: - /** - * Describes the roles for items. Roles for collections are defined by the superclass. - */ - enum Roles { - ItemRole = Akonadi::CollectionModel::UserRole + 1, ///< The item. - ItemIdRole, ///< The item id - MimeTypeRole, ///< The mimetype of the entity - RemoteIdRole, ///< The remoteId of the entity -// EntityAboveRole, ///< The remoteId of the entity above @p index. - UserRole = Akonadi::CollectionModel::UserRole + 20 ///< Role for user extensions. - }; - - /** - * Creates a new collection and item model. - * - * @param parent The parent object. - * @param mimeTypes The list of mimetypes to be retrieved in the model. - */ - explicit EntityTreeModel( const QStringList &mimeTypes, QObject *parent = 0 ); - - /** - * Destroys the collection and item model. - */ - virtual ~EntityTreeModel(); - - virtual QVariant data( const QModelIndex & index, int role = Qt::DisplayRole ) const; - virtual QModelIndex index( int row, int column, const QModelIndex & parent = QModelIndex() ) const; - virtual QModelIndex parent( const QModelIndex & index ) const; - virtual int rowCount( const QModelIndex & parent = QModelIndex() ) const; - virtual QMimeData *mimeData( const QModelIndexList &indexes ) const; - virtual Qt::ItemFlags flags( const QModelIndex &index ) const; - virtual bool setData( const QModelIndex &index, const QVariant &value, int role = Qt::EditRole ); - - // TODO: - virtual bool dropMimeData( const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent ); - - protected: - /** - * Returns true if the index @p index refers to an item. - */ - bool isItem( const QModelIndex &index ) const; - - /** - * Returns true if the index @p index refers to a collection. - */ - bool isCollection( const QModelIndex &index ) const; - - private: - Q_DECLARE_PRIVATE( EntityTreeModel ) - - Q_PRIVATE_SLOT( d_func(), void listDone( KJob* ) ) - Q_PRIVATE_SLOT( d_func(), void itemChanged( const Akonadi::Item&, const QSet& ) ) - Q_PRIVATE_SLOT( d_func(), void itemMoved( const Akonadi::Item&, const Akonadi::Collection&, const Akonadi::Collection& ) ) - Q_PRIVATE_SLOT( d_func(), void itemAdded( const Akonadi::Item&, const Akonadi::Collection& ) ) - Q_PRIVATE_SLOT( d_func(), void itemsAdded( const Akonadi::Item::List& ) ) - Q_PRIVATE_SLOT( d_func(), void itemRemoved( const Akonadi::Item& ) ) - Q_PRIVATE_SLOT( d_func(), void onRowsInserted( const QModelIndex &parent, int start, int end ) ) -}; - -} // namespace - -#endif diff --git a/akonadi/entitytreemodel_p.cpp b/akonadi/entitytreemodel_p.cpp deleted file mode 100644 index 4b1f1a809..000000000 --- a/akonadi/entitytreemodel_p.cpp +++ /dev/null @@ -1,223 +0,0 @@ -/* - Copyright (c) 2008 Stephen Kelly - - This library is free software; you can redistribute it and/or modify it - under the terms of the GNU Library General Public License as published by - the Free Software Foundation; either version 2 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 Library General Public - License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to the - Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -#include "entitytreemodel_p.h" -#include "entitytreemodel.h" - - - -#include -#include -#include -#include - -#include - -#include "collection.h" -#include "collectionfetchjob.h" -#include "collectionmodel_p.h" -// #include "entityaboveattribute.h" -#include "entitydisplayattribute.h" -#include "itemfetchjob.h" -#include "itemfetchscope.h" -#include "monitor.h" - -#include - -using namespace Akonadi; - -EntityTreeModelPrivate::EntityTreeModelPrivate( EntityTreeModel *parent ) - : CollectionModelPrivate( parent ) -{ - itemMonitor = new Monitor(); - itemMonitor->setCollectionMonitored( Collection::root() ); - itemMonitor->fetchCollection( true ); -// itemMonitor->itemFetchScope().fetchAttribute(); - itemMonitor->itemFetchScope().fetchAttribute< EntityDisplayAttribute >(); -} - - -void EntityTreeModelPrivate::onRowsInserted( const QModelIndex & parent, int start, int end ) -{ - Q_Q( EntityTreeModel ); - - // This slot can be notified of several new collections in the model. - // Iterate to add items for each one. - for ( int iCount = start; iCount <= end; iCount++ ) { - QModelIndex i = q->CollectionModel::index( iCount, 0, parent ); - - if ( !i.isValid() ) - continue; // This is not a collection, so it doesn't have any items. - - QVariant datav = q->data( i, CollectionModel::CollectionRole ); - - if ( datav == QVariant() ) { - // This is not a collection, so it doesn't have any items. - continue; - } - - Akonadi::Collection col = qvariant_cast< Akonadi::Collection > ( datav ); - - if ( !mimetypeMatches( col.contentMimeTypes() ) ) { - // New collection shouldn't have its items added to the model. - continue; - } - - Akonadi::ItemFetchJob *itemJob = new Akonadi::ItemFetchJob( col ); - itemJob->fetchScope().fetchFullPayload(); - itemJob->fetchScope().fetchAttribute< EntityDisplayAttribute >(); -// itemJob->fetchScope().fetchAttribute(); - - itemJob->setProperty( ItemFetchCollectionId(), QVariant( col.id() ) ); - - q->connect( itemJob, SIGNAL( itemsReceived( Akonadi::Item::List ) ), - q, SLOT( itemsAdded( Akonadi::Item::List ) ) ); - q->connect( itemJob, SIGNAL( result( KJob* ) ), - q, SLOT( listDone( KJob* ) ) ); - } -} - - -bool EntityTreeModelPrivate::mimetypeMatches( const QStringList &mimetypes ) -{ - QStringList::const_iterator constIterator; - bool found = false; - - for ( constIterator = mimetypes.constBegin(); constIterator != mimetypes.constEnd(); ++constIterator ) { - if ( m_mimeTypeFilter.contains(( *constIterator ) ) ) { - found = true; - break; - } - } - return found; -} - -void EntityTreeModelPrivate::itemChanged( const Akonadi::Item &item, const QSet< QByteArray >& ) -{ - Q_Q( EntityTreeModel ); - // No need to check if this is an item. - if ( m_items.contains( item.id() ) ) { - QModelIndex i = indexForItem( item ); - emit q->dataChanged( i, i ); - } -} - -QModelIndex EntityTreeModelPrivate::indexForItem( Item item ) -{ - Q_Q( EntityTreeModel ); - - Item::Id id = item.id(); - - QHashIterator< Collection::Id, QList< Item::Id > > iter( m_itemsInCollection ); - while ( iter.hasNext() ) { - iter.next(); - if ( iter.value().contains( id ) ) { // value is the QList. - QModelIndex parentIndex = indexForId( iter.key() ); // key is the Collection::Id. - Collection::Id parentId = parentIndex.internalId(); - int collectionCount = childCollections.value( parentId ).size(); - int row = collectionCount + m_itemsInCollection[ parentId ].indexOf( id ); - return q->index( row, 0, parentIndex ); - } - } - - return QModelIndex(); -} - -void EntityTreeModelPrivate::itemMoved( const Akonadi::Item &item, const Akonadi::Collection& colSrc, const Akonadi::Collection& colDst ) -{ - kDebug() << "item.remoteId=" << item.remoteId() << "sourceCollectionId=" << colSrc.remoteId() - << "destCollectionId=" << colDst.remoteId(); - - // TODO: Implement this. - -} - -void EntityTreeModelPrivate::itemsAdded( const Akonadi::Item::List &list ) -{ - Q_Q( EntityTreeModel ); - QObject *job = q->sender(); - if (job) - { - Collection::Id colId = job->property( ItemFetchCollectionId() ).value(); - - Item::List itemsToInsert; - - foreach( Item item, list ) { - if ( mimetypeMatches( QStringList() << item.mimeType() ) ) { - itemsToInsert << item; - } - } - - if ( itemsToInsert.size() > 0 ) { - QModelIndex parentIndex = indexForId( colId ); - q->beginInsertRows( parentIndex, - childEntitiesCount( parentIndex ), - childEntitiesCount( parentIndex ) + itemsToInsert.size() - 1 ); - foreach( Item item, itemsToInsert ) { - Item::Id itemId = item.id(); - m_items.insert( itemId, item ); - m_itemsInCollection[ colId ].append( itemId ); - } - q->endInsertRows(); - } - } -} - -void EntityTreeModelPrivate::itemAdded( const Akonadi::Item &item, const Akonadi::Collection& col ) -{ - Q_Q( EntityTreeModel ); - - QModelIndex parentIndex = indexForId( col.id() ); - q->beginInsertRows( parentIndex, childEntitiesCount( parentIndex ), childEntitiesCount( parentIndex ) ); - m_items.insert( item.id(), item ); - m_itemsInCollection[ col.id()].append( item.id() ); - q->endInsertRows(); - -} - -void EntityTreeModelPrivate::itemRemoved( const Akonadi::Item &item ) -{ - Q_Q( EntityTreeModel ); - QModelIndex itemIndex = indexForItem( item ); - QModelIndex parent = itemIndex.parent(); - int row = m_itemsInCollection.value( parent.internalId() ).indexOf( item.id() ); - - q->beginRemoveRows( itemIndex.parent(), row, row ); - - m_items.remove( item.id() ); - - QList list = m_itemsInCollection.value( parent.internalId() ); - list.removeAt( row ); - m_itemsInCollection.insert( parent.internalId(), list ); - - q->endRemoveRows(); -} - -void EntityTreeModelPrivate::listDone( KJob * job ) -{ - if ( job->error() ) { - kWarning( 5250 ) << "Job error: " << job->errorString() << endl; - } -} - - -int EntityTreeModelPrivate::childEntitiesCount( const QModelIndex & parent ) const -{ - return childCollections.value( parent.internalId() ).size() + m_itemsInCollection.value( parent.internalId() ).size(); -} diff --git a/akonadi/entitytreemodel_p.h b/akonadi/entitytreemodel_p.h deleted file mode 100644 index f095ea5c0..000000000 --- a/akonadi/entitytreemodel_p.h +++ /dev/null @@ -1,93 +0,0 @@ -/* - Copyright (c) 2008 Stephen Kelly - - This library is free software; you can redistribute it and/or modify it - under the terms of the GNU Library General Public License as published by - the Free Software Foundation; either version 2 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 Library General Public - License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to the - Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. -*/ - -#ifndef ENTITYTREEMODELPRIVATE_H -#define ENTITYTREEMODELPRIVATE_H - -#include - -class QModelIndex; - -class KJob; - -namespace Akonadi -{ -class Collection; -class Monitor; -} - -#include "item.h" -#include "collectionmodel_p.h" - -#include "entitytreemodel.h" - -namespace Akonadi -{ - -class EntityTreeModelPrivate : public CollectionModelPrivate -{ - public: - - EntityTreeModelPrivate( EntityTreeModel *parent ); - - bool mimetypeMatches( const QStringList &mimetypes ); - - void listDone( KJob* ); - void itemChanged( const Item&, const QSet& ); - void itemsAdded( const Item::List &list ); - - /* - * Warning: This slot should never be called directly. It should only be connected to by the itemsRetrieved signal - * of the ItemFetchJob. - */ - void itemAdded( const Item &item, const Collection& ); - - void itemMoved( const Item&, const Collection& src, const Collection& dst ); - void itemRemoved( const Item& ); - - /* - * Adds items to the model when notified to do so for @p parent. - */ - void onRowsInserted( const QModelIndex &parent, int start, int end ); - - int childEntitiesCount( const QModelIndex & parent ) const; - - QHash< Collection::Id, QList< Item::Id > > m_itemsInCollection; - QHash< Item::Id, Item > m_items; - QStringList m_mimeTypeFilter; - - Monitor *itemMonitor; - - QModelIndex indexForItem( Item ); - - /* - * The id of the collection which starts an item fetch job. This is part of a hack with QObject::sender - * in itemsAdded to correctly insert items into the model. - */ - static QByteArray ItemFetchCollectionId() { - return "ItemFetchCollectionId"; - } - - Q_DECLARE_PUBLIC( EntityTreeModel ) -}; - -} - -#endif -