summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Weghorn <m.weghorn@posteo.de>2024-12-21 00:41:12 +0100
committerMichael Weghorn <m.weghorn@posteo.de>2024-12-21 09:32:15 +0100
commitd4317567357228f75eb10f22decc55ac2be26dd2 (patch)
tree6a16f675e0480ac805e5fb05ff04a24162d397ce
parent8c98986b5bd5e2e841a2e1a2f78621f3d4d7b8da (diff)
tdf#130857 qt weld: Handle more QtInstanceTreeView::insert params
* Don't always append, but evaluate the insert position (with special value -1 to append). * If an iterator is passed for `pRet`, set its model index to the new item's model index. Change-Id: I2db8718f4b572d4ae3dcfa7183033f04174b72a1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178975 Reviewed-by: Michael Weghorn <m.weghorn@posteo.de> Tested-by: Jenkins
-rw-r--r--vcl/inc/qt5/QtInstanceTreeView.hxx2
-rw-r--r--vcl/qt5/QtInstanceTreeView.cxx14
2 files changed, 9 insertions, 7 deletions
diff --git a/vcl/inc/qt5/QtInstanceTreeView.hxx b/vcl/inc/qt5/QtInstanceTreeView.hxx
index 1e8ebbec2d21..2367afc815e0 100644
--- a/vcl/inc/qt5/QtInstanceTreeView.hxx
+++ b/vcl/inc/qt5/QtInstanceTreeView.hxx
@@ -25,7 +25,7 @@ class QtInstanceTreeView : public QtInstanceWidget, public virtual weld::TreeVie
public:
QtInstanceTreeView(QTreeView* pTreeView);
- virtual void insert(const weld::TreeIter* pParent, int pos, const OUString* pStr,
+ virtual void insert(const weld::TreeIter* pParent, int nPos, const OUString* pStr,
const OUString* pId, const OUString* pIconName,
VirtualDevice* pImageSurface, bool bChildrenOnDemand,
weld::TreeIter* pRet) override;
diff --git a/vcl/qt5/QtInstanceTreeView.cxx b/vcl/qt5/QtInstanceTreeView.cxx
index f9173920e5e9..e1e60e03bb44 100644
--- a/vcl/qt5/QtInstanceTreeView.cxx
+++ b/vcl/qt5/QtInstanceTreeView.cxx
@@ -50,7 +50,7 @@ QtInstanceTreeView::QtInstanceTreeView(QTreeView* pTreeView)
&QtInstanceTreeView::handleSelectionChanged);
}
-void QtInstanceTreeView::insert(const weld::TreeIter* pParent, int pos, const OUString* pStr,
+void QtInstanceTreeView::insert(const weld::TreeIter* pParent, int nPos, const OUString* pStr,
const OUString* pId, const OUString* pIconName,
VirtualDevice* pImageSurface, bool bChildrenOnDemand,
weld::TreeIter* pRet)
@@ -59,18 +59,14 @@ void QtInstanceTreeView::insert(const weld::TreeIter* pParent, int pos, const OU
// assert only these are used at the moment and implement remaining cases
// when needed to support more dialogs, then adjust/remove asserts below
assert(!pParent && "Not implemented yet");
- assert(pos == -1 && "Not implemented yet");
assert(!pIconName && "Not implemented yet");
assert(!pImageSurface && "Not implemented yet");
assert(!bChildrenOnDemand && "Not implemented yet");
- assert(!pRet && "Not implemented yet");
// avoid -Werror=unused-parameter for release build
(void)pParent;
- (void)pos;
(void)pIconName;
(void)pImageSurface;
(void)bChildrenOnDemand;
- (void)pRet;
SolarMutexGuard g;
GetQtInstance().RunInMainThread([&] {
@@ -79,7 +75,13 @@ void QtInstanceTreeView::insert(const weld::TreeIter* pParent, int pos, const OU
pItem->setText(toQString(*pStr));
if (pId)
pItem->setData(toQString(*pId), ROLE_ID);
- m_pModel->appendRow(pItem);
+
+ if (nPos == -1)
+ nPos = m_pModel->rowCount();
+ m_pModel->insertRow(nPos, pItem);
+
+ if (pRet)
+ static_cast<QtInstanceTreeIter*>(pRet)->m_aModelIndex = modelIndex(nPos);
});
}