mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-21 08:53:52 +00:00
fixed segfault
This commit is contained in:
parent
d1290ac556
commit
919065db32
2 changed files with 37 additions and 3 deletions
|
@ -356,6 +356,7 @@ CSVWorld::DialogueSubView::DialogueSubView (const CSMWorld::UniversalId& id, CSM
|
||||||
mLocked(false)
|
mLocked(false)
|
||||||
|
|
||||||
{
|
{
|
||||||
|
connect(mTable, SIGNAL(dataChanged ( const QModelIndex &, const QModelIndex &)), this, SLOT(dataChanged()));
|
||||||
mRow = mTable->getModelIndex (id.getId(), 0).row();
|
mRow = mTable->getModelIndex (id.getId(), 0).row();
|
||||||
QWidget *mainWidget = new QWidget(this);
|
QWidget *mainWidget = new QWidget(this);
|
||||||
|
|
||||||
|
@ -375,12 +376,24 @@ CSVWorld::DialogueSubView::DialogueSubView (const CSMWorld::UniversalId& id, CSM
|
||||||
mEditWidget->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
|
mEditWidget->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
|
||||||
|
|
||||||
setWidget(mainWidget);
|
setWidget(mainWidget);
|
||||||
mEditWidget->setDisabled(mLocked);
|
|
||||||
|
CSMWorld::RecordBase::State state = static_cast<CSMWorld::RecordBase::State>(mTable->data (mTable->index (mRow, 1)).toInt());
|
||||||
|
if (state == CSMWorld::RecordBase::State_Deleted || state == CSMWorld::RecordBase::State_Erased)
|
||||||
|
{
|
||||||
|
mEditWidget->setDisabled(true);
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
mEditWidget->setDisabled(mLocked);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVWorld::DialogueSubView::prevId()
|
void CSVWorld::DialogueSubView::prevId()
|
||||||
{
|
{
|
||||||
int newRow = mRow - 1;
|
int newRow = mRow - 1;
|
||||||
|
if (newRow < 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
QModelIndex newIndex(mTable->index(newRow, 0));
|
QModelIndex newIndex(mTable->index(newRow, 0));
|
||||||
|
|
||||||
if (!newIndex.isValid())
|
if (!newIndex.isValid())
|
||||||
|
@ -389,7 +402,7 @@ void CSVWorld::DialogueSubView::prevId()
|
||||||
}
|
}
|
||||||
|
|
||||||
CSMWorld::RecordBase::State state = static_cast<CSMWorld::RecordBase::State>(mTable->data (mTable->index (newRow, 1)).toInt());
|
CSMWorld::RecordBase::State state = static_cast<CSMWorld::RecordBase::State>(mTable->data (mTable->index (newRow, 1)).toInt());
|
||||||
if (state == CSMWorld::RecordBase::State_Deleted || state == CSMWorld::RecordBase::State_Deleted)
|
if (state == CSMWorld::RecordBase::State_Deleted || state == CSMWorld::RecordBase::State_Erased)
|
||||||
{
|
{
|
||||||
prevId();
|
prevId();
|
||||||
return;
|
return;
|
||||||
|
@ -405,6 +418,12 @@ void CSVWorld::DialogueSubView::prevId()
|
||||||
void CSVWorld::DialogueSubView::nextId()
|
void CSVWorld::DialogueSubView::nextId()
|
||||||
{
|
{
|
||||||
int newRow = mRow + 1;
|
int newRow = mRow + 1;
|
||||||
|
|
||||||
|
if (newRow > mTable->rowCount())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
QModelIndex newIndex(mTable->index(newRow, 0));
|
QModelIndex newIndex(mTable->index(newRow, 0));
|
||||||
|
|
||||||
if (!newIndex.isValid())
|
if (!newIndex.isValid())
|
||||||
|
@ -413,7 +432,7 @@ void CSVWorld::DialogueSubView::nextId()
|
||||||
}
|
}
|
||||||
|
|
||||||
CSMWorld::RecordBase::State state = static_cast<CSMWorld::RecordBase::State>(mTable->data (mTable->index (newRow, 1)).toInt());
|
CSMWorld::RecordBase::State state = static_cast<CSMWorld::RecordBase::State>(mTable->data (mTable->index (newRow, 1)).toInt());
|
||||||
if (state == CSMWorld::RecordBase::State_Deleted || state == CSMWorld::RecordBase::State_Deleted)
|
if (state == CSMWorld::RecordBase::State_Deleted || state == CSMWorld::RecordBase::State_Erased)
|
||||||
{
|
{
|
||||||
nextId();
|
nextId();
|
||||||
return;
|
return;
|
||||||
|
@ -430,4 +449,16 @@ void CSVWorld::DialogueSubView::setEditLock (bool locked)
|
||||||
{
|
{
|
||||||
mLocked = locked;
|
mLocked = locked;
|
||||||
mEditWidget->setDisabled(mLocked);
|
mEditWidget->setDisabled(mLocked);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVWorld::DialogueSubView::dataChanged()
|
||||||
|
{
|
||||||
|
CSMWorld::RecordBase::State state = static_cast<CSMWorld::RecordBase::State>(mTable->data (mTable->index (mRow, 1)).toInt());
|
||||||
|
if (state == CSMWorld::RecordBase::State_Deleted || state == CSMWorld::RecordBase::State_Erased)
|
||||||
|
{
|
||||||
|
mEditWidget->setDisabled(true);
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
mEditWidget->setDisabled(mLocked);
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -158,6 +158,9 @@ namespace CSVWorld
|
||||||
void nextId();
|
void nextId();
|
||||||
|
|
||||||
void prevId();
|
void prevId();
|
||||||
|
|
||||||
|
void dataChanged();
|
||||||
|
///\brief we need to care for deleting currently edited record
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue