mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-29 19:36:43 +00:00
revert button
This commit is contained in:
parent
09ba547630
commit
7296b09357
2 changed files with 45 additions and 0 deletions
|
@ -27,6 +27,7 @@
|
||||||
#include "../../model/world/record.hpp"
|
#include "../../model/world/record.hpp"
|
||||||
#include "../../model/world/tablemimedata.hpp"
|
#include "../../model/world/tablemimedata.hpp"
|
||||||
#include "../../model/doc/document.hpp"
|
#include "../../model/doc/document.hpp"
|
||||||
|
#include "../../model/world/commands.hpp"
|
||||||
|
|
||||||
#include "recordstatusdelegate.hpp"
|
#include "recordstatusdelegate.hpp"
|
||||||
#include "util.hpp"
|
#include "util.hpp"
|
||||||
|
@ -402,9 +403,22 @@ CSVWorld::DialogueSubView::DialogueSubView (const CSMWorld::UniversalId& id, CSM
|
||||||
buttonsLayout->addWidget(prevButton, 0);
|
buttonsLayout->addWidget(prevButton, 0);
|
||||||
buttonsLayout->addWidget(nextButton, 1);
|
buttonsLayout->addWidget(nextButton, 1);
|
||||||
buttonsLayout->addStretch(2);
|
buttonsLayout->addStretch(2);
|
||||||
|
|
||||||
|
QToolButton* cloneButton = new QToolButton(mainWidget);
|
||||||
|
QToolButton* addButton = new QToolButton(mainWidget);
|
||||||
|
QToolButton* deleteButton = new QToolButton(mainWidget);
|
||||||
|
QToolButton* revertButton = new QToolButton(mainWidget);
|
||||||
|
|
||||||
|
buttonsLayout->addWidget(cloneButton);
|
||||||
|
buttonsLayout->addWidget(addButton);
|
||||||
|
buttonsLayout->addWidget(deleteButton);
|
||||||
|
buttonsLayout->addWidget(revertButton);
|
||||||
|
|
||||||
connect(nextButton, SIGNAL(clicked()), this, SLOT(nextId()));
|
connect(nextButton, SIGNAL(clicked()), this, SLOT(nextId()));
|
||||||
connect(prevButton, SIGNAL(clicked()), this, SLOT(prevId()));
|
connect(prevButton, SIGNAL(clicked()), this, SLOT(prevId()));
|
||||||
|
|
||||||
|
connect(revertButton, SIGNAL(clicked()), this, SLOT(revertRecord()));
|
||||||
|
|
||||||
mMainLayout = new QVBoxLayout(mainWidget);
|
mMainLayout = new QVBoxLayout(mainWidget);
|
||||||
|
|
||||||
mEditWidget = new EditWidget(mainWidget, mRow, mTable, mUndoStack, false);
|
mEditWidget = new EditWidget(mainWidget, mRow, mTable, mUndoStack, false);
|
||||||
|
@ -519,3 +533,32 @@ void CSVWorld::DialogueSubView::tableMimeDataDropped(QWidget* editor,
|
||||||
qobject_cast<DropLineEdit*>(editor)->setText(id.getId().c_str());
|
qobject_cast<DropLineEdit*>(editor)->setText(id.getId().c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSVWorld::DialogueSubView::revertRecord()
|
||||||
|
{
|
||||||
|
int rows = mTable->rowCount();
|
||||||
|
if (!mLocked && mTable->columnCount() > 0 && mRow < mTable->rowCount() )
|
||||||
|
{
|
||||||
|
CSMWorld::RecordBase::State state =
|
||||||
|
static_cast<CSMWorld::RecordBase::State> (mTable->data (mTable->index (mRow, 1)).toInt());
|
||||||
|
|
||||||
|
if (state!=CSMWorld::RecordBase::State_BaseOnly)
|
||||||
|
{
|
||||||
|
mUndoStack.push(new CSMWorld::RevertCommand(*mTable, mTable->data(mTable->index (mRow, 0)).toString().toStdString()));
|
||||||
|
}
|
||||||
|
if (rows != mTable->rowCount())
|
||||||
|
{
|
||||||
|
if (mTable->rowCount() == 0)
|
||||||
|
{
|
||||||
|
mEditWidget->setDisabled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (mRow >= mTable->rowCount())
|
||||||
|
{
|
||||||
|
prevId();
|
||||||
|
} else {
|
||||||
|
dataChanged(mTable->index(mRow, 0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -179,6 +179,8 @@ namespace CSVWorld
|
||||||
|
|
||||||
void prevId();
|
void prevId();
|
||||||
|
|
||||||
|
void revertRecord();
|
||||||
|
|
||||||
void dataChanged(const QModelIndex & index);
|
void dataChanged(const QModelIndex & index);
|
||||||
///\brief we need to care for deleting currently edited record
|
///\brief we need to care for deleting currently edited record
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue