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:
@@ -131,6 +131,31 @@ QVariant ElementsCollectionModel::data(const QModelIndex &index, int role) const
|
||||
return item->data(index.column(), role);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ElementsCollectionModel::removeRows
|
||||
* Reimplemented from QAbstractItemModel
|
||||
* @param row
|
||||
* @param count
|
||||
* @param parent
|
||||
* @return true if rows was successfully removed
|
||||
*/
|
||||
bool ElementsCollectionModel::removeRows(int row, int count, const QModelIndex &parent)
|
||||
{
|
||||
ElementCollectionItem *eci = nullptr;
|
||||
if (!parent.isValid())
|
||||
eci = m_root_item;
|
||||
else
|
||||
eci = static_cast<ElementCollectionItem *>(parent.internalPointer());
|
||||
|
||||
if (!(0 <= row+count && row+count <= eci->childCount())) return false;
|
||||
|
||||
beginRemoveRows(parent, row, (row + count -1));
|
||||
bool r = eci->removeChild(row, count);
|
||||
endRemoveRows();
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ElementsCollectionModel::mimeData
|
||||
* @param indexes
|
||||
|
||||
Reference in New Issue
Block a user