}
}
+//***************************************************
+void XGUI_ObjectsBrowser::ensureVisible(const ObjectPtr theObject)
+{
+ QModelIndex aIndex = myDocModel->objectIndex(theObject);
+ if (aIndex.isValid()) {
+ QModelIndex aParent = aIndex.parent();
+ while (aParent.isValid()) {
+ myTreeView->expand(aParent);
+ aParent = aParent.parent();
+ }
+ myTreeView->scrollTo(aIndex);
+ }
+}
+
//***************************************************
void XGUI_ObjectsBrowser::clearContent()
{
/// \param theObjects list of objects to select
void setObjectsSelected(const QObjectPtrList& theObjects);
+ //! Scroll TreeView to make given object visible
+ //! \param theObject object to make it visible
+ void ensureVisible(const ObjectPtr theObject);
+
//! Returns currently selected indexes
QModelIndexList selectedIndexes() const
{
{
FeaturePtr aFeature;
QObjectPtrList aSelList = theObjects;
+ QObjectPtrList aNewSel;
bool aHasHidden = false;
foreach(ObjectPtr aObj, theObjects) {
aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aObj);
for(aIt = aResults.cbegin(); aIt != aResults.cend(); aIt++) {
aHasHidden |= (*aIt)->isConcealed();
aSelList.append(*aIt);
+ aNewSel.append(*aIt);
}
}
}
bool aBlocked = objectBrowser()->blockSignals(true);
objectBrowser()->setObjectsSelected(aSelList);
objectBrowser()->blockSignals(aBlocked);
+ objectBrowser()->ensureVisible(aNewSel.first());
}
if (aHasHidden)
QMessageBox::information(desktop(), tr("Find results"),
{
ResultPtr aResult;
QObjectPtrList aSelList = theObjects;
+ QObjectPtrList aNewSel;
FeaturePtr aFeature;
foreach(ObjectPtr aObj, theObjects) {
aResult = std::dynamic_pointer_cast<ModelAPI_Result>(aObj);
aFeature = ModelAPI_Feature::feature(aResult);
if (aFeature.get()) {
aSelList.append(aFeature);
+ aNewSel.append(aFeature);
}
}
}
bool aBlocked = objectBrowser()->blockSignals(true);
objectBrowser()->setObjectsSelected(aSelList);
objectBrowser()->blockSignals(aBlocked);
+ objectBrowser()->ensureVisible(aNewSel.first());
}
}