Tizen 2.1 base
[apps/osp/MyFiles.git] / inc / MfSearchForm.h
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
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
7 //
8 //     http://floralicense.org/license/
9 //
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.
15 //
16
17 /**
18  * @file: MfSearchForm.h
19  * @brief: This file contains declaration of  of SearchForm class.
20  */
21
22 #ifndef _MF_SEARCH_FORM_H_
23 #define _MF_SEARCH_FORM_H_
24
25 #include <FApp.h>
26 #include <FAppPkg.h>
27 #include <FContent.h>
28 #include <FGraphics.h>
29 #include <FIo.h>
30 #include <FSysEnvironment.h>
31 #include <FUi.h>
32
33 #include "MfBaseForm.h"
34 #include "MfFolderNavigationPresentationModel.h"
35 #include "MfContentListItem.h"
36 #include "MfCustomAppControl.h"
37 #include "MfDirectoryEntry.h"
38 #include "MfINotificationListener.h"
39 #include "MfMyFilesApp.h"
40 #include "MfSceneRegister.h"
41 #include "MfSearchPresentationModel.h"
42 #include "MfThumbnailManager.h"
43 #include "MfTypes.h"
44 #include "MfUtility.h"
45
46 class SearchForm
47 : public BaseForm
48   , public Tizen::App::IAppControlResponseListener
49   , public Tizen::App::Package::IPackageInstallationEventListener
50   , public Tizen::App::Package::IPackageInstallationResponseListener
51   , public Tizen::Ui::IKeypadEventListener
52   , public Tizen::Ui::ITextEventListener
53   , public Tizen::Ui::Controls::ISearchBarEventListener
54   , public Tizen::Io::IFileEventListener
55   {
56 public:
57         //! Constructor of the class.
58         /*!@fn SearchForm()
59          * @brief Initializes the member variables of the class.
60          * @param Takes no parameters
61          * @return No value returned */
62         SearchForm(void);
63
64         //! Destructor of the class.
65         /*!@fn ~SearchForm()
66          * @brief Frees the memory allocated to the member variables.
67          * @param Takes no parameters
68          * @return No value returned
69          * */
70         virtual ~SearchForm(void);
71
72         //!Initializes the SearchForm
73         /*! @fn Initialize()
74          * @brief constructs the SearchForm
75          * @param No parameters
76          * @return true if form is constructed successfully , false otherwise
77          */
78         bool Initialize(void);
79
80         result OnInitializing(void);
81         result OnTerminating(void);
82
83         //IActionEventListener
84         void OnActionPerformed(const Tizen::Ui::Control& source, int actionId);
85
86         //IFormBackEventListener
87         void OnFormBackRequested(Tizen::Ui::Controls::Form& source);
88
89         // IListViewItemEventListener
90         virtual void OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state);
91         virtual void OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status);
92         virtual void OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction);
93
94         //IListViewItemProvider
95         virtual Tizen::Ui::Controls::ListItemBase* CreateItem(int index, int itemWidth);
96         virtual bool DeleteItem(int index, Tizen::Ui::Controls::ListItemBase* pItem, int itemWidth);
97         virtual int GetItemCount(void);
98
99         //ISceneEventListener
100         virtual void OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs);
101         virtual void OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId);
102
103         //ISceneManagerEventListener
104         virtual void OnSceneTransitionCompleted (const Tizen::Ui::Scenes::SceneId &previousSceneId, const Tizen::Ui::Scenes::SceneId &currentSceneId);
105         virtual void OnSceneTransitionStarted (const Tizen::Ui::Scenes::SceneId &currentSceneId, const Tizen::Ui::Scenes::SceneId &nextSceneId);
106
107         //IKeyPadActionEventListener
108         void OnKeypadActionPerformed(Tizen::Ui::Control& source, Tizen::Ui::KeypadAction keypadAction);
109         void OnKeypadClosed(Tizen::Ui::Control& source);
110         void OnKeypadOpened(Tizen::Ui::Control& source);
111         void OnKeypadWillOpen(Tizen::Ui::Control& source);
112
113         //ITextEventListener
114         void OnTextValueChangeCanceled(const Tizen::Ui::Control& source);
115         void OnTextValueChanged(const Tizen::Ui::Control& source);
116
117         //SearchBar Control
118         void OnSearchBarModeChanged(Tizen::Ui::Controls::SearchBar& source, Tizen::Ui::Controls::SearchBarMode mode);
119
120         //IAppControlEventListener
121         //virtual void OnAppControlCompleted(const Tizen::Base::String& providerId, const Tizen::Base::String& operationId, const Tizen::Base::Collection::IList* pResultList);
122         //! IAppControlResponseListener
123         /*! @fn OnAppControlCompleted(const Tizen::Base::String& providerId, const Tizen::Base::String& operationId, const Tizen::Base::Collection::IList* pResultList)
124          * @brief Called when the application control is completed. The client can get callback result for some application controls by implementing this listener.
125          */
126         void OnAppControlCompleteResponseReceived(const Tizen::App::AppId& appId, const Tizen::Base::String& operationId, Tizen::App::AppCtrlResult appControlResult, const Tizen::Base::Collection::IMap* pExtraData);
127
128         //IFileNotificationListener
129         void OnNotificationReceived(Tizen::Base::Collection::ArrayList* pArgs);
130
131         //IContentSearchListener
132         virtual void OnFolderSearchStarted(Tizen::Base::String& folderName);
133         virtual void OnAllFoldersSearchCompleted(void);
134
135         //from IPackageInstallationEventListener
136         virtual void OnPackageInstallationCompleted(const Tizen::App::PackageId& packageId, Tizen::App::Package::PackageInstallationResult installationResult);
137         virtual void OnPackageInstallationInProgress(const Tizen::App::PackageId& packageId, int progress);
138         virtual void OnPackageUninstallationCompleted(const Tizen::App::PackageId& packageId, bool uninstallationResult);
139         //
140         //      //IPackageInstallationResponseListener
141         virtual void OnPackageInstallationResponseReceived(const Tizen::App::PackageId& packageId, Tizen::App::Package::PackageInstallationResult installationResult);
142         virtual void OnPackageInstallationInProgressResponseReceived(const Tizen::App::PackageId& packageId, int progress);
143
144         //IFileProcessingListener
145         /*! A public virtual member function of IFileProcessingListener taking and returning no arguments.
146          * @fn OnFileManagingStart(void)
147          * @brief Used to show the FileProcessing Popup.
148          * @param No parameters
149          * @return No Return Values.
150          */
151         void OnFileManagingStart(void);
152
153         /*! A public virtual member function of IFileProcessingListener returning no arguments.
154          * @fn OnFileManagingStop(FileManagingResult fileManagingResult)
155          * @brief Used to hide the FileProcessing Popup.
156          * @param [FileManagingResult]Enumerator indicating the result of file processing.
157          * @return No Return Values.
158          */
159         void OnFileManagingStop(FileManagingResult fileManagingResult);
160
161         /*! A public purely virtual member function of IListViewStateChangeListener returning no arguments.
162          * @fn OnListViewItemStateChangedNotify(ViewType viewType)
163          * @brief Notifies the form if the view type is changed by the User and accordingly updates the lists.
164          * @param [ViewType] viewType, the enum indicating the selected view type: List, List and Details or Thumbnails.
165          * @return No Return Values.
166          */
167         virtual void OnListViewItemStateChangedNotify(ViewType viewType);
168
169         /*! A public purely virtual member function of IListViewStateChangeListener returning a pointer to the FileListPresentationModel.
170          * @fn  OnThumbnailReceived(ThumbRequest* pThumbReq)
171          * @brief Used to refresh the image of the listitem from the default image to the generated thumbnail.
172          * @param [ThumbRequest] pThumbReq, the structure containing the thumbnail corresponding to a filepath.
173          * @return No Return Values.
174          */
175         virtual void OnThumbnailReceived(ThumbRequest* pThumbReq);
176
177         //IDeviceEventListener
178         virtual void OnDeviceStateChanged(Tizen::System::DeviceType deviceType, const Tizen::Base::String& state);
179
180         /*!IDeviceNotificationListener
181          * A public callback from the IDeviceNotificationListener taking deviceType and state as argument and returning nothing
182          * @fn OnDeviceChange
183          * @brief Used to handle device event changes. When memory card is inserted, removed then this method will be called
184          * @param ComponentType, String
185          * @return no return value
186          */
187         void OnDeviceChange(ComponentType deviceType, const Tizen::Base::String& state);
188
189         //IFileEventListener
190         virtual void OnFileEventOccured(const unsigned long events,const Tizen::Base::String &  path, const unsigned int        eventId);
191
192
193 private:
194         /*
195          * A protected member function taking and returning no arguments.
196          * @fn CreateDeleteConfirmationPopUp()
197          * @brief Called OnContextItemStateChanged(), used to personalize the Delete Confirmation PopUp.
198          * @param No parameters taken.
199          * @return[result] An ErrorCode.
200          */
201         result CreateDeleteConfirmationPopup(void);
202
203         /*
204          * A protected member function taking and returning no arguments.
205          * @fn CreateFileProgressingPopup()
206          * @brief Called during OnInitializing(), used to personalize the Animation PopUp.
207          * @param No parameters taken.
208          * @return[result] An ErrorCode.
209          */
210         result CreateFileProgressingPopup(void);
211
212         /*
213          * A protected member function returning no arguments.
214          * @fn CreateInstallationConfirmationPopUp(void)
215          * @brief Called to create the InstallationConfirmationPopUp and all controls in it.
216          * @param No parameters taken.
217          * @return Void return type
218          */
219         result CreateInstallationConfirmationPopUp(void);
220
221         /*
222          * A private member function returning no arguments.
223          * @fn CreateInstallationProgressPopUp(void)
224          * @brief Called to create the CreateInstallationProgressPopUp and all controls in it.
225          * @param No parameters taken.
226          * @return Void return type
227          */
228         result CreateInstallationProgressPopUp(void);
229
230         /*
231          * A private member function taking a string as parameter and returning an error code.
232          * @fn DeleteFile(Tizen::Base::String&).
233          * @brief Used to delete the items selected in the Edit view.
234          * @param[String] Filepath of the String to be deleted.
235          * @return An ErrorCode.
236          */
237         void DeleteFile(Tizen::Base::String& filePath);
238
239         /*
240          * A private member function taking and returning no arguments.
241          * @fn HideDeleteConfirmationPopup()
242          * @brief Called to hide the delete confirmation popup.
243          * @param No parameters
244          * @return Void return type
245          */
246         void HideDeleteConfirmationPopup(void);
247
248         /*
249          * A protected member function taking and returning no arguments.
250          * @fn HideFileProgressingPopup()
251          * @brief  Called to hide the Animation PopUp containing the progress bar from the form.
252          * @param No parameters
253          * @return Void return type
254          */
255         void HideFileProgressingPopup(void);
256
257         /*
258          * A private member function taking and returning no arguments.
259          * @fn HideInstallationConfirmationPopup()
260          * @brief  Called to hide the InstallationConfirmationPopup.
261          * @param No parameters
262          * @return Void return type
263          */
264         void HideInstallationConfirmationPopup(void);
265
266         /*
267          * A private member function taking and returning no arguments.
268          * @fn HideInstallationProgressPopup()
269          * @brief  Called to hide the InstallationProgressPopup containing the progress bar from the form.
270          * @param No parameters
271          * @return Void return type
272          */
273         void HideInstallationProgressPopup(void);
274
275         /*
276          * A protected function taking a String parameter and returning no values
277          * @fn LoadDetailForm
278          * @brief Called during OnActionPerformed() Loads the form which shows the details of selected file or folder
279          * @param[String] Fullpath containing the full filepath of the selected directory
280          * @return Void return type
281          */
282         void LoadDetailForm(Tizen::Base::String& Fullpath);
283
284         /*
285          * A protected member function taking and returning no arguments.
286          * @fn LoadRenameForm(int index, DirectoryEntry* pDirectory)
287          * @brief Called OnActionPerformed on the ContextItem, initializes the Rename form.
288          * @param [int, DirectoryEntry*] index, of the element from where the context item was clicked, pDirectory, corresponding
289          * file information on DirectoryEntry.
290          * @return Void return type
291          */
292         void LoadRenameForm(int index, DirectoryEntry* pDirectory);
293
294         //!Opens SubDirectory View upon clicking on listview Items
295         /*! @fn LoadSubDirectoryForm
296          * @brief Opens SubDirectory view
297          * @param [Tizen::Base::String, Tizen::Base::String] Full file path and file name of Path of the selected content
298          * @returns No value returned
299          */
300         void LoadSubDirectoryForm(Tizen::Base::String& fullPath, Tizen::Base::String& fileName);
301
302         /*
303          * A private member function taking and returning no arguments.
304          * @fn ShowDeleteConfirmationPopup()
305          * @brief Called to show the delete confirmation popup.
306          * @param No parameters
307          * @return Void return type
308          */
309         void ShowDeleteConfirmationPopup(void);
310
311         /*
312          * A protected member function taking and returning no arguments.
313          * @fn ShowFileProgressingPopup()
314          * @brief  Called to draw the Animation PopUp containing the progress bar on the form.
315          * @param No parameters
316          * @return Void return type
317          */
318         void ShowFileProgressingPopup(void);
319
320         /*
321          * A private member function taking and returning no arguments.
322          * @fn ShowInstallationConfirmationPopup()
323          * @brief Called to show the InstallationConfirmationPopup.
324          * @param No parameters
325          * @return Void return type
326          */
327         void ShowInstallationConfirmationPopup(void);
328
329         /*
330          * A private member function taking and returning no arguments.
331          * @fn ShowInstallationProgressPopup()
332          * @brief Called to show the InstallationProgressPopup.
333          * @param No parameters
334          * @return Void return type
335          */
336         void ShowInstallationProgressPopup(void);
337
338         /*
339          * A Private member function to Start Searching after setting all required parameters
340          * @fn StartSearch()
341          * @param No parameters
342          */
343         void StartSearch(void);
344
345         // Copy Constructor of the class.
346         /*@fn SearchForm(const SearchForm&)
347          * @brief Copy Constructor
348          * @param Takes Reference of the class
349          * @return No value returned
350          * */
351         SearchForm(const SearchForm&);
352
353         // Assignment operator of the class.
354         /*@fn SearchForm& operator = (const SearchForm& pSearchForm)
355          * @brief Assignment operator of the class.
356          * @param Takes Reference of the class
357          * @return No value returned
358          * */
359         SearchForm& operator =(const SearchForm& pSearchForm);
360 private:
361         bool __searchedAllFolders;
362         bool __isSearchCompleted;
363         bool __isSearchStarted;
364         bool __isCancelClicked;
365         bool __bCheckArgsNull;
366
367         int __itemCount;
368         int __searchItemIndex;
369         int __selectedItemIndexForRename;
370         int __selectedItemIndexForDelete;
371
372         MemoryType __SelectedTab;
373         MemoryType __previouFormTab;
374
375         Tizen::App::Package::PackageManager* __pPackageManager;
376
377         Tizen::Base::Collection::ArrayList* __pContentListFromLastView;
378         Tizen::Base::Collection::ArrayList* __pSearchedContentList;
379         Tizen::Base::String __displayPath;
380         Tizen::Base::String __fileToDelete;
381         Tizen::Base::String __searchText;
382         Tizen::Base::String __previousFormPath;
383         Tizen::Base::String __previousSceneId;
384         Tizen::Base::String __pathOfSelectedFile;
385
386         Tizen::Graphics::Bitmap* __pDummyImage;
387         Tizen::Graphics::Bitmap* __pFolderBitmap;
388         Tizen::Graphics::Rectangle __listViewRectangle;
389
390         Tizen::Ui::Controls::Button* __pCancelDeletion;
391         Tizen::Ui::Controls::Button* __pCancelInstallation;
392         Tizen::Ui::Controls::Button* __pCancelSearch;
393         Tizen::Ui::Controls::Button* __pDelete;
394         Tizen::Ui::Controls::Button* __pFileProgressingCancelButton;
395         Tizen::Ui::Controls::Button* __pInstall;
396
397         Tizen::Ui::Controls::Label* __pDividerLabel;
398         Tizen::Ui::Controls::Label* __pFileProgressingHeaderLabel;
399         Tizen::Ui::Controls::Label* __pFileProgressingLabel;
400         Tizen::Ui::Controls::Label* __pPopUpLabel;
401
402         Tizen::Ui::Controls::ListContextItem* __pItemContext;
403         Tizen::Ui::Controls::ListView* __pListView;
404
405         Tizen::Ui::Controls::Panel* __pPopUpPanel;
406
407         Tizen::Ui::Controls::Popup* __pDeleteConfirmationPopUp;
408         Tizen::Ui::Controls::Popup* __pFileProgressingPopup;
409         Tizen::Ui::Controls::Popup* __pInstallationConfirmationPopUp;
410         Tizen::Ui::Controls::Popup* __pInstallationProgressPopup;
411
412         Tizen::Ui::Controls::Progress* __pFileProgressingProgress;
413
414         Tizen::Ui::Controls::SearchBar* __pSearchBar;
415         Tizen::Ui::Controls::SearchBarMode __searchBarMode;
416
417         Tizen::Io::FileEventManager* __pFileEventManager;
418
419
420         SearchPresentationModel* __pSearchModel;
421         ThumbnailManager* __pThumbnailManager;
422         FolderEntryPresentationModel* __pFolderEntryPM;
423
424         static int searchBackSelected;
425
426         static const int ID_BACK = 100;
427
428         static const int IDA_CONTEXT_DETAIL = 101;
429         static const int IDA_CONTEXT_RENAME = 102;
430         static const int IDA_CONTEXT_DELETE = 103;
431
432         static const int IDA_BTN_POPUP_SEARCH_CANCEL = 200;
433         static const int IDA_CANCEL_INSTALLATION = 303;
434         static const int IDA_INSTALL_APP = 304;
435         static const int IDA_CANCEL_DELETION = 203;
436         static const int IDA_DELETE_FILE = 204;
437
438         static const int IDA_BTN_ANIMATION_POPUP_CANCEL = 300;
439   };
440
441 #endif //_MF_SEARCH_FORM_H_