25 #include <QStringList>
32 class KDescendantsProxyModelPrivate
37 m_ignoreNextLayoutAboutToBeChanged(
false),
38 m_ignoreNextLayoutChanged(
false),
40 m_displayAncestorData(
false ),
41 m_ancestorSeparator( QLatin1String(
" / " ) )
48 mutable QVector<QPersistentModelIndex> m_pendingParents;
50 void scheduleProcessPendingParents()
const;
51 void processPendingParents();
53 void synchronousMappingRefresh();
55 void updateInternalIndexes(
int start,
int offset);
57 void resetInternalData();
59 void sourceRowsAboutToBeInserted(
const QModelIndex &,
int,
int);
60 void sourceRowsInserted(
const QModelIndex &,
int,
int);
61 void sourceRowsAboutToBeRemoved(
const QModelIndex &,
int,
int);
62 void sourceRowsRemoved(
const QModelIndex &,
int,
int);
63 void sourceRowsAboutToBeMoved(
const QModelIndex &,
int,
int,
const QModelIndex &,
int);
64 void sourceRowsMoved(
const QModelIndex &,
int,
int,
const QModelIndex &,
int);
65 void sourceModelAboutToBeReset();
66 void sourceModelReset();
67 void sourceLayoutAboutToBeChanged();
68 void sourceLayoutChanged();
69 void sourceDataChanged(
const QModelIndex &,
const QModelIndex &);
70 void sourceModelDestroyed();
74 QPair<int, int> m_removePair;
75 QPair<int, int> m_insertPair;
77 bool m_ignoreNextLayoutAboutToBeChanged;
78 bool m_ignoreNextLayoutChanged;
81 bool m_displayAncestorData;
82 QString m_ancestorSeparator;
84 QList<QPersistentModelIndex> m_layoutChangePersistentIndexes;
85 QModelIndexList m_proxyIndexes;
88 void KDescendantsProxyModelPrivate::resetInternalData()
92 m_layoutChangePersistentIndexes.clear();
93 m_proxyIndexes.clear();
96 void KDescendantsProxyModelPrivate::synchronousMappingRefresh()
100 m_pendingParents.clear();
102 m_pendingParents.append(QModelIndex());
104 m_relayouting =
true;
105 while (!m_pendingParents.isEmpty())
107 processPendingParents();
109 m_relayouting =
false;
112 void KDescendantsProxyModelPrivate::scheduleProcessPendingParents()
const
115 const_cast<KDescendantsProxyModelPrivate*
>(
this)->processPendingParents();
118 void KDescendantsProxyModelPrivate::processPendingParents()
121 const QVector<QPersistentModelIndex>::iterator begin = m_pendingParents.begin();
122 QVector<QPersistentModelIndex>::iterator it = begin;
127 const QVector<QPersistentModelIndex>::iterator end =
128 m_pendingParents.end();
130 QVector<QPersistentModelIndex> newPendingParents;
132 while (it != end && it != m_pendingParents.end()) {
133 const QModelIndex sourceParent = *it;
134 if (!sourceParent.isValid() && m_rowCount > 0)
137 it = m_pendingParents.erase(it);
140 const int rowCount = q->sourceModel()->rowCount(sourceParent);
142 Q_ASSERT(rowCount > 0);
143 const QPersistentModelIndex sourceIndex = q->sourceModel()->index(rowCount - 1, 0, sourceParent);
145 Q_ASSERT(sourceIndex.isValid());
147 const QModelIndex proxyParent = q->mapFromSource(sourceParent);
149 Q_ASSERT(sourceParent.isValid() == proxyParent.isValid());
150 const int proxyEndRow = proxyParent.row() + rowCount;
151 const int proxyStartRow = proxyEndRow - rowCount + 1;
154 q->beginInsertRows(QModelIndex(), proxyStartRow, proxyEndRow);
156 updateInternalIndexes(proxyStartRow, rowCount);
157 m_mapping.insert(sourceIndex, proxyEndRow);
158 it = m_pendingParents.erase(it);
159 m_rowCount += rowCount;
164 for (
int sourceRow = 0; sourceRow < rowCount; ++sourceRow ) {
165 static const int column = 0;
166 const QModelIndex child = q->sourceModel()->index(sourceRow, column, sourceParent);
167 Q_ASSERT(child.isValid());
169 if (q->sourceModel()->hasChildren(child))
171 Q_ASSERT(q->sourceModel()->rowCount(child) > 0);
172 newPendingParents.append(child);
176 m_pendingParents += newPendingParents;
177 if (!m_pendingParents.isEmpty())
178 processPendingParents();
182 void KDescendantsProxyModelPrivate::updateInternalIndexes(
int start,
int offset)
185 QHash<int, QPersistentModelIndex> updates;
192 updates.insert(it.key() + offset, *it);
198 QHash<int, QPersistentModelIndex>::const_iterator it = updates.constBegin();
199 const QHash<int, QPersistentModelIndex>::const_iterator end = updates.constEnd();
201 for ( ; it != end; ++it)
203 m_mapping.insert(it.value(), it.key());
226 return QAbstractProxyModel::match(start, role, value, hits, flags);
232 d->m_displayAncestorData = display;
238 return d->m_displayAncestorData;
244 d->m_ancestorSeparator = separator;
250 return d->m_ancestorSeparator;
260 disconnect(sourceModel(), SIGNAL(rowsAboutToBeInserted(QModelIndex,
int,
int)),
261 this, SLOT(sourceRowsAboutToBeInserted(QModelIndex,
int,
int)));
262 disconnect(sourceModel(), SIGNAL(rowsInserted(QModelIndex,
int,
int)),
263 this, SLOT(sourceRowsInserted(QModelIndex,
int,
int)));
264 disconnect(sourceModel(), SIGNAL(rowsAboutToBeRemoved(QModelIndex,
int,
int)),
265 this, SLOT(sourceRowsAboutToBeRemoved(QModelIndex,
int,
int)));
266 disconnect(sourceModel(), SIGNAL(rowsRemoved(QModelIndex,
int,
int)),
267 this, SLOT(sourceRowsRemoved(QModelIndex,
int,
int)));
272 disconnect(sourceModel(), SIGNAL(modelAboutToBeReset()),
273 this, SLOT(sourceModelAboutToBeReset()));
274 disconnect(sourceModel(), SIGNAL(modelReset()),
275 this, SLOT(sourceModelReset()));
276 disconnect(sourceModel(), SIGNAL(dataChanged(QModelIndex,QModelIndex)),
277 this, SLOT(sourceDataChanged(QModelIndex,QModelIndex)));
278 disconnect(sourceModel(), SIGNAL(layoutAboutToBeChanged()),
279 this, SLOT(sourceLayoutAboutToBeChanged()));
280 disconnect(sourceModel(), SIGNAL(layoutChanged()),
281 this, SLOT(sourceLayoutChanged()));
282 disconnect(sourceModel(), SIGNAL(destroyed()),
283 this, SLOT(sourceModelDestroyed()));
286 QAbstractProxyModel::setSourceModel(_sourceModel);
289 Q_ASSERT( sourceModel()->
rowCount() > 0 );
290 const_cast<KDescendantsProxyModelPrivate*
>(d)->synchronousMappingRefresh();
294 connect(_sourceModel, SIGNAL(rowsAboutToBeInserted(QModelIndex,
int,
int)),
295 SLOT(sourceRowsAboutToBeInserted(QModelIndex,
int,
int)));
296 connect(_sourceModel, SIGNAL(rowsInserted(QModelIndex,
int,
int)),
297 SLOT(sourceRowsInserted(QModelIndex,
int,
int)));
298 connect(_sourceModel, SIGNAL(rowsAboutToBeRemoved(QModelIndex,
int,
int)),
299 SLOT(sourceRowsAboutToBeRemoved(QModelIndex,
int,
int)));
300 connect(_sourceModel, SIGNAL(rowsRemoved(QModelIndex,
int,
int)),
301 SLOT(sourceRowsRemoved(QModelIndex,
int,
int)));
306 connect(_sourceModel, SIGNAL(modelAboutToBeReset()),
307 SLOT(sourceModelAboutToBeReset()));
308 connect(_sourceModel, SIGNAL(modelReset()),
309 SLOT(sourceModelReset()));
310 connect(_sourceModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)),
311 SLOT(sourceDataChanged(QModelIndex,QModelIndex)));
312 connect(_sourceModel, SIGNAL(layoutAboutToBeChanged()),
313 SLOT(sourceLayoutAboutToBeChanged()));
314 connect(_sourceModel, SIGNAL(layoutChanged()),
315 SLOT(sourceLayoutChanged()));
316 connect(_sourceModel, SIGNAL(destroyed()),
317 SLOT(sourceModelDestroyed()));
326 return QModelIndex();
332 return !(d->m_mapping.isEmpty() || parent.isValid());
338 if (d->m_pendingParents.contains(parent) || parent.isValid() || !sourceModel())
341 if (d->m_mapping.isEmpty() && sourceModel()->hasChildren())
343 Q_ASSERT(sourceModel()->
rowCount() > 0);
344 const_cast<KDescendantsProxyModelPrivate*
>(d)->synchronousMappingRefresh();
346 return d->m_rowCount;
351 if (parent.isValid())
352 return QModelIndex();
354 if (!hasIndex(row, column, parent))
355 return QModelIndex();
357 return createIndex(row, column);
363 if (d->m_mapping.isEmpty() || !proxyIndex.isValid() || !sourceModel())
364 return QModelIndex();
367 Q_ASSERT(result != d->m_mapping.rightEnd());
369 const int proxyLastRow = result.key();
370 const QModelIndex sourceLastChild = result.value();
371 Q_ASSERT(sourceLastChild.isValid());
402 int verticalDistance = proxyLastRow - proxyIndex.row();
406 QModelIndex ancestor = sourceLastChild;
407 while (ancestor.isValid())
409 const int ancestorRow = ancestor.row();
410 if (verticalDistance <= ancestorRow)
412 return ancestor.sibling(ancestorRow - verticalDistance, proxyIndex.column());
414 verticalDistance -= (ancestorRow + 1);
415 ancestor = ancestor.parent();
417 Q_ASSERT(!
"Didn't find target row.");
418 return QModelIndex();
426 return QModelIndex();
428 if (d->m_mapping.isEmpty())
429 return QModelIndex();
436 const QModelIndex sourceParent = sourceIndex.parent();
439 for ( ; it != end; ++it )
441 QModelIndex
index = it.value();
442 bool found_block =
false;
443 while (index.isValid())
445 const QModelIndex ancestor = index.parent();
446 if (ancestor == sourceParent && index.row() >= sourceIndex.row())
449 if (result == end || it.key() < result.key())
457 if (found_block && !index.isValid())
462 Q_ASSERT(result != end);
463 const QModelIndex sourceLastChild = result.value();
464 int proxyRow = result.key();
465 QModelIndex
index = sourceLastChild;
466 while (index.isValid())
468 const QModelIndex ancestor = index.parent();
469 if (ancestor == sourceParent)
471 return createIndex(proxyRow - (index.row() - sourceIndex.row()), sourceIndex.column());
473 proxyRow -= (index.row() + 1);
476 Q_ASSERT(!
"Didn't find valid proxy mapping.");
477 return QModelIndex();
484 if (parent.isValid() || !sourceModel())
487 return sourceModel()->columnCount();
497 if (!index.isValid())
498 return sourceModel()->data(index, role);
502 if ((d->m_displayAncestorData) && ( role == Qt::DisplayRole ) )
504 if (!sourceIndex.isValid())
508 QString displayData = sourceIndex.data().toString();
509 sourceIndex = sourceIndex.parent();
510 while (sourceIndex.isValid())
512 displayData.prepend(d->m_ancestorSeparator);
513 displayData.prepend(sourceIndex.data().toString());
514 sourceIndex = sourceIndex.parent();
518 return sourceIndex.data(role);
527 return QAbstractProxyModel::headerData(section, orientation, role);
532 if (!index.isValid() || !sourceModel())
533 return QAbstractProxyModel::flags(index);
536 Q_ASSERT(srcIndex.isValid());
537 return sourceModel()->flags(srcIndex);
540 void KDescendantsProxyModelPrivate::sourceRowsAboutToBeInserted(
const QModelIndex &parent,
int start,
int end)
544 if (!q->sourceModel()->hasChildren(parent))
546 Q_ASSERT(q->sourceModel()->rowCount(parent) == 0);
553 const int rowCount = q->sourceModel()->rowCount(parent);
555 if (rowCount > start)
557 const QModelIndex belowStart = q->sourceModel()->index(start, 0, parent);
558 proxyStart = q->mapFromSource(belowStart).row();
559 }
else if (rowCount == 0)
561 proxyStart = q->mapFromSource(parent).row() + 1;
563 Q_ASSERT(rowCount == start);
564 static const int column = 0;
565 QModelIndex idx = q->sourceModel()->index(rowCount - 1, column, parent);
566 while (q->sourceModel()->hasChildren(idx))
568 Q_ASSERT(q->sourceModel()->rowCount(idx) > 0);
569 idx = q->sourceModel()->index(q->sourceModel()->rowCount(idx) - 1, column, idx);
572 proxyStart = q->mapFromSource(idx).row() + 1;
574 const int proxyEnd = proxyStart + (end - start);
576 m_insertPair = qMakePair(proxyStart, proxyEnd);
577 q->beginInsertRows(QModelIndex(), proxyStart, proxyEnd);
580 void KDescendantsProxyModelPrivate::sourceRowsInserted(
const QModelIndex &parent,
int start,
int end)
584 const QModelIndex sourceStart = q->sourceModel()->index(start, 0, parent);
585 Q_ASSERT(sourceStart.isValid());
587 const int rowCount = q->sourceModel()->rowCount(parent);
588 Q_ASSERT(rowCount > 0);
590 const int difference = end - start + 1;
592 if (rowCount == difference)
595 m_pendingParents.append(parent);
596 scheduleProcessPendingParents();
600 const int proxyStart = m_insertPair.first;
602 Q_ASSERT(proxyStart >= 0);
604 updateInternalIndexes(proxyStart, difference);
606 if (rowCount - 1 == end)
639 Q_ASSERT(!m_mapping.isEmpty());
640 static const int column = 0;
641 const QModelIndex oldIndex = q->sourceModel()->index(rowCount - 1 - difference, column, parent);
642 Q_ASSERT(m_mapping.leftContains(oldIndex));
644 const QModelIndex newIndex = q->sourceModel()->index(rowCount - 1, column, parent);
646 QModelIndex indexAbove = oldIndex;
658 while (q->sourceModel()->hasChildren(indexAbove)) {
659 Q_ASSERT(q->sourceModel()->rowCount(indexAbove) > 0);
660 indexAbove = q->sourceModel()->index(q->sourceModel()->rowCount(indexAbove) - 1, column, indexAbove);
662 Q_ASSERT(q->sourceModel()->rowCount(indexAbove) == 0);
665 Q_ASSERT(m_mapping.leftContains(indexAbove));
667 const int newProxyRow = m_mapping.leftToRight(indexAbove) + difference;
670 m_mapping.removeLeft(oldIndex);
673 m_mapping.insert(newIndex, newProxyRow);
676 for (
int row = start; row <= end; ++row)
678 static const int column = 0;
679 const QModelIndex idx = q->sourceModel()->index(row, column, parent);
680 Q_ASSERT(idx.isValid());
681 if (q->sourceModel()->hasChildren(idx))
683 Q_ASSERT(q->sourceModel()->rowCount(idx) > 0);
684 m_pendingParents.append(idx);
688 m_rowCount += difference;
691 scheduleProcessPendingParents();
694 void KDescendantsProxyModelPrivate::sourceRowsAboutToBeRemoved(
const QModelIndex &parent,
int start,
int end)
698 const int proxyStart = q->mapFromSource(q->sourceModel()->index(start, 0, parent)).row();
700 static const int column = 0;
701 QModelIndex idx = q->sourceModel()->index(end, column, parent);
702 while (q->sourceModel()->hasChildren(idx))
704 Q_ASSERT(q->sourceModel()->rowCount(idx) > 0);
705 idx = q->sourceModel()->index(q->sourceModel()->rowCount(idx) - 1, column, idx);
707 const int proxyEnd = q->mapFromSource(idx).row();
709 m_removePair = qMakePair(proxyStart, proxyEnd);
711 q->beginRemoveRows(QModelIndex(), proxyStart, proxyEnd);
715 static const int column = 0;
716 Q_ASSERT(model->hasChildren(parent));
717 Q_ASSERT(model->rowCount(parent) > 0);
718 for (
int row = 0; row < model->rowCount(parent); ++row) {
720 const QModelIndex child = model->index(row, column, parent);
721 Q_ASSERT(child.isValid());
722 if (model->hasChildren(child))
725 return model->index(model->rowCount(parent) - 1, column, parent);
728 void KDescendantsProxyModelPrivate::sourceRowsRemoved(
const QModelIndex &parent,
int start,
int end)
733 const
int rowCount = q->sourceModel()->rowCount(parent);
736 const
int proxyStart = m_removePair.first;
737 const
int proxyEnd = m_removePair.second;
739 const
int difference = proxyEnd - proxyStart + 1;
744 if (endIt != m_mapping.rightEnd())
746 it = m_mapping.eraseRight(it);
748 while (it != m_mapping.rightUpperBound(proxyEnd))
749 it = m_mapping.eraseRight(it);
752 m_removePair = qMakePair(-1, -1);
753 m_rowCount -= difference;
754 Q_ASSERT(m_rowCount >= 0);
756 updateInternalIndexes(proxyStart, -1 * difference);
758 if (rowCount != start || rowCount == 0) {
763 static const int column = 0;
764 const QModelIndex newEnd = q->sourceModel()->index(rowCount - 1, column, parent);
765 Q_ASSERT(newEnd.isValid());
767 if (m_mapping.isEmpty()) {
768 m_mapping.insert(newEnd, newEnd.row());
772 if (q->sourceModel()->hasChildren(newEnd)) {
774 const QModelIndex firstDeepest =
getFirstDeepest(q->sourceModel(), newEnd, &count);
775 Q_ASSERT(firstDeepest.isValid());
776 const int firstDeepestProxy = m_mapping.leftToRight(firstDeepest);
778 m_mapping.insert(newEnd, firstDeepestProxy - count);
783 if (lowerBound == m_mapping.rightEnd()) {
784 int proxyRow = (lowerBound - 1).key();
786 for (
int row = newEnd.row(); row >= 0; --row ) {
787 const QModelIndex newEndSibling = q->sourceModel()->index(row, column, parent);
788 if (!q->sourceModel()->hasChildren(newEndSibling)) {
794 m_mapping.insert(newEnd, proxyRow);
797 }
else if (lowerBound == m_mapping.rightBegin()) {
798 int proxyRow = rowCount - 1;
799 QModelIndex trackedParent = parent;
800 while (trackedParent.isValid()) {
801 proxyRow += (trackedParent.row() + 1);
802 trackedParent = trackedParent.parent();
804 m_mapping.insert(newEnd, proxyRow);
810 QVector<QModelIndex> targetParents;
811 targetParents.push_back(parent);
813 QModelIndex target = parent;
815 while (target.isValid()) {
816 if (target == boundAbove.value()) {
817 m_mapping.insert(newEnd, count + boundAbove.key() + newEnd.row() + 1);
821 count += (target.row() + 1);
822 target = target.parent();
823 if (target.isValid())
824 targetParents.push_back(target);
828 QModelIndex boundParent = boundAbove.value().parent();
829 QModelIndex prevParent = boundParent;
830 Q_ASSERT(boundParent.isValid());
831 while (boundParent.isValid()) {
832 prevParent = boundParent;
833 boundParent = boundParent.parent();
835 if (targetParents.contains(prevParent))
838 if (!m_mapping.leftContains(prevParent))
841 if (m_mapping.leftToRight(prevParent) > boundAbove.key())
845 QModelIndex trackedParent = parent;
847 int proxyRow = boundAbove.key();
849 Q_ASSERT(prevParent.isValid());
850 proxyRow -= prevParent.row();
851 while (trackedParent != boundParent) {
852 proxyRow += (trackedParent.row() + 1);
853 trackedParent = trackedParent.parent();
855 m_mapping.insert(newEnd, proxyRow + newEnd.row());
859 void KDescendantsProxyModelPrivate::sourceRowsAboutToBeMoved(
const QModelIndex &srcParent,
int srcStart,
int srcEnd,
const QModelIndex &destParent,
int destStart)
867 q->beginResetModel();
870 void KDescendantsProxyModelPrivate::sourceRowsMoved(const QModelIndex &srcParent,
int srcStart,
int srcEnd, const QModelIndex &destParent,
int destStart)
877 Q_Q(KDescendantsProxyModel);
882 void KDescendantsProxyModelPrivate::sourceModelAboutToBeReset()
884 Q_Q(KDescendantsProxyModel);
885 q->beginResetModel();
888 void KDescendantsProxyModelPrivate::sourceModelReset()
890 Q_Q(KDescendantsProxyModel);
892 if (q->sourceModel()->hasChildren())
894 Q_ASSERT(q->sourceModel()->rowCount() > 0);
895 m_pendingParents.append(QModelIndex());
896 scheduleProcessPendingParents();
901 void KDescendantsProxyModelPrivate::sourceLayoutAboutToBeChanged()
903 Q_Q(KDescendantsProxyModel);
905 if (m_ignoreNextLayoutChanged) {
906 m_ignoreNextLayoutChanged =
false;
910 if (m_mapping.isEmpty())
913 QPersistentModelIndex srcPersistentIndex;
914 foreach(
const QPersistentModelIndex &proxyPersistentIndex, q->persistentIndexList()) {
915 m_proxyIndexes << proxyPersistentIndex;
916 Q_ASSERT(proxyPersistentIndex.isValid());
917 srcPersistentIndex = q->mapToSource(proxyPersistentIndex);
918 Q_ASSERT(srcPersistentIndex.isValid());
919 m_layoutChangePersistentIndexes << srcPersistentIndex;
922 q->layoutAboutToBeChanged();
925 void KDescendantsProxyModelPrivate::sourceLayoutChanged()
927 Q_Q(KDescendantsProxyModel);
929 if (m_ignoreNextLayoutAboutToBeChanged) {
930 m_ignoreNextLayoutAboutToBeChanged =
false;
934 if (m_mapping.isEmpty())
939 synchronousMappingRefresh();
941 for (
int i = 0; i < m_proxyIndexes.size(); ++i) {
942 q->changePersistentIndex(m_proxyIndexes.at(i), q->mapFromSource(m_layoutChangePersistentIndexes.at(i)));
945 m_layoutChangePersistentIndexes.clear();
946 m_proxyIndexes.clear();
951 void KDescendantsProxyModelPrivate::sourceDataChanged(
const QModelIndex &topLeft,
const QModelIndex &bottomRight)
953 Q_Q(KDescendantsProxyModel);
954 Q_ASSERT(topLeft.model() == q->sourceModel());
955 Q_ASSERT(bottomRight.model() == q->sourceModel());
957 const int topRow = topLeft.row();
958 const int bottomRow = bottomRight.row();
960 if (m_mapping.isEmpty() && q->sourceModel()->hasChildren())
962 Q_ASSERT(q->sourceModel()->rowCount() > 0);
963 synchronousMappingRefresh();
966 for(
int i = topRow; i <= bottomRow; ++i)
968 const QModelIndex sourceTopLeft = q->sourceModel()->index(i, topLeft.column(), topLeft.parent());
969 Q_ASSERT(sourceTopLeft.isValid());
970 const QModelIndex proxyTopLeft = q->mapFromSource(sourceTopLeft);
973 const QModelIndex sourceBottomRight = q->sourceModel()->index(i, bottomRight.column(), bottomRight.parent());
974 const QModelIndex proxyBottomRight = q->mapFromSource(sourceBottomRight);
975 Q_ASSERT(proxyTopLeft.isValid());
976 Q_ASSERT(proxyBottomRight.isValid());
977 emit q->dataChanged(proxyTopLeft, proxyBottomRight);
981 void KDescendantsProxyModelPrivate::sourceModelDestroyed()
991 return QAbstractProxyModel::mimeData(indexes);
992 Q_ASSERT(sourceModel());
993 QModelIndexList sourceIndexes;
994 foreach(
const QModelIndex&
index, indexes)
996 return sourceModel()->mimeData(sourceIndexes);
1002 return QAbstractProxyModel::mimeTypes();
1003 Q_ASSERT(sourceModel());
1004 return sourceModel()->mimeTypes();
1010 return QAbstractProxyModel::supportedDropActions();
1011 return sourceModel()->supportedDropActions();
1014 #include "kdescendantsproxymodel.moc"
void setRootIndex(const QModelIndex &index)
Sets the root index to index.
virtual QModelIndex index(int, int, const QModelIndex &parent=QModelIndex()) const
Proxy Model for restructuring a Tree into a list.
virtual QMimeData * mimeData(const QModelIndexList &indexes) const
QModelIndex mapToSource(const QModelIndex &proxyIndex) const
virtual QModelIndex parent(const QModelIndex &) const
void setAncestorSeparator(const QString &separator)
Sets the ancestor separator used between data of ancestors.
QMap< int, QPersistentModelIndex >::const_iterator right_const_iterator
_iterator< QMap< int, QPersistentModelIndex > > right_iterator
virtual bool hasChildren(const QModelIndex &parent=QModelIndex()) const
QModelIndex mapFromSource(const QModelIndex &sourceIndex) const
QString ancestorSeparator() const
Separator used between data of ancestors.
static QModelIndex getFirstDeepest(QAbstractItemModel *model, const QModelIndex &parent, int *count)
KDescendantsProxyModel(QObject *parent=0)
Creates a new descendant entities proxy model.
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const
virtual Qt::DropActions supportedDropActions() const
virtual int columnCount(const QModelIndex &index=QModelIndex()) const
virtual void setSourceModel(QAbstractItemModel *model)
Sets the source model of the proxy.
virtual Qt::ItemFlags flags(const QModelIndex &index) const
KHash2Map< QPersistentModelIndex, int > Mapping
void setDisplayAncestorData(bool display)
Set whether to show ancestor data in the model.
virtual int rowCount(const QModelIndex &parent=QModelIndex()) const
virtual ~KDescendantsProxyModel()
Destroys the descendant entities proxy model.
virtual QStringList mimeTypes() const
bool displayAncestorData() const
Whether ancestor data will be displayed.
virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const
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 match all descendants.