2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://floralicense.org/license/
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an AS IS BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
18 * @file: MfFolderEntryPresentationModel.h
19 * @brief: This model is responsible for getting the details of any Directory/File entries in the
20 * file system. Constructs the structure which contains basic information of these entries.
21 * Acts as Content browser for any given file path or directory path.
24 #ifndef _MF_FOLDER_ENTRY_PRESENTATION_MODEL_H_
25 #define _MF_FOLDER_ENTRY_PRESENTATION_MODEL_H_
30 #include <FSysEnvironment.h>
34 #include "MfBasePresentationModel.h"
35 #include "MfDirectoryEntry.h"
36 #include "MfIFileEventNotification.h"
37 #include "MfIListViewStateChangeListener.h"
38 #include "MfThumbnailManager.h"
41 class FolderEntryPresentationModel;
43 class IFolderEntryProviderListener
46 virtual ~IFolderEntryProviderListener(void);
48 //! IFolderEntryProviderListener
49 /*! A public virtual member function of IFolderEntryProviderListener returning a pointer to the FolderEntryPresentationModel.
50 * @fn GetFoldeEntryPresentationModel(void)
51 * @brief Used to get the pointer to the FileListPresentationModel Class.
52 * @param No parameters taken.
53 * @return [FolderEntryPresentationModel*] A pointer to the FolderEntryPresentationModel model.
55 virtual FolderEntryPresentationModel* GetFoldeEntryPresentationModel(void) = 0;
58 class FolderEntryPresentationModel
59 : public BasePresentationModel
62 //!This is the constructor for the class
64 * @fn FileListPresentationModel()
65 * @param Takes no parameters
66 * @return No value returned
68 FolderEntryPresentationModel(void);
70 //!This is the Destructor for the class
71 /*!@fn ~FileListPresentationModel()
72 * @param Takes no parameters
73 * @return No value returned
75 virtual ~FolderEntryPresentationModel(void);
77 //!This is the Construct method for the class in which memory will be allocated for member variables
79 * @param Takes no parameters
80 * @return result value
82 result Construct(void);
84 /*!@fn UpdateEntryCount()
85 * @params [string, int, int] filepath for which structure is constructed,
86 * currentDirectoryCount which will be updated with number of directories present in the given filepath
87 * currentFileCount which will be updated with number of files present in the given filepath
88 * Returns no parameters
90 void GetFolderEntryCount(const Tizen::Base::String& filePath, int& currentDirectoryCount, int& currentFileCount);
92 /*!@fn GetDirectoryEntryList()
93 * @param Takes no parameters
94 * @return[ArrayList] Returns an arraylist containing the directory entries
96 Tizen::Base::Collection::ArrayList* GetFolderEntryList(void);
98 /*!@fnGetSourceForm(void)
99 * @brief Used to get the parent form which invoked FolderEntryPesentationModel.
100 * @params No Parameters taken
101 * @return [CreateItemSource], source form which invoked FolderEntryPesentationModel
103 CreateItemSource GetSourceForm(void);
105 /*!@fn InitThumbnailManager
106 * This function is a public member of this model and called by views for generating thumbnails
107 * @param taken integer value index as a parameter for of the list view item for which it is suppose to genetrate thumbnail.
110 result InitThumbnailManager(void);
111 //result InitThumbnailManager(int iItemIndex);
114 /*!@fn void setFileEventListener(IFileEventNotification *pIFileEventNotification,Tizen::Base::String& currentFilePath)
115 * used to set listeners for the respective view if some file addition or delete activity take place
116 * @param Takes filenotification listener and path
117 * Returns no parameters
119 void SetFileEventListener(IFolderEntryEventListener* pIFileEventNotification);
121 /*!@fn SetFolderEntryPath()
122 * @param Takes a string as a parameter. This is the filepath from which structure is constructed.
123 * Returns no parameters
125 void SetFolderEntryPath(const Tizen::Base::String& filePath);
127 /*!@fn void SetType(FileType currentType)
128 * used to set the type of file
129 * @param FileType enum
130 * Returns no parameters
132 void SetFolderEntryType(FileType currentType);
136 * @brief: This method determines whether the directory entries have to be sorted or not
138 * @return No Return Value
140 void SetSortEnabled(bool enableFlag);
142 /*!@fn SetSourceForm(CreateItemSource currentSource)
143 * @brief Used to set the parent for which the FolderEntryPesentationModel is invoked.
144 * @params[CreateItemSource], source form which invoked FolderEntryPesentationModel
145 * @return No Return Value
147 void SetSourceForm(CreateItemSource currentSource);
150 * used to sort all the entries which are present in __pFileEntries arraylist
151 * @param Takes no parameters
152 * Returns no parameters
154 void SortFolderEntries(void);
156 /*@fn StartThumbnailRequest
157 * This function requests thumbnailmanager to get the thumbnail for a file.
158 *Takes index as an argument, this is the index of the file in the data-stucture maintained by the presentation model.
159 * Returns result value. Result of the StartThumbnailRequest function call
161 result StartThumbnailRequest(int iReqIndex = -1);
163 result SetListUpdateEventListener(IListViewStateChangeListener* pListener);
165 /*@fn StopThumbnailManager
166 * This function send request to thumbnailmanager to stops processing further thumbnail request.
168 * Returns result value
170 result StopThumbnailManager(bool bForceStop=false);
172 void RefreshFolderEntries(void);
175 * It executes when some fileEvent Occured
176 * param long event, string refernce and event id
177 * @return No Return values
179 virtual void OnFileEventOccured(unsigned long events, const Tizen::Base::String& path, unsigned int eventId);
181 /*@fn OnThumbnailResponseReceived
182 * This function receives thumbnail image received from thumbnailmanager.
183 * Takes pointer to the bitmap and index of the item for which bitmap is received as argument
184 * Returns result value
186 result OnThumbnailResponseReceived(Tizen::Graphics::Bitmap* pThumb, int Index);
188 /*@fn OnThumbnailResponseFailed
189 * This function is the callback of the thumbnail loading failed
190 * Takes index of the item for which bitmap is generation failed as an argument
191 * Returns result value
193 result OnThumbnailResponseFailed(int Index = -1);
196 /*@fn FileListPresentationModel()
197 * Copy Constructor for the FileListPresentationModel class
198 * Takes FileListPresentationModel as a parameter
199 * Returns no parameters
201 FolderEntryPresentationModel(const FolderEntryPresentationModel& content);
204 * Overloaded assignment operator for FileListPresentationModel class
205 * Takes FileListPresentationModel as a parameter
206 * Returns FileListPresentationModel as a return value
208 FolderEntryPresentationModel& operator =(const FolderEntryPresentationModel& source);
211 * Responsible for creating the entries in __pFileEntries.
213 void CreateFolderEntryList(const Tizen::Base::String& directoryName);
216 *This method is used to get the next available position in the arraylist of the directory entry during Swap operation.
217 * \param pList an arraylist which contains all the DirectoryStructure entries of the given path
218 * @return Returns the next available position where swapping can be done
220 int GetSwapIndex(void);
223 * Responsible for constructing all the entries in the given path
225 result MakeFolderEntryList(const Tizen::Base::String& directoryName);
228 * This method is used to swap two DirectoryStructure entries. This will be useful while sorting the elements of any file entry list.
229 * \param source a DirectoryStructure variable which contains the first object.
230 * \param destination a DirectoryStructure variable which contains the second object.
231 * @return No Return values
233 void SwapFolderEntries(DirectoryEntry& source, DirectoryEntry& destination);
236 * It Updates the folder enteries on occuring of file event
237 * param long events and one string refernce
238 * @return No Return values
240 void UpdateFileListEnteries(unsigned long events, const Tizen::Base::String& path);
247 bool __ThumbnailRequestInProgress;
249 AppControlView __currentViewType;
250 CreateItemSource __sourceForm;
251 FileType __entryType;
253 Tizen::Base::Collection::ArrayList* __pFolderEntries;
254 Tizen::Base::String __currentFilePath;
255 Tizen::Io::FileEventManager* __pFileEventManager;
257 static IFolderEntryEventListener* __pFolderEntryEventListener;
258 ThumbnailManager* __pThumbnailManager;
261 #endif // _MF_FOLDER_ENTRY_PRESENTATION_MODEL_H_