From 0a1048a445616b9c1347e2ed2fd15ed0f45e09df Mon Sep 17 00:00:00 2001 From: Peter Penz Date: Sat, 20 Jun 2009 11:45:34 +0000 Subject: [PATCH] =?utf8?q?We=20won't=20get=20translated=20labels=20for=20N?= =?utf8?q?epomuk=20literals=20in=20KDE=204.3.0...=20At=20least=20assure=20?= =?utf8?q?that=20camelcase=20labels=20like=20"fileLocation:"=20are=20repla?= =?utf8?q?ced=20by=20"File=20location:"=20(thanks=20to=20Sebastian=20Tr?= =?utf8?q?=C3=BCg=20for=20the=20code)?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit svn path=/trunk/KDE/kdebase/apps/; revision=984190 --- src/panels/information/informationpanel.cpp | 25 +++++++++++++++++++-- src/panels/information/informationpanel.h | 7 ++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/panels/information/informationpanel.cpp b/src/panels/information/informationpanel.cpp index 30a41fefc..1fa5565d7 100644 --- a/src/panels/information/informationpanel.cpp +++ b/src/panels/information/informationpanel.cpp @@ -583,9 +583,11 @@ void InformationPanel::showMetaInfo() Nepomuk::Types::Property prop(it.key()); const QString label = prop.label(); if (settings.readEntry(label, true)) { - // TODO: use Nepomuk::formatValue(res, prop) if available + // TODO #1: use Nepomuk::formatValue(res, prop) if available // instead of it.value().toString() - m_metaTextLabel->add(label, it.value().toString()); + // TODO #2: using tunedLabel() is a workaround for KDE 4.3 until + // we get translated labels + m_metaTextLabel->add(tunedLabel(label), it.value().toString()); } ++it; } @@ -714,6 +716,25 @@ void InformationPanel::updatePhononWidget() } } +QString InformationPanel::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; +} + void InformationPanel::init() { m_infoTimer = new QTimer(this); diff --git a/src/panels/information/informationpanel.h b/src/panels/information/informationpanel.h index 46f080507..76af6a66a 100644 --- a/src/panels/information/informationpanel.h +++ b/src/panels/information/informationpanel.h @@ -194,6 +194,13 @@ private: void updatePhononWidget(); + /** + * Temporary helper method for KDE 4.3 as we currently don't get + * translated labels for Nepmok literals: Replaces camelcase labels + * like "fileLocation" by "File Location:". + */ + QString tunedLabel(const QString& label) const; + void init(); private: -- 2.47.3