+#ifdef HAVE_BALOO
+ Baloo::File file(item.localPath());
+ file.load();
+
+ const KBalooRolesProvider& rolesProvider = KBalooRolesProvider::instance();
+ QHash<QByteArray, QVariant> data;
+
+ foreach (const QByteArray& role, rolesProvider.roles()) {
+ // Overwrite all the role values with an empty QVariant, because the roles
+ // provider doesn't overwrite it when the property value list is empty.
+ // See bug 322348
+ data.insert(role, QVariant());
+ }
+
+ QHashIterator<QByteArray, QVariant> it(rolesProvider.roleValues(file, m_roles));
+ while (it.hasNext()) {
+ it.next();
+ data.insert(it.key(), it.value());
+ }
+
+ disconnect(m_model, &KFileItemModel::itemsChanged,
+ this, &KFileItemModelRolesUpdater::slotItemsChanged);
+ const int index = m_model->index(item);
+ m_model->setData(index, data);
+ connect(m_model, &KFileItemModel::itemsChanged,
+ this, &KFileItemModelRolesUpdater::slotItemsChanged);
+#else
+#ifndef Q_CC_MSVC
+ Q_UNUSED(item);
+#endif
+#endif
+}
+
+void KFileItemModelRolesUpdater::slotDirectoryContentsCountReceived(const QString& path, int count)
+{
+ const bool getSizeRole = m_roles.contains("size");
+ const bool getIsExpandableRole = m_roles.contains("isExpandable");
+
+ if (getSizeRole || getIsExpandableRole) {
+ const int index = m_model->index(QUrl::fromLocalFile(path));
+ if (index >= 0) {
+ QHash<QByteArray, QVariant> data;
+
+ if (getSizeRole) {
+ data.insert("size", count);
+ }
+ if (getIsExpandableRole) {
+ data.insert("isExpandable", count > 0);
+ }
+
+ disconnect(m_model, &KFileItemModel::itemsChanged,
+ this, &KFileItemModelRolesUpdater::slotItemsChanged);
+ m_model->setData(index, data);
+ connect(m_model, &KFileItemModel::itemsChanged,
+ this, &KFileItemModelRolesUpdater::slotItemsChanged);
+ }
+ }
+}
+
+void KFileItemModelRolesUpdater::startUpdating()
+{
+ if (m_state == Paused) {