aboutsummaryrefslogtreecommitdiff
path: root/lumina-fm
diff options
context:
space:
mode:
Diffstat (limited to 'lumina-fm')
-rw-r--r--lumina-fm/DDFileSystemModel.h36
-rw-r--r--lumina-fm/MainUI.cpp4
-rw-r--r--lumina-fm/MainUI.h4
-rw-r--r--lumina-fm/MainUI.ui10
-rw-r--r--lumina-fm/lumina-fm.pro3
5 files changed, 49 insertions, 8 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
diff --git a/lumina-fm/MainUI.cpp b/lumina-fm/MainUI.cpp
index e2d0cbd2..fe3240dc 100644
--- a/lumina-fm/MainUI.cpp
+++ b/lumina-fm/MainUI.cpp
@@ -44,8 +44,10 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI){
worker = new BackgroundWorker;
worker->moveToThread(workThread);
if(DEBUG){ qDebug() << " - File System Model"; }
- fsmod = new QFileSystemModel(this);
+ fsmod = new DDFileSystemModel(this);
fsmod->setRootPath("/");
+ //fsmod->setReadOnly(false); //required for DnD, but also enables a lot of other stuff
+ //qDebug() << "DnD options:" << fsmod->supportedDropActions();
ui->tree_dir_view->setModel(fsmod);
ui->tree_dir_view->sortByColumn(0, Qt::AscendingOrder);
ui->tree_dir_view->setColumnWidth(0,200);
diff --git a/lumina-fm/MainUI.h b/lumina-fm/MainUI.h
index 9b93b1d7..40ef25ff 100644
--- a/lumina-fm/MainUI.h
+++ b/lumina-fm/MainUI.h
@@ -53,6 +53,7 @@
#include "BMMDialog.h" //bookmark manager dialog
#include "MimeIconProvider.h" //icon provider for the view widgets
#include "BackgroundWorker.h"
+#include "DDFileSystemModel.h"
namespace Ui{
class MainUI;
@@ -76,7 +77,8 @@ private:
//Internal non-ui widgets
QTabBar *tabBar;
QLineEdit *currentDir;
- QFileSystemModel *fsmod, *snapmod;
+ DDFileSystemModel *fsmod;
+ QFileSystemModel *snapmod;
//QFileSystemWatcher *fswatcher;
MimeIconProvider *iconProv;
QMenu *contextMenu;
diff --git a/lumina-fm/MainUI.ui b/lumina-fm/MainUI.ui
index 8c954061..4b2156c2 100644
--- a/lumina-fm/MainUI.ui
+++ b/lumina-fm/MainUI.ui
@@ -30,7 +30,7 @@
<item>
<widget class="QStackedWidget" name="stackedWidget">
<property name="currentIndex">
- <number>2</number>
+ <number>0</number>
</property>
<widget class="QWidget" name="page_browser">
<layout class="QGridLayout" name="gridLayout">
@@ -69,10 +69,10 @@
<bool>true</bool>
</property>
<property name="dragDropMode">
- <enum>QAbstractItemView::NoDragDrop</enum>
+ <enum>QAbstractItemView::InternalMove</enum>
</property>
<property name="defaultDropAction">
- <enum>Qt::IgnoreAction</enum>
+ <enum>Qt::MoveAction</enum>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::ExtendedSelection</enum>
@@ -124,10 +124,10 @@
<bool>true</bool>
</property>
<property name="dragDropMode">
- <enum>QAbstractItemView::NoDragDrop</enum>
+ <enum>QAbstractItemView::InternalMove</enum>
</property>
<property name="defaultDropAction">
- <enum>Qt::IgnoreAction</enum>
+ <enum>Qt::MoveAction</enum>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::ExtendedSelection</enum>
diff --git a/lumina-fm/lumina-fm.pro b/lumina-fm/lumina-fm.pro
index 8f01a93c..53e2dd2d 100644
--- a/lumina-fm/lumina-fm.pro
+++ b/lumina-fm/lumina-fm.pro
@@ -24,7 +24,8 @@ HEADERS += MainUI.h \
FODialog.h \
BMMDialog.h \
MimeIconProvider.h \
- BackgroundWorker.h
+ BackgroundWorker.h \
+ DDFileSystemModel.h
FORMS += MainUI.ui \
FODialog.ui \
bgstack15