X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/50a7b6fd45d88e61b06961dc9a4e564a13330acc..093efca22dfd247f06e2a669ad968300e71ef08d:/src/viewproperties.cpp diff --git a/src/viewproperties.cpp b/src/viewproperties.cpp index 835be2aad..319a06bc2 100644 --- a/src/viewproperties.cpp +++ b/src/viewproperties.cpp @@ -29,10 +29,16 @@ #include #include +#ifdef HAVE_NEPOMUK + #include +#endif + #include #include #include +bool ViewProperties::m_nepomukSupport = false; + #define FILE_NAME "/.directory" ViewProperties::ViewProperties(const KUrl& url) : @@ -40,6 +46,14 @@ ViewProperties::ViewProperties(const KUrl& url) : m_autoSave(true), m_node(0) { +#ifdef HAVE_NEPOMUK + static bool checkedNepomukSupport = false; + if (!checkedNepomukSupport) { + m_nepomukSupport = !Nepomuk::ResourceManager::instance()->init(); + checkedNepomukSupport = true; + } +#endif + KUrl cleanUrl(url); cleanUrl.cleanPath(); m_filepath = cleanUrl.path(); @@ -159,7 +173,15 @@ void ViewProperties::setSorting(DolphinView::Sorting sorting) DolphinView::Sorting ViewProperties::sorting() const { - return static_cast(m_node->sorting()); + // If Nepomuk is not available, return SortByName as fallback if SortByRating + // or SortByTags is stored. + DolphinView::Sorting sorting = static_cast(m_node->sorting()); + const bool sortByName = !m_nepomukSupport && + ((sorting == DolphinView::SortByRating) || (sorting == DolphinView::SortByTags)); + if (sortByName) { + sorting = DolphinView::SortByName; + } + return sorting; } void ViewProperties::setSortOrder(Qt::SortOrder sortOrder)