#3249 caf: Add isSelected method to selection manager

This commit is contained in:
Jacob Støren 2018-08-29 15:42:35 +02:00
parent ed518a94a6
commit 99bdece40e
2 changed files with 29 additions and 0 deletions

View File

@ -209,6 +209,33 @@ void SelectionManager::setSelectionFromReferences(const std::vector<QString>& re
setSelectedItems(uiItems, selectionLevel);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool SelectionManager::isSelected(PdmUiItem* item, int selectionLevel) const
{
auto levelIter = m_selectionPrLevel.find(selectionLevel);
if (levelIter == m_selectionPrLevel.end()) return false;
const std::vector< std::pair<PdmPointer<PdmObjectHandle>, PdmUiItem*> >& selection = levelIter->second;
auto iter = selection.begin();
while ( iter != selection.end() )
{
if ( iter->second == item )
{
return true;
}
else
{
++iter;
}
}
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -87,6 +87,8 @@ public:
void selectionAsReferences(std::vector<QString>& referenceList, int selectionLevel = 0) const;
void setSelectionFromReferences(const std::vector<QString>& referenceList, int selectionLevel = 0);
bool isSelected(PdmUiItem* item, int selectionLevel) const;
void clearAll();
void clear(int selectionLevel);
void removeObjectFromAllSelections(PdmObjectHandle* pdmObject);