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:
blacksun
2015-12-12 11:09:31 +00:00
parent 6bf52bb525
commit ed28d06d9d
8 changed files with 118 additions and 24 deletions

View File

@@ -44,6 +44,25 @@ void ElementCollectionItem::appendChild(ElementCollectionItem *item) {
m_child_items << item;
}
/**
* @brief ElementCollectionItem::removeChild
* Remove and delete count childs starting at position row
* @param row
* @return true if childs was successfully removed
*/
bool ElementCollectionItem::removeChild(int row, int count)
{
if (!(0 <= row+count && row+count <= m_child_items.size())) return false;
for (int i=0 ; i<count ; i++)
{
ElementCollectionItem *eci = m_child_items.takeAt(row);
delete eci;
}
return true;
}
/**
* @brief ElementCollectionItem::child
* @param row
@@ -177,3 +196,22 @@ QList<ElementCollectionItem *> ElementCollectionItem::items() const
list.append(eci->items());
return list;
}
/**
* @brief ElementCollectionItem::canRemoveContent
* @return true if this item can remove the content that he represent
* By default return false.
*/
bool ElementCollectionItem::canRemoveContent() {
return false;
}
/**
* @brief ElementCollectionItem::removeContent
* Remove the content that he represent this item (a directory or an element).
* This method do nothing and return false. Inherit it, to handle removing
* @return true if the content was successfully removed
*/
bool ElementCollectionItem::removeContent() {
return false;
}