diff options
author | Michael Weghorn <m.weghorn@posteo.de> | 2025-04-26 20:15:47 +0200 |
---|---|---|
committer | Michael Weghorn <m.weghorn@posteo.de> | 2025-04-27 07:25:23 +0200 |
commit | 0361f96e463e3db7d771fd9a30e3ae27b5a94ee8 (patch) | |
tree | 18d6b2a79d3aa955edc4bc05cc4f2fd5a85f7ee9 | |
parent | 873e22528cf6749520fb7f03f58c4f52fbb9dc03 (diff) |
tdf#130857 qt weld: Implement QtInstanceTreeView::iter_*
Implement methods to get previous/next sibling, parent or first child. Change-Id: Icc32b980b595f23d727f0563afdad9e42a05d2b9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184677 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
-rw-r--r-- | vcl/qt5/QtInstanceTreeView.cxx | 38 |
1 files changed, 26 insertions, 12 deletions
diff --git a/vcl/qt5/QtInstanceTreeView.cxx b/vcl/qt5/QtInstanceTreeView.cxx index 59988976cc9a..508c0ee73590 100644 --- a/vcl/qt5/QtInstanceTreeView.cxx +++ b/vcl/qt5/QtInstanceTreeView.cxx @@ -374,16 +374,24 @@ bool QtInstanceTreeView::get_iter_first(weld::TreeIter& rIter) const return aIndex.isValid(); } -bool QtInstanceTreeView::iter_next_sibling(weld::TreeIter&) const +bool QtInstanceTreeView::iter_next_sibling(weld::TreeIter& rIter) const { - assert(false && "Not implemented yet"); - return false; + QtInstanceTreeIter& rQtIter = static_cast<QtInstanceTreeIter&>(rIter); + const QModelIndex aIndex = rQtIter.modelIndex(); + const QModelIndex aSiblingIndex = m_pModel->sibling(aIndex.row() + 1, 0, aIndex); + rQtIter.setModelIndex(aSiblingIndex); + + return aSiblingIndex.isValid(); } -bool QtInstanceTreeView::iter_previous_sibling(weld::TreeIter&) const +bool QtInstanceTreeView::iter_previous_sibling(weld::TreeIter& rIter) const { - assert(false && "Not implemented yet"); - return false; + QtInstanceTreeIter& rQtIter = static_cast<QtInstanceTreeIter&>(rIter); + const QModelIndex aIndex = rQtIter.modelIndex(); + const QModelIndex aSiblingIndex = m_pModel->sibling(aIndex.row() - 1, 0, aIndex); + rQtIter.setModelIndex(aSiblingIndex); + + return aSiblingIndex.isValid(); } bool QtInstanceTreeView::iter_next(weld::TreeIter&) const @@ -398,16 +406,22 @@ bool QtInstanceTreeView::iter_previous(weld::TreeIter&) const return false; } -bool QtInstanceTreeView::iter_children(weld::TreeIter&) const +bool QtInstanceTreeView::iter_children(weld::TreeIter& rIter) const { - assert(false && "Not implemented yet"); - return false; + QtInstanceTreeIter& rQtIter = static_cast<QtInstanceTreeIter&>(rIter); + const QModelIndex aChildIndex = m_pModel->index(0, 0, rQtIter.modelIndex()); + rQtIter.setModelIndex(aChildIndex); + + return aChildIndex.isValid(); } -bool QtInstanceTreeView::iter_parent(weld::TreeIter&) const +bool QtInstanceTreeView::iter_parent(weld::TreeIter& rIter) const { - assert(false && "Not implemented yet"); - return false; + QtInstanceTreeIter& rQtIter = static_cast<QtInstanceTreeIter&>(rIter); + const QModelIndex aParentIndex = rQtIter.modelIndex().parent(); + rQtIter.setModelIndex(aParentIndex); + + return aParentIndex.isValid(); } int QtInstanceTreeView::get_iter_depth(const weld::TreeIter& rIter) const |