]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/viewproperties.cpp
Whenever we are trying to sort, bypass lessThanGeneralPurpose when is not allowed...
[dolphin.git] / src / viewproperties.cpp
index 21f0c39da8844c35ed26a1d9bc9e2ee77eb86e1c..319a06bc230a16c834fcd758fc366e70aa21570b 100644 (file)
  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA          *
  ***************************************************************************/
 
-#include <assert.h>
+#include "viewproperties.h"
 
-#include <QDateTime>
-#include <QFile>
-#include <QFileInfo>
+#include "dolphinsettings.h"
+#include "dolphin_directoryviewpropertysettings.h"
+#include "dolphin_generalsettings.h"
 
 #include <kcomponentdata.h>
 #include <klocale.h>
 #include <kstandarddirs.h>
 #include <kurl.h>
 
-#include "viewproperties.h"
-#include "dolphinsettings.h"
-#include "dolphin_directoryviewpropertysettings.h"
-#include "dolphin_generalsettings.h"
+#ifdef HAVE_NEPOMUK
+    #include <nepomuk/resourcemanager.h>
+#endif
+
+#include <QDate>
+#include <QFile>
+#include <QFileInfo>
+
+bool ViewProperties::m_nepomukSupport = false;
 
 #define FILE_NAME "/.directory"
 
@@ -41,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();
@@ -160,7 +173,15 @@ void ViewProperties::setSorting(DolphinView::Sorting sorting)
 
 DolphinView::Sorting ViewProperties::sorting() const
 {
-    return static_cast<DolphinView::Sorting>(m_node->sorting());
+    // If Nepomuk is not available, return SortByName as fallback if SortByRating
+    // or SortByTags is stored.
+    DolphinView::Sorting sorting = static_cast<DolphinView::Sorting>(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)