mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-26 21:40:52 +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:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user