mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-18 13:30:34 +01:00
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:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user