+ if (m_requestRole[ExpansionLevelRole] && m_rootExpansionLevel >= 0) {
+ // If the expanding of items is enabled in the model, it might be
+ // possible that the call dirLister->openUrl(url, KDirLister::Keep) in
+ // KFileItemModel::setExpanded() results in emitting of the same items
+ // twice due to the Keep-parameter. This case happens if an item gets
+ // expanded, collapsed and expanded again before the items could be loaded
+ // for the first expansion.
+ foreach (const KFileItem& item, items) {
+ const int index = m_items.value(item.url(), -1);
+ if (index >= 0) {
+ // The items are already part of the model.
+ return;
+ }
+ }
+ }
+