Close DialogueSubView if the corresponding record is deleted. Should resolve Bug #2575.

- ToDo: Doesn't seem to shrink the widget width properly (when horizontal scrollbar is active)
c++11
cc9cii 10 years ago
parent 53b4c15d85
commit 22420c3a83

@ -578,6 +578,7 @@ CSVWorld::DialogueSubView::DialogueSubView (const CSMWorld::UniversalId& id, CSM
mCommandDispatcher (document, CSMWorld::UniversalId::getParentType (id.getType()))
{
connect(mTable, SIGNAL(dataChanged (const QModelIndex&, const QModelIndex&)), this, SLOT(dataChanged(const QModelIndex&)));
connect(mTable, SIGNAL(rowsAboutToBeRemoved(const QModelIndex&, int, int)), this, SLOT(rowsAboutToBeRemoved(const QModelIndex&, int, int)));
changeCurrentId(id.getId());
@ -740,6 +741,9 @@ void CSVWorld::DialogueSubView::nextId ()
void CSVWorld::DialogueSubView::setEditLock (bool locked)
{
if (!mEditWidget) // hack to indicate that mCurrentId is no longer valid
return;
mLocked = locked;
QModelIndex currentIndex(mTable->getModelIndex(mCurrentId, 0));
@ -766,6 +770,21 @@ void CSVWorld::DialogueSubView::dataChanged (const QModelIndex & index)
}
}
void CSVWorld::DialogueSubView::rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end)
{
QModelIndex currentIndex(mTable->getModelIndex(mCurrentId, 0));
if (currentIndex.isValid() && currentIndex.row() >= start && currentIndex.row() <= end)
{
if(mEditWidget)
{
delete mEditWidget;
mEditWidget = 0;
}
emit closeRequest(this);
}
}
void CSVWorld::DialogueSubView::tableMimeDataDropped (QWidget* editor,
const QModelIndex& index,
const CSMWorld::UniversalId& id,

@ -235,6 +235,8 @@ namespace CSVWorld
const CSMDoc::Document* document);
void requestFocus (const std::string& id);
void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end);
};
}

Loading…
Cancel
Save