New element panel: User can now drop an item from custom or common collection, inside an item of embedded collection of a project

(drag an item from an embedded collection to another embedded collection don't work yet)


git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@4352 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
blacksun
2016-02-21 18:53:40 +00:00
parent 90c769c013
commit 014f3c8f13
10 changed files with 360 additions and 32 deletions

View File

@@ -17,6 +17,8 @@
*/
#include "elementcollectionhandler.h"
#include "renamedialog.h"
#include "xmlelementcollection.h"
#include "qetxml.h"
#include <QFile>
#include <QDir>
@@ -123,6 +125,42 @@ ElementLocation ECHSFileToFile::copyElement(ElementLocation &source, ElementLoca
/******************************************************/
/**
* @brief ECHSFileToXml::ECHSFileToXml
* @param source
* @param destination
*/
ECHSFileToXml::ECHSFileToXml(ElementLocation &source, ElementLocation &destination) :
ECHStrategy(source, destination)
{}
/**
* @brief ECHSFileToXml::copy
* @return
*/
ElementLocation ECHSFileToXml::copy()
{
if (!(m_source.isFileSystem() && m_destination.isDirectory() && m_destination.isProject())) return ElementLocation();
//Check if the destination already have an item with the same name of the item to copy
ElementLocation location(m_destination.projectCollectionPath() + "/" + m_source.fileName());
QString rename;
if (location.exist())
{
RenameDialog rd(location.collectionPath());
if(rd.exec() == QDialog::Accepted)
{
if (rd.selectedAction() == QET::Rename)
rename = rd.newName();
}
else
return ElementLocation();
}
return m_destination.projectCollection()->copy(m_source, m_destination, rename);
}
/**
* @brief ElementCollectionHandler::ElementCollectionHandler
* @param widget
@@ -148,6 +186,7 @@ ElementLocation ElementCollectionHandler::copy(ElementLocation &source, ElementL
if (!source.exist() || !destination.exist() || destination.isElement()) return ElementLocation();
if (source.isFileSystem() && destination.isFileSystem()) m_strategy = new ECHSFileToFile(source, destination);
else if (source.isFileSystem() && destination.isProject()) m_strategy = new ECHSFileToXml(source, destination);
if (m_strategy)
return m_strategy->copy();