]> cloud.milkyroute.net Git - dolphin.git/blob - src/panels/information/knfotranslator.cpp
Remove connection to non-existent slot.
[dolphin.git] / src / panels / information / knfotranslator.cpp
1 /*****************************************************************************
2 * Copyright (C) 2010 by Peter Penz <peter.penz@gmx.at> *
3 * *
4 * This library is free software; you can redistribute it and/or *
5 * modify it under the terms of the GNU Library General Public *
6 * License version 2 as published by the Free Software Foundation. *
7 * *
8 * This library is distributed in the hope that it will be useful, *
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
11 * Library General Public License for more details. *
12 * *
13 * You should have received a copy of the GNU Library General Public License *
14 * along with this library; see the file COPYING.LIB. If not, write to *
15 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, *
16 * Boston, MA 02110-1301, USA. *
17 *****************************************************************************/
18
19 #include "knfotranslator_p.h"
20 #include <klocale.h>
21 #include <kstandarddirs.h>
22
23 #include <kurl.h>
24
25 struct TranslationTuple {
26 const char* const key;
27 const char* const value;
28 };
29
30 // TODO: a lot of NFO's are missing yet
31 static const TranslationTuple g_translations[] = {
32 { "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#comment", I18N_NOOP2("@label", "Comment") },
33 { "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#contentCreated", I18N_NOOP2("@label creation date", "Created") },
34 { "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#contentSize", I18N_NOOP2("@label file content size", "Size") },
35 { "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#depends", I18N_NOOP2("@label file depends from", "Depends") },
36 { "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#isPartOf", I18N_NOOP2("@label parent directory", "Part of") },
37 { "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#lastModified", I18N_NOOP2("@label modified date of file", "Modified") },
38 { "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#mimeType", I18N_NOOP2("@label", "MIME Type") },
39 { "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#plainTextContent", I18N_NOOP2("@label", "Content") },
40 { "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#title", I18N_NOOP2("@label music title", "Title") },
41 { "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#url", I18N_NOOP2("@label file URL", "Location") },
42 { "http://www.semanticdesktop.org/ontologies/2007/03/22/nco#creator", I18N_NOOP2("@label", "Creator") },
43 { "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#averageBitrate", I18N_NOOP2("@label", "Average Bitrate") },
44 { "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#channels", I18N_NOOP2("@label", "Channels") },
45 { "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#characterCount", I18N_NOOP2("@label number of characters", "Characters") },
46 { "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#codec", I18N_NOOP2("@label", "Codec") },
47 { "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#colorDepth", I18N_NOOP2("@label", "Color Depth") },
48 { "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#fileName", I18N_NOOP2("@label", "Filename") },
49 { "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#height", I18N_NOOP2("@label", "Height") },
50 { "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#interlaceMode", I18N_NOOP2("@label", "Interlace Mode") },
51 { "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#lineCount", I18N_NOOP2("@label number of lines", "Lines") },
52 { "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#programmingLanguage", I18N_NOOP2("@label", "Programming Language") },
53 { "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#sampleRate", I18N_NOOP2("@label", "Sample Rate") },
54 { "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#width", I18N_NOOP2("@label", "Width") },
55 { "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#wordCount", I18N_NOOP2("@label number of words", "Words") },
56 { "http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#apertureValue", I18N_NOOP2("@label EXIF aperture value", "Aperture") },
57 { "http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#exposureBiasValue", I18N_NOOP2("@label EXIF", "Exposure Bias Value") },
58 { "http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#exposureTime", I18N_NOOP2("@label EXIF", "Exposure Time") },
59 { "http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#flash", I18N_NOOP2("@label EXIF", "Flash") },
60 { "http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#focalLength", I18N_NOOP2("@label EXIF", "Focal Length") },
61 { "http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#focalLengthIn35mmFilm", I18N_NOOP2("@label EXIF", "Focal Length 35 mm") },
62 { "http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#isoSpeedRatings", I18N_NOOP2("@label EXIF", "ISO Speed Ratings") },
63 { "http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#make", I18N_NOOP2("@label EXIF", "Make") },
64 { "http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#meteringMode", I18N_NOOP2("@label EXIF", "Metering Mode") },
65 { "http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#model", I18N_NOOP2("@label EXIF", "Model") },
66 { "http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#orientation", I18N_NOOP2("@label EXIF", "Orientation") },
67 { "http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#whiteBalance", I18N_NOOP2("@label EXIF", "White Balance") },
68 { "http://www.semanticdesktop.org/ontologies/2009/02/19/nmm#genre", I18N_NOOP2("@label music genre", "Genre") },
69 { "http://www.semanticdesktop.org/ontologies/2009/02/19/nmm#musicAlbum", I18N_NOOP2("@label music album", "Album") },
70 { "http://www.semanticdesktop.org/ontologies/2009/02/19/nmm#trackNumber", I18N_NOOP2("@label music track number", "Track") },
71 { "http://www.w3.org/1999/02/22-rdf-syntax-ns#type", I18N_NOOP2("@label file type", "Type") },
72 { 0, 0 } // mandatory last entry
73 };
74
75 class KNfoTranslatorSingleton
76 {
77 public:
78 KNfoTranslator instance;
79 };
80 K_GLOBAL_STATIC(KNfoTranslatorSingleton, s_nfoTranslator)
81
82 KNfoTranslator& KNfoTranslator::instance()
83 {
84 return s_nfoTranslator->instance;
85 }
86
87 QString KNfoTranslator::translation(const KUrl& uri) const
88 {
89 const QString key = uri.url();
90 if (m_hash.contains(key)) {
91 return m_hash.value(key);
92 }
93
94 // fallback if the URI is not translated
95 QString translation;
96 const int index = key.indexOf(QChar('#'));
97 if (index >= 0) {
98 translation = key.right(key.size() - index - 1);
99 }
100 return translation;
101 }
102
103 KNfoTranslator::KNfoTranslator() :
104 m_hash()
105 {
106 const TranslationTuple* tuple = &g_translations[0];
107 while (tuple->key != 0) {
108 m_hash.insert(tuple->key, i18n(tuple->value));
109 ++tuple;
110 }
111 }
112
113 KNfoTranslator::~KNfoTranslator()
114 {
115 }