Element collection : improve drag and drop behavior

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@4325 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
blacksun
2016-01-16 14:25:20 +00:00
parent 518af4497a
commit 7ead0b64b0
10 changed files with 197 additions and 115 deletions

View File

@@ -27,8 +27,7 @@
* @brief ElementLocation::ElementLocation
* @param path : path of item in file system
*/
ElementLocation::ElementLocation(QString path):
m_project(nullptr)
ElementLocation::ElementLocation(QString path)
{
if (!path.isEmpty())
setPath(path);
@@ -47,6 +46,19 @@ ElementLocation::ElementLocation(QString path, QETProject *project) :
setPath(path);
}
/**
* @brief ElementLocation::ElementLocation
* Constructor, build an ElementLocation from a QMimeData, the mime data format
* must be "application/x-qet-element-uri" or "application/x-qet-category-uri".
* This location can be null even if format is valid.
* @param data
*/
ElementLocation::ElementLocation(const QMimeData *data)
{
if (data->hasFormat("application/x-qet-element-uri") || data->hasFormat("application/x-qet-category-uri"))
setPath(data->text());
}
ElementLocation::~ElementLocation()
{}
@@ -194,9 +206,10 @@ bool ElementLocation::setPath(QString path)
*/
bool ElementLocation::isNull() const
{
if (!m_file_system_path.isEmpty()) return false;
else if (!m_collection_path.isEmpty()) return false;
else return true;
if (isFileSystem() || isProject())
return false;
else
return true;
}
/**
@@ -223,6 +236,29 @@ bool ElementLocation::isDirectory() const {
return !isElement();
}
/**
* @brief ElementLocation::isFileSystem
* @return True if this location represent a file system item.
*/
bool ElementLocation::isFileSystem() const
{
if (m_project) return false;
if (m_file_system_path.isEmpty()) return false;
return true;
}
/**
* @brief ElementLocation::isProject
* @return True if this location represent an item from a project.
*/
bool ElementLocation::isProject() const
{
if (m_project && !m_collection_path.isEmpty())
return true;
else
return false;
}
/**
* @brief ElementLocation::collectionPath
* @return the colletion relative to the collection