mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-21 09:39:56 +00:00
Disable editing for blocked records in both table and dialogue edit widget.
This commit is contained in:
parent
7227a83e60
commit
0a5571f19e
@ -371,6 +371,7 @@ namespace CSMWorld
|
|||||||
{ ColumnId_Skill7, "Skill 7" },
|
{ ColumnId_Skill7, "Skill 7" },
|
||||||
|
|
||||||
{ ColumnId_Persistent, "Persistent" },
|
{ ColumnId_Persistent, "Persistent" },
|
||||||
|
{ ColumnId_Blocked, "Blocked" },
|
||||||
|
|
||||||
{ -1, 0 } // end marker
|
{ -1, 0 } // end marker
|
||||||
};
|
};
|
||||||
|
@ -344,6 +344,7 @@ namespace CSMWorld
|
|||||||
ColumnId_FactionAttrib2 = 312,
|
ColumnId_FactionAttrib2 = 312,
|
||||||
|
|
||||||
ColumnId_Persistent = 313,
|
ColumnId_Persistent = 313,
|
||||||
|
ColumnId_Blocked = 314,
|
||||||
|
|
||||||
// Allocated to a separate value range, so we don't get a collision should we ever need
|
// Allocated to a separate value range, so we don't get a collision should we ever need
|
||||||
// to extend the number of use values.
|
// to extend the number of use values.
|
||||||
|
@ -123,6 +123,14 @@ Qt::ItemFlags CSMWorld::IdTable::flags (const QModelIndex & index) const
|
|||||||
if (mIdCollection->getColumn (index.column()).isUserEditable())
|
if (mIdCollection->getColumn (index.column()).isUserEditable())
|
||||||
flags |= Qt::ItemIsEditable;
|
flags |= Qt::ItemIsEditable;
|
||||||
|
|
||||||
|
int blockedColumn = searchColumnIndex(Columns::ColumnId_Blocked);
|
||||||
|
if (blockedColumn != -1 && blockedColumn != index.column())
|
||||||
|
{
|
||||||
|
bool isBlocked = mIdCollection->getData(index.row(), blockedColumn).toInt();
|
||||||
|
if (isBlocked)
|
||||||
|
flags = Qt::ItemIsSelectable; // not enabled (to grey out)
|
||||||
|
}
|
||||||
|
|
||||||
return flags;
|
return flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,6 +25,9 @@ namespace CSMWorld
|
|||||||
const RefIdColumn *mId;
|
const RefIdColumn *mId;
|
||||||
const RefIdColumn *mModified;
|
const RefIdColumn *mModified;
|
||||||
const RefIdColumn *mType;
|
const RefIdColumn *mType;
|
||||||
|
const RefIdColumn *mBlocked;
|
||||||
|
|
||||||
|
BaseColumns () : mBlocked(nullptr) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// \brief Base adapter for all refereceable record types
|
/// \brief Base adapter for all refereceable record types
|
||||||
@ -90,6 +93,9 @@ namespace CSMWorld
|
|||||||
if (column==mBase.mType)
|
if (column==mBase.mType)
|
||||||
return static_cast<int> (mType);
|
return static_cast<int> (mType);
|
||||||
|
|
||||||
|
if (column==mBase.mBlocked)
|
||||||
|
return (record.get().mRecordFlags & ESM::FLAG_Blocked) != 0;
|
||||||
|
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,6 +108,17 @@ namespace CSMWorld
|
|||||||
|
|
||||||
if (column==mBase.mModified)
|
if (column==mBase.mModified)
|
||||||
record.mState = static_cast<RecordBase::State> (value.toInt());
|
record.mState = static_cast<RecordBase::State> (value.toInt());
|
||||||
|
else if (column==mBase.mBlocked)
|
||||||
|
{
|
||||||
|
RecordT record2 = record.get();
|
||||||
|
|
||||||
|
if (value.toInt() != 0)
|
||||||
|
record2.mRecordFlags |= ESM::FLAG_Blocked;
|
||||||
|
else
|
||||||
|
record2.mRecordFlags &= ~ESM::FLAG_Blocked;
|
||||||
|
|
||||||
|
record.setModified(record2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename RecordT>
|
template<typename RecordT>
|
||||||
@ -110,6 +127,14 @@ namespace CSMWorld
|
|||||||
return mType;
|
return mType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NOTE: Body Part should not have persistence (but BodyPart is not listed in the Objects
|
||||||
|
// table at the moment).
|
||||||
|
//
|
||||||
|
// Spellmaking - not persistent - currently not part of objects table
|
||||||
|
// Enchanting - not persistent - currently not part of objects table
|
||||||
|
//
|
||||||
|
// Leveled Creature - no model, so not persistent
|
||||||
|
// Leveled Item - no model, so not persistent
|
||||||
|
|
||||||
struct ModelColumns : public BaseColumns
|
struct ModelColumns : public BaseColumns
|
||||||
{
|
{
|
||||||
|
@ -49,13 +49,16 @@ CSMWorld::RefIdCollection::RefIdCollection()
|
|||||||
mColumns.emplace_back(Columns::ColumnId_RecordType, ColumnBase::Display_RefRecordType,
|
mColumns.emplace_back(Columns::ColumnId_RecordType, ColumnBase::Display_RefRecordType,
|
||||||
ColumnBase::Flag_Table | ColumnBase::Flag_Dialogue, false, false);
|
ColumnBase::Flag_Table | ColumnBase::Flag_Dialogue, false, false);
|
||||||
baseColumns.mType = &mColumns.back();
|
baseColumns.mType = &mColumns.back();
|
||||||
|
mColumns.emplace_back(Columns::ColumnId_Blocked, ColumnBase::Display_Boolean,
|
||||||
|
ColumnBase::Flag_Table | ColumnBase::Flag_Dialogue | ColumnBase::Flag_Dialogue_Refresh);
|
||||||
|
baseColumns.mBlocked = &mColumns.back();
|
||||||
|
|
||||||
ModelColumns modelColumns (baseColumns);
|
ModelColumns modelColumns (baseColumns);
|
||||||
|
|
||||||
mColumns.emplace_back(Columns::ColumnId_Model, ColumnBase::Display_Mesh);
|
|
||||||
modelColumns.mModel = &mColumns.back();
|
|
||||||
mColumns.emplace_back(Columns::ColumnId_Persistent, ColumnBase::Display_Boolean);
|
mColumns.emplace_back(Columns::ColumnId_Persistent, ColumnBase::Display_Boolean);
|
||||||
modelColumns.mPersistence = &mColumns.back();
|
modelColumns.mPersistence = &mColumns.back();
|
||||||
|
mColumns.emplace_back(Columns::ColumnId_Model, ColumnBase::Display_Mesh);
|
||||||
|
modelColumns.mModel = &mColumns.back();
|
||||||
|
|
||||||
NameColumns nameColumns (modelColumns);
|
NameColumns nameColumns (modelColumns);
|
||||||
|
|
||||||
|
@ -538,6 +538,9 @@ void CSVWorld::EditWidget::remake(int row)
|
|||||||
mainLayout->addLayout(tablesLayout, QSizePolicy::Preferred);
|
mainLayout->addLayout(tablesLayout, QSizePolicy::Preferred);
|
||||||
mainLayout->addStretch(1);
|
mainLayout->addStretch(1);
|
||||||
|
|
||||||
|
int blockedColumn = mTable->searchColumnIndex(CSMWorld::Columns::ColumnId_Blocked);
|
||||||
|
bool isBlocked = mTable->data(mTable->index(row, blockedColumn)).toInt();
|
||||||
|
|
||||||
int unlocked = 0;
|
int unlocked = 0;
|
||||||
int locked = 0;
|
int locked = 0;
|
||||||
const int columns = mTable->columnCount();
|
const int columns = mTable->columnCount();
|
||||||
@ -583,6 +586,8 @@ void CSVWorld::EditWidget::remake(int row)
|
|||||||
NestedTable* table =
|
NestedTable* table =
|
||||||
new NestedTable(mDocument, id, mNestedModels.back(), this, editable, fixedRows);
|
new NestedTable(mDocument, id, mNestedModels.back(), this, editable, fixedRows);
|
||||||
table->resizeColumnsToContents();
|
table->resizeColumnsToContents();
|
||||||
|
if (isBlocked)
|
||||||
|
table->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
||||||
|
|
||||||
int rows = mTable->rowCount(mTable->index(row, i));
|
int rows = mTable->rowCount(mTable->index(row, i));
|
||||||
int rowHeight = (rows == 0) ? table->horizontalHeader()->height() : table->rowHeight(0);
|
int rowHeight = (rows == 0) ? table->horizontalHeader()->height() : table->rowHeight(0);
|
||||||
@ -617,7 +622,9 @@ void CSVWorld::EditWidget::remake(int row)
|
|||||||
label->setSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed);
|
label->setSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||||
editor->setSizePolicy (QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
|
editor->setSizePolicy (QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
|
||||||
|
|
||||||
if (! (mTable->flags (mTable->index (row, i)) & Qt::ItemIsEditable))
|
// HACK: the blocked checkbox needs to keep the same position
|
||||||
|
// FIXME: unfortunately blocked record displays a little differently to unblocked one
|
||||||
|
if (!(mTable->flags (mTable->index (row, i)) & Qt::ItemIsEditable) || i == blockedColumn)
|
||||||
{
|
{
|
||||||
lockedLayout->addWidget (label, locked, 0);
|
lockedLayout->addWidget (label, locked, 0);
|
||||||
lockedLayout->addWidget (editor, locked, 1);
|
lockedLayout->addWidget (editor, locked, 1);
|
||||||
@ -639,7 +646,7 @@ void CSVWorld::EditWidget::remake(int row)
|
|||||||
createEditorContextMenu(editor, display, row);
|
createEditorContextMenu(editor, display, row);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else // Flag_Dialogue_List
|
||||||
{
|
{
|
||||||
CSMWorld::IdTree *tree = static_cast<CSMWorld::IdTree *>(mTable);
|
CSMWorld::IdTree *tree = static_cast<CSMWorld::IdTree *>(mTable);
|
||||||
mNestedTableMapper = new QDataWidgetMapper (this);
|
mNestedTableMapper = new QDataWidgetMapper (this);
|
||||||
@ -686,7 +693,10 @@ void CSVWorld::EditWidget::remake(int row)
|
|||||||
label->setEnabled(false);
|
label->setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
createEditorContextMenu(editor, display, row);
|
if (!isBlocked)
|
||||||
|
createEditorContextMenu(editor, display, row);
|
||||||
|
else
|
||||||
|
editor->setEnabled(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mNestedTableMapper->setCurrentModelIndex(tree->index(0, 0, tree->index(row, i)));
|
mNestedTableMapper->setCurrentModelIndex(tree->index(0, 0, tree->index(row, i)));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user