mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-21 18:40:01 +00:00
Move touch command to creator, to allow customization and not break abstraction
This commit is contained in:
parent
1d480015b4
commit
30ba1d4c25
@ -31,6 +31,9 @@ namespace CSVWorld
|
|||||||
virtual void cloneMode(const std::string& originId,
|
virtual void cloneMode(const std::string& originId,
|
||||||
const CSMWorld::UniversalId::Type type) = 0;
|
const CSMWorld::UniversalId::Type type) = 0;
|
||||||
|
|
||||||
|
/// Touches a record, if the creator supports it.
|
||||||
|
virtual void touch(const std::vector<CSMWorld::UniversalId>& ids) = 0;
|
||||||
|
|
||||||
virtual void setEditLock (bool locked) = 0;
|
virtual void setEditLock (bool locked) = 0;
|
||||||
|
|
||||||
virtual void toggleWidgets(bool active = true) = 0;
|
virtual void toggleWidgets(bool active = true) = 0;
|
||||||
|
@ -254,6 +254,23 @@ void CSVWorld::GenericCreator::cloneMode(const std::string& originId,
|
|||||||
mClonedType = type;
|
mClonedType = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSVWorld::GenericCreator::touch(const std::vector<CSMWorld::UniversalId>& ids)
|
||||||
|
{
|
||||||
|
// Combine multiple touch commands into one "macro" command
|
||||||
|
std::unique_ptr<QUndoCommand> macro(new QUndoCommand());
|
||||||
|
macro->setText("Touch records");
|
||||||
|
|
||||||
|
CSMWorld::IdTable& table = dynamic_cast<CSMWorld::IdTable&>(*mData.getTableModel(mListId));
|
||||||
|
for (const CSMWorld::UniversalId& uid : ids)
|
||||||
|
{
|
||||||
|
// This is not leaked, touchCmd is a child of macro and managed by Qt
|
||||||
|
CSMWorld::TouchCommand* touchCmd = new CSMWorld::TouchCommand(table, uid.getId(), macro.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
mUndoStack.push(macro.release());
|
||||||
|
}
|
||||||
|
|
||||||
void CSVWorld::GenericCreator::toggleWidgets(bool active)
|
void CSVWorld::GenericCreator::toggleWidgets(bool active)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -103,6 +103,8 @@ namespace CSVWorld
|
|||||||
virtual void cloneMode(const std::string& originId,
|
virtual void cloneMode(const std::string& originId,
|
||||||
const CSMWorld::UniversalId::Type type);
|
const CSMWorld::UniversalId::Type type);
|
||||||
|
|
||||||
|
virtual void touch(const std::vector<CSMWorld::UniversalId>& ids);
|
||||||
|
|
||||||
virtual std::string getErrors() const;
|
virtual std::string getErrors() const;
|
||||||
///< Return formatted error descriptions for the current state of the creator. if an empty
|
///< Return formatted error descriptions for the current state of the creator. if an empty
|
||||||
/// string is returned, there is no error.
|
/// string is returned, there is no error.
|
||||||
|
@ -458,23 +458,15 @@ void CSVWorld::Table::touchRecord()
|
|||||||
{
|
{
|
||||||
if (!mEditLock && mModel->getFeatures() & CSMWorld::IdTableBase::Feature_AllowTouch)
|
if (!mEditLock && mModel->getFeatures() & CSMWorld::IdTableBase::Feature_AllowTouch)
|
||||||
{
|
{
|
||||||
if (CSMWorld::IdTable* table = dynamic_cast<CSMWorld::IdTable*>(mModel))
|
std::vector<CSMWorld::UniversalId> touchIds;
|
||||||
{
|
|
||||||
QUndoCommand* touchRecords = new QUndoCommand();
|
|
||||||
touchRecords->setText("Touch records");
|
|
||||||
|
|
||||||
QModelIndexList selectedRows = selectionModel()->selectedRows();
|
QModelIndexList selectedRows = selectionModel()->selectedRows();
|
||||||
for (auto it = selectedRows.begin(); it != selectedRows.end(); ++it)
|
for (auto it = selectedRows.begin(); it != selectedRows.end(); ++it)
|
||||||
{
|
{
|
||||||
QModelIndex index = mProxyModel->mapToSource(mProxyModel->index(it->row(),0));
|
touchIds.push_back(getUniversalId(it->row()));
|
||||||
std::string id = table->getId(index.row());
|
|
||||||
|
|
||||||
// command is a child of touchRecords
|
|
||||||
QUndoCommand* command = new CSMWorld::TouchCommand(*table, id, touchRecords);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mDocument.getUndoStack().push(touchRecords);
|
emit touchRequest(touchIds);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,6 +116,8 @@ namespace CSVWorld
|
|||||||
|
|
||||||
void cloneRequest(const CSMWorld::UniversalId&);
|
void cloneRequest(const CSMWorld::UniversalId&);
|
||||||
|
|
||||||
|
void touchRequest(const std::vector<CSMWorld::UniversalId>& ids);
|
||||||
|
|
||||||
void closeRequest();
|
void closeRequest();
|
||||||
|
|
||||||
void extendedDeleteConfigRequest(const std::vector<std::string> &selectedIds);
|
void extendedDeleteConfigRequest(const std::vector<std::string> &selectedIds);
|
||||||
|
@ -249,6 +249,11 @@ void CSVWorld::TableBottomBox::cloneRequest(const std::string& id,
|
|||||||
mCreator->focus();
|
mCreator->focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSVWorld::TableBottomBox::touchRequest(const std::vector<CSMWorld::UniversalId>& ids)
|
||||||
|
{
|
||||||
|
mCreator->touch(ids);
|
||||||
|
}
|
||||||
|
|
||||||
void CSVWorld::TableBottomBox::extendedDeleteConfigRequest(const std::vector<std::string> &selectedIds)
|
void CSVWorld::TableBottomBox::extendedDeleteConfigRequest(const std::vector<std::string> &selectedIds)
|
||||||
{
|
{
|
||||||
extendedConfigRequest(ExtendedCommandConfigurator::Mode_Delete, selectedIds);
|
extendedConfigRequest(ExtendedCommandConfigurator::Mode_Delete, selectedIds);
|
||||||
|
@ -102,6 +102,7 @@ namespace CSVWorld
|
|||||||
void createRequest();
|
void createRequest();
|
||||||
void cloneRequest(const std::string& id,
|
void cloneRequest(const std::string& id,
|
||||||
const CSMWorld::UniversalId::Type type);
|
const CSMWorld::UniversalId::Type type);
|
||||||
|
void touchRequest(const std::vector<CSMWorld::UniversalId>&);
|
||||||
|
|
||||||
void extendedDeleteConfigRequest(const std::vector<std::string> &selectedIds);
|
void extendedDeleteConfigRequest(const std::vector<std::string> &selectedIds);
|
||||||
void extendedRevertConfigRequest(const std::vector<std::string> &selectedIds);
|
void extendedRevertConfigRequest(const std::vector<std::string> &selectedIds);
|
||||||
|
@ -69,6 +69,9 @@ CSVWorld::TableSubView::TableSubView (const CSMWorld::UniversalId& id, CSMDoc::D
|
|||||||
connect (this, SIGNAL(cloneRequest(const std::string&, const CSMWorld::UniversalId::Type)),
|
connect (this, SIGNAL(cloneRequest(const std::string&, const CSMWorld::UniversalId::Type)),
|
||||||
mBottom, SLOT(cloneRequest(const std::string&, const CSMWorld::UniversalId::Type)));
|
mBottom, SLOT(cloneRequest(const std::string&, const CSMWorld::UniversalId::Type)));
|
||||||
|
|
||||||
|
connect (mTable, SIGNAL(touchRequest(const std::vector<CSMWorld::UniversalId>&)),
|
||||||
|
mBottom, SLOT(touchRequest(const std::vector<CSMWorld::UniversalId>&)));
|
||||||
|
|
||||||
connect (mTable, SIGNAL(extendedDeleteConfigRequest(const std::vector<std::string> &)),
|
connect (mTable, SIGNAL(extendedDeleteConfigRequest(const std::vector<std::string> &)),
|
||||||
mBottom, SLOT(extendedDeleteConfigRequest(const std::vector<std::string> &)));
|
mBottom, SLOT(extendedDeleteConfigRequest(const std::vector<std::string> &)));
|
||||||
connect (mTable, SIGNAL(extendedRevertConfigRequest(const std::vector<std::string> &)),
|
connect (mTable, SIGNAL(extendedRevertConfigRequest(const std::vector<std::string> &)),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user