AppFwk TableEditor : Add selection of owner object

If no objects in the table is selected, add the owner object to selection. This makes it possible to access the owner object from features to add new items into empty tables.
This commit is contained in:
Magne Sjaastad 2018-08-01 11:04:56 +02:00
parent 2c55506a9b
commit b79a340333

View File

@ -190,6 +190,8 @@ void PdmUiTableViewEditor::configureAndUpdateUi(const QString& uiConfigName)
m_tableView->resizeRowsToContents();
m_previousFieldHandle = childArrayFH;
}
updateSelectionManagerFromTableSelection();
}
//--------------------------------------------------------------------------------------------------
@ -310,6 +312,14 @@ void PdmUiTableViewEditor::updateSelectionManagerFromTableSelection()
std::vector<PdmUiItem*> items { selectedRowObjects.begin(), selectedRowObjects.end() };
if (items.empty() && childArrayFieldHandle() && childArrayFieldHandle()->ownerObject())
{
// If no rows are selected, add the owner object to the selection.
// This enables features to retrieve the owner object to add of new objects into
// an empty table or table without selection
items.push_back(childArrayFieldHandle()->ownerObject()->uiCapability());
}
m_isBlockingSelectionManagerChanged = true;
SelectionManager::instance()->setSelectedItems(items, m_selectionRole);
m_isBlockingSelectionManagerChanged = false;