m_nepomukResourceWatcher = new Nepomuk2::ResourceWatcher(this);
connect(m_nepomukResourceWatcher, SIGNAL(propertyChanged(Nepomuk2::Resource,Nepomuk2::Types::Property,QVariantList,QVariantList)),
- this, SLOT(applyChangedNepomukRoles(Nepomuk2::Resource)));
+ this, SLOT(applyChangedNepomukRoles(Nepomuk2::Resource,Nepomuk2::Types::Property)));
} else if (!hasNepomukRole && m_nepomukResourceWatcher) {
delete m_nepomukResourceWatcher;
m_nepomukResourceWatcher = 0;
updateChangedItems();
}
-void KFileItemModelRolesUpdater::applyChangedNepomukRoles(const Nepomuk2::Resource& resource)
+void KFileItemModelRolesUpdater::applyChangedNepomukRoles(const Nepomuk2::Resource& resource, const Nepomuk2::Types::Property& property)
{
#ifdef HAVE_NEPOMUK
if (!Nepomuk2::ResourceManager::instance()->initialized()) {
QHash<QByteArray, QVariant> data = rolesData(item);
const KNepomukRolesProvider& rolesProvider = KNepomukRolesProvider::instance();
+ const QByteArray role = rolesProvider.roleForPropertyUri(property.uri());
+ if (!role.isEmpty() && m_roles.contains(role)) {
+ // Overwrite the changed role value 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(resource, m_roles));
while (it.hasNext()) {
it.next();
{
class ResourceWatcher;
class Resource;
+ namespace Types
+ {
+ class Property;
+ }
}
#else
// Required for the slot applyChangedNepomukRoles() that
*/
void resolveRecentlyChangedItems();
- void applyChangedNepomukRoles(const Nepomuk2::Resource& resource);
+ void applyChangedNepomukRoles(const Nepomuk2::Resource& resource, const Nepomuk2::Types::Property& property);
/**
* Is invoked if a directory watched by KDirWatch got dirty. Updates
it.next();
const Nepomuk2::Types::Property property = it.key();
- const QByteArray role = m_roleForUri.value(property.uri());
+ const QByteArray role = roleForPropertyUri(property.uri());
if (role.isEmpty() || !roles.contains(role)) {
continue;
}
return values;
}
+QByteArray KNepomukRolesProvider::roleForPropertyUri(const QUrl& uri) const
+{
+ return m_roleForUri.value(uri);
+}
+
KNepomukRolesProvider::KNepomukRolesProvider() :
m_roles(),
m_roleForUri()