tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / dbaccess / source / ui / app / AppDetailView.hxx
blob18c572b1a9570d32be8f3038fcee22f8f12849b0
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
19 #pragma once
21 #include <com/sun/star/container/XNameAccess.hpp>
22 #include <com/sun/star/sdbc/XConnection.hpp>
23 #include <com/sun/star/ucb/XContent.hpp>
24 #include <com/sun/star/sdb/application/NamedDatabaseObject.hpp>
25 #include <vcl/mnemonic.hxx>
26 #include <IClipBoardTest.hxx>
27 #include "AppTitleWindow.hxx"
28 #include <AppElementType.hxx>
30 #include <vector>
32 namespace dbaui
34 class OAppBorderWindow;
35 class OApplicationDetailView;
36 class OAppDetailPageHelper;
37 class OTasksWindow;
38 class TreeListBox;
40 struct TaskEntry
42 OUString sUNOCommand;
43 TranslateId pHelpID;
44 OUString sTitle;
45 bool bHideWhenDisabled;
46 // TODO: we should be consistent in the task pane and the menus/toolbars:
47 // If an entry is disabled in the latter, it should also be disabled in the former.
48 // If an entry is *hidden* in the former, it should also be hidden in the latter.
50 TaskEntry( const OUString& _rAsciiUNOCommand, TranslateId pHelpID, TranslateId pTitleResourceID, bool _bHideWhenDisabled = false );
52 typedef std::vector< TaskEntry > TaskEntryList;
54 struct TaskPaneData
56 /// the tasks available in the pane
57 TaskEntryList aTasks;
58 /// the resource ID for the title of the pane
59 TranslateId pTitleId;
62 class OTasksWindow final : public OChildWindow
64 std::unique_ptr<weld::TreeView> m_xTreeView;
65 std::unique_ptr<weld::Label> m_xDescription;
66 std::unique_ptr<weld::TextView> m_xHelpText;
67 OApplicationDetailView* m_pDetailView;
69 int m_nCursorIndex;
71 DECL_LINK(onSelected, weld::TreeView&, bool);
72 DECL_LINK(OnEntrySelectHdl, weld::TreeView&, void);
73 DECL_LINK(FocusInHdl, weld::Widget&, void);
74 DECL_LINK(FocusOutHdl, weld::Widget&, void);
76 void updateHelpText();
78 public:
79 OTasksWindow(weld::Container* pParent, OApplicationDetailView* pDetailView);
80 ~OTasksWindow();
82 virtual void GrabFocus() override;
84 virtual bool HasChildPathFocus() const override;
86 OApplicationDetailView* getDetailView() const { return m_pDetailView; }
88 /// fills the Creation listbox with the necessary strings and images
89 void fillTaskEntryList( const TaskEntryList& _rList );
91 void Clear();
92 void setHelpText(TranslateId pId);
95 class OApplicationDetailView final : public IClipboardTest
97 std::unique_ptr<weld::Builder> m_xBuilder;
98 std::unique_ptr<weld::Container> m_xContainer;
99 std::unique_ptr<weld::Paned> m_xHorzSplitter;
100 std::unique_ptr<weld::Container> m_xTasksParent;
101 std::unique_ptr<weld::Container> m_xContainerParent;
102 std::unique_ptr<OTitleWindow> m_xTasks;
103 std::unique_ptr<OTitleWindow> m_xTitleContainer;
104 OAppBorderWindow& m_rBorderWin; // my parent
105 std::shared_ptr<OChildWindow> m_xControlHelper;
106 std::vector< TaskPaneData > m_aTaskPaneData;
107 MnemonicGenerator m_aExternalMnemonics;
109 const OAppDetailPageHelper* GetControlHelper() const;
110 OAppDetailPageHelper* GetControlHelper();
112 public:
113 OApplicationDetailView(weld::Container* pParent, OAppBorderWindow& rBorder, PreviewMode ePreviewMode);
114 ~OApplicationDetailView();
116 /** creates the tables page
117 @param _xConnection
118 The connection to get the table names
120 void createTablesPage(const css::uno::Reference< css::sdbc::XConnection>& _xConnection);
122 /** creates the page for the specific type.
123 @param _eType
124 The type which should be created. E_TABLE isn't allowed.
125 @param _xContainer
126 The container of the elements to be inserted.
128 void createPage(ElementType _eType,const css::uno::Reference< css::container::XNameAccess >& _xContainer);
130 void setTaskExternalMnemonics( MnemonicGenerator const & _rMnemonics );
132 OAppBorderWindow& getBorderWin() const { return m_rBorderWin; }
133 OTasksWindow& getTasksWindow() const { return *static_cast< OTasksWindow* >( m_xTasks->getChildWindow() ); }
135 bool isCutAllowed() override ;
136 bool isCopyAllowed() override ;
137 bool isPasteAllowed() override;
138 void copy() override;
139 void cut() override;
140 void paste() override;
142 /** return the qualified name.
143 @param _pEntry
144 The entry of a table, or query, form, report to get the qualified name.
145 If the entry is <NULL/>, the first selected is chosen.
146 @return
147 the qualified name
149 OUString getQualifiedName(const weld::TreeIter* _pEntry) const;
151 /** returns if an entry is a leaf
152 @param rTreeView
153 The TreeView pEntry belongs to
154 @param rEntry
155 The entry to check
156 @return
157 <TRUE/> if the entry is a leaf, otherwise <FALSE/>
159 static bool isLeaf(const weld::TreeView& rTreeView, const weld::TreeIter& rEntry);
161 /** returns if one of the selected entries is a leaf
162 @return
163 <TRUE/> if the entry is a leaf, otherwise <FALSE/>
165 bool isALeafSelected() const;
167 /** select all entries in the detail page
169 void selectAll();
171 /// returns <TRUE/> if it sorts ascending
172 bool isSortUp() const;
174 /// sort the entries in the detail page down
175 void sortDown();
177 /// sort the entries in the detail page up
178 void sortUp();
180 /// returns <TRUE/> when a detail page was filled
181 bool isFilled() const;
183 /// return the element of currently select entry
184 ElementType getElementType() const;
186 /** clears the detail pages.
187 @param _bTaskAlso
188 If <TRUE/> the task window will also be cleared.
190 void clearPages(bool _bTaskAlso = true);
192 /// returns the count of entries
193 sal_Int32 getElementCount() const;
195 /// returns the count of selected entries
196 sal_Int32 getSelectionCount();
198 /** returns the element names which are selected
199 @param _rNames
200 The list will be filled.
202 void getSelectionElementNames(std::vector< OUString>& _rNames ) const;
204 /** describes the current selection for the given control
206 void describeCurrentSelectionForControl(
207 const weld::TreeView& rControl,
208 css::uno::Sequence< css::sdb::application::NamedDatabaseObject >& _out_rSelectedObjects
211 /** describes the current selection for the given ElementType
213 void describeCurrentSelectionForType(
214 const ElementType _eType,
215 css::uno::Sequence< css::sdb::application::NamedDatabaseObject >& _out_rSelectedObjects
218 /** get the menu parent window for the given control
220 vcl::Window* getMenuParent() const;
221 void adjustMenuPosition(const weld::TreeView& rControl, ::Point& rPos) const;
223 /** select all names on the currently selected container. Non existence names where ignored.
225 * \param _aNames the element names
227 void selectElements(const css::uno::Sequence< OUString>& _aNames);
229 /** adds a new object to the detail page.
230 @param _eType
231 The type where the entry should be appended.
232 @param _rName
233 The name of the object to be inserted
234 @param _rObject
235 The object to add.
236 @param _rxConn
237 If we insert a table, the connection must be set.
239 std::unique_ptr<weld::TreeIter> elementAdded(ElementType eType,
240 const OUString& rName,
241 const css::uno::Any& rObject);
243 /** replaces an objects name with a new one
244 @param _eType
245 The type where the entry should be appended.
246 @param _rOldName
247 The old name of the object to be replaced
248 @param _rNewName
249 The new name of the object to be replaced
250 @param _rxConn
251 If we insert a table, the connection must be set.
252 @param _xObject
253 The object which was replaced
255 void elementReplaced(ElementType eType
256 ,const OUString& _rOldName
257 ,const OUString& _rNewName );
259 /** removes an element from the detail page.
260 @param _eType
261 The type where the entry should be appended.
262 @param _rName
263 The name of the element to be removed.
264 @param _rxConn
265 If we remove a table, the connection must be set.
267 void elementRemoved(ElementType _eType
268 ,const OUString& _rName );
270 /// returns the preview mode
271 PreviewMode getPreviewMode() const;
273 /// <TRUE/> if the preview is enabled
274 bool isPreviewEnabled() const;
276 /** switches to the given preview mode
277 @param _eMode
278 the mode to set for the preview
280 void switchPreview(PreviewMode _eMode);
282 /** shows the Preview of the content when it is enabled.
283 @param _xContent
284 The content which must support the "preview" command.
286 void showPreview(const css::uno::Reference< css::ucb::XContent >& _xContent);
288 /** shows the Preview of a table or query
289 @param _sDataSourceName
290 the name of the data source
291 @param _sName
292 the name of table or query
293 @param _bTable
294 <TRUE/> if it is a table, otherwise <FALSE/>
295 @return void
297 void showPreview( const OUString& _sDataSourceName,
298 const OUString& _sName,
299 bool _bTable);
301 std::unique_ptr<weld::TreeIter> getEntry(const Point& rPosPixel) const;
303 TreeListBox* getTreeWindow() const;
305 bool HasChildPathFocus() const;
306 private:
307 void impl_createPage(
308 ElementType _eType,
309 const css::uno::Reference< css::sdbc::XConnection >& _rxConnection,
310 const css::uno::Reference< css::container::XNameAccess >& _rxNonTableElements
313 const TaskPaneData& impl_getTaskPaneData( ElementType _eType );
314 void impl_fillTaskPaneData( ElementType _eType, TaskPaneData& _rData ) const;
318 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */