1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <vcl/InterimItemWindow.hxx>
22 #include <vcl/transfer.hxx>
23 #include <vcl/timer.hxx>
24 #include <vcl/weld.hxx>
33 virtual bool includeEntry(const void* pUserData
) const = 0;
39 class IControlActionListener
;
40 class IContextMenuProvider
;
44 class TreeListBoxDropTarget
: public DropTargetHelper
47 TreeListBox
& m_rTreeView
;
49 virtual sal_Int8
AcceptDrop( const AcceptDropEvent
& rEvt
) override
;
50 virtual sal_Int8
ExecuteDrop( const ExecuteDropEvent
& rEvt
) override
;
53 TreeListBoxDropTarget(TreeListBox
& rTreeView
);
59 std::unique_ptr
<weld::TreeView
> m_xTreeView
;
60 TreeListBoxDropTarget m_aDropTargetHelper
;
62 std::unique_ptr
<weld::TreeIter
> m_xDragedEntry
;
63 IControlActionListener
* m_pActionListener
;
64 IContextMenuProvider
* m_pContextMenuProvider
;
66 DECL_LINK(KeyInputHdl
, const KeyEvent
&, bool);
67 DECL_LINK(SelectHdl
, weld::TreeView
&, void);
68 DECL_LINK(QueryTooltipHdl
, const weld::TreeIter
&, OUString
);
69 DECL_LINK(CommandHdl
, const CommandEvent
&, bool);
70 DECL_LINK(DragBeginHdl
, bool&, bool);
73 Timer m_aTimer
; // is needed for table updates
74 rtl::Reference
<TransferDataContainer
> m_xHelper
;
76 Link
<LinkParamNone
*,void> m_aSelChangeHdl
; // handler to be called (asynchronously) when the selection changes in any way
77 Link
<LinkParamNone
*,void> m_aCopyHandler
; // called when someone press CTRL+C
78 Link
<LinkParamNone
*,void> m_aPasteHandler
; // called when someone press CTRL+V
79 Link
<LinkParamNone
*,void> m_aDeleteHandler
; // called when someone press DELETE Key
81 DECL_LINK(OnTimeOut
, Timer
*, void);
84 void implStopSelectionTimer();
85 void implStartSelectionTimer();
87 virtual bool DoChildKeyInput(const KeyEvent
& rKEvt
);
90 TreeListBox(std::unique_ptr
<weld::TreeView
> xTreeView
, bool bSQLType
);
91 virtual ~TreeListBox();
93 std::unique_ptr
<weld::TreeIter
> GetEntryPosByName(std::u16string_view rName
,
94 const weld::TreeIter
* pStart
= nullptr,
95 const IEntryFilter
* pFilter
= nullptr) const;
97 std::unique_ptr
<weld::TreeIter
> GetRootLevelParent(const weld::TreeIter
* pEntry
) const;
99 void setControlActionListener(IControlActionListener
* pListener
) { m_pActionListener
= pListener
; }
100 void setContextMenuProvider(IContextMenuProvider
* pContextMenuProvider
) { m_pContextMenuProvider
= pContextMenuProvider
; }
102 weld::TreeView
& GetWidget() { return *m_xTreeView
; }
103 const weld::TreeView
& GetWidget() const { return *m_xTreeView
; }
105 TransferDataContainer
& GetDataTransfer() { return *m_xHelper
; }
107 sal_Int8
AcceptDrop(const AcceptDropEvent
& rEvt
);
108 sal_Int8
ExecuteDrop(const ExecuteDropEvent
& rEvt
);
110 void SetSelChangeHdl( const Link
<LinkParamNone
*,void>& _rHdl
) { m_aSelChangeHdl
= _rHdl
; }
111 void setCopyHandler(const Link
<LinkParamNone
*,void>& _rHdl
) { m_aCopyHandler
= _rHdl
; }
112 void setPasteHandler(const Link
<LinkParamNone
*,void>& _rHdl
) { m_aPasteHandler
= _rHdl
; }
113 void setDeleteHandler(const Link
<LinkParamNone
*,void>& _rHdl
) { m_aDeleteHandler
= _rHdl
; }
116 class InterimDBTreeListBox
: public InterimItemWindow
120 std::unique_ptr
<weld::Label
> m_xStatusBar
;
122 InterimDBTreeListBox(vcl::Window
* pParent
);
123 virtual void dispose() override
;
124 weld::Label
& GetStatusBar() { return *m_xStatusBar
; }
125 virtual ~InterimDBTreeListBox() override
;
126 void show_container() { m_xContainer
->show(); }
128 virtual bool DoChildKeyInput(const KeyEvent
& rKEvt
) override
;
134 std::unique_ptr
<weld::Builder
> m_xBuilder
;
135 std::unique_ptr
<weld::Container
> m_xContainer
;
136 std::unique_ptr
<TreeListBox
> m_xTreeListBox
;
138 DBTreeViewBase(weld::Container
* pContainer
);
139 virtual ~DBTreeViewBase();
141 weld::TreeView
& GetWidget() { return m_xTreeListBox
->GetWidget(); }
142 const weld::TreeView
& GetWidget() const { return m_xTreeListBox
->GetWidget(); }
144 TreeListBox
& getListBox() const { return *m_xTreeListBox
; }
146 void hide() { m_xContainer
->hide(); }
147 void show() { m_xContainer
->show(); }
148 bool get_visible() const { return m_xContainer
->get_visible(); }
151 class DBTreeView final
: public DBTreeViewBase
154 DBTreeView(weld::Container
* pContainer
, bool bSQLType
);
157 class DBTableTreeView final
: public DBTreeViewBase
160 DBTableTreeView(weld::Container
* pContainer
);
164 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */