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 .
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>
42 class DbaIndexList
: public SvTreeListBox
45 css::uno::Reference
< css::sdbc::XConnection
> m_xConnection
;
46 Link
<DbaIndexList
&,void> m_aSelectHdl
;
47 Link
<SvTreeListEntry
*,bool> m_aEndEditHdl
;
48 bool m_bSuspendSelectHdl
;
51 DbaIndexList(vcl::Window
* _pParent
, WinBits nWinBits
);
53 void SetSelectHdl(const Link
<DbaIndexList
&,void>& _rHdl
) { m_aSelectHdl
= _rHdl
; }
55 void SetEndEditHdl(const Link
<SvTreeListEntry
*,bool>& _rHdl
) { m_aEndEditHdl
= _rHdl
; }
57 virtual bool Select(SvTreeListEntry
* pEntry
, bool bSelect
) override
;
59 void enableSelectHandler();
60 void disableSelectHandler();
62 void SelectNoHandlerCall( SvTreeListEntry
* pEntry
);
64 inline void setConnection(const css::uno::Reference
< css::sdbc::XConnection
>& _rxConnection
)
66 m_xConnection
= _rxConnection
;
70 virtual bool EditedEntry( SvTreeListEntry
* pEntry
, const OUString
& rNewText
) override
;
73 using SvTreeListBox::Select
;
77 class IndexFieldsControl
;
78 class OIndexCollection
;
79 class DbaIndexDialog
: public ModalDialog
,
83 css::uno::Reference
< css::sdbc::XConnection
> m_xConnection
;
85 VclPtr
<ToolBox
> m_pActions
;
86 VclPtr
<DbaIndexList
> m_pIndexList
;
87 VclPtr
<FixedText
> m_pIndexDetails
;
88 VclPtr
<FixedText
> m_pDescriptionLabel
;
89 VclPtr
<FixedText
> m_pDescription
;
90 VclPtr
<CheckBox
> m_pUnique
;
91 VclPtr
<FixedText
> m_pFieldsLabel
;
92 VclPtr
<IndexFieldsControl
> m_pFields
;
93 VclPtr
<PushButton
> m_pClose
;
95 OIndexCollection
* m_pIndexes
;
96 SvTreeListEntry
* m_pPreviousSelection
;
99 css::uno::Reference
< css::uno::XComponentContext
>
103 vcl::Window
* _pParent
,
104 const css::uno::Sequence
< OUString
>& _rFieldNames
,
105 const css::uno::Reference
< css::container::XNameAccess
>& _rxIndexes
,
106 const css::uno::Reference
< css::sdbc::XConnection
>& _rxConnection
,
107 const css::uno::Reference
< css::uno::XComponentContext
>& _rxContext
,
108 sal_Int32 _nMaxColumnsInIndex
110 virtual ~DbaIndexDialog();
111 virtual void dispose() override
;
113 virtual void StateChanged( StateChangedType nStateChange
) override
;
114 virtual void DataChanged( const DataChangedEvent
& rDCEvt
) override
;
116 //TO-DO, remove when all other OToolBoxHelper are converted to .ui
117 virtual void resizeControls(const Size
&) override
;
119 /** will be called when the id of the image list needs to change
123 virtual void setImageList(sal_Int16 _eBitmapSet
) override
;
125 void fillIndexList();
126 void updateToolbox();
127 void updateControls(const SvTreeListEntry
* _pEntry
);
130 DECL_LINK_TYPED( OnIndexSelected
, DbaIndexList
&, void );
131 DECL_LINK_TYPED( OnIndexAction
, ToolBox
*, void );
132 DECL_LINK_TYPED( OnEntryEdited
, SvTreeListEntry
*, bool );
133 DECL_LINK_TYPED( OnModifiedClick
, Button
*, void );
134 DECL_LINK_TYPED( OnModified
, IndexFieldsControl
&, void );
135 DECL_LINK_TYPED( OnCloseDialog
, Button
*, void );
137 DECL_LINK_TYPED( OnEditIndexAgain
, void*, void );
140 sal_uInt16 mnNewCmdId
;
141 sal_uInt16 mnDropCmdId
;
142 sal_uInt16 mnRenameCmdId
;
143 sal_uInt16 mnSaveCmdId
;
144 sal_uInt16 mnResetCmdId
;
147 Image maScDropCmdImg
;
148 Image maScRenameCmdImg
;
149 Image maScSaveCmdImg
;
150 Image maScResetCmdImg
;
152 Image maLcDropCmdImg
;
153 Image maLcRenameCmdImg
;
154 Image maLcSaveCmdImg
;
155 Image maLcResetCmdImg
;
158 void OnDropIndex(bool _bConfirm
= true);
159 void OnRenameIndex();
163 bool implCommit(SvTreeListEntry
* _pEntry
);
164 bool implSaveModified(bool _bPlausibility
= true);
165 bool implCommitPreviouslySelected();
167 bool implDropIndex(SvTreeListEntry
* _pEntry
, bool _bRemoveFromCollection
);
169 bool implCheckPlausibility(const Indexes::const_iterator
& _rPos
);
174 #endif // INCLUDED_DBACCESS_SOURCE_UI_INC_INDEXDIALOG_HXX
176 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */