void QObjectListModel::removeItem(int index) { beginRemoveRows(QModelIndex(), index, index); disconnect(((QObject*)_list->at(index)), SIGNAL(destroyed()), this, SLOT(removeDestroyedItem())); _list->removeAt(index); endRemoveRows(); emit itemCountChanged(); }
void QObjectListModel::insertItem(int index, QObject *item) { beginInsertRows(QModelIndex(), index, index); _list->insert(index, item); connect(item, SIGNAL(destroyed()), this, SLOT(removeDestroyedItem())); endInsertRows(); emit itemAdded(item); emit itemCountChanged(); }
void QObjectListModel::removeItem(QObject *item) { int index = _list->indexOf(item); if (index >= 0) { beginRemoveRows(QModelIndex(), index, index); _list->removeAt(index); disconnect(item, SIGNAL(destroyed()), this, SLOT(removeDestroyedItem())); endRemoveRows(); emit itemCountChanged(); } }
void QObjectListModel::addItem(QObject *item) { int z = _list->count(); beginInsertRows(QModelIndex(), z, z); _list->append(item); connect(item, SIGNAL(destroyed()), this, SLOT(removeDestroyedItem())); endInsertRows(); emit itemAdded(item); emit itemCountChanged(); }