Bump version to 5.0-14
[LibreOffice.git] / dbaccess / source / ui / inc / indexdialog.hxx
blobc4cc5c620a90895c510d7c5aee2b556931be6686
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 .
20 #ifndef INCLUDED_DBACCESS_SOURCE_UI_INC_INDEXDIALOG_HXX
21 #define INCLUDED_DBACCESS_SOURCE_UI_INC_INDEXDIALOG_HXX
23 #include <vcl/dialog.hxx>
24 #include <vcl/fixed.hxx>
25 #include <vcl/lstbox.hxx>
26 #include <vcl/button.hxx>
27 #include <com/sun/star/container/XNameAccess.hpp>
28 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
29 #include <com/sun/star/sdbc/XConnection.hpp>
30 #include <com/sun/star/uno/Sequence.hxx>
31 #include <com/sun/star/uno/XComponentContext.hpp>
32 #include <vcl/toolbox.hxx>
33 #include <svtools/treelistbox.hxx>
34 #include <unotools/viewoptions.hxx>
35 #include "indexes.hxx"
36 #include <dbaccess/ToolBoxHelper.hxx>
38 namespace dbaui
41 // DbaIndexList
42 class DbaIndexList : public SvTreeListBox
44 protected:
45 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > m_xConnection;
46 Link<> m_aSelectHdl;
47 Link<> m_aEndEditHdl;
48 bool m_bSuspendSelectHdl;
50 public:
51 DbaIndexList(vcl::Window* _pParent, WinBits nWinBits);
53 void SetSelectHdl(const Link<>& _rHdl) { m_aSelectHdl = _rHdl; }
54 Link<> GetSelectHdl() const { return m_aSelectHdl; }
56 void SetEndEditHdl(const Link<>& _rHdl) { m_aEndEditHdl = _rHdl; }
57 Link<> GetEndEditHdl() const { return m_aEndEditHdl; }
59 virtual bool Select(SvTreeListEntry* pEntry, bool bSelect) SAL_OVERRIDE;
61 void enableSelectHandler();
62 void disableSelectHandler();
64 void SelectNoHandlerCall( SvTreeListEntry* pEntry );
66 inline void setConnection(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection)
68 m_xConnection = _rxConnection;
71 protected:
72 virtual bool EditedEntry( SvTreeListEntry* pEntry, const OUString& rNewText ) SAL_OVERRIDE;
74 private:
75 using SvTreeListBox::Select;
78 // DbaIndexDialog
79 class IndexFieldsControl;
80 class OIndexCollection;
81 class DbaIndexDialog : public ModalDialog,
82 public OToolBoxHelper
84 protected:
85 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > m_xConnection;
86 SvtViewOptions m_aGeometrySettings;
88 VclPtr<ToolBox> m_pActions;
89 VclPtr<DbaIndexList> m_pIndexList;
90 VclPtr<FixedText> m_pIndexDetails;
91 VclPtr<FixedText> m_pDescriptionLabel;
92 VclPtr<FixedText> m_pDescription;
93 VclPtr<CheckBox> m_pUnique;
94 VclPtr<FixedText> m_pFieldsLabel;
95 VclPtr<IndexFieldsControl> m_pFields;
96 VclPtr<PushButton> m_pClose;
98 OIndexCollection* m_pIndexes;
99 SvTreeListEntry* m_pPreviousSelection;
100 bool m_bEditAgain;
102 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >
103 m_xContext;
104 public:
105 DbaIndexDialog(
106 vcl::Window* _pParent,
107 const ::com::sun::star::uno::Sequence< OUString >& _rFieldNames,
108 const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxIndexes,
109 const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
110 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext,
111 sal_Int32 _nMaxColumnsInIndex
113 virtual ~DbaIndexDialog();
114 virtual void dispose() SAL_OVERRIDE;
116 virtual void StateChanged( StateChangedType nStateChange ) SAL_OVERRIDE;
117 virtual void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
119 //TO-DO, remove when all other OToolBoxHelper are converted to .ui
120 virtual void resizeControls(const Size&) SAL_OVERRIDE;
122 /** will be called when the id of the image list needs to change
123 @param _eBitmapSet
124 <svtools/imgdef.hxx>
126 virtual void setImageList(sal_Int16 _eBitmapSet) SAL_OVERRIDE;
127 protected:
128 void fillIndexList();
129 void updateToolbox();
130 void updateControls(const SvTreeListEntry* _pEntry);
132 protected:
133 DECL_LINK( OnIndexSelected, DbaIndexList* );
134 DECL_LINK_TYPED( OnIndexAction, ToolBox*, void );
135 DECL_LINK( OnEntryEdited, SvTreeListEntry* );
136 DECL_LINK( OnModified, void* );
137 DECL_LINK( OnCloseDialog, void* );
139 DECL_LINK( OnEditIndexAgain, SvTreeListEntry* );
141 private:
142 sal_uInt16 mnNewCmdId;
143 sal_uInt16 mnDropCmdId;
144 sal_uInt16 mnRenameCmdId;
145 sal_uInt16 mnSaveCmdId;
146 sal_uInt16 mnResetCmdId;
148 Image maScNewCmdImg;
149 Image maScDropCmdImg;
150 Image maScRenameCmdImg;
151 Image maScSaveCmdImg;
152 Image maScResetCmdImg;
153 Image maLcNewCmdImg;
154 Image maLcDropCmdImg;
155 Image maLcRenameCmdImg;
156 Image maLcSaveCmdImg;
157 Image maLcResetCmdImg;
159 void OnNewIndex();
160 void OnDropIndex(bool _bConfirm = true);
161 void OnRenameIndex();
162 void OnSaveIndex();
163 void OnResetIndex();
165 bool implCommit(SvTreeListEntry* _pEntry);
166 bool implSaveModified(bool _bPlausibility = true);
167 bool implCommitPreviouslySelected();
169 bool implDropIndex(SvTreeListEntry* _pEntry, bool _bRemoveFromCollection);
171 bool implCheckPlausibility(const Indexes::const_iterator& _rPos);
173 /** checks if the controls have to be replaced and moved.
175 void checkControls();
178 } // namespace dbaui
180 #endif // INCLUDED_DBACCESS_SOURCE_UI_INC_INDEXDIALOG_HXX
182 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */