mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 12:40:35 +01:00
Improve the remove of an item in the new panel. No need to reload the collection, use QAbstractItemModel::removeRows instead.
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@4285 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -349,6 +349,40 @@ QString FileElementCollectionItem::name()
|
||||
return m_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief FileElementCollectionItem::canRemoveContent
|
||||
* Reimplemented from ElementCollectionItem
|
||||
* @return
|
||||
*/
|
||||
bool FileElementCollectionItem::canRemoveContent()
|
||||
{
|
||||
if (isCommonCollection()) return false;
|
||||
else if (isDir() && isCollectionRoot()) return false;
|
||||
else return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief FileElementCollectionItem::removeContent
|
||||
* Reimplemented from ElementCollectionItem
|
||||
* @return
|
||||
*/
|
||||
bool FileElementCollectionItem::removeContent()
|
||||
{
|
||||
if (!canRemoveContent()) return false;
|
||||
|
||||
if (isElement())
|
||||
{
|
||||
QFile file(fileSystemPath());
|
||||
return file.remove();
|
||||
}
|
||||
else if (isDir() && !isCollectionRoot())
|
||||
{
|
||||
QDir dir (fileSystemPath());
|
||||
return dir.removeRecursively();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief FileElementCollectionItem::setPathName
|
||||
* Set the name of this item in the file system path.
|
||||
|
||||
Reference in New Issue
Block a user