When the filter has been enabled, the sibblings got not updated. Explicitely
update the sibblings when inserting, removing or moving items. For layouting
implicitely update the sibblings only for recycled widgets.
int KFileItemModel::expandedParentsCount(int index) const
{
if (index >= 0 && index < count()) {
int KFileItemModel::expandedParentsCount(int index) const
{
if (index >= 0 && index < count()) {
- return m_itemData.at(index)->values.value("expandedParentsCount").toInt();
+ const int parentsCount = m_itemData.at(index)->values.value("expandedParentsCount").toInt();
+ if (parentsCount > 0) {
+ return parentsCount;
+ }
if (!hasMultipleRanges) {
doLayout(animateChangedItemCount(count) ? Animation : NoAnimation, index, count);
if (!hasMultipleRanges) {
doLayout(animateChangedItemCount(count) ? Animation : NoAnimation, index, count);
+ updateSiblingsInformation();
}
if (hasMultipleRanges) {
}
if (hasMultipleRanges) {
+ m_endTransactionAnimationHint = NoAnimation;
+ updateSiblingsInformation();
m_activeTransactions = 0;
doLayout(animateChangedItemCount(count) ? Animation : NoAnimation, index, -count);
m_activeTransactions = activeTransactions;
m_activeTransactions = 0;
doLayout(animateChangedItemCount(count) ? Animation : NoAnimation, index, -count);
m_activeTransactions = activeTransactions;
+ updateSiblingsInformation();
}
if (hasMultipleRanges) {
}
if (hasMultipleRanges) {
+ m_endTransactionAnimationHint = NoAnimation;
+ updateSiblingsInformation();
- if (supportsItemExpanding()) {
- // The siblings information only gets updated in KItemListView::doLayout() if
- // items have been inserted or removed. In the case of just moving the items
- // the siblings must be updated manually:
- updateSiblingsInformation(firstVisibleMovedIndex, lastVisibleMovedIndex);
- }
-
+ updateSiblingsInformation();
}
void KItemListView::slotItemsChanged(const KItemRangeList& itemRanges,
}
void KItemListView::slotItemsChanged(const KItemRangeList& itemRanges,
const int lastVisibleIndex = m_layouter->lastVisibleIndex();
const int lastVisibleIndex = m_layouter->lastVisibleIndex();
- int firstExpansionIndex = -1;
- int lastExpansionIndex = -1;
+ int firstSibblingIndex = -1;
+ int lastSibblingIndex = -1;
const bool supportsExpanding = supportsItemExpanding();
const bool supportsExpanding = supportsItemExpanding();
- if (supportsExpanding && changedCount != 0) {
- // Any inserting or removing of items might result in changing the siblings-information
- // of other visible items.
- firstExpansionIndex = firstVisibleIndex;
- lastExpansionIndex = lastVisibleIndex;
- }
QList<int> reusableItems = recycleInvisibleItems(firstVisibleIndex, lastVisibleIndex, hint);
QList<int> reusableItems = recycleInvisibleItems(firstVisibleIndex, lastVisibleIndex, hint);
}
if (supportsExpanding && changedCount == 0) {
}
if (supportsExpanding && changedCount == 0) {
- if (firstExpansionIndex < 0) {
- firstExpansionIndex = i;
+ if (firstSibblingIndex < 0) {
+ firstSibblingIndex = i;
- lastExpansionIndex = i;
recycleWidget(m_visibleItems.value(index));
}
recycleWidget(m_visibleItems.value(index));
}
- if (supportsExpanding) {
- updateSiblingsInformation(firstExpansionIndex, lastExpansionIndex);
+ if (supportsExpanding && firstSibblingIndex >= 0) {
+ Q_ASSERT(lastSibblingIndex >= 0);
+ updateSiblingsInformation(firstSibblingIndex, lastSibblingIndex);
void KItemListView::updateSiblingsInformation(int firstIndex, int lastIndex)
{
void KItemListView::updateSiblingsInformation(int firstIndex, int lastIndex)
{
- const int firstVisibleIndex = m_layouter->firstVisibleIndex();
- const int lastVisibleIndex = m_layouter->lastVisibleIndex();
- const bool isRangeVisible = firstIndex >= 0 &&
- lastIndex >= firstIndex &&
- lastIndex >= firstVisibleIndex &&
- firstIndex <= lastVisibleIndex;
- if (!isRangeVisible) {
+ if (!supportsItemExpanding()) {
+ if (firstIndex < 0 || lastIndex < 0) {
+ firstIndex = m_layouter->firstVisibleIndex();
+ lastIndex = m_layouter->lastVisibleIndex();
+ } else {
+ const bool isRangeVisible = (firstIndex <= m_layouter->lastVisibleIndex() &&
+ lastIndex >= m_layouter->firstVisibleIndex());
+ if (!isRangeVisible) {
+ return;
+ }
+ }
+
int previousParents = 0;
QBitArray previousSiblings;
int previousParents = 0;
QBitArray previousSiblings;
+ Q_ASSERT(previousParents >= 0);
for (int i = rootIndex; i <= lastIndex; ++i) {
// Update the parent-siblings in case if the current item represents
// a child or an upper parent.
const int currentParents = m_model->expandedParentsCount(i);
for (int i = rootIndex; i <= lastIndex; ++i) {
// Update the parent-siblings in case if the current item represents
// a child or an upper parent.
const int currentParents = m_model->expandedParentsCount(i);
+ Q_ASSERT(currentParents >= 0);
if (previousParents < currentParents) {
previousParents = currentParents;
previousSiblings.resize(currentParents);
if (previousParents < currentParents) {
previousParents = currentParents;
previousSiblings.resize(currentParents);
/**
* Updates the siblings-information for all visible items that are inside
/**
* Updates the siblings-information for all visible items that are inside
- * the range of \p firstIndex and \p lastIndex.
+ * the range of \p firstIndex and \p lastIndex. If firstIndex or lastIndex
+ * is smaller than 0, the siblings-information for all visible items gets
+ * updated.
* @see KItemListWidget::setSiblingsInformation()
*/
* @see KItemListWidget::setSiblingsInformation()
*/
- void updateSiblingsInformation(int firstIndex, int lastIndex);
+ void updateSiblingsInformation(int firstIndex = -1, int lastIndex = -1);
/**
* Helper method for updateExpansionIndicators().
/**
* Helper method for updateExpansionIndicators().