┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/CMakeLists.txt3
-rw-r--r--src/panels/information/kloadmetadatathread.cpp33
-rw-r--r--src/panels/information/kloadmetadatathread_p.h7
-rw-r--r--src/panels/information/kmetadatawidget.cpp18
-rw-r--r--src/panels/information/nfotranslator.cpp114
-rw-r--r--src/panels/information/nfotranslator.h47
6 files changed, 181 insertions, 41 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 264fc6ec1..37e24da11 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -57,6 +57,7 @@ set(dolphinprivate_LIB_SRCS
if(Nepomuk_FOUND)
set(dolphinprivate_LIB_SRCS
${dolphinprivate_LIB_SRCS}
+ panels/information/nfotranslator.cpp
panels/information/kcommentwidget.cpp
panels/information/kedittagsdialog.cpp
panels/information/kloadmetadatathread.cpp
@@ -168,6 +169,7 @@ kde4_add_kcfg_files(dolphin_SRCS
if(Nepomuk_FOUND)
set(dolphin_SRCS
${dolphin_SRCS}
+ panels/information/nfotranslator.cpp
panels/information/kcommentwidget.cpp
panels/information/kedittagsdialog.cpp
panels/information/kloadmetadatathread.cpp
@@ -255,6 +257,7 @@ set(kcm_dolphingeneral_PART_SRCS
if (Nepomuk_FOUND)
set(kcm_dolphingeneral_PART_SRCS
${kcm_dolphingeneral_PART_SRCS}
+ panels/information/nfotranslator.cpp
panels/information/kcommentwidget.cpp
panels/information/kedittagsdialog.cpp
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 <kconfig.h>
#include <kconfiggroup.h>
#include <kfilemetainfo.h>
@@ -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<QUrl, Nepomuk::Variant> variants = file.properties();
QHash<QUrl, Nepomuk::Variant>::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<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.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()) {
diff --git a/src/panels/information/kloadmetadatathread_p.h b/src/panels/information/kloadmetadatathread_p.h
index 08e4b0855..fddb01a1a 100644
--- a/src/panels/information/kloadmetadatathread_p.h
+++ b/src/panels/information/kloadmetadatathread_p.h
@@ -78,13 +78,6 @@ private slots:
private:
/**
- * Temporary helper method there is a way to get translated
- * labels for Nepmok literals: Replaces camelcase labels
- * like "fileLocation" by "File Location:".
- */
- QString tunedLabel(const QString& label) const;
-
- /**
* Temporary helper method until there is a proper formatting facility in Nepomuk.
* Here we simply handle the most common formatting situations that do not look nice
* when using Nepomuk::Variant::toString().
diff --git a/src/panels/information/kmetadatawidget.cpp b/src/panels/information/kmetadatawidget.cpp
index d5920ecb7..4d2812637 100644
--- a/src/panels/information/kmetadatawidget.cpp
+++ b/src/panels/information/kmetadatawidget.cpp
@@ -522,7 +522,7 @@ QList<KLoadMetaDataThread::Item>
mergedItems.insert(0, height);
} else if (foundWidth && foundHeight) {
KLoadMetaDataThread::Item size;
- size.label = i18nc("@label", "Width x Height:");
+ size.label = i18nc("@label image width and height", "Width x Height");
size.value = width.value + " x " + height.value;
mergedItems.insert(0, size);
}
@@ -546,7 +546,7 @@ void KMetaDataWidget::setItem(const KFileItem& item)
{
// update values for "type", "size", "modified",
// "owner" and "permissions" synchronously
- d->m_sizeLabel->setText(i18nc("@label", "Size:"));
+ d->m_sizeLabel->setText(i18nc("@label", "Size"));
if (item.isDir()) {
d->m_typeInfo->setText(i18nc("@label", "Folder"));
d->setRowVisible(d->m_sizeInfo, false);
@@ -679,17 +679,17 @@ bool KMetaDataWidget::event(QEvent* event)
// client of KMetaDataWidget to set a proper foreground role which
// will be respected by the rows.
- d->addRow(new QLabel(i18nc("@label", "Type:"), this), d->m_typeInfo);
+ d->addRow(new QLabel(i18nc("@label file type", "Type"), this), d->m_typeInfo);
d->addRow(d->m_sizeLabel, d->m_sizeInfo);
- d->addRow(new QLabel(i18nc("@label", "Modified:"), this), d->m_modifiedInfo);
- d->addRow(new QLabel(i18nc("@label", "Owner:"), this), d->m_ownerInfo);
- d->addRow(new QLabel(i18nc("@label", "Permissions:"), this), d->m_permissionsInfo);
+ d->addRow(new QLabel(i18nc("@label", "Modified"), this), d->m_modifiedInfo);
+ d->addRow(new QLabel(i18nc("@label", "Owner"), this), d->m_ownerInfo);
+ d->addRow(new QLabel(i18nc("@label", "Permissions"), this), d->m_permissionsInfo);
#ifdef HAVE_NEPOMUK
if (d->m_nepomukActivated) {
- d->addRow(new QLabel(i18nc("@label", "Rating:"), this), d->m_ratingWidget);
- d->addRow(new QLabel(i18nc("@label", "Tags:"), this), d->m_taggingWidget);
- d->addRow(new QLabel(i18nc("@label", "Comment:"), this), d->m_commentWidget);
+ d->addRow(new QLabel(i18nc("@label", "Rating"), this), d->m_ratingWidget);
+ d->addRow(new QLabel(i18nc("@label", "Tags"), this), d->m_taggingWidget);
+ d->addRow(new QLabel(i18nc("@label", "Comment"), this), d->m_commentWidget);
}
#endif
diff --git a/src/panels/information/nfotranslator.cpp b/src/panels/information/nfotranslator.cpp
new file mode 100644
index 000000000..10ec8d143
--- /dev/null
+++ b/src/panels/information/nfotranslator.cpp
@@ -0,0 +1,114 @@
+/*****************************************************************************
+ * Copyright (C) 2010 by Peter Penz <[email protected]> *
+ * *
+ * This library is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU Library General Public *
+ * License version 2 as published by the Free Software Foundation. *
+ * *
+ * This library is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Library General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Library General Public License *
+ * along with this library; see the file COPYING.LIB. If not, write to *
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, *
+ * Boston, MA 02110-1301, USA. *
+ *****************************************************************************/
+
+#include "nfotranslator.h"
+#include <klocale.h>
+#include <kstandarddirs.h>
+
+#include <QUrl>
+
+struct TranslationTuple {
+ const char* const key;
+ const char* const value;
+};
+
+// TODO: a lot of NFO's are missing yet
+static const TranslationTuple g_translations[] = {
+ { "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#comment", I18N_NOOP2("@label", "Comment") },
+ { "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#contentCreated", I18N_NOOP2("@label creation date", "Created") },
+ { "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#contentSize", I18N_NOOP2("@label file content size", "Size") },
+ { "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#isPartOf", I18N_NOOP2("@label parent directory", "Part of") },
+ { "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#lastModified", I18N_NOOP2("@label modified date of file", "Modified") },
+ { "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#mimeType", I18N_NOOP2("@label", "MIME Type") },
+ { "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#title", I18N_NOOP2("@label music title", "Title") },
+ { "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#url", I18N_NOOP2("@label file URL", "Location") },
+ { "http://www.semanticdesktop.org/ontologies/2007/03/22/nco#creator", I18N_NOOP2("@label", "Creator") },
+ { "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#averageBitrate", I18N_NOOP2("@label", "Average Bitrate") },
+ { "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#channels", I18N_NOOP2("@label", "Channels") },
+ { "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#characterCount", I18N_NOOP2("@label number of characters", "Characters") },
+ { "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#codec", I18N_NOOP2("@label", "Codec") },
+ { "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#colorDepth", I18N_NOOP2("@label", "Color Depth") },
+ { "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#fileName", I18N_NOOP2("@label", "File Name") },
+ { "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#height", I18N_NOOP2("@label", "Height") },
+ { "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#height", I18N_NOOP2("@label", "Height") },
+ { "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#interlaceMode", I18N_NOOP2("@label", "Interlace Mode") },
+ { "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#lineCount", I18N_NOOP2("@label number of lines", "Lines") },
+ { "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#sampleRate", I18N_NOOP2("@label", "Sample Rate") },
+ { "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#width", I18N_NOOP2("@label", "Width") },
+ { "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#wordCount", I18N_NOOP2("@label number of words", "Words") },
+ { "http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#apertureValue", I18N_NOOP2("@label EXIF aperture value", "Aperture") },
+ { "http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#exposureBiasValue", I18N_NOOP2("@label EXIF", "Exposure Bias Value") },
+ { "http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#exposureTime", I18N_NOOP2("@label EXIF", "Exposure Time") },
+ { "http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#flash", I18N_NOOP2("@label EXIF", "Flash") },
+ { "http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#flash", I18N_NOOP2("@label", "Flash") },
+ { "http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#focalLength", I18N_NOOP2("@label EXIF", "Focal Length") },
+ { "http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#isoSpeedRatings", I18N_NOOP2("@label EXIF", "ISO Speed Ratings") },
+ { "http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#make", I18N_NOOP2("@label EXIF", "Make") },
+ { "http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#meteringMode", I18N_NOOP2("@label EXIF", "Metering Mode") },
+ { "http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#meteringMode", I18N_NOOP2("@label", "Metering Mode") },
+ { "http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#model", I18N_NOOP2("@label EXIF", "Model") },
+ { "http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#orientation", I18N_NOOP2("@label EXIF", "Orientation") },
+ { "http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#whiteBalance", I18N_NOOP2("@label", "White Balance") },
+ { "http://www.semanticdesktop.org/ontologies/2009/02/19/nmm#genre", I18N_NOOP2("@label music genre", "Genre") },
+ { "http://www.semanticdesktop.org/ontologies/2009/02/19/nmm#musicAlbum", I18N_NOOP2("@label music album", "Album") },
+ { "http://www.semanticdesktop.org/ontologies/2009/02/19/nmm#trackNumber", I18N_NOOP2("@label music track number", "Track") },
+ { "http://www.w3.org/1999/02/22-rdf-syntax-ns#type", I18N_NOOP2("@label file type", "Type") },
+ { 0, 0 } // mandatory last entry
+};
+
+class NfoTranslatorSingleton
+{
+public:
+ NfoTranslator instance;
+};
+K_GLOBAL_STATIC(NfoTranslatorSingleton, s_nfoTranslator)
+
+NfoTranslator& NfoTranslator::instance()
+{
+ return s_nfoTranslator->instance;
+}
+
+QString NfoTranslator::translation(const QUrl& uri) const
+{
+ const QString key = uri.toString();
+ if (m_hash.contains(key)) {
+ return m_hash.value(key);
+ }
+
+ // fallback if the URI is not translated
+ QString translation;
+ const int index = key.indexOf(QChar('#'));
+ if (index >= 0) {
+ translation = key.right(key.size() - index - 1);
+ }
+ return translation;
+}
+
+NfoTranslator::NfoTranslator() :
+ m_hash()
+{
+ const TranslationTuple* tuple = &g_translations[0];
+ while (tuple->key != 0) {
+ m_hash.insert(tuple->key, i18n(tuple->value));
+ ++tuple;
+ }
+}
+
+NfoTranslator::~NfoTranslator()
+{
+}
diff --git a/src/panels/information/nfotranslator.h b/src/panels/information/nfotranslator.h
new file mode 100644
index 000000000..4a51c60f3
--- /dev/null
+++ b/src/panels/information/nfotranslator.h
@@ -0,0 +1,47 @@
+/*****************************************************************************
+ * Copyright (C) 2010 by Peter Penz <[email protected]> *
+ * *
+ * This library is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU Library General Public *
+ * License version 2 as published by the Free Software Foundation. *
+ * *
+ * This library is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Library General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Library General Public License *
+ * along with this library; see the file COPYING.LIB. If not, write to *
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, *
+ * Boston, MA 02110-1301, USA. *
+ *****************************************************************************/
+
+#ifndef NFOTRANSLATOR_H
+#define NFOTRANSLATOR_H
+
+#include <QHash>
+#include <QString>
+
+class QUrl;
+
+/**
+ * @brief Returns translations for Nepomuk File Ontology URIs.
+ *
+ * See http://www.semanticdesktop.org/ontologies/nfo/.
+ */
+class NfoTranslator
+{
+public:
+ static NfoTranslator& instance();
+ QString translation(const QUrl& uri) const;
+
+protected:
+ NfoTranslator();
+ virtual ~NfoTranslator();
+ friend class NfoTranslatorSingleton;
+
+private:
+ QHash<QString, QString> m_hash;
+};
+
+#endif // NFO_TRANSLATOR_H