Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 : #ifndef INCLUDED_SVTOOLS_FILEVIEW_HXX
20 : #define INCLUDED_SVTOOLS_FILEVIEW_HXX
21 :
22 : #include <svtools/svtdllapi.h>
23 : #include <com/sun/star/uno/Sequence.h>
24 : #include <com/sun/star/ucb/XContent.hpp>
25 : #include <vcl/ctrl.hxx>
26 : #include <vcl/image.hxx>
27 : #include <vcl/fixed.hxx>
28 : #include <vcl/dialog.hxx>
29 : #include <vcl/button.hxx>
30 : #include <vcl/layout.hxx>
31 : #include <rtl/ustring.hxx>
32 :
33 : // class SvtFileView -----------------------------------------------------
34 :
35 : #define FILEVIEW_ONLYFOLDER 0x0001
36 : #define FILEVIEW_MULTISELECTION 0x0002
37 :
38 : #define FILEVIEW_SHOW_ONLYTITLE 0x0010
39 : #define FILEVIEW_SHOW_NONE 0x0020
40 :
41 : class ViewTabListBox_Impl;
42 : class SvtFileView_Impl;
43 : class SvTreeListEntry;
44 : class HeaderBar;
45 :
46 : /// the result of an action in the FileView
47 : enum FileViewResult
48 : {
49 : eSuccess,
50 : eFailure,
51 : eTimeout,
52 : eStillRunning
53 : };
54 :
55 : /// describes parameters for doing an action on the FileView asynchronously
56 : struct FileViewAsyncAction
57 : {
58 : sal_uInt32 nMinTimeout; /// minimum time to wait for a result, in milliseconds
59 : sal_uInt32 nMaxTimeout; /// maximum time to wait for a result, in milliseconds, until eTimeout is returned
60 : Link aFinishHandler; /// the handler to be called when the action is finished. Called in every case, no matter of the result
61 :
62 0 : FileViewAsyncAction()
63 0 : {
64 0 : nMinTimeout = nMaxTimeout = 0;
65 0 : }
66 : };
67 :
68 : class SVT_DLLPUBLIC SvtFileView : public Control
69 : {
70 : private:
71 : SvtFileView_Impl* mpImp;
72 : bool bSortColumn;
73 :
74 : ::com::sun::star::uno::Sequence< OUString > mpBlackList;
75 :
76 : DECL_DLLPRIVATE_LINK( HeaderSelect_Impl, HeaderBar * );
77 : DECL_DLLPRIVATE_LINK( HeaderEndDrag_Impl, HeaderBar * );
78 :
79 : protected:
80 : virtual void GetFocus() SAL_OVERRIDE;
81 :
82 : public:
83 : SvtFileView( vcl::Window* pParent, WinBits nBits, bool bOnlyFolder, bool bMultiSelection );
84 : virtual ~SvtFileView();
85 :
86 : virtual Size GetOptimalSize() const SAL_OVERRIDE;
87 :
88 : const OUString& GetViewURL() const;
89 : OUString GetURL( SvTreeListEntry* pEntry ) const;
90 : OUString GetCurrentURL() const;
91 :
92 : bool GetParentURL( OUString& _rParentURL ) const;
93 : void CreatedFolder( const OUString& rUrl, const OUString& rNewFolder );
94 :
95 : void SetHelpId( const OString& rHelpId );
96 : const OString& GetHelpId( ) const;
97 : void SetSizePixel( const Size& rNewSize ) SAL_OVERRIDE;
98 : virtual void SetPosSizePixel( const Point& rNewPos, const Size& rNewSize ) SAL_OVERRIDE;
99 0 : void SetSortColumn( bool bValue ) { bSortColumn = bValue; }
100 : bool GetSortColumn() { return bSortColumn; }
101 :
102 : /** initialize the view with the content of a folder given by URL, and aply an immediate filter
103 :
104 : @param rFolderURL
105 : the URL of the folder whose content is to be read
106 : @param rFilter
107 : the initial filter to be applied
108 : @param pAsyncDescriptor
109 : If not <NULL/>, this struct describes the parameters for doing the
110 : action asynchronously.
111 : */
112 : FileViewResult Initialize(
113 : const OUString& rFolderURL,
114 : const OUString& rFilter,
115 : const FileViewAsyncAction* pAsyncDescriptor,
116 : const ::com::sun::star::uno::Sequence< OUString >& rBlackList
117 : );
118 :
119 : /** initializes the view with the content of a folder given by an UCB content
120 : */
121 : bool Initialize( const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContent>& _xContent,
122 : const OUString& rFilter );
123 :
124 : /** reads the current content of the current folder again, and applies the given filter to it
125 :
126 : Note 1: The folder is really read a second time. This implies that any new elements (which were
127 : not present when you called Initialize the last time) are now displayed.
128 :
129 : Note 2: This method must not be called when you previously initialized the view from a sequence
130 : of strings, or a UNO content object.
131 :
132 : @param rFilter
133 : the filter to be applied
134 : @param pAsyncDescriptor
135 : If not <NULL/>, this struct describes the parameters for doing the
136 : action asynchronously.
137 : */
138 : FileViewResult ExecuteFilter(
139 : const OUString& rFilter,
140 : const FileViewAsyncAction* pAsyncDescriptor
141 : );
142 :
143 : /** cancels a running async action (if any)
144 :
145 : @seealso Initialize
146 : @seealso ExecuteFilter
147 : @seealso FileViewAsyncAction
148 : */
149 : void CancelRunningAsyncAction();
150 :
151 : /** initializes the view with the parent folder of the current folder
152 :
153 : @param rNewURL
154 : the URL of the folder which we just navigated to
155 : @param pAsyncDescriptor
156 : If not <NULL/>, this struct describes the parameters for doing the
157 : action asynchronously.
158 : */
159 : FileViewResult PreviousLevel(
160 : const FileViewAsyncAction* pAsyncDescriptor
161 : );
162 :
163 : void SetNoSelection();
164 :
165 : void SetSelectHdl( const Link& rHdl );
166 : void SetDoubleClickHdl( const Link& rHdl );
167 : void SetOpenDoneHdl( const Link& rHdl );
168 :
169 : sal_uLong GetSelectionCount() const;
170 : SvTreeListEntry* FirstSelected() const;
171 : SvTreeListEntry* NextSelected( SvTreeListEntry* pEntry ) const;
172 : void EnableAutoResize();
173 :
174 : void EnableDelete( bool bEnable );
175 :
176 : // save and load column size and sort order
177 : OUString GetConfigString() const;
178 : void SetConfigString( const OUString& rCfgStr );
179 :
180 : void EndInplaceEditing( bool _bCancel );
181 :
182 : protected:
183 : virtual void StateChanged( StateChangedType nStateChange ) SAL_OVERRIDE;
184 : };
185 :
186 : // struct SvtContentEntry ------------------------------------------------
187 :
188 0 : struct SvtContentEntry
189 : {
190 : bool mbIsFolder;
191 : OUString maURL;
192 :
193 0 : SvtContentEntry( const OUString& rURL, bool bIsFolder ) :
194 0 : mbIsFolder( bIsFolder ), maURL( rURL ) {}
195 : };
196 :
197 : namespace svtools {
198 :
199 :
200 : // QueryDeleteDlg_Impl
201 :
202 :
203 : enum QueryDeleteResult_Impl
204 : {
205 : QUERYDELETE_CANCEL = RET_CANCEL,
206 : QUERYDELETE_YES = RET_YES,
207 : QUERYDELETE_NO = RET_NO,
208 : QUERYDELETE_ALL = -1
209 : };
210 :
211 0 : class SVT_DLLPUBLIC QueryDeleteDlg_Impl : public MessageDialog
212 : {
213 : private:
214 : PushButton* m_pAllButton;
215 : public:
216 :
217 : QueryDeleteDlg_Impl(vcl::Window* pParent, const OUString& rName);
218 :
219 0 : void EnableAllButton() { m_pAllButton->Enable(true); }
220 : };
221 :
222 : }
223 :
224 : #endif // INCLUDED_SVTOOLS_FILEVIEW_HXX
225 :
226 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|