[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: =?utf-8?q?=5Bkdelibs/KDE/4=2E6=5D_nepomuk/core=3A_Better_generic?=
From: Sebastian Trueg <trueg () kde ! org>
Date: 2011-02-25 8:50:15
Message-ID: 20110225085015.5B822A609B () git ! kde ! org
[Download RAW message or body]
Git commit acf6b58892575b95255fffd93162bcb856260fbb by Sebastian Trueg.
Committed on 25/02/2011 at 09:41.
Pushed by trueg into branch 'KDE/4.6'.
Better genericLabel() which uses the full nie:url for non-local URLs like web pages.
M +43 -46 nepomuk/core/resource.cpp
http://commits.kde.org/kdelibs/acf6b58892575b95255fffd93162bcb856260fbb
diff --git a/nepomuk/core/resource.cpp b/nepomuk/core/resource.cpp
index e9c5f60..f2134af 100644
--- a/nepomuk/core/resource.cpp
+++ b/nepomuk/core/resource.cpp
@@ -369,58 +369,55 @@ bool Nepomuk::Resource::isValid() const
}
-// KDE 4.5: cache this one in ResourceData
+// TODO: cache this one in ResourceData
QString Nepomuk::Resource::genericLabel() const
{
QString label = this->label();
- if ( label.isEmpty() ) {
- label = property( Soprano::Vocabulary::RDFS::label() ).toString();
-
- if ( label.isEmpty() ) {
- label = property( Nepomuk::Vocabulary::NIE::title() ).toString();
-
- if ( label.isEmpty() ) {
- label = property( Nepomuk::Vocabulary::NCO::fullname() ).toString();
-
- if ( label.isEmpty() ) {
- label = property( Soprano::Vocabulary::NAO::identifier() \
).toString();
-
- if ( label.isEmpty() ) {
- label = property( Soprano::Vocabulary::Xesam::name() \
).toString();
-
- if ( label.isEmpty() ) {
- label = m_data->pimoThing().label();
-
- if ( label.isEmpty() ) {
- label = property( \
Nepomuk::Vocabulary::NFO::fileName() ).toString();
-
- if ( label.isEmpty() ) {
- label = KUrl(property( \
Nepomuk::Vocabulary::NIE::url() ).toUrl()).fileName();
-
- if ( label.isEmpty() ) {
- QList<Resource> go = property( \
Vocabulary::PIMO::groundingOccurrence() ).toResourceList();
- if( !go.isEmpty() ) {
- label = go.first().genericLabel();
- if( label == \
KUrl(go.first().resourceUri()).pathOrUrl() ) {
- label.clear();
- }
- }
-
- if ( label.isEmpty() ) {
- // ugly fallback
- label = KUrl(resourceUri()).pathOrUrl();
- }
- }
- }
- }
- }
- }
- }
- }
+ if(!label.isEmpty())
+ return label;
+
+ label = property( Soprano::Vocabulary::RDFS::label() ).toString();
+ if(!label.isEmpty())
+ return label;
+
+ label = property( Nepomuk::Vocabulary::NIE::title() ).toString();
+ if(!label.isEmpty())
+ return label;
+
+ label = property( Nepomuk::Vocabulary::NCO::fullname() ).toString();
+ if(!label.isEmpty())
+ return label;
+
+ label = property( Soprano::Vocabulary::NAO::identifier() ).toString();
+ if(!label.isEmpty())
+ return label;
+
+ label = m_data->pimoThing().label();
+ if(!label.isEmpty())
+ return label;
+
+ label = property( Nepomuk::Vocabulary::NFO::fileName() ).toString();
+ if(!label.isEmpty())
+ return label;
+
+ const KUrl nieUrl = property( Nepomuk::Vocabulary::NIE::url() ).toUrl();
+ if(!nieUrl.isEmpty()) {
+ if(nieUrl.isLocalFile())
+ return nieUrl.fileName();
+ else
+ return nieUrl.prettyUrl();
+ }
+
+ QList<Resource> go = property( Vocabulary::PIMO::groundingOccurrence() \
).toResourceList(); + if( !go.isEmpty() ) {
+ label = go.first().genericLabel();
+ if( label != KUrl(go.first().resourceUri()).pathOrUrl() ) {
+ return label;
}
}
- return label;
+ // ugly fallback
+ return KUrl(resourceUri()).pathOrUrl();
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic