[qet] [4284] Enable the drag and drop inside the new element panel

[ Thread Index | Date Index | More lists.tuxfamily.org/qet Archives ]


Revision: 4284
Author:   blacksun
Date:     2015-12-09 21:27:31 +0100 (Wed, 09 Dec 2015)
Log Message:
-----------
Enable the drag and drop inside the new element panel

Modified Paths:
--------------
    trunk/sources/ElementsCollection/elementcollectionitem.cpp
    trunk/sources/ElementsCollection/elementcollectionitem.h
    trunk/sources/ElementsCollection/elementlocation.cpp
    trunk/sources/ElementsCollection/elementlocation.h
    trunk/sources/ElementsCollection/elementscollectionmodel.cpp
    trunk/sources/ElementsCollection/elementscollectionmodel.h
    trunk/sources/ElementsCollection/elementscollectionwidget.cpp
    trunk/sources/ElementsCollection/elementscollectionwidget.h
    trunk/sources/ElementsCollection/fileelementcollectionitem.cpp
    trunk/sources/ElementsCollection/fileelementcollectionitem.h

Modified: trunk/sources/ElementsCollection/elementcollectionitem.cpp
===================================================================
--- trunk/sources/ElementsCollection/elementcollectionitem.cpp	2015-12-08 16:52:10 UTC (rev 4283)
+++ trunk/sources/ElementsCollection/elementcollectionitem.cpp	2015-12-09 20:27:31 UTC (rev 4284)
@@ -163,3 +163,17 @@
 bool ElementCollectionItem::isValid() const {
 	return false;
 }
+
+/**
+ * @brief ElementCollectionItem::items
+ * @return all child and subchild subsubchild... contained by this item
+ * This item isn't stored in the list
+ */
+QList<ElementCollectionItem *> ElementCollectionItem::items() const
+{
+	QList<ElementCollectionItem *> list;
+	list.append(m_child_items);
+	foreach(ElementCollectionItem *eci, m_child_items)
+		list.append(eci->items());
+	return list;
+}

Modified: trunk/sources/ElementsCollection/elementcollectionitem.h
===================================================================
--- trunk/sources/ElementsCollection/elementcollectionitem.h	2015-12-08 16:52:10 UTC (rev 4283)
+++ trunk/sources/ElementsCollection/elementcollectionitem.h	2015-12-09 20:27:31 UTC (rev 4284)
@@ -55,6 +55,7 @@
 		virtual bool isDir() const;
 		virtual bool isElement() const;
 		virtual bool isValid() const;
+		virtual QList <ElementCollectionItem *> items() const;
 
 	protected:
         ElementCollectionItem *m_parent_item;

Modified: trunk/sources/ElementsCollection/elementlocation.cpp
===================================================================
--- trunk/sources/ElementsCollection/elementlocation.cpp	2015-12-08 16:52:10 UTC (rev 4283)
+++ trunk/sources/ElementsCollection/elementlocation.cpp	2015-12-09 20:27:31 UTC (rev 4284)
@@ -1,19 +1,19 @@
 /*
-        Copyright 2006-2015 The QElectroTech Team
-        This file is part of QElectroTech.
+		Copyright 2006-2015 The QElectroTech Team
+		This file is part of QElectroTech.
 
-        QElectroTech is free software: you can redistribute it and/or modify
-        it under the terms of the GNU General Public License as published by
-        the Free Software Foundation, either version 2 of the License, or
-        (at your option) any later version.
+		QElectroTech is free software: you can redistribute it and/or modify
+		it under the terms of the GNU General Public License as published by
+		the Free Software Foundation, either version 2 of the License, or
+		(at your option) any later version.
 
-        QElectroTech is distributed in the hope that it will be useful,
-        but WITHOUT ANY WARRANTY; without even the implied warranty of
-        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-        GNU General Public License for more details.
+		QElectroTech is distributed in the hope that it will be useful,
+		but WITHOUT ANY WARRANTY; without even the implied warranty of
+		MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+		GNU General Public License for more details.
 
-        You should have received a copy of the GNU General Public License
-        along with QElectroTech.  If not, see <http://www.gnu.org/licenses/>.
+		You should have received a copy of the GNU General Public License
+		along with QElectroTech.  If not, see <http://www.gnu.org/licenses/>.
 */
 #include "elementlocation.h"
 #include "qetapp.h"
@@ -25,10 +25,10 @@
  * @param path : path of item in file system
  */
 ElementLocation::ElementLocation(QString path):
-    m_project(nullptr)
+	m_project(nullptr)
 {
-    if (!path.isEmpty())
-        setPath(path);
+	if (!path.isEmpty())
+		setPath(path);
 }
 
 /**
@@ -37,10 +37,10 @@
  * @param project : project
  */
 ElementLocation::ElementLocation(QString path, QETProject *project) :
-    m_project(project)
+	m_project(project)
 {
-    if (!path.isEmpty())
-        setPath(path);
+	if (!path.isEmpty())
+		setPath(path);
 }
 
 ElementLocation::~ElementLocation()
@@ -56,69 +56,101 @@
  */
 bool ElementLocation::setPath(QString path)
 {
-    if (!path.endsWith(".elmt")) return false;
+	QString tmp_path = path;
 
-    QString tmp_path = path;
+		//The path is in file system
+	if (!m_project)
+	{
+			//The given path is relative to common or custom collection
+		if (path.startsWith("common://") || path.startsWith("custom://"))
+		{
+			QString p;
+			if (path.startsWith("common://"))
+			{
+				tmp_path.remove("common://");
+				p = QETApp::commonElementsDir() + tmp_path;
+			}
+			else
+			{
+				tmp_path.remove("custom://");
+				p = QETApp::customElementsDir() + tmp_path;
+			}
 
-        //The path is in file system
-    if (!m_project)
-    {
-            //Common collection
-        if (path.startsWith("common://"))
-        {
-            tmp_path.remove("common://");
-            QString p = QETApp::commonElementsDir() + tmp_path;
-            QFile file(p);
-            if (file.exists())
-            {
-                m_file_system_path = p;
-                m_collection_path = path;
-                return true;
-            }
+				//This is an element
+			if (path.endsWith(".elmt"))
+			{
+				QFile file(p);
+				if (file.exists())
+				{
+					m_file_system_path = p;
+					m_collection_path = path;
+					return true;
+				}
+				return false;
+			}
+				//They must be a directory
+			else
+			{
+				QDir dir(p);
+				if(dir.exists())
+				{
+					m_file_system_path = p;
+					m_collection_path = path;
+					return true;
+				}
+				return false;
+			}
+		}
+			//In this case, the path is supposed to be relative to the file system.
+		else
+		{
+			if(path.endsWith(".elmt"))
+			{
+				QFile file(path);
+				if (file.exists())
+				{
+					m_file_system_path = path;
+					if (path.startsWith(QETApp::commonElementsDir()))
+					{
+						path.remove(QETApp::commonElementsDir());
+						path.prepend("common://");
+						m_collection_path = path;
+					}
+					else if (path.startsWith(QETApp::customElementsDir()))
+					{
+						path.remove(QETApp::customElementsDir());
+						path.prepend("custom://");
+						m_collection_path = path;
+					}
+					return true;
+				}
+				return false;
+			}
+			else
+			{
+				QDir dir(path);
+				if (dir.exists())
+				{
+					m_file_system_path = path;
+					if (path.startsWith(QETApp::commonElementsDir()))
+					{
+						path.remove(QETApp::commonElementsDir());
+						path.prepend("common://");
+						m_collection_path = path;
+					}
+					else if (path.startsWith(QETApp::customElementsDir()))
+					{
+						path.remove(QETApp::customElementsDir());
+						path.prepend("custom://");
+						m_collection_path = path;
+					}
+					return true;
+				}
+				return false;
+			}
+		}
+	}
 
-            return false;
-        }
-
-            //Custom collection
-        if (path.startsWith("custom://"))
-        {
-            tmp_path.remove("custom://");
-            QString p = QETApp::customElementsDir() + tmp_path;
-            QFile file(p);
-            if (file.exists())
-            {
-                m_file_system_path = p;
-                m_collection_path = path;
-                return true;
-            }
-
-            return false;
-        }
-            //In this case, the path is supposed to be relative to the file system.
-        else
-        {
-            QFile file(path);
-            if (file.exists())
-            {
-                m_file_system_path = path;
-                if (path.startsWith(QETApp::commonElementsDir()))
-                {
-                    path.remove(QETApp::commonElementsDir());
-                    path.prepend("common://");
-                    m_collection_path = path;
-                }
-                else if (path.startsWith(QETApp::customElementsDir()))
-                {
-                    path.remove(QETApp::customElementsDir());
-                    path.prepend("common://");
-                    m_collection_path = path;
-                }
-                return true;
-            }
-            return false;
-        }
-    }
-
 	return false;
 }
 
@@ -136,38 +168,52 @@
  */
 void ElementLocation::setProject(QETProject *project)
 {
-    m_project = project;
+	m_project = project;
 }
 
 /**
+ * @brief ElementLocation::isElement
+ * @return true if this location represent an element
+ */
+bool ElementLocation::isElement() const {
+	return m_collection_path.endsWith(".elmt");
+}
+
+/**
+ * @brief ElementLocation::isDirectory
+ * @return true if this location represent a directory
+ */
+bool ElementLocation::isDirectory() const {
+	return !isElement();
+}
+
+/**
  * @brief ElementLocation::collectionPath
  * @return the colletion relative to the collection
  */
-QString ElementLocation::collectionPath() const
-{
-    return m_collection_path;
+QString ElementLocation::collectionPath() const {
+	return m_collection_path;
 }
 
 /**
  * @brief ElementLocation::fileSystemPath
- * @return The file system path of this element,
+ * @return The file system path of this element, (the separator is always '/' see QDir::toNativeSeparators())
  * If this element is embedded in a project return an empty string;
  */
 QString ElementLocation::fileSystemPath() const
 {
-    if (!m_project)
-        return QDir::fromNativeSeparators(m_file_system_path);
-    else
-        return QString();
+	if (!m_project)
+		return m_file_system_path;
+	else
+		return QString();
 }
 
 /**
  * @brief ElementLocation::project
  * @return the project of this location if he was set.
  */
-QETProject *ElementLocation::project() const
-{
-    return m_project;
+QETProject *ElementLocation::project() const {
+	return m_project;
 }
 
 /**
@@ -177,18 +223,18 @@
  */
 QDomElement ElementLocation::xml()
 {
-    if (!m_xml.isNull())
-        return m_xml;
+	if (!m_xml.isNull())
+		return m_xml;
 
-    if (!m_project)
-    {
-        QFile file (m_file_system_path);
-        QDomDocument docu;
-        if (docu.setContent(&file))
-            m_xml = docu.documentElement().cloneNode().toElement();
-    }
+	if (!m_project)
+	{
+		QFile file (m_file_system_path);
+		QDomDocument docu;
+		if (docu.setContent(&file))
+			m_xml = docu.documentElement().cloneNode().toElement();
+	}
 
-    return m_xml;
+	return m_xml;
 }
 
 /**
@@ -197,15 +243,13 @@
  */
 QUuid ElementLocation::uuid()
 {
-    if (!m_uuid.isNull()) return m_uuid;
+	if (!m_uuid.isNull()) return m_uuid;
 
-        //Get the uuid of element
-    QList<QDomElement>  list_ = QET::findInDomElement(xml(), "uuid");
+		//Get the uuid of element
+	QList<QDomElement>  list_ = QET::findInDomElement(xml(), "uuid");
 
-    if (!list_.isEmpty())
-        m_uuid = QUuid(list_.first().attribute("uuid"));
-//    else
-//        qDebug() << "The element : " << m_file_system_path << "haven't got an uuid, please edit and save this element with element editor to create an uuid";
+	if (!list_.isEmpty())
+		m_uuid = QUuid(list_.first().attribute("uuid"));
 
 	return m_uuid;
 }

Modified: trunk/sources/ElementsCollection/elementlocation.h
===================================================================
--- trunk/sources/ElementsCollection/elementlocation.h	2015-12-08 16:52:10 UTC (rev 4283)
+++ trunk/sources/ElementsCollection/elementlocation.h	2015-12-09 20:27:31 UTC (rev 4284)
@@ -27,7 +27,7 @@
 
 /**
  * @brief The ElementLocation class
- * This class represent the location of an element in the file system
+ * This class represent the location of an element or a directory in the file system
  * or an embedded collection of a project.
  * They also provide common things about an element, like the icon, uuid etc...
  */
@@ -41,6 +41,8 @@
         bool setPath(QString path);
 		bool isNull() const;
         void setProject(QETProject *project);
+		bool isElement() const;
+		bool isDirectory() const;
 
         QString collectionPath() const;
         QString fileSystemPath() const;

Modified: trunk/sources/ElementsCollection/elementscollectionmodel.cpp
===================================================================
--- trunk/sources/ElementsCollection/elementscollectionmodel.cpp	2015-12-08 16:52:10 UTC (rev 4283)
+++ trunk/sources/ElementsCollection/elementscollectionmodel.cpp	2015-12-09 20:27:31 UTC (rev 4284)
@@ -197,11 +197,22 @@
 QStringList ElementsCollectionModel::mimeTypes() const
 {
 	QStringList mime_list = QAbstractItemModel::mimeTypes();
-	mime_list << "application/x-qet-element-uri";
+	mime_list << "application/x-qet-element-uri" << "application/x-qet-category-uri";
 	return mime_list;
 }
 
 /**
+ * @brief ElementsCollectionModel::items
+ * @return All items handled by this model. The root item isn't stored in the list
+ */
+QList<ElementCollectionItem *> ElementsCollectionModel::items() const
+{
+	QList <ElementCollectionItem *> list;
+	list.append(m_root_item->items());
+	return list;
+}
+
+/**
  * @brief ElementsCollectionModel::addCommonCollection
  * Add the common elements collection to this model
  */

Modified: trunk/sources/ElementsCollection/elementscollectionmodel.h
===================================================================
--- trunk/sources/ElementsCollection/elementscollectionmodel.h	2015-12-08 16:52:10 UTC (rev 4283)
+++ trunk/sources/ElementsCollection/elementscollectionmodel.h	2015-12-09 20:27:31 UTC (rev 4284)
@@ -46,6 +46,7 @@
 		virtual bool canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const;
 		virtual bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent);
 		QStringList mimeTypes() const;
+		QList <ElementCollectionItem *> items() const;
 
 		void addCommonCollection();
 		void addCustomCollection();

Modified: trunk/sources/ElementsCollection/elementscollectionwidget.cpp
===================================================================
--- trunk/sources/ElementsCollection/elementscollectionwidget.cpp	2015-12-08 16:52:10 UTC (rev 4283)
+++ trunk/sources/ElementsCollection/elementscollectionwidget.cpp	2015-12-09 20:27:31 UTC (rev 4284)
@@ -40,11 +40,14 @@
  */
 ElementsCollectionWidget::ElementsCollectionWidget(QWidget *parent):
 	QWidget(parent),
+	m_model(nullptr),
 	m_item_at_context_menu(nullptr)
 {
 	setUpWidget();
 	setUpAction();
 	setUpConnection();
+
+	reload();
 }
 
 /**
@@ -100,11 +103,11 @@
 	m_tree_view->setContextMenuPolicy(Qt::CustomContextMenu);
 	m_main_vlayout->addWidget(m_tree_view);
 
-		//Setup the element collection model
-	m_model = new ElementsCollectionModel(m_tree_view);
-	m_model->addCommonCollection();
-	m_model->addCustomCollection();
-	m_tree_view->setModel(m_model);
+		//Setup the progress bar
+	m_progress_bar = new QProgressBar(this);
+	m_progress_bar->setFormat(tr("Chargement") + " %p%");
+	m_main_vlayout->addWidget(m_progress_bar);
+	m_progress_bar->hide();
 
 	m_context_menu = new QMenu(this);
 }
@@ -345,13 +348,25 @@
  */
 void ElementsCollectionWidget::reload()
 {
+	m_progress_bar->show();
 	ElementsCollectionModel *new_model = new ElementsCollectionModel(m_tree_view);
 	new_model->addCommonCollection();
 	new_model->addCustomCollection();
+
+	QList <ElementCollectionItem *> list = new_model->items();
+	m_progress_bar->setMaximum(list.size());
+	m_progress_bar->setValue(0);
+	foreach (ElementCollectionItem *item, new_model->items())
+	{
+		item->name();
+		m_progress_bar->setValue(m_progress_bar->value() + 1);
+	}
+
 	m_tree_view->setModel(new_model);
-	delete m_model;
+	if (m_model) delete m_model;
 	m_model = new_model;
 	expandFirstItems();
+	m_progress_bar->hide();
 }
 
 /**

Modified: trunk/sources/ElementsCollection/elementscollectionwidget.h
===================================================================
--- trunk/sources/ElementsCollection/elementscollectionwidget.h	2015-12-08 16:52:10 UTC (rev 4283)
+++ trunk/sources/ElementsCollection/elementscollectionwidget.h	2015-12-09 20:27:31 UTC (rev 4284)
@@ -27,6 +27,7 @@
 class QMenu;
 class QLineEdit;
 class ElementCollectionItem;
+class QProgressBar;
 
 /**
  * @brief The ElementsCollectionWidget class
@@ -69,6 +70,7 @@
         QVBoxLayout *m_main_vlayout;
 		QMenu *m_context_menu;
 		ElementCollectionItem *m_item_at_context_menu;
+		QProgressBar *m_progress_bar;
 
 		QAction *m_open_dir,
 				*m_edit_element,

Modified: trunk/sources/ElementsCollection/fileelementcollectionitem.cpp
===================================================================
--- trunk/sources/ElementsCollection/fileelementcollectionitem.cpp	2015-12-08 16:52:10 UTC (rev 4283)
+++ trunk/sources/ElementsCollection/fileelementcollectionitem.cpp	2015-12-09 20:27:31 UTC (rev 4284)
@@ -53,10 +53,8 @@
 	{
 		m_path = path;
 		populate();
-		name();
 		return true;
 	}
-
 	return false;
 }
 
@@ -73,8 +71,10 @@
     FileElementCollectionItem *parent = static_cast<FileElementCollectionItem*>(m_parent_item);
 
         //Get the path of the parent.
-	QString path = parent->fileSystemPath();
-	return path + "/" + m_path;
+	if (parent->isCollectionRoot())
+		return parent->fileSystemPath() + m_path;
+	else
+		return parent->fileSystemPath() + "/" + m_path;
 }
 
 /**
@@ -135,19 +135,7 @@
 
 	switch (role)
 	{
-		case Qt::DisplayRole:
-		{
-				//This item have no parent or parent isn't a file element, so it is the root of a collection
-			if (!m_parent_item || m_parent_item->type() != FileElementCollectionItem::Type)
-			{
-				if (m_path == QETApp::commonElementsDir())
-					return QObject::tr("Collection QET");
-				else if (m_path == QETApp::customElementsDir())
-					return QObject::tr("Collection utilisateur");
-				else
-					return QObject::tr("Collection inconnue");
-			}
-
+		case Qt::DisplayRole: {
 			return name();
 		}
 			break;
@@ -193,7 +181,12 @@
 {
 	QMimeData *mime_data = new QMimeData();
 	mime_data->setText(collectionPath());
-	mime_data->setData("application/x-qet-element-uri", collectionPath().toLatin1());
+
+	if (isElement())
+		mime_data->setData("application/x-qet-element-uri", collectionPath().toLatin1());
+	else
+		mime_data->setData("application/x-qet-category-uri", collectionPath().toLatin1());
+
 	return mime_data;
 }
 
@@ -207,9 +200,9 @@
 bool FileElementCollectionItem::canDropMimeData(const QMimeData *data, Qt::DropAction action, int column) const
 {
 	Q_UNUSED(action); Q_UNUSED(column);
+	if (isCommonCollection()) return false;
 
-	if (data->hasFormat("application/x-qet-element-uri") &&
-		fileSystemPath().startsWith(QETApp::customElementsDir()))
+	if (data->hasFormat("application/x-qet-element-uri") || data->hasFormat("application/x-qet-category-uri"))
 		return true;
 	else
 		return false;
@@ -224,7 +217,18 @@
  */
 bool FileElementCollectionItem::dropMimeData(const QMimeData *data, Qt::DropAction action, int column)
 {
-	Q_UNUSED(data); Q_UNUSED(action); Q_UNUSED(column);
+	Q_UNUSED(action); Q_UNUSED(column);
+	if (isCommonCollection()) return false;
+
+	FileElementCollectionItem *feci = this;
+	if (isElement() && parent() && parent()->type() == FileElementCollectionItem::Type)
+		feci = static_cast<FileElementCollectionItem *>(parent());
+
+	if (data->hasFormat("application/x-qet-element-uri"))
+		return feci->handleElementDrop(data);
+	else if (data->hasFormat("application/x-qet-category-uri"))
+		return feci->handleDirectoryDrop(data);
+
 	return false;
 }
 
@@ -303,27 +307,39 @@
 
 	else if (isDir())
 	{
-			//Open the qet_directory file, to get the traductions name of this dir
-		QFile dir_conf(fileSystemPath() + "/qet_directory");
-		if (!dir_conf.exists())
-			m_name = QString("");
+		if (isCollectionRoot())
+		{
+			if (m_path == QETApp::commonElementsDir())
+				m_name = QObject::tr("Collection QET");
+			else if (m_path == QETApp::customElementsDir())
+				m_name = QObject::tr("Collection utilisateur");
+			else
+				m_name = QObject::tr("Collection inconnue");
+		}
+		else
+		{
+				//Open the qet_directory file, to get the traductions name of this dir
+			QFile dir_conf(fileSystemPath() + "/qet_directory");
+			if (!dir_conf.exists())
+				m_name = QString("");
 
-		if (!dir_conf.open(QIODevice::ReadOnly | QIODevice::Text))
-			m_name = QString("");
+			if (!dir_conf.open(QIODevice::ReadOnly | QIODevice::Text))
+				m_name = QString("");
 
-			//Get the content of the file
-		QDomDocument document;
-		if (!document.setContent(&dir_conf))
-			m_name = QString("");
+				//Get the content of the file
+			QDomDocument document;
+			if (!document.setContent(&dir_conf))
+				m_name = QString("");
 
-		QDomElement root = document.documentElement();
-		if (root.tagName() != "qet-directory")
-			m_name = QString("");
+			QDomElement root = document.documentElement();
+			if (root.tagName() != "qet-directory")
+				m_name = QString("");
 
-			//Return the name for the current langage.
-		NamesList nl;
-		nl.fromXml(root);
-		m_name = nl.name();
+				//Return the name for the current langage.
+			NamesList nl;
+			nl.fromXml(root);
+			m_name = nl.name();
+		}
 	}
 	else if (isElement())
 	{		
@@ -345,7 +361,6 @@
 	if (!m_parent_item) return;
 
 	m_path = path_name;
-	name();
 
 		//This isn't an element, we create the childs
 	if (!path_name.endsWith(".elmt"))
@@ -377,3 +392,64 @@
 		appendChild(feci);
 	}
 }
+
+/**
+ * @brief FileElementCollectionItem::handleElementDrop
+ * Handle a drop data that represente an element.
+ * @param data
+ * @return true if the data is successfully dropped
+ */
+bool FileElementCollectionItem::handleElementDrop(const QMimeData *data)
+{
+	ElementLocation location(data->text());
+	return QFile::copy(location.fileSystemPath(), fileSystemPath() + "/" + location.fileSystemPath().split("/").last());
+}
+
+/**
+ * @brief FileElementCollectionItem::handleDirectoryDrop
+ * Handle a drop data that represent a directory
+ * @param data
+ * @return true if the data is successfully dropped
+ */
+bool FileElementCollectionItem::handleDirectoryDrop(const QMimeData *data)
+{
+	ElementLocation location(data->text());
+	QDir origin_dir(location.fileSystemPath());
+
+	if (origin_dir.exists())
+		return createSubDir(origin_dir, QDir(fileSystemPath()));
+	else
+		return false;
+}
+
+/**
+ * @brief FileElementCollectionItem::createSubDir
+ * Copy the directory @ dir_to_copy and the qet_directory file to destination.
+ * Also copy all directorys and elements find in @dir_to_copy recursively
+ * @param dir_to_copy
+ * @param destination
+ * @return true if the copy of @dir_to_copy to destination is successfull.
+ */
+bool FileElementCollectionItem::createSubDir(QDir dir_to_copy, QDir destination)
+{
+	if (destination.mkdir(dir_to_copy.dirName()))
+	{
+		QDir created_dir(destination.canonicalPath() + "/" + dir_to_copy.dirName());
+
+			//Copy the qet_directory file
+		QFile::copy(dir_to_copy.canonicalPath() + "/qet_directory", created_dir.canonicalPath() +"/qet_directory");
+
+			//Copy all dirs found in dir_to_copy to destination
+		foreach(QString str, dir_to_copy.entryList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name))
+			createSubDir(QDir(dir_to_copy.canonicalPath() + "/" + str), created_dir);
+
+			//Copy all elements found in dir_to_copy to destination
+		dir_to_copy.setNameFilters(QStringList() << "*.elmt");
+		foreach(QString str, dir_to_copy.entryList(QDir::Files | QDir::NoDotAndDotDot, QDir::Name))
+			QFile::copy(dir_to_copy.canonicalPath() + "/" + str, created_dir.canonicalPath() + "/" + str);
+
+		return true;
+	}
+	else
+		return false;
+}

Modified: trunk/sources/ElementsCollection/fileelementcollectionitem.h
===================================================================
--- trunk/sources/ElementsCollection/fileelementcollectionitem.h	2015-12-08 16:52:10 UTC (rev 4283)
+++ trunk/sources/ElementsCollection/fileelementcollectionitem.h	2015-12-09 20:27:31 UTC (rev 4284)
@@ -21,6 +21,7 @@
 #include "elementcollectionitem.h"
 #include "elementlocation.h"
 #include <QString>
+#include <QDir>
 
 /**
  * @brief The FileElementCollectionItem class
@@ -58,6 +59,9 @@
     private:
 		void setPathName(QString path_name);
 		void populate();
+		bool handleElementDrop (const QMimeData *data);
+		bool handleDirectoryDrop (const QMimeData *data);
+		bool createSubDir (QDir dir_to_copy, QDir destination);
 
     private:
 		QString m_path;


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/