Made translation between PdmUiItem and QModelIndex available in PdmUiTreeView

After considering the different options, I concluded that it is important to
support the Qt way of doing things.
If the App programmer wants to do things the Qt way, it should be possible.
This commit is contained in:
Jacob Støren 2015-08-16 09:57:57 +02:00
parent 6ca74621ef
commit 6d7bf0ae9e
4 changed files with 40 additions and 0 deletions

View File

@ -155,5 +155,21 @@ void PdmUiTreeView::setExpanded(const PdmUiItem* uiItem, bool doExpand) const
m_treeViewEditor->setExpanded(uiItem, doExpand);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
PdmUiItem* PdmUiTreeView::uiItemFromModelIndex(const QModelIndex& index) const
{
return m_treeViewEditor->uiItemFromModelIndex(index);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QModelIndex PdmUiTreeView::findModelIndex(const PdmUiItem* object) const
{
return m_treeViewEditor->findModelIndex(object);
}
} //End of namespace caf

View File

@ -43,6 +43,7 @@ class QVBoxLayout;
class QTreeView;
class QItemSelection;
class QMenu;
class QModelIndex;
namespace caf
{
@ -73,6 +74,10 @@ public:
void selectAsCurrentItem(PdmUiItem* uiItem);
void setExpanded(const PdmUiItem* uiItem, bool doExpand) const ;
PdmUiItem* uiItemFromModelIndex(const QModelIndex& index) const;
QModelIndex findModelIndex(const PdmUiItem* object) const;
signals:
void selectionChanged();

View File

@ -274,5 +274,21 @@ void PdmUiTreeViewEditor::setExpanded(const PdmUiItem* uiItem, bool doExpand) co
m_treeView->setExpanded(index, doExpand);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
PdmUiItem* PdmUiTreeViewEditor::uiItemFromModelIndex(const QModelIndex& index) const
{
return m_treeViewModel->uiItemFromModelIndex(index);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QModelIndex PdmUiTreeViewEditor::findModelIndex(const PdmUiItem* object) const
{
return m_treeViewModel->findModelIndex(object);
}
} // end namespace caf

View File

@ -91,6 +91,9 @@ public:
void selectedUiItems(std::vector<PdmUiItem*>& objects);
void setExpanded(const PdmUiItem* uiItem, bool doExpand) const;
PdmUiItem* uiItemFromModelIndex(const QModelIndex& index) const;
QModelIndex findModelIndex(const PdmUiItem* object) const;
QWidget* createWidget(QWidget* parent);
signals: