Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / fpicker / source / office / fileview.hxx
blob4c2a8f60af58e10045b7bc9622080effef7d600f
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 #ifndef INCLUDED_VCL_FILEVIEW_HXX
20 #define INCLUDED_VCL_FILEVIEW_HXX
22 #include <memory>
23 #include <com/sun/star/uno/Sequence.h>
24 #include <vcl/errinf.hxx>
25 #include <vcl/weld.hxx>
26 #include <rtl/ustring.hxx>
28 namespace com :: sun :: star :: ucb { class XContent; }
30 // class SvtFileView -----------------------------------------------------
32 class SvtFileView_Impl;
33 struct SvtContentEntry;
35 /// the result of an action in the FileView
36 enum FileViewResult
38 eSuccess,
39 eFailure,
40 eTimeout,
41 eStillRunning
44 enum FileViewMode
46 eDetailedList,
47 eIcon
50 /// describes parameters for doing an action on the FileView asynchronously
51 struct FileViewAsyncAction
53 sal_uInt32 nMinTimeout; /// minimum time to wait for a result, in milliseconds
54 sal_uInt32 nMaxTimeout; /// maximum time to wait for a result, in milliseconds, until eTimeout is returned
55 Link<void*,void> aFinishHandler; /// the handler to be called when the action is finished. Called in every case, no matter of the result
57 FileViewAsyncAction()
59 nMinTimeout = nMaxTimeout = 0;
63 class SvtFileView
65 private:
66 std::unique_ptr<SvtFileView_Impl> mpImpl;
67 css::uno::Sequence<OUString> maBlackList;
69 DECL_LINK(HeaderSelect_Impl, int, void);
71 public:
72 SvtFileView(weld::Window* pTopLevel,
73 std::unique_ptr<weld::TreeView> xTreeView,
74 std::unique_ptr<weld::IconView> xIconView,
75 bool bOnlyFolder, bool bMultiSelection, bool bShowType = true);
76 ~SvtFileView();
78 void SetViewMode( FileViewMode eMode );
80 const OUString& GetViewURL() const;
81 OUString GetURL(const weld::TreeIter& rEntry) const;
82 OUString GetCurrentURL() const;
84 bool GetParentURL( OUString& _rParentURL ) const;
85 void CreatedFolder( const OUString& rUrl, const OUString& rNewFolder );
87 void set_help_id(const OString& rHelpId);
88 OString get_help_id() const;
90 void grab_focus();
91 bool has_focus() const;
93 OUString get_selected_text() const;
95 weld::Widget* identifier() const; // just to uniquely identify this widget
97 /** initialize the view with the content of a folder given by URL, and apply an immediate filter
99 @param rFolderURL
100 the URL of the folder whose content is to be read
101 @param rFilter
102 the initial filter to be applied
103 @param pAsyncDescriptor
104 If not <NULL/>, this struct describes the parameters for doing the
105 action asynchronously.
107 FileViewResult Initialize(
108 const OUString& rFolderURL,
109 const OUString& rFilter,
110 const FileViewAsyncAction* pAsyncDescriptor,
111 const css::uno::Sequence< OUString >& rBlackList
114 /** reads the current content of the current folder again, and applies the given filter to it
116 Note 1: The folder is really read a second time. This implies that any new elements (which were
117 not present when you called Initialize the last time) are now displayed.
119 Note 2: This method must not be called when you previously initialized the view from a sequence
120 of strings, or a UNO content object.
122 @param rFilter
123 the filter to be applied
124 @param pAsyncDescriptor
125 If not <NULL/>, this struct describes the parameters for doing the
126 action asynchronously.
128 FileViewResult ExecuteFilter(
129 const OUString& rFilter,
130 const FileViewAsyncAction* pAsyncDescriptor
133 /** cancels a running async action (if any)
135 @seealso Initialize
136 @seealso ExecuteFilter
137 @seealso FileViewAsyncAction
139 void CancelRunningAsyncAction();
141 /** initializes the view with the parent folder of the current folder
143 @param rNewURL
144 the URL of the folder which we just navigated to
145 @param pAsyncDescriptor
146 If not <NULL/>, this struct describes the parameters for doing the
147 action asynchronously.
149 FileViewResult PreviousLevel(
150 const FileViewAsyncAction* pAsyncDescriptor
153 void SetNoSelection();
155 void SetSelectHdl( const Link<SvtFileView*,void>& rHdl );
156 void SetDoubleClickHdl( const Link<SvtFileView*,bool>& rHdl );
157 void SetOpenDoneHdl( const Link<SvtFileView*,void>& rHdl );
159 sal_uInt32 GetSelectionCount() const;
160 SvtContentEntry* FirstSelected() const;
162 void selected_foreach(const std::function<bool(weld::TreeIter&)>& func);
164 void EnableDelete( bool bEnable );
166 // save and load column size and sort order
167 OUString GetConfigString() const;
168 void SetConfigString( const OUString& rCfgStr );
170 void EndInplaceEditing();
172 ::std::vector< SvtContentEntry > GetContent();
175 // struct SvtContentEntry ------------------------------------------------
177 struct SvtContentEntry
179 bool const mbIsFolder;
180 OUString maURL;
182 SvtContentEntry( const OUString& rURL, bool bIsFolder ) :
183 mbIsFolder( bIsFolder ), maURL( rURL ) {}
186 #endif // INCLUDED_VCL_FILEVIEW_HXX
188 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */