* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/
-#include <assert.h>
+#include "viewproperties.h"
-#include <QDateTime>
-#include <QFile>
+#include "dolphinsettings.h"
+#include "dolphin_directoryviewpropertysettings.h"
+#include "dolphin_generalsettings.h"
#include <kcomponentdata.h>
#include <klocale.h>
#include <kstandarddirs.h>
#include <kurl.h>
-#include <kcomponentdata.h>
-#include "viewproperties.h"
-#include "dolphinsettings.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"
ViewProperties::ViewProperties(const KUrl& url) :
- m_changedProps(false),
- m_autoSave(true),
- m_node(0)
+ m_changedProps(false),
+ 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();
const bool useGlobalViewProps = settings->globalViewProps();
if (useGlobalViewProps) {
m_filepath = destinationDir("global");
- }
- else if (cleanUrl.isLocalFile()) {
+ } else if (cleanUrl.isLocalFile()) {
const QFileInfo info(m_filepath);
if (!info.isWritable()) {
m_filepath = destinationDir("local") + m_filepath;
}
- }
- else {
+ } else {
m_filepath = destinationDir("remote") + m_filepath;
}
}
}
+void ViewProperties::setCategorizedSorting(bool categorized)
+{
+ if (m_node->categorizedSorting() != categorized) {
+ m_node->setCategorizedSorting(categorized);
+ updateTimeStamp();
+ }
+}
+
+bool ViewProperties::categorizedSorting() const
+{
+ return m_node->categorizedSorting();
+}
+
+
bool ViewProperties::showHiddenFiles() const
{
return m_node->showHiddenFiles();
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)
setViewMode(props.viewMode());
setShowPreview(props.showPreview());
setShowHiddenFiles(props.showHiddenFiles());
+ setCategorizedSorting(props.categorizedSorting());
setSorting(props.sorting());
setSortOrder(props.sortOrder());
setAdditionalInfo(props.additionalInfo());