Dolphin: Do not try to connect to Nepomuk if it is not running

Each time one uses any of the Nepomuk classes, an attempt is made to
connect to the database. This slows down the application since
connecting to Nepomuk is not so cheap.

BUG: 321299
This commit is contained in:
Vishesh Handa 2013-06-21 00:09:15 +05:30
parent 7a7cfa6add
commit 5778e10e9b

View file

@ -43,6 +43,7 @@
#ifdef HAVE_NEPOMUK
#include "private/knepomukrolesprovider.h"
#include <Nepomuk2/ResourceWatcher>
#include <Nepomuk2/ResourceManager>
#endif
// Required includes for subItemsCount():
@ -274,6 +275,7 @@ void KFileItemModelRolesUpdater::setRoles(const QSet<QByteArray>& roles)
m_roles = roles;
#ifdef HAVE_NEPOMUK
if (Nepomuk2::ResourceManager::instance()->initialized()) {
// Check whether there is at least one role that must be resolved
// with the help of Nepomuk. If this is the case, a (quite expensive)
// resolving will be done in KFileItemModelRolesUpdater::rolesData() and
@ -300,6 +302,7 @@ void KFileItemModelRolesUpdater::setRoles(const QSet<QByteArray>& roles)
m_nepomukResourceWatcher = 0;
m_nepomukUriItems.clear();
}
}
#endif
if (m_state == Paused) {
@ -737,6 +740,10 @@ void KFileItemModelRolesUpdater::resolveRecentlyChangedItems()
void KFileItemModelRolesUpdater::applyChangedNepomukRoles(const Nepomuk2::Resource& resource)
{
#ifdef HAVE_NEPOMUK
if (!Nepomuk2::ResourceManager::instance()->initialized()) {
return;
}
const KUrl itemUrl = m_nepomukUriItems.value(resource.uri());
const KFileItem item = m_model->fileItem(itemUrl);