mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-19 23:20:52 +01:00
New elements panel : fix crash at drag and drop due to a wrong use of QAbstractItemModel
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@4353 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
* @param parent : the parent item of this item
|
||||
*/
|
||||
ElementCollectionItem::ElementCollectionItem(ElementCollectionItem *parent) :
|
||||
QObject(parent),
|
||||
m_parent_item (parent)
|
||||
{}
|
||||
|
||||
@@ -52,7 +53,12 @@ void ElementCollectionItem::appendChild(ElementCollectionItem *item) {
|
||||
*/
|
||||
bool ElementCollectionItem::removeChild(int row, int count)
|
||||
{
|
||||
if (!(0 <= row+count && row+count <= m_child_items.size())) return false;
|
||||
if (!(1 <= row+count && row+count <= m_child_items.size())) return false;
|
||||
|
||||
int last_ = row + (count-1);
|
||||
if (last_ < row) return false;
|
||||
|
||||
emit beginRemoveRows(this, row, last_);
|
||||
|
||||
for (int i=0 ; i<count ; i++)
|
||||
{
|
||||
@@ -60,6 +66,8 @@ bool ElementCollectionItem::removeChild(int row, int count)
|
||||
delete eci;
|
||||
}
|
||||
|
||||
emit endRemoveRows();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -74,7 +82,9 @@ bool ElementCollectionItem::insertChild(int row, ElementCollectionItem *item)
|
||||
{
|
||||
if (m_child_items.contains(item)) return false;
|
||||
|
||||
beginInsertRows(this, row, row);
|
||||
m_child_items.insert(row, item);
|
||||
endInsertRows();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user