Also show meta informations of files, if Nepomuk is not running or if the file is not indexed.

Still a lot of cleanups are required (e. g. the labels are not human readable currently).

svn path=/trunk/KDE/kdebase/apps/; revision=1096092
This commit is contained in:
Peter Penz 2010-02-25 19:34:58 +00:00
parent 3beca2e7f1
commit e488496286
2 changed files with 39 additions and 24 deletions

View file

@ -21,9 +21,10 @@
#include <kconfig.h>
#include <kconfiggroup.h>
#include <kfilemetainfo.h>
#include <kfilemetainfoitem.h>
#include <kglobal.h>
#include <klocale.h>
#include <kdebug.h>
#include <kprotocolinfo.h>
#include <nepomuk/resource.h>
@ -111,6 +112,20 @@ void KLoadMetaDataThread::run()
}
++it;
}
if (variants.isEmpty()) {
// TODO: The following code is just meant as temporary fallback to show
// non-indexed meta data.
KFileMetaInfo metaInfo(m_urls.first());
const QHash<QString, KFileMetaInfoItem> metaInfoItems = metaInfo.items();
foreach (const KFileMetaInfoItem& metaInfoItem, metaInfoItems) {
Item item;
item.name = metaInfoItem.name();
item.label = metaInfoItem.name() + metaInfoItem.prefix() + metaInfoItem.suffix();
item.value = metaInfoItem.value().toString();
m_items.append(item);
}
}
}
first = false;

View file

@ -358,12 +358,14 @@ void KMetaDataWidget::Private::slotLoadingFinished()
return;
}
Q_ASSERT(m_ratingWidget != 0);
Q_ASSERT(m_commentWidget != 0);
Q_ASSERT(m_taggingWidget != 0);
m_ratingWidget->setRating(m_loadMetaDataThread->rating());
m_commentWidget->setText(m_loadMetaDataThread->comment());
m_taggingWidget->setTags(m_loadMetaDataThread->tags());
if (m_nepomukActivated) {
Q_ASSERT(m_ratingWidget != 0);
Q_ASSERT(m_commentWidget != 0);
Q_ASSERT(m_taggingWidget != 0);
m_ratingWidget->setRating(m_loadMetaDataThread->rating());
m_commentWidget->setText(m_loadMetaDataThread->comment());
m_taggingWidget->setTags(m_loadMetaDataThread->tags());
}
// Show the remaining meta information as text. The number
// of required rows may very. Existing rows are reused to
@ -415,7 +417,7 @@ void KMetaDataWidget::Private::slotLoadingFinished()
m_files = m_loadMetaDataThread->files();
delete m_loadMetaDataThread;
m_loadMetaDataThread->deleteLater();
m_loadMetaDataThread = 0;
#endif
@ -581,24 +583,22 @@ void KMetaDataWidget::setItems(const KFileItemList& items)
}
#ifdef HAVE_NEPOMUK
if (d->m_nepomukActivated) {
QList<KUrl> urls;
foreach (const KFileItem& item, items) {
const KUrl url = item.nepomukUri();
if (url.isValid()) {
urls.append(url);
}
QList<KUrl> urls;
foreach (const KFileItem& item, items) {
const KUrl url = item.nepomukUri();
if (url.isValid()) {
urls.append(url);
}
if (d->m_loadMetaDataThread != 0) {
disconnect(d->m_loadMetaDataThread, SIGNAL(finished()), this, SLOT(slotLoadingFinished()));
d->m_loadMetaDataThread->cancelAndDelete();
}
d->m_loadMetaDataThread = new KLoadMetaDataThread();
connect(d->m_loadMetaDataThread, SIGNAL(finished()), this, SLOT(slotLoadingFinished()));
d->m_loadMetaDataThread->load(urls);
}
if (d->m_loadMetaDataThread != 0) {
disconnect(d->m_loadMetaDataThread, SIGNAL(finished()), this, SLOT(slotLoadingFinished()));
d->m_loadMetaDataThread->cancelAndDelete();
}
d->m_loadMetaDataThread = new KLoadMetaDataThread();
connect(d->m_loadMetaDataThread, SIGNAL(finished()), this, SLOT(slotLoadingFinished()));
d->m_loadMetaDataThread->load(urls);
#endif
}