20#include "asyncselectionhandler_p.h"
22#include <akonadi/entitytreemodel.h>
26AsyncSelectionHandler::AsyncSelectionHandler(QAbstractItemModel *model, QObject *parent)
32 connect(mModel, SIGNAL(rowsInserted(QModelIndex,
int,
int)),
33 this, SLOT(rowsInserted(QModelIndex,
int,
int)));
36AsyncSelectionHandler::~AsyncSelectionHandler()
40bool AsyncSelectionHandler::scanSubTree(
const QModelIndex &index,
bool searchForItem)
45 if (mItem.id() ==
id) {
46 emit itemAvailable(index);
52 if (mCollection.
id() ==
id) {
53 emit collectionAvailable(index);
58 for (
int row = 0; row < mModel->rowCount(index); ++row) {
59 const QModelIndex childIndex = mModel->index(row, 0, index);
60 if (scanSubTree(childIndex, searchForItem)) {
68void AsyncSelectionHandler::waitForCollection(
const Collection &collection)
70 mCollection = collection;
72 scanSubTree(QModelIndex(),
false);
75void AsyncSelectionHandler::waitForItem(
const Item &item)
79 scanSubTree(QModelIndex(),
true);
82void AsyncSelectionHandler::rowsInserted(
const QModelIndex &parent,
int start,
int end)
84 for (
int i = start; i <= end; ++i) {
85 scanSubTree(mModel->index(i, 0, parent),
false);
86 scanSubTree(mModel->index(i, 0, parent),
true);
90#include "moc_asyncselectionhandler_p.cpp"
Represents a collection of PIM items.
@ CollectionIdRole
The collection id.
Id id() const
Returns the unique identifier of the entity.
qint64 Id
Describes the unique id type.
FreeBusyManager::Singleton.