Overwrite the changed role value with an empty QVariant,

because the nepomuk roles provider doesn't overwrite it when the property
value list is empty.

BUG: 322348
REVIEW: 111505
FIXED-IN: 4.11.0
This commit is contained in:
Emmanuel Pescosta 2013-07-18 17:07:34 +02:00
parent 63b26cbf2c
commit aa2dda8cb4
4 changed files with 23 additions and 4 deletions

View file

@ -294,7 +294,7 @@ void KFileItemModelRolesUpdater::setRoles(const QSet<QByteArray>& roles)
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;
@ -721,7 +721,7 @@ void KFileItemModelRolesUpdater::resolveRecentlyChangedItems()
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()) {
@ -740,6 +740,14 @@ void KFileItemModelRolesUpdater::applyChangedNepomukRoles(const Nepomuk2::Resour
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();

View file

@ -43,6 +43,10 @@ class QTimer;
{
class ResourceWatcher;
class Resource;
namespace Types
{
class Property;
}
}
#else
// Required for the slot applyChangedNepomukRoles() that
@ -208,7 +212,7 @@ private slots:
*/
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

View file

@ -68,7 +68,7 @@ QHash<QByteArray, QVariant> KNepomukRolesProvider::roleValues(const Nepomuk2::Re
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;
}
@ -118,6 +118,11 @@ QHash<QByteArray, QVariant> KNepomukRolesProvider::roleValues(const Nepomuk2::Re
return values;
}
QByteArray KNepomukRolesProvider::roleForPropertyUri(const QUrl& uri) const
{
return m_roleForUri.value(uri);
}
KNepomukRolesProvider::KNepomukRolesProvider() :
m_roles(),
m_roleForUri()

View file

@ -55,6 +55,8 @@ public:
QHash<QByteArray, QVariant> roleValues(const Nepomuk2::Resource& resource,
const QSet<QByteArray>& roles) const;
QByteArray roleForPropertyUri(const QUrl& uri) const;
protected:
KNepomukRolesProvider();