diff options
author | Caolán McNamara <caolanm@redhat.com> | 2020-08-07 14:33:07 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2020-08-12 20:21:10 +0200 |
commit | 46c34d5abcc3fb709de4c3a6a62649f1fe41ec9c (patch) | |
tree | cb2033f6b83d3109e9144dddade1a92dc3d1e54c /dbaccess/source/ui/inc | |
parent | c299e1255974c5564333480a5f8f0877c1011bc4 (diff) |
weld DBTreeListBox
Change-Id: I4b7369a496339b9bbab0c885c7360a5d7818a62e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100329
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'dbaccess/source/ui/inc')
-rw-r--r-- | dbaccess/source/ui/inc/callbacks.hxx | 11 | ||||
-rw-r--r-- | dbaccess/source/ui/inc/dbtreelistbox.hxx | 84 | ||||
-rw-r--r-- | dbaccess/source/ui/inc/tabletree.hxx | 110 | ||||
-rw-r--r-- | dbaccess/source/ui/inc/unodatbr.hxx | 4 |
4 files changed, 151 insertions, 58 deletions
diff --git a/dbaccess/source/ui/inc/callbacks.hxx b/dbaccess/source/ui/inc/callbacks.hxx index 8a607db34eff..e18a6556036f 100644 --- a/dbaccess/source/ui/inc/callbacks.hxx +++ b/dbaccess/source/ui/inc/callbacks.hxx @@ -31,6 +31,11 @@ struct ExecuteDropEvent; namespace comphelper { class OInterfaceContainerHelper2; } +namespace weld +{ + class TreeIter; +} + namespace dbaui { @@ -43,11 +48,13 @@ namespace dbaui @return <FALSE/> if the default quick help text should be used */ virtual bool requestQuickHelp( const SvTreeListEntry* _pEntry, OUString& _rText ) const = 0; + virtual bool requestQuickHelp(const void* pUserData, OUString& rText) const = 0; /** handler for StartDrag requests @return <TRUE/> if a drag operation was started */ - virtual bool requestDrag( const Point& _rPosPixel ) = 0; + virtual bool requestDrag(const Point& _rPosPixel) = 0; + virtual bool requestDrag(const weld::TreeIter& rEntry) = 0; /** check whether or not a drop request should be accepted */ @@ -69,7 +76,7 @@ namespace dbaui Supposed to be a valid name from uiconfig/<module>/popupmenu folder. */ - virtual OUString getContextMenuResourceName( Control& _rControl ) const = 0; + virtual OUString getContextMenuResourceName() const = 0; /** returns the controller which is responsible for providing states of certain features, and executing them. diff --git a/dbaccess/source/ui/inc/dbtreelistbox.hxx b/dbaccess/source/ui/inc/dbtreelistbox.hxx index f79abe8f5df7..70b891f0ef56 100644 --- a/dbaccess/source/ui/inc/dbtreelistbox.hxx +++ b/dbaccess/source/ui/inc/dbtreelistbox.hxx @@ -23,8 +23,10 @@ #include <com/sun/star/frame/XPopupMenuController.hpp> +#include <vcl/InterimItemWindow.hxx> #include <vcl/treelistbox.hxx> #include <vcl/timer.hxx> +#include <vcl/weld.hxx> #include <memory> #include <set> @@ -133,6 +135,88 @@ namespace dbaui protected: using SvTreeListBox::ExecuteDrop; }; + + class TreeListBox; + + class TreeListBoxDropTarget : public DropTargetHelper + { + private: + TreeListBox& m_rTreeView; + + virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ) override; + virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt ) override; + + public: + TreeListBoxDropTarget(TreeListBox& rTreeView); + }; + + class TreeListBox + { + protected: + std::unique_ptr<weld::TreeView> m_xTreeView; + TreeListBoxDropTarget m_aDropTargetHelper; + + std::unique_ptr<weld::TreeIter> m_xDragedEntry; + IControlActionListener* m_pActionListener; + IContextMenuProvider* m_pContextMenuProvider; + + DECL_LINK(KeyInputHdl, const KeyEvent&, bool); + DECL_LINK(SelectHdl, weld::TreeView&, void); + DECL_LINK(QueryTooltipHdl, const weld::TreeIter&, OUString); + DECL_LINK(CommandHdl, const CommandEvent&, bool); + DECL_LINK(DragBeginHdl, bool&, bool); + + private: + Timer m_aTimer; // is needed for table updates + + Link<LinkParamNone*,void> m_aSelChangeHdl; // handler to be called (asynchronously) when the selection changes in any way + Link<LinkParamNone*,void> m_aCopyHandler; // called when someone press CTRL+C + Link<LinkParamNone*,void> m_aPasteHandler; // called when someone press CTRL+V + Link<LinkParamNone*,void> m_aDeleteHandler; // called when someone press DELETE Key + + DECL_LINK(OnTimeOut, Timer*, void); + + protected: + void implStopSelectionTimer(); + void implStartSelectionTimer(); + + virtual bool DoChildKeyInput(const KeyEvent& rKEvt); + virtual bool DoContextMenu(const CommandEvent& rCEvt); + + public: + TreeListBox(std::unique_ptr<weld::TreeView> xTreeView); + virtual ~TreeListBox(); + + std::unique_ptr<weld::TreeIter> GetEntryPosByName(const OUString& rName, + const weld::TreeIter* pStart = nullptr, + const IEntryFilter* pFilter = nullptr) const; + + void setControlActionListener(IControlActionListener* pListener) { m_pActionListener = pListener; } + void setContextMenuProvider(IContextMenuProvider* pContextMenuProvider) { m_pContextMenuProvider = pContextMenuProvider; } + + weld::TreeView& GetWidget() { return *m_xTreeView; } + const weld::TreeView& GetWidget() const { return *m_xTreeView; } + + sal_Int8 AcceptDrop(const AcceptDropEvent& rEvt); + sal_Int8 ExecuteDrop(const ExecuteDropEvent& rEvt); + + void SetSelChangeHdl( const Link<LinkParamNone*,void>& _rHdl ) { m_aSelChangeHdl = _rHdl; } + void setCopyHandler(const Link<LinkParamNone*,void>& _rHdl) { m_aCopyHandler = _rHdl; } + void setPasteHandler(const Link<LinkParamNone*,void>& _rHdl) { m_aPasteHandler = _rHdl; } + void setDeleteHandler(const Link<LinkParamNone*,void>& _rHdl) { m_aDeleteHandler = _rHdl; } + }; + + class InterimDBTreeListBox : public InterimItemWindow + , public TreeListBox + { + public: + InterimDBTreeListBox(vcl::Window* pParent); + virtual void dispose() override; + virtual ~InterimDBTreeListBox() override; + protected: + virtual bool DoChildKeyInput(const KeyEvent& rKEvt) override; + virtual bool DoContextMenu(const CommandEvent& rCEvt) override; + }; } #endif // INCLUDED_DBACCESS_SOURCE_UI_INC_DBTREELISTBOX_HXX diff --git a/dbaccess/source/ui/inc/tabletree.hxx b/dbaccess/source/ui/inc/tabletree.hxx index 97b1ba7cc666..53e425980b13 100644 --- a/dbaccess/source/ui/inc/tabletree.hxx +++ b/dbaccess/source/ui/inc/tabletree.hxx @@ -26,43 +26,36 @@ #include <com/sun/star/sdbc/XDatabaseMetaData.hpp> #include <com/sun/star/sdbc/XConnection.hpp> #include <com/sun/star/sdb/application/NamedDatabaseObject.hpp> -#include <vcl/weld.hxx> #include <memory> namespace dbaui { // OTableTreeListBox -class OTableTreeListBox final : public DBTreeListBox +class OTableTreeListBox final : public InterimDBTreeListBox { - std::unique_ptr<SvLBoxButtonData> m_pCheckButton; - Link<void*,void> m_aCheckButtonHandler; - css::uno::Reference< css::sdbc::XConnection > m_xConnection; // the connection we're working for, set in implOnNewConnection, called by UpdateTableList std::unique_ptr< ImageProvider > m_xImageProvider; // provider for our images bool m_bVirtualRoot; // should the first entry be visible bool m_bNoEmptyFolders; // should empty catalogs/schematas be prevented from being displayed? + bool m_bShowToggles; // show toggle buttons public: - OTableTreeListBox(vcl::Window* pParent, WinBits nWinStyle); - virtual void dispose() override; + OTableTreeListBox(vcl::Window* pParent, bool bShowToggles); + virtual ~OTableTreeListBox(); void init() { m_bVirtualRoot = true; } typedef std::pair< OUString, bool > TTableViewName; typedef std::vector< TTableViewName > TNames; - void suppressEmptyFolders() { m_bNoEmptyFolders = true; } - - /** call when HiContrast change. - */ - void notifyHiContrastChanged(); + void SuppressEmptyFolders() { m_bNoEmptyFolders = true; } /** determines whether the given entry denotes a tables folder */ - static bool isFolderEntry( const SvTreeListEntry* _pEntry ); + bool isFolderEntry(const weld::TreeIter& rEntry) const; /** fill the table list with the tables belonging to the connection described by the parameters @param _rxConnection @@ -87,28 +80,21 @@ public: const css::uno::Sequence< OUString>& _rViews ); - /** returns a NamedDatabaseObject record which describes the given entry - */ - css::sdb::application::NamedDatabaseObject - describeObject( SvTreeListEntry* _pEntry ); - - /** to be used if a foreign instance added a table - */ - SvTreeListEntry* addedTable( const OUString& _rName ); + std::unique_ptr<weld::TreeIter> getAllObjectsEntry() const; - /** to be used if a foreign instance removed a table + /** does a wildcard check of the given entry + <p>There are two different 'checked' states: If the user checks all children of an entry, this is different + from checking the entry itself. The second is called 'wildcard' checking, 'cause in the resulting + table filter it's represented by a wildcard.</p> */ - void removedTable( const OUString& _rName ); + void checkWildcard(weld::TreeIter& rEntry); - /** returns the fully qualified name of a table entry - @param _pEntry - the entry whose name is to be obtained. Must not denote a folder entry. + /** determine if the given entry is 'wildcard checked' + @see checkWildcard */ - OUString getQualifiedTableName( SvTreeListEntry* _pEntry ) const; - - SvTreeListEntry* getEntryByQualifiedName( const OUString& _rName ); + bool isWildcardChecked(const weld::TreeIter& rEntry); - SvTreeListEntry* getAllObjectsEntry() const; + void CheckButtons(); // make the button states consistent (bottom-up) /** does a wildcard check of the given entry <p>There are two different 'checked' states: If the user checks all children of an entry, this is different @@ -123,32 +109,29 @@ public: static bool isWildcardChecked(SvTreeListEntry* pEntry); private: - virtual void InitEntry(SvTreeListEntry* _pEntry, const OUString& _rString, const Image& _rCollapsedBitmap, const Image& _rExpandedBitmap) override; + void CheckButtonHdl(); - virtual void CheckButtonHdl() override; - void checkedButton_noBroadcast(SvTreeListEntry* _pEntry); + void checkedButton_noBroadcast(const weld::TreeIter& rEntry); - void implEmphasize(SvTreeListEntry* _pEntry, bool _bChecked, bool _bUpdateDescendants = true, bool _bUpdateAncestors = true); + void implEmphasize(const weld::TreeIter& rEntry, bool _bChecked, bool _bUpdateDescendants = true, bool _bUpdateAncestors = true); /** adds the given entry to our list @precond our image provider must already have been reset to the connection to which the meta data belong. */ - SvTreeListEntry* implAddEntry( + std::unique_ptr<weld::TreeIter> implAddEntry( const css::uno::Reference< css::sdbc::XDatabaseMetaData >& _rxMeta, - const OUString& _rTableName, - bool _bCheckName = true + const OUString& _rTableName, bool _bCheckName = true ); - void implSetDefaultImages(); - void implOnNewConnection( const css::uno::Reference< css::sdbc::XConnection >& _rxConnection ); bool impl_getAndAssertMetaData( css::uno::Reference< css::sdbc::XDatabaseMetaData >& _out_rMetaData ) const; bool haveVirtualRoot() const { return m_bVirtualRoot; } +public: /** fill the table list with the tables and views determined by the two given containers @param _rxConnection the connection where you got the object names from. Must not be NULL. Used to split the full qualified names into its parts. @@ -159,21 +142,32 @@ private: const TNames& _rTables ); - void InitButtonData(); + /** returns a NamedDatabaseObject record which describes the given entry + */ + css::sdb::application::NamedDatabaseObject + describeObject(weld::TreeIter& rEntry); + + /** to be used if a foreign instance added a table + */ + std::unique_ptr<weld::TreeIter> addedTable(const OUString& rName); - /// the handler given is called whenever the check state of one or more items changed - void SetCheckHandler(const Link<void*,void>& _rHdl) { m_aCheckButtonHandler = _rHdl; } + /** to be used if a foreign instance removed a table + */ + void removedTable( const OUString& _rName ); - SvButtonState implDetermineState(SvTreeListEntry* _pEntry); + TriState implDetermineState(weld::TreeIter& rEntry); // determines the check state of the given entry, by analyzing the states of all descendants - void CheckButtons(); // make the button states consistent (bottom-up) + /** returns the fully qualified name of a table entry + @param _pEntry + the entry whose name is to be obtained. Must not denote a folder entry. + */ + OUString getQualifiedTableName(weld::TreeIter& rEntry) const; - virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& _rRect) override; - virtual void KeyInput( const KeyEvent& rKEvt ) override; + std::unique_ptr<weld::TreeIter> getEntryByQualifiedName(const OUString& rName); }; -class TableTreeListBox +class TableTreeListBox : public TreeListBox { css::uno::Reference< css::sdbc::XConnection > m_xConnection; // the connection we're working for, set in implOnNewConnection, called by UpdateTableList @@ -182,12 +176,9 @@ class TableTreeListBox bool m_bVirtualRoot; // should the first entry be visible bool m_bNoEmptyFolders; // should empty catalogs/schematas be prevented from being displayed? bool m_bShowToggles; // show toggle buttons - std::unique_ptr<weld::TreeView> m_xTreeView; public: - TableTreeListBox(std::unique_ptr<weld::TreeView> xTreeView); - - weld::TreeView& GetWidget() { return *m_xTreeView; } + TableTreeListBox(std::unique_ptr<weld::TreeView> xTreeView, bool bShowToggles); void init() { m_bVirtualRoot = true; } @@ -195,7 +186,6 @@ public: typedef std::vector< TTableViewName > TNames; void SuppressEmptyFolders() { m_bNoEmptyFolders = true; } - void DisableCheckButtons(); /** determines whether the given entry denotes a tables folder */ @@ -231,7 +221,7 @@ public: /** to be used if a foreign instance added a table */ - SvTreeListEntry* addedTable( const OUString& _rName ); + std::unique_ptr<weld::TreeIter> addedTable( const OUString& _rName ); /** to be used if a foreign instance removed a table */ @@ -259,8 +249,6 @@ public: */ bool isWildcardChecked(const weld::TreeIter& rEntry); - std::unique_ptr<weld::TreeIter> GetEntryPosByName(const OUString& aName, const weld::TreeIter* pStart = nullptr, const IEntryFilter* _pFilter = nullptr) const; - void CheckButtons(); // make the button states consistent (bottom-up) void checkedButton_noBroadcast(const weld::TreeIter& rEntry); @@ -284,6 +272,7 @@ private: bool haveVirtualRoot() const { return m_bVirtualRoot; } +public: /** fill the table list with the tables and views determined by the two given containers @param _rxConnection the connection where you got the object names from. Must not be NULL. Used to split the full qualified names into its parts. @@ -293,6 +282,17 @@ private: const css::uno::Reference< css::sdbc::XConnection >& _rxConnection, const TNames& _rTables ); + + /** returns a NamedDatabaseObject record which describes the given entry + */ + css::sdb::application::NamedDatabaseObject + describeObject(weld::TreeIter& rEntry); + + /** returns the fully qualified name of a table entry + @param _pEntry + the entry whose name is to be obtained. Must not denote a folder entry. + */ + OUString getQualifiedTableName(weld::TreeIter& rEntry) const; }; } // namespace dbaui diff --git a/dbaccess/source/ui/inc/unodatbr.hxx b/dbaccess/source/ui/inc/unodatbr.hxx index 498b634f2575..810586a2d70c 100644 --- a/dbaccess/source/ui/inc/unodatbr.hxx +++ b/dbaccess/source/ui/inc/unodatbr.hxx @@ -214,12 +214,14 @@ namespace dbaui // IControlActionListener overridables virtual bool requestQuickHelp( const SvTreeListEntry* _pEntry, OUString& _rText ) const override; + virtual bool requestQuickHelp(const void* pUserData, OUString& rText) const override; virtual bool requestDrag( const Point& _rPosPixel ) override; + virtual bool requestDrag(const weld::TreeIter& rEntry) override; virtual sal_Int8 queryDrop( const AcceptDropEvent& _rEvt, const DataFlavorExVector& _rFlavors ) override; virtual sal_Int8 executeDrop( const ExecuteDropEvent& _rEvt ) override; // IContextMenuProvider - virtual OUString getContextMenuResourceName( Control& _rControl ) const override; + virtual OUString getContextMenuResourceName() const override; virtual IController& getCommandController() override; virtual ::comphelper::OInterfaceContainerHelper2* getContextMenuInterceptors() override; |