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 /include/vcl | |
parent | e0fa72a714c1992370f023308814acf96763e2c9 (diff) |
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 'include/vcl')
-rw-r--r-- | include/vcl/weldutils.hxx | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/include/vcl/weldutils.hxx b/include/vcl/weldutils.hxx index 8cb591ce8140..cadbd5585ef7 100644 --- a/include/vcl/weldutils.hxx +++ b/include/vcl/weldutils.hxx @@ -21,6 +21,7 @@ #include <vcl/dllapi.h> #include <vcl/formatter.hxx> #include <vcl/timer.hxx> +#include <vcl/transfer.hxx> #include <vcl/weld.hxx> class CalendarWrapper; @@ -418,6 +419,26 @@ public: bool IsModKeyPressed() const { return m_bModKey; } }; +/* + If a TreeView is used as a list, rather than a tree, and DnD should just + reorder rows, then this can be used to implement that. + + Because the TreeView doesn't want or need subnodes, the drop target can be + simply visually indicated as being between rows (the issue of a final drop + location of a child of the drop target doesn't arise), and the meaning of + what a drop before or after the last row should do is unambigious. +*/ +class VCL_DLLPUBLIC ReorderingDropTarget : public DropTargetHelper +{ +protected: + weld::TreeView& m_rTreeView; + virtual sal_Int8 AcceptDrop(const AcceptDropEvent& rEvt) override; + virtual sal_Int8 ExecuteDrop(const ExecuteDropEvent& rEvt) override; + +public: + ReorderingDropTarget(weld::TreeView& rTreeView); +}; + // get the row the iterator is on VCL_DLLPUBLIC size_t GetAbsPos(const weld::TreeView& rTreeView, const weld::TreeIter& rIter); |