mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-27 09:41:16 +00:00
Merge remote-tracking branch 'smbas/fix-opencs-bugs'
This commit is contained in:
commit
9ba85f697c
@ -192,6 +192,12 @@ namespace CSMWorld
|
|||||||
ColumnBase::Display_NestedHeader, flags)
|
ColumnBase::Display_NestedHeader, flags)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
virtual void set (Record<ESXRecordT>& record, const QVariant& data)
|
||||||
|
{
|
||||||
|
// There is nothing to do here.
|
||||||
|
// This prevents exceptions from parent's implementation
|
||||||
|
}
|
||||||
|
|
||||||
virtual QVariant get (const Record<ESXRecordT>& record) const
|
virtual QVariant get (const Record<ESXRecordT>& record) const
|
||||||
{
|
{
|
||||||
return true; // required by IdTree::hasChildren()
|
return true; // required by IdTree::hasChildren()
|
||||||
|
@ -33,7 +33,14 @@ CSMWorld::ModifyCommand::ModifyCommand (QAbstractItemModel& model, const QModelI
|
|||||||
{
|
{
|
||||||
mHasRecordState = true;
|
mHasRecordState = true;
|
||||||
int stateColumnIndex = table->findColumnIndex(Columns::ColumnId_Modification);
|
int stateColumnIndex = table->findColumnIndex(Columns::ColumnId_Modification);
|
||||||
mRecordStateIndex = table->index(mIndex.row(), stateColumnIndex);
|
|
||||||
|
int rowIndex = mIndex.row();
|
||||||
|
if (mIndex.parent().isValid())
|
||||||
|
{
|
||||||
|
rowIndex = mIndex.parent().row();
|
||||||
|
}
|
||||||
|
|
||||||
|
mRecordStateIndex = table->index(rowIndex, stateColumnIndex);
|
||||||
mOldRecordState = static_cast<CSMWorld::RecordBase::State>(table->data(mRecordStateIndex).toInt());
|
mOldRecordState = static_cast<CSMWorld::RecordBase::State>(table->data(mRecordStateIndex).toInt());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -282,21 +289,24 @@ CSMWorld::DeleteNestedCommand::DeleteNestedCommand (IdTree& model,
|
|||||||
std::string title =
|
std::string title =
|
||||||
model.headerData(parentColumn, Qt::Horizontal, Qt::DisplayRole).toString().toUtf8().constData();
|
model.headerData(parentColumn, Qt::Horizontal, Qt::DisplayRole).toString().toUtf8().constData();
|
||||||
setText (("Delete row in " + title + " sub-table of " + mId).c_str());
|
setText (("Delete row in " + title + " sub-table of " + mId).c_str());
|
||||||
|
|
||||||
|
QModelIndex parentIndex = mModel.getModelIndex(mId, mParentColumn);
|
||||||
|
mModifyParentCommand = new ModifyCommand(mModel, parentIndex, parentIndex.data(Qt::EditRole), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSMWorld::DeleteNestedCommand::redo()
|
void CSMWorld::DeleteNestedCommand::redo()
|
||||||
{
|
{
|
||||||
const QModelIndex& parentIndex = mModel.getModelIndex(mId, mParentColumn);
|
QModelIndex parentIndex = mModel.getModelIndex(mId, mParentColumn);
|
||||||
|
|
||||||
mModel.removeRows (mNestedRow, 1, parentIndex);
|
mModel.removeRows (mNestedRow, 1, parentIndex);
|
||||||
|
mModifyParentCommand->redo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CSMWorld::DeleteNestedCommand::undo()
|
void CSMWorld::DeleteNestedCommand::undo()
|
||||||
{
|
{
|
||||||
const QModelIndex& parentIndex = mModel.getModelIndex(mId, mParentColumn);
|
QModelIndex parentIndex = mModel.getModelIndex(mId, mParentColumn);
|
||||||
|
|
||||||
mModel.setNestedTable(parentIndex, getOld());
|
mModel.setNestedTable(parentIndex, getOld());
|
||||||
|
mModifyParentCommand->undo();
|
||||||
}
|
}
|
||||||
|
|
||||||
CSMWorld::AddNestedCommand::AddNestedCommand(IdTree& model, const std::string& id, int nestedRow, int parentColumn, QUndoCommand* parent)
|
CSMWorld::AddNestedCommand::AddNestedCommand(IdTree& model, const std::string& id, int nestedRow, int parentColumn, QUndoCommand* parent)
|
||||||
@ -310,20 +320,23 @@ CSMWorld::AddNestedCommand::AddNestedCommand(IdTree& model, const std::string& i
|
|||||||
std::string title =
|
std::string title =
|
||||||
model.headerData(parentColumn, Qt::Horizontal, Qt::DisplayRole).toString().toUtf8().constData();
|
model.headerData(parentColumn, Qt::Horizontal, Qt::DisplayRole).toString().toUtf8().constData();
|
||||||
setText (("Add row in " + title + " sub-table of " + mId).c_str());
|
setText (("Add row in " + title + " sub-table of " + mId).c_str());
|
||||||
|
|
||||||
|
QModelIndex parentIndex = mModel.getModelIndex(mId, mParentColumn);
|
||||||
|
mModifyParentCommand = new ModifyCommand(mModel, parentIndex, parentIndex.data(Qt::EditRole), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSMWorld::AddNestedCommand::redo()
|
void CSMWorld::AddNestedCommand::redo()
|
||||||
{
|
{
|
||||||
const QModelIndex& parentIndex = mModel.getModelIndex(mId, mParentColumn);
|
QModelIndex parentIndex = mModel.getModelIndex(mId, mParentColumn);
|
||||||
|
|
||||||
mModel.addNestedRow (parentIndex, mNewRow);
|
mModel.addNestedRow (parentIndex, mNewRow);
|
||||||
|
mModifyParentCommand->redo();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSMWorld::AddNestedCommand::undo()
|
void CSMWorld::AddNestedCommand::undo()
|
||||||
{
|
{
|
||||||
const QModelIndex& parentIndex = mModel.getModelIndex(mId, mParentColumn);
|
QModelIndex parentIndex = mModel.getModelIndex(mId, mParentColumn);
|
||||||
|
|
||||||
mModel.setNestedTable(parentIndex, getOld());
|
mModel.setNestedTable(parentIndex, getOld());
|
||||||
|
mModifyParentCommand->undo();
|
||||||
}
|
}
|
||||||
|
|
||||||
CSMWorld::NestedTableStoring::NestedTableStoring(const IdTree& model, const std::string& id, int parentColumn)
|
CSMWorld::NestedTableStoring::NestedTableStoring(const IdTree& model, const std::string& id, int parentColumn)
|
||||||
|
@ -200,6 +200,9 @@ namespace CSMWorld
|
|||||||
|
|
||||||
int mNestedRow;
|
int mNestedRow;
|
||||||
|
|
||||||
|
// The command to redo/undo the Modified status of a record
|
||||||
|
ModifyCommand *mModifyParentCommand;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
DeleteNestedCommand (IdTree& model, const std::string& id, int nestedRow, int parentColumn, QUndoCommand* parent = 0);
|
DeleteNestedCommand (IdTree& model, const std::string& id, int nestedRow, int parentColumn, QUndoCommand* parent = 0);
|
||||||
@ -219,6 +222,9 @@ namespace CSMWorld
|
|||||||
|
|
||||||
int mParentColumn;
|
int mParentColumn;
|
||||||
|
|
||||||
|
// The command to redo/undo the Modified status of a record
|
||||||
|
ModifyCommand *mModifyParentCommand;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
AddNestedCommand(IdTree& model, const std::string& id, int nestedRow, int parentColumn, QUndoCommand* parent = 0);
|
AddNestedCommand(IdTree& model, const std::string& id, int nestedRow, int parentColumn, QUndoCommand* parent = 0);
|
||||||
|
@ -77,7 +77,11 @@ bool CSMWorld::IdTable::setData (const QModelIndex &index, const QVariant &value
|
|||||||
{
|
{
|
||||||
mIdCollection->setData (index.row(), index.column(), value);
|
mIdCollection->setData (index.row(), index.column(), value);
|
||||||
|
|
||||||
emit dataChanged (index, index);
|
// Modifying a value can also change the Modified status of a record.
|
||||||
|
// To track this, we inform about the change of a whole row.
|
||||||
|
QModelIndex rowStart = this->index(index.row(), 0);
|
||||||
|
QModelIndex rowEnd = this->index(index.row(), columnCount(index.parent()) - 1);
|
||||||
|
emit dataChanged(rowStart, rowEnd);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -96,7 +96,13 @@ bool CSMWorld::IdTree::setData (const QModelIndex &index, const QVariant &value,
|
|||||||
|
|
||||||
mNestedCollection->setNestedData(parentAddress.first, parentAddress.second, value, index.row(), index.column());
|
mNestedCollection->setNestedData(parentAddress.first, parentAddress.second, value, index.row(), index.column());
|
||||||
|
|
||||||
emit dataChanged (index, index);
|
emit dataChanged(index, index);
|
||||||
|
|
||||||
|
// Modifying a value can also change the Modified status of a record (located in the parent row).
|
||||||
|
// To track this, we inform about the change of a whole parent row.
|
||||||
|
QModelIndex parentRowStart = this->index(index.parent().row(), 0);
|
||||||
|
QModelIndex parentRowEnd = this->index(index.parent().row(), columnCount(index.parent()) - 1);
|
||||||
|
emit dataChanged(parentRowStart, parentRowEnd);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -570,8 +570,6 @@ void CSVWorld::EditWidget::remake(int row)
|
|||||||
table->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
table->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
||||||
table->setEnabled(false);
|
table->setEnabled(false);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
table->setEditTriggers(QAbstractItemView::SelectedClicked | QAbstractItemView::CurrentChanged);
|
|
||||||
|
|
||||||
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);
|
||||||
@ -811,8 +809,13 @@ void CSVWorld::SimpleDialogueSubView::dataChanged (const QModelIndex & index)
|
|||||||
void CSVWorld::SimpleDialogueSubView::rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end)
|
void CSVWorld::SimpleDialogueSubView::rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end)
|
||||||
{
|
{
|
||||||
QModelIndex currentIndex(mTable->getModelIndex(getUniversalId().getId(), 0));
|
QModelIndex currentIndex(mTable->getModelIndex(getUniversalId().getId(), 0));
|
||||||
|
|
||||||
|
if (!currentIndex.isValid())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (currentIndex.isValid() && currentIndex.row() >= start && currentIndex.row() <= end)
|
if (currentIndex.parent() == parent && currentIndex.row() >= start && currentIndex.row() <= end)
|
||||||
{
|
{
|
||||||
if(mEditWidget)
|
if(mEditWidget)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user