From 4e370297de110dbb5c6c231dd460e2a7d46e496b Mon Sep 17 00:00:00 2001 From: Peter Penz Date: Fri, 26 Feb 2010 18:03:13 +0000 Subject: Show meta information also for files, which are not indexed (or in the case if Nepomuk is turned off). Beside the new translations the fix is based on several other fixes in kdelibs + strigi and cannot be backported to KDE SC 4.4.x. As soon as the meta data widget has been moved to kdelibs, this meta data information will also be available in the properties dialog. BUG: 193592 svn path=/trunk/KDE/kdebase/apps/; revision=1096472 --- src/panels/information/kloadmetadatathread.cpp | 33 +++++++------------------- 1 file changed, 8 insertions(+), 25 deletions(-) (limited to 'src/panels/information/kloadmetadatathread.cpp') diff --git a/src/panels/information/kloadmetadatathread.cpp b/src/panels/information/kloadmetadatathread.cpp index 5569933a1..0239503be 100644 --- a/src/panels/information/kloadmetadatathread.cpp +++ b/src/panels/information/kloadmetadatathread.cpp @@ -19,6 +19,8 @@ #include "kloadmetadatathread_p.h" +#include "nfotranslator.h" + #include #include #include @@ -96,9 +98,9 @@ void KLoadMetaDataThread::run() m_tags = file.tags(); } + NfoTranslator& nfo = NfoTranslator::instance(); if (first && (m_urls.count() == 1)) { - // TODO: show shared meta information instead - // of not showing anything on multiple selections + // get cached meta data by checking the indexed files QHash variants = file.properties(); QHash::const_iterator it = variants.constBegin(); while (it != variants.constEnd()) { @@ -106,7 +108,7 @@ void KLoadMetaDataThread::run() if (settings.readEntry(prop.name(), true)) { Item item; item.name = prop.name(); - item.label = tunedLabel(prop.label()); + item.label = nfo.translation(prop.uri()); item.value = formatValue(it.value()); m_items.append(item); } @@ -114,14 +116,14 @@ void KLoadMetaDataThread::run() } if (variants.isEmpty()) { - // TODO: The following code is just meant as temporary fallback to show - // non-indexed meta data. + // the file has not been indexed, query the meta data + // directly from the file KFileMetaInfo metaInfo(m_urls.first()); const QHash metaInfoItems = metaInfo.items(); foreach (const KFileMetaInfoItem& metaInfoItem, metaInfoItems) { Item item; item.name = metaInfoItem.name(); - item.label = metaInfoItem.name() + metaInfoItem.prefix() + metaInfoItem.suffix(); + item.label = nfo.translation(metaInfoItem.name()); item.value = metaInfoItem.value().toString(); m_items.append(item); } @@ -162,25 +164,6 @@ void KLoadMetaDataThread::slotFinished() deleteLater(); } -QString KLoadMetaDataThread::tunedLabel(const QString& label) const -{ - QString tunedLabel; - const int labelLength = label.length(); - if (labelLength > 0) { - tunedLabel.reserve(labelLength); - tunedLabel = label[0].toUpper(); - for (int i = 1; i < labelLength; ++i) { - if (label[i].isUpper() && !label[i - 1].isSpace() && !label[i - 1].isUpper()) { - tunedLabel += ' '; - tunedLabel += label[i].toLower(); - } else { - tunedLabel += label[i]; - } - } - } - return tunedLabel + ':'; -} - QString KLoadMetaDataThread::formatValue(const Nepomuk::Variant& value) { if (value.isDateTime()) { -- cgit v1.3