mirror of
				https://github.com/TES3MP/openmw-tes3mp.git
				synced 2025-10-31 20:26:48 +00:00 
			
		
		
		
	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/commands.hpp" | ||||
| #include "../../model/world/commanddispatcher.hpp" | ||||
| #include "../../model/world/commandmacro.hpp" | ||||
| 
 | ||||
| #include "tableeditidaction.hpp" | ||||
| #include "util.hpp" | ||||
|  | @ -63,7 +64,7 @@ CSVWorld::NestedTable::NestedTable(CSMDoc::Document& document, | |||
|             connect(mAddNewRowAction, SIGNAL(triggered()), | ||||
|                     this, SLOT(addNewRowActionTriggered())); | ||||
| 
 | ||||
|             mRemoveRowAction = new QAction (tr ("Remove row"), this); | ||||
|             mRemoveRowAction = new QAction (tr ("Remove rows"), this); | ||||
| 
 | ||||
|             connect(mRemoveRowAction, SIGNAL(triggered()), | ||||
|                     this, SLOT(removeRowActionTriggered())); | ||||
|  | @ -100,10 +101,8 @@ void CSVWorld::NestedTable::contextMenuEvent (QContextMenuEvent *event) | |||
| 
 | ||||
|     if (mAddNewRowAction && mRemoveRowAction) | ||||
|     { | ||||
|         if (selectionModel()->selectedRows().size() == 1) | ||||
|             menu.addAction(mRemoveRowAction); | ||||
| 
 | ||||
|         menu.addAction(mAddNewRowAction); | ||||
|         menu.addAction(mRemoveRowAction); | ||||
|     } | ||||
| 
 | ||||
|     menu.exec (event->globalPos()); | ||||
|  | @ -111,10 +110,15 @@ void CSVWorld::NestedTable::contextMenuEvent (QContextMenuEvent *event) | |||
| 
 | ||||
| void CSVWorld::NestedTable::removeRowActionTriggered() | ||||
| { | ||||
|     mDocument.getUndoStack().push(new CSMWorld::DeleteNestedCommand(*(mModel->model()), | ||||
|                                                                     mModel->getParentId(), | ||||
|                                                                     selectionModel()->selectedRows().begin()->row(), | ||||
|                                                                     mModel->getParentColumn())); | ||||
|     CSMWorld::CommandMacro macro(mDocument.getUndoStack(), | ||||
|         selectionModel()->selectedRows().size() > 1 ? tr("Remove rows") : ""); | ||||
| 
 | ||||
|     // 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() | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue