mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-20 15:53:54 +00:00
Removing rows and undo works
This commit is contained in:
parent
77afb754e5
commit
bb675ff41d
3 changed files with 33 additions and 5 deletions
|
@ -125,19 +125,22 @@ Qt::ItemFlags CSMWorld::IdTable::flags (const QModelIndex & index) const
|
|||
|
||||
bool CSMWorld::IdTable::removeRows (int row, int count, const QModelIndex& parent)
|
||||
{
|
||||
beginRemoveRows (parent, row, row+count-1);
|
||||
|
||||
if (parent.isValid())
|
||||
{
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
mIdCollection->removeNestedRows(parent.row(), parent.column(), row+i);
|
||||
}
|
||||
return true;
|
||||
} else
|
||||
{
|
||||
|
||||
beginRemoveRows (parent, row, row+count-1);
|
||||
|
||||
mIdCollection->removeRows (row, count);
|
||||
}
|
||||
|
||||
beginRemoveRows (parent, row, row+count-1);
|
||||
|
||||
mIdCollection->removeRows (row, count);
|
||||
|
||||
endRemoveRows();
|
||||
|
||||
return true;
|
||||
|
|
|
@ -22,6 +22,11 @@ CSMWorld::NestedTableModel::NestedTableModel(const QModelIndex& parent,
|
|||
connect(mMainModel, SIGNAL(rowsInserted(const QModelIndex &, int, int)),
|
||||
this, SLOT(forwardRowsInserted(const QModelIndex &, int, int)));
|
||||
|
||||
connect(mMainModel, SIGNAL(rowsAboutToBeRemoved(const QModelIndex &, int, int)),
|
||||
this, SLOT(forwardRowsAboutToRemoved(const QModelIndex &, int, int)));
|
||||
|
||||
connect(mMainModel, SIGNAL(rowsRemoved(const QModelIndex &, int, int)),
|
||||
this, SLOT(forwardRowsRemoved(const QModelIndex &, int, int)));
|
||||
}
|
||||
|
||||
QModelIndex CSMWorld::NestedTableModel::mapFromSource(const QModelIndex& sourceIndex) const
|
||||
|
@ -142,3 +147,19 @@ bool CSMWorld::NestedTableModel::indexIsParent(const QModelIndex& index)
|
|||
index.column() == mParentColumn &&
|
||||
mMainModel->data(mMainModel->index(index.row(), 0)).toString().toUtf8().constData() == mId);
|
||||
}
|
||||
|
||||
void CSMWorld::NestedTableModel::forwardRowsAboutToRemoved(const QModelIndex& parent, int first, int last)
|
||||
{
|
||||
if (indexIsParent(parent))
|
||||
{
|
||||
beginRemoveRows(QModelIndex(), first, last);
|
||||
}
|
||||
}
|
||||
|
||||
void CSMWorld::NestedTableModel::forwardRowsRemoved(const QModelIndex& parent, int first, int last)
|
||||
{
|
||||
if (indexIsParent(parent))
|
||||
{
|
||||
endRemoveRows();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,6 +66,10 @@ namespace CSMWorld
|
|||
void forwardRowsAboutToInserted(const QModelIndex & parent, int first, int last);
|
||||
|
||||
void forwardRowsInserted(const QModelIndex & parent, int first, int last);
|
||||
|
||||
void forwardRowsAboutToRemoved(const QModelIndex & parent, int first, int last);
|
||||
|
||||
void forwardRowsRemoved(const QModelIndex & parent, int first, int last);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue