#include "kfileitemmodel.h"
-#include <KDirModel>
#include <KGlobalSettings>
#include <KLocale>
#include <KStringHandler>
KUrl::List urls;
KUrl::List mostLocalUrls;
bool canUseMostLocalUrls = true;
+ const ItemData* lastAddedItem = 0;
foreach (int index, indexes) {
- const KFileItem item = fileItem(index);
+ const ItemData* itemData = m_itemData.at(index);
+ const ItemData* parent = itemData->parent;
+
+ while (parent && parent != lastAddedItem) {
+ parent = parent->parent;
+ }
+
+ if (parent && parent == lastAddedItem) {
+ // A parent of 'itemData' has been added already.
+ continue;
+ }
+
+ lastAddedItem = itemData;
+ const KFileItem& item = itemData->item;
if (!item.isNull()) {
urls << item.targetUrl();
}
const bool different = canUseMostLocalUrls && mostLocalUrls != urls;
- urls = KDirModel::simplifiedUrlList(urls); // TODO: Check if we still need KDirModel for this in KDE 5.0
if (different) {
- mostLocalUrls = KDirModel::simplifiedUrlList(mostLocalUrls);
urls.populateMimeData(mostLocalUrls, data);
} else {
urls.populateMimeData(data);
// menus tries to put the actions into sub menus otherwise.
info.group = QString();
}
- info.requiresNepomuk = map[i].requiresNepomuk;
+ info.requiresBaloo = map[i].requiresBaloo;
info.requiresIndexer = map[i].requiresIndexer;
rolesInfo.append(info);
}
m_items.remove(oldItem.url());
m_items.insert(newItem.url(), index);
indexes.append(index);
+ } else {
+ // Check if 'oldItem' is one of the filtered items.
+ QHash<KFileItem, ItemData*>::iterator it = m_filteredItems.find(oldItem);
+ if (it != m_filteredItems.end()) {
+ ItemData* itemData = it.value();
+ itemData->item = newItem;
+
+ // The data stored in 'values' might have changed. Therefore, we clear
+ // 'values' and re-populate it the next time it is requested via data(int).
+ itemData->values.clear();
+
+ m_filteredItems.erase(it);
+ m_filteredItems.insert(newItem, itemData);
+ }
}
}
const KFileItemModel::RoleInfoMap* KFileItemModel::rolesInfoMap(int& count)
{
static const RoleInfoMap rolesInfoMap[] = {
- // | role | roleType | role translation | group translation | requires Nepomuk | requires indexer
+ // | role | roleType | role translation | group translation | requires Baloo | requires indexer
{ 0, NoRole, 0, 0, 0, 0, false, false },
{ "text", NameRole, I18N_NOOP2_NOSTRIP("@label", "Name"), 0, 0, false, false },
{ "size", SizeRole, I18N_NOOP2_NOSTRIP("@label", "Size"), 0, 0, false, false },