forked from mirror/openmw-tes3mp
Add ability to remove multiple rows in subrecords.
This commit is contained in:
parent
3dce406829
commit
ae50300053
1 changed files with 12 additions and 8 deletions
|
@ -9,6 +9,7 @@
|
||||||
#include "../../model/world/universalid.hpp"
|
#include "../../model/world/universalid.hpp"
|
||||||
#include "../../model/world/commands.hpp"
|
#include "../../model/world/commands.hpp"
|
||||||
#include "../../model/world/commanddispatcher.hpp"
|
#include "../../model/world/commanddispatcher.hpp"
|
||||||
|
#include "../../model/world/commandmacro.hpp"
|
||||||
|
|
||||||
#include "tableeditidaction.hpp"
|
#include "tableeditidaction.hpp"
|
||||||
#include "util.hpp"
|
#include "util.hpp"
|
||||||
|
@ -63,7 +64,7 @@ CSVWorld::NestedTable::NestedTable(CSMDoc::Document& document,
|
||||||
connect(mAddNewRowAction, SIGNAL(triggered()),
|
connect(mAddNewRowAction, SIGNAL(triggered()),
|
||||||
this, SLOT(addNewRowActionTriggered()));
|
this, SLOT(addNewRowActionTriggered()));
|
||||||
|
|
||||||
mRemoveRowAction = new QAction (tr ("Remove row"), this);
|
mRemoveRowAction = new QAction (tr ("Remove rows"), this);
|
||||||
|
|
||||||
connect(mRemoveRowAction, SIGNAL(triggered()),
|
connect(mRemoveRowAction, SIGNAL(triggered()),
|
||||||
this, SLOT(removeRowActionTriggered()));
|
this, SLOT(removeRowActionTriggered()));
|
||||||
|
@ -100,10 +101,8 @@ void CSVWorld::NestedTable::contextMenuEvent (QContextMenuEvent *event)
|
||||||
|
|
||||||
if (mAddNewRowAction && mRemoveRowAction)
|
if (mAddNewRowAction && mRemoveRowAction)
|
||||||
{
|
{
|
||||||
if (selectionModel()->selectedRows().size() == 1)
|
|
||||||
menu.addAction(mRemoveRowAction);
|
|
||||||
|
|
||||||
menu.addAction(mAddNewRowAction);
|
menu.addAction(mAddNewRowAction);
|
||||||
|
menu.addAction(mRemoveRowAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
menu.exec (event->globalPos());
|
menu.exec (event->globalPos());
|
||||||
|
@ -111,10 +110,15 @@ void CSVWorld::NestedTable::contextMenuEvent (QContextMenuEvent *event)
|
||||||
|
|
||||||
void CSVWorld::NestedTable::removeRowActionTriggered()
|
void CSVWorld::NestedTable::removeRowActionTriggered()
|
||||||
{
|
{
|
||||||
mDocument.getUndoStack().push(new CSMWorld::DeleteNestedCommand(*(mModel->model()),
|
CSMWorld::CommandMacro macro(mDocument.getUndoStack(),
|
||||||
mModel->getParentId(),
|
selectionModel()->selectedRows().size() > 1 ? tr("Remove rows") : "");
|
||||||
selectionModel()->selectedRows().begin()->row(),
|
|
||||||
mModel->getParentColumn()));
|
// Remove rows in reverse order
|
||||||
|
for (int i = selectionModel()->selectedRows().size() - 1; i >= 0; --i)
|
||||||
|
{
|
||||||
|
macro.push(new CSMWorld::DeleteNestedCommand(*(mModel->model()), mModel->getParentId(),
|
||||||
|
selectionModel()->selectedRows()[i].row(), mModel->getParentColumn()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVWorld::NestedTable::addNewRowActionTriggered()
|
void CSVWorld::NestedTable::addNewRowActionTriggered()
|
||||||
|
|
Loading…
Reference in a new issue