mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-02-21 21:39:40 +00:00
rewrote refnum handling code (fixes broken reference creation, but not reference cloning yet)
This commit is contained in:
parent
6fbffdb98f
commit
3add4bdf35
2 changed files with 27 additions and 12 deletions
|
@ -16,11 +16,19 @@ std::string CSVWorld::ReferenceCreator::getId() const
|
||||||
|
|
||||||
void CSVWorld::ReferenceCreator::configureCreateCommand (CSMWorld::CreateCommand& command) const
|
void CSVWorld::ReferenceCreator::configureCreateCommand (CSMWorld::CreateCommand& command) const
|
||||||
{
|
{
|
||||||
int index =
|
// Set cellID
|
||||||
|
int cellIdColumn =
|
||||||
dynamic_cast<CSMWorld::IdTable&> (*getData().getTableModel (getCollectionId())).
|
dynamic_cast<CSMWorld::IdTable&> (*getData().getTableModel (getCollectionId())).
|
||||||
findColumnIndex (CSMWorld::Columns::ColumnId_Cell);
|
findColumnIndex (CSMWorld::Columns::ColumnId_Cell);
|
||||||
|
|
||||||
command.addValue (index, mCell->text());
|
command.addValue (cellIdColumn, mCell->text());
|
||||||
|
|
||||||
|
// Set RefNum
|
||||||
|
int refNumColumn = dynamic_cast<CSMWorld::IdTable&> (
|
||||||
|
*getData().getTableModel (CSMWorld::UniversalId::Type_References)).
|
||||||
|
findColumnIndex (CSMWorld::Columns::ColumnId_RefNum);
|
||||||
|
|
||||||
|
command.addValue (refNumColumn, getRefNumCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVWorld::ReferenceCreator::pushCommand (std::auto_ptr<QUndoCommand> command,
|
void CSVWorld::ReferenceCreator::pushCommand (std::auto_ptr<QUndoCommand> command,
|
||||||
|
@ -38,26 +46,30 @@ void CSVWorld::ReferenceCreator::pushCommand (std::auto_ptr<QUndoCommand> comman
|
||||||
|
|
||||||
int count = cellTable.data (countIndex).toInt();
|
int count = cellTable.data (countIndex).toInt();
|
||||||
|
|
||||||
// command for setting the refnum in the newly created reference
|
|
||||||
CSMWorld::IdTable& referenceTable = dynamic_cast<CSMWorld::IdTable&> (
|
|
||||||
*getData().getTableModel (CSMWorld::UniversalId::Type_References));
|
|
||||||
|
|
||||||
int refNumColumn = referenceTable.findColumnIndex (CSMWorld::Columns::ColumnId_RefNum);
|
|
||||||
|
|
||||||
std::auto_ptr<CSMWorld::ModifyCommand> setRefNum (new CSMWorld::ModifyCommand
|
|
||||||
(referenceTable, referenceTable.getModelIndex (id, refNumColumn), count));
|
|
||||||
|
|
||||||
// command for incrementing counter
|
// command for incrementing counter
|
||||||
std::auto_ptr<CSMWorld::ModifyCommand> increment (new CSMWorld::ModifyCommand
|
std::auto_ptr<CSMWorld::ModifyCommand> increment (new CSMWorld::ModifyCommand
|
||||||
(cellTable, countIndex, count+1));
|
(cellTable, countIndex, count+1));
|
||||||
|
|
||||||
getUndoStack().beginMacro (command->text());
|
getUndoStack().beginMacro (command->text());
|
||||||
GenericCreator::pushCommand (command, id);
|
GenericCreator::pushCommand (command, id);
|
||||||
getUndoStack().push (setRefNum.release());
|
|
||||||
getUndoStack().push (increment.release());
|
getUndoStack().push (increment.release());
|
||||||
getUndoStack().endMacro();
|
getUndoStack().endMacro();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int CSVWorld::ReferenceCreator::getRefNumCount() const
|
||||||
|
{
|
||||||
|
std::string cellId = mCell->text().toUtf8().constData();
|
||||||
|
|
||||||
|
CSMWorld::IdTable& cellTable = dynamic_cast<CSMWorld::IdTable&> (
|
||||||
|
*getData().getTableModel (CSMWorld::UniversalId::Type_Cells));
|
||||||
|
|
||||||
|
int countColumn = cellTable.findColumnIndex (CSMWorld::Columns::ColumnId_RefNumCounter);
|
||||||
|
|
||||||
|
QModelIndex countIndex = cellTable.getModelIndex (cellId, countColumn);
|
||||||
|
|
||||||
|
return cellTable.data (countIndex).toInt();
|
||||||
|
}
|
||||||
|
|
||||||
CSVWorld::ReferenceCreator::ReferenceCreator (CSMWorld::Data& data, QUndoStack& undoStack,
|
CSVWorld::ReferenceCreator::ReferenceCreator (CSMWorld::Data& data, QUndoStack& undoStack,
|
||||||
const CSMWorld::UniversalId& id)
|
const CSMWorld::UniversalId& id)
|
||||||
: GenericCreator (data, undoStack, id)
|
: GenericCreator (data, undoStack, id)
|
||||||
|
|
|
@ -23,6 +23,9 @@ namespace CSVWorld
|
||||||
virtual void pushCommand (std::auto_ptr<QUndoCommand> command,
|
virtual void pushCommand (std::auto_ptr<QUndoCommand> command,
|
||||||
const std::string& id);
|
const std::string& id);
|
||||||
|
|
||||||
|
/// Return next available RefNum for the cell the creator is currently operating on
|
||||||
|
int getRefNumCount() const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
ReferenceCreator (CSMWorld::Data& data, QUndoStack& undoStack,
|
ReferenceCreator (CSMWorld::Data& data, QUndoStack& undoStack,
|
||||||
|
|
Loading…
Reference in a new issue