aboutsummaryrefslogtreecommitdiff
path: root/lumina-fm/DDFileSystemModel.h
diff options
context:
space:
mode:
authorKen Moore <ken@pcbsd.org>2015-02-24 12:32:00 -0500
committerKen Moore <ken@pcbsd.org>2015-02-24 12:32:00 -0500
commitbece1d27f3a650683aa1ee5efe27c0797193a19f (patch)
tree6df66a92a79d89b5983feca0f02888b0bf33d0d1 /lumina-fm/DDFileSystemModel.h
parentFinish up some little things in lumina-xconfig, and add it to the build/port. (diff)
downloadlumina-bece1d27f3a650683aa1ee5efe27c0797193a19f.tar.gz
lumina-bece1d27f3a650683aa1ee5efe27c0797193a19f.tar.bz2
lumina-bece1d27f3a650683aa1ee5efe27c0797193a19f.zip
Subclass the main QFileSystemModel to provide drag and drop support. This still appears to be able to "drop" items outside the window (for other applications) and has strange behavior in those cases (although non-critical - it does not change the filesystem in any way).
Diffstat (limited to 'lumina-fm/DDFileSystemModel.h')
-rw-r--r--lumina-fm/DDFileSystemModel.h36
1 files changed, 36 insertions, 0 deletions
diff --git a/lumina-fm/DDFileSystemModel.h b/lumina-fm/DDFileSystemModel.h
new file mode 100644
index 00000000..caa83b0e
--- /dev/null
+++ b/lumina-fm/DDFileSystemModel.h
@@ -0,0 +1,36 @@
+//===========================================
+// Lumina-DE source code
+// Copyright (c) 2014, Ken Moore
+// Available under the 3-clause BSD license
+// See the LICENSE file for full details
+//===========================================
+// This is a simple subclassed QFileSystemModel to enable drag and drop
+// (and moving) but disable all the other filesystem modifications
+//===========================================
+#ifndef _LUMINA_FILE_MANAGER_DDFILESYSTEMMODEL_H
+#define _LUMINA_FILE_MANAGER_DDFILESYSTEMMODEL_H
+
+#include <QFileSystemModel>
+#include <QObject>
+
+class DDFileSystemModel : public QFileSystemModel{
+ Q_OBJECT
+public:
+ DDFileSystemModel(QObject *parent = 0) : QFileSystemModel(parent){
+ this->setReadOnly(false); //need this to enable DnD
+ }
+ ~DDFileSystemModel(){}
+
+ virtual Qt::ItemFlags flags(const QModelIndex &index) const {
+ //First get all the flags from the standard QFileSystemModel
+ Qt::ItemFlags defaultflags = QFileSystemModel::flags(index);
+ //Now if it has the "Editable" flag set - remove it
+ if(defaultflags & Qt::ItemIsEditable){
+ defaultflags ^= Qt::ItemIsEditable;
+ }
+
+ return defaultflags;
+ }
+};
+
+#endif \ No newline at end of file
bgstack15