disabling works

actorid
Marek Kochanowicz 11 years ago
parent c97172d89c
commit 4a623ace71

@ -363,7 +363,7 @@ void CSVWorld::EditWidget::remake(int row)
mWidgetMapper->setCurrentModelIndex(mTable->index(row, 0));
this->setMinimumWidth(300);
this->setMinimumWidth(325); //TODO find better way to set the width
this->setWidget(mMainWidget);
this->setWidgetResizable(true);
}
@ -385,7 +385,7 @@ CSVWorld::DialogueSubView::DialogueSubView (const CSMWorld::UniversalId& id, CSM
mDocument(document)
{
connect(mTable, SIGNAL(dataChanged ( const QModelIndex &, const QModelIndex &)), this, SLOT(dataChanged()));
connect(mTable, SIGNAL(dataChanged (const QModelIndex&, const QModelIndex&)), this, SLOT(dataChanged(const QModelIndex&)));
mRow = mTable->getModelIndex (id.getId(), 0).row();
QWidget *mainWidget = new QWidget(this);
@ -403,14 +403,12 @@ CSVWorld::DialogueSubView::DialogueSubView (const CSMWorld::UniversalId& id, CSM
connect(mEditWidget, SIGNAL(tableMimeDataDropped(QWidget*, const QModelIndex&, const CSMWorld::UniversalId&, const CSMDoc::Document*)),
this, SLOT(tableMimeDataDropped(QWidget*, const QModelIndex&, const CSMWorld::UniversalId&, const CSMDoc::Document*)));
mMainLayout->addLayout(buttonsLayout);
mMainLayout->addWidget(mEditWidget);
mEditWidget->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
dataChanged(mTable->index(mRow, 0));
setWidget(mainWidget);
dataChanged();
}
void CSVWorld::DialogueSubView::prevId()
@ -478,11 +476,6 @@ void CSVWorld::DialogueSubView::nextId()
void CSVWorld::DialogueSubView::setEditLock (bool locked)
{
mLocked = locked;
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)
{
@ -493,6 +486,21 @@ void CSVWorld::DialogueSubView::dataChanged()
}
}
void CSVWorld::DialogueSubView::dataChanged(const QModelIndex & index)
{
if (index.row() == mRow)
{
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::tableMimeDataDropped(QWidget* editor,
const QModelIndex& index,
const CSMWorld::UniversalId& id,

@ -179,7 +179,7 @@ namespace CSVWorld
void prevId();
void dataChanged();
void dataChanged(const QModelIndex & index);
///\brief we need to care for deleting currently edited record
void tableMimeDataDropped(QWidget* editor, const QModelIndex& index,

Loading…
Cancel
Save