diff options
author | Caolán McNamara <caolanm@redhat.com> | 2021-11-02 11:44:47 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2021-11-02 17:13:35 +0100 |
commit | 0f684565d9246ccc39766289e9a5c383e8f9d838 (patch) | |
tree | 695530330800b234e9e1a026d01a17e807d422c9 /cui/source | |
parent | SwNavigator: Make list of open files in Display sub menu consistent (diff) | |
download | core-0f684565d9246ccc39766289e9a5c383e8f9d838.tar.gz core-0f684565d9246ccc39766289e9a5c383e8f9d838.zip |
extract a ReorderingDropTarget for reuse
Change-Id: I0ae69bbf644e220e1bf3352d98eb4fd735167416
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124596
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'cui/source')
-rw-r--r-- | cui/source/customize/cfg.cxx | 31 | ||||
-rw-r--r-- | cui/source/inc/cfg.hxx | 6 |
2 files changed, 6 insertions, 31 deletions
diff --git a/cui/source/customize/cfg.cxx b/cui/source/customize/cfg.cxx index 943dc83247d4..79961fe690c2 100644 --- a/cui/source/customize/cfg.cxx +++ b/cui/source/customize/cfg.cxx @@ -3201,39 +3201,16 @@ SvxIconChangeDialog::SvxIconChangeDialog(weld::Window *pWindow, const OUString& } SvxConfigPageFunctionDropTarget::SvxConfigPageFunctionDropTarget(SvxConfigPage&rPage, weld::TreeView& rTreeView) - : DropTargetHelper(rTreeView.get_drop_target()) + : weld::ReorderingDropTarget(rTreeView) , m_rPage(rPage) - , m_rTreeView(rTreeView) { } -sal_Int8 SvxConfigPageFunctionDropTarget::AcceptDrop(const AcceptDropEvent& rEvt) +sal_Int8 SvxConfigPageFunctionDropTarget::ExecuteDrop(const ExecuteDropEvent& rEvt) { - // to enable the autoscroll when we're close to the edges - m_rTreeView.get_dest_row_at_pos(rEvt.maPosPixel, nullptr, true); - return DND_ACTION_MOVE; -} - -sal_Int8 SvxConfigPageFunctionDropTarget::ExecuteDrop( const ExecuteDropEvent& rEvt ) -{ - weld::TreeView* pSource = m_rTreeView.get_drag_source(); - // only dragging within the same widget allowed - if (!pSource || pSource != &m_rTreeView) - return DND_ACTION_NONE; - - std::unique_ptr<weld::TreeIter> xSource(m_rTreeView.make_iterator()); - if (!m_rTreeView.get_selected(xSource.get())) - return DND_ACTION_NONE; - - std::unique_ptr<weld::TreeIter> xTarget(m_rTreeView.make_iterator()); - int nTargetPos = -1; - if (m_rTreeView.get_dest_row_at_pos(rEvt.maPosPixel, xTarget.get(), true)) - nTargetPos = m_rTreeView.get_iter_index_in_parent(*xTarget); - m_rTreeView.move_subtree(*xSource, nullptr, nTargetPos); - + sal_Int8 nRet = weld::ReorderingDropTarget::ExecuteDrop(rEvt); m_rPage.ListModified(); - - return DND_ACTION_NONE; + return nRet;; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cui/source/inc/cfg.hxx b/cui/source/inc/cfg.hxx index c1b492cb4b90..b143367a547f 100644 --- a/cui/source/inc/cfg.hxx +++ b/cui/source/inc/cfg.hxx @@ -19,9 +19,9 @@ #pragma once -#include <vcl/transfer.hxx> #include <vcl/timer.hxx> #include <vcl/weld.hxx> +#include <vcl/weldutils.hxx> #include <svtools/valueset.hxx> #include <com/sun/star/container/XIndexContainer.hpp> @@ -352,13 +352,11 @@ public: void CreateDropDown(); }; -class SvxConfigPageFunctionDropTarget : public DropTargetHelper +class SvxConfigPageFunctionDropTarget : public weld::ReorderingDropTarget { private: SvxConfigPage& m_rPage; - weld::TreeView& m_rTreeView; - virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ) override; virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt ) override; public: |