111952abd2260009003dabb30d649cc5c7e8577f
[apps/osp/MyFiles.git] / src / MfDetailsForm.cpp
1 //\r
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.\r
3 //\r
4 // Licensed under the Flora License, Version 1.0 (the License);\r
5 // you may not use this file except in compliance with the License.\r
6 // You may obtain a copy of the License at\r
7 //\r
8 //     http://floralicense.org/license/\r
9 //\r
10 // Unless required by applicable law or agreed to in writing, software\r
11 // distributed under the License is distributed on an AS IS BASIS,\r
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
13 // See the License for the specific language governing permissions and\r
14 // limitations under the License.\r
15 //\r
16 \r
17 /**\r
18  * @file: MfFileDetailForm.cpp\r
19  * @brief: This file contains the implementation of class DetailsForm, which acts as a View to display\r
20  * the details of files or folders.\r
21  */\r
22 \r
23 #include <FApp.h>\r
24 #include <FUiControl.h>\r
25 \r
26 #include "MfDetailsForm.h"\r
27 \r
28 using namespace Tizen::App;\r
29 using namespace Tizen::Base::Collection;\r
30 using namespace Tizen::Base;\r
31 using namespace Tizen::Graphics;\r
32 using namespace Tizen::Io;\r
33 using namespace Tizen::Locales;\r
34 using namespace Tizen::System;\r
35 using namespace Tizen::Ui;\r
36 using namespace Tizen::Ui::Controls;\r
37 using namespace Tizen::Ui::Scenes;\r
38 \r
39 DetailsForm::DetailsForm(void)\r
40         : __pMediaMetaData(null)\r
41         , __pFileDetailList(null)\r
42         , __pFileHeaderDetailList(null)\r
43         , __pGroupedDetailListView(null)\r
44 {\r
45         //Empty Implementation.\r
46 }\r
47 \r
48 DetailsForm::~DetailsForm(void)\r
49 {\r
50         if (__pFileDetailList != null)\r
51         {\r
52                 __pFileDetailList->RemoveAll(true);\r
53                 delete __pFileDetailList;\r
54         }\r
55 \r
56         if (__pFileHeaderDetailList != null)\r
57         {\r
58                 __pFileHeaderDetailList->RemoveAll(true);\r
59                 delete __pFileHeaderDetailList;\r
60         }\r
61 }\r
62 \r
63 DetailsForm&\r
64 DetailsForm::operator =(const DetailsForm& fileDetailForm)\r
65 {\r
66         return *this;\r
67 }\r
68 \r
69 DetailsForm::DetailsForm(const DetailsForm& fileDetailForm)\r
70 {\r
71         //Do Nothing\r
72 }\r
73 \r
74 bool\r
75 DetailsForm::Initialize(void)\r
76 {\r
77         result r = E_SUCCESS;\r
78         Construct(L"IDL_DETAIL_FORM");\r
79         __pFileDetailList = new (std::nothrow) ArrayList();\r
80         r = __pFileDetailList->Construct();\r
81 \r
82         __pFileHeaderDetailList = new (std::nothrow) ArrayList();\r
83         r = __pFileHeaderDetailList->Construct();\r
84 \r
85         return true;\r
86 }\r
87 \r
88 result\r
89 DetailsForm::OnInitializing(void)\r
90 {\r
91         AppLogDebug("Entry");\r
92         result r = E_SUCCESS;\r
93         // Setup back event listener\r
94         SetFormBackEventListener(this);\r
95 \r
96         __pGroupedDetailListView = static_cast< GroupedListView* >(GetControl(L"IDC_GROUPEDLISTVIEW1"));\r
97         if (__pGroupedDetailListView != null)\r
98         {\r
99                 __pGroupedDetailListView->SetItemProvider(*this);\r
100                 __pGroupedDetailListView->AddGroupedListViewItemEventListener(*this);\r
101                 __pGroupedDetailListView->SetMultipointTouchEnabled(false);\r
102         }\r
103 \r
104         SetMultipointTouchEnabled(false);\r
105         AppLogDebug("Exit");\r
106         return r;\r
107 }\r
108 \r
109 result\r
110 DetailsForm::OnTerminating(void)\r
111 {\r
112         result r = E_SUCCESS;\r
113         return r;\r
114 }\r
115 \r
116 void\r
117 DetailsForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)\r
118 {\r
119         AppLogDebug("Entry");\r
120         SceneManager* pSceneManager = SceneManager::GetInstance();\r
121         if (pSceneManager != null)\r
122         {\r
123                 pSceneManager->GoBackward(BackwardSceneTransition());\r
124         }\r
125         AppLogDebug("Exit");\r
126 }\r
127 \r
128 \r
129 void\r
130 DetailsForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,\r
131                                                            const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)\r
132 {\r
133         AppLogDebug("Entry");\r
134         String* pFilePath = null;\r
135         FolderEntryDetailPresentationModel mediaUtility;\r
136         FileAttributes fileAttrib;\r
137         String imageFileFormat;\r
138 \r
139         SceneManager::GetInstance()->AddSceneManagerEventListener(*this);\r
140         DeviceManager::AddDeviceEventListener(DEVICE_TYPE_STORAGE_CARD, *this);\r
141 \r
142         if (pArgs != null)\r
143         {\r
144                 pFilePath = dynamic_cast< String* >(pArgs->GetAt(0));\r
145                 __fileFullPath.Clear();\r
146                 if (pFilePath != null)\r
147                 {\r
148                         __fileFullPath.Append(*pFilePath);\r
149                 }\r
150                 pArgs->RemoveAll(true);\r
151 \r
152                 File::GetAttributes(__fileFullPath, fileAttrib);\r
153 \r
154                 if (fileAttrib.IsDirectory())\r
155                 {\r
156                         __pMediaMetaData = mediaUtility.GetFolderEntryMetaDataN(__fileFullPath, FILE_TYPE_FOLDER_TYPE);\r
157                         SetFileDetailList(FILE_TYPE_FOLDER_TYPE);\r
158                 }\r
159                 else\r
160                 {\r
161                         int chkForFileFormatFlag = IMAGE_FILE_FORMAT;\r
162                         int counter = 0;\r
163                         if (chkForFileFormatFlag == IMAGE_FILE_FORMAT)\r
164                         {\r
165 \r
166                                 for (counter = 0; counter < IMAGE_FILE_FORMAT_COUNT; counter++)\r
167                                 {\r
168                                         imageFileFormat = typeImage[counter];\r
169 \r
170                                         if (__fileFullPath.EndsWith(imageFileFormat))\r
171                                         {\r
172                                                 chkForFileFormatFlag = IMAGE_FILE_FORMAT;\r
173 \r
174                                                 __pMediaMetaData = mediaUtility.GetFolderEntryMetaDataN(__fileFullPath, FILE_TYPE_IMAGE_TYPE);\r
175                                                 SetFileDetailList(FILE_TYPE_IMAGE_TYPE);\r
176                                                 break;\r
177                                         }\r
178                                         else\r
179                                         {\r
180                                                 chkForFileFormatFlag = AUDIO_FILE_FORMAT;\r
181                                         }\r
182 \r
183                                 }\r
184                         }\r
185 \r
186                         if (chkForFileFormatFlag == AUDIO_FILE_FORMAT)\r
187                         {\r
188                                 int counter = 0;\r
189 \r
190                                 for (counter = 0; counter < AUDIO_FILE_FORMAT_COUNT; counter++)\r
191                                 {\r
192 \r
193                                         String audioFileFormat = typeAudio[counter];\r
194 \r
195                                         if (__fileFullPath.EndsWith(audioFileFormat))\r
196                                         {\r
197                                                 chkForFileFormatFlag = AUDIO_FILE_FORMAT;\r
198 \r
199                                                 __pMediaMetaData = mediaUtility.GetFolderEntryMetaDataN(__fileFullPath, FILE_TYPE_AUDIO_TYPE);\r
200                                                 SetFileDetailList(FILE_TYPE_AUDIO_TYPE);\r
201                                                 break;\r
202                                         }\r
203                                         else\r
204                                         {\r
205                                                 chkForFileFormatFlag = VIDEO_FILE_FORMAT;\r
206                                         }\r
207                                 }\r
208                         }\r
209                         if (chkForFileFormatFlag == VIDEO_FILE_FORMAT)\r
210                         {\r
211                                 int counter = 0;\r
212                                 for (counter = 0; counter < VIDEO_FILE_FORMAT_COUNT; counter++)\r
213                                 {\r
214                                         String videoFileFormat = typeVideo[counter];\r
215                                         if (__fileFullPath.EndsWith(videoFileFormat))\r
216                                         {\r
217                                                 chkForFileFormatFlag = VIDEO_FILE_FORMAT;\r
218 \r
219                                                 __pMediaMetaData = mediaUtility.GetFolderEntryMetaDataN(__fileFullPath, FILE_TYPE_VIDEO_TYPE);\r
220                                                 SetFileDetailList(FILE_TYPE_VIDEO_TYPE);\r
221                                                 break;\r
222                                         }\r
223                                         else\r
224                                         {\r
225                                                 chkForFileFormatFlag = OTHER_FILE_FORMAT;\r
226                                         }\r
227                                 }\r
228                         }\r
229                         if (chkForFileFormatFlag == OTHER_FILE_FORMAT)\r
230                         {\r
231 \r
232                                 __pMediaMetaData = mediaUtility.GetFolderEntryMetaDataN(__fileFullPath, FILE_TYPE_OTHER_TYPE);\r
233                                 SetFileDetailList(FILE_TYPE_OTHER_TYPE);\r
234                         }\r
235 \r
236                 }\r
237                 delete pArgs;\r
238         }\r
239 \r
240         AppLogDebug("Exit");\r
241 }\r
242 \r
243 void\r
244 DetailsForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,\r
245                                                                 const Tizen::Ui::Scenes::SceneId& nextSceneId)\r
246 {\r
247         DeviceManager::RemoveAllDeviceEventListeners();\r
248 }\r
249 \r
250 void\r
251 DetailsForm::SetFileDetailList(FileType fileType)\r
252 {\r
253         AppLogDebug("Entry");\r
254         String* pNameHeading = null;\r
255         String* pFileName = null;\r
256         String* pSizeHeading = null;\r
257         String* pSize = null;\r
258         String* pContainsHeading = null;\r
259         String* pFileAndFolders = null;\r
260         String* pDateCreateHeading = null;\r
261         String* pDateAndTime = null;\r
262         String* pLocationHeading = null;\r
263         String* pFilePath = null;\r
264         String* pFormatHeading = null;\r
265         String* pFormat = null;\r
266         String* pResolutionHeading = null;\r
267         String* pResolution = null;\r
268         AppResource* pAppResource = null;\r
269 \r
270         pAppResource = Application::GetInstance()->GetAppResource();\r
271         TryCatch(pAppResource != null, , "Failed to get instance of pAppResource");\r
272 \r
273         switch (fileType)\r
274         {\r
275         case FILE_TYPE_FOLDER_TYPE:\r
276         {\r
277                 String nameHeading;\r
278                 String sizeHeading;\r
279                 String containsHeading;\r
280                 String dateCreatedHeading;\r
281                 String locationHeading;\r
282                 String size;\r
283                 String fileAndFolders;\r
284                 String dateAndTime;\r
285                 String files;\r
286                 String folders;\r
287 \r
288                 FolderMediaMetaData* folderMediaMetaData = static_cast< FolderMediaMetaData* >(__pMediaMetaData);\r
289 \r
290                 pAppResource->GetString(L"IDS_COM_BODY_FOLDERS", folders);\r
291                 pAppResource->GetString(L"IDS_COM_OPT_FILES", files);\r
292 \r
293 \r
294                 pAppResource->GetString(L"IDS_MF_OPT_LISTBY_NAME", nameHeading);\r
295                 pNameHeading = new (std::nothrow) String(nameHeading);\r
296 \r
297                 __pFileHeaderDetailList->Add(pNameHeading);\r
298 \r
299 \r
300                 pFileName = new (std::nothrow) String(*(folderMediaMetaData->GetFileName()));\r
301                 __pFileDetailList->Add(pFileName);\r
302 \r
303                 pAppResource->GetString(L"IDS_COM_BODY_SIZE", sizeHeading);\r
304 \r
305                 pSizeHeading = new (std::nothrow) String(sizeHeading);\r
306                 __pFileHeaderDetailList->Add(pSizeHeading);\r
307 \r
308 \r
309                 size = MfUtility::ConvertFileSizeToString(folderMediaMetaData->GetFileSize());\r
310 \r
311                 pSize = new (std::nothrow) String(size);\r
312                 __pFileDetailList->Add(pSize);\r
313 \r
314                 fileAndFolders.Append(folderMediaMetaData->GetNoOfFiles());\r
315                 fileAndFolders.Append(L" ");\r
316                 fileAndFolders.Append(files);\r
317                 fileAndFolders.Append(", ");\r
318                 fileAndFolders.Append(folderMediaMetaData->GetNoOfFolders());\r
319                 fileAndFolders.Append(L" ");\r
320                 fileAndFolders.Append(folders);\r
321 \r
322                 pAppResource->GetString(L"IDS_MF_BODY_CONTAINS", containsHeading);\r
323 \r
324 \r
325                 pContainsHeading = new (std::nothrow) String(containsHeading);\r
326                 __pFileHeaderDetailList->Add(pContainsHeading);\r
327 \r
328                 pFileAndFolders = new (std::nothrow) String(fileAndFolders);\r
329                 __pFileDetailList->Add(pFileAndFolders);\r
330 \r
331                 pAppResource->GetString(L"IDS_MF_BODY_CREATED_DATE", dateCreatedHeading);\r
332 \r
333                 pDateCreateHeading = new (std::nothrow) String(dateCreatedHeading);\r
334                 __pFileHeaderDetailList->Add(pDateCreateHeading);\r
335 \r
336                 dateAndTime = MfUtility::ConvertDateTimeToString(folderMediaMetaData->GetFileCreationTime());\r
337 \r
338                 pDateAndTime = new (std::nothrow) String(dateAndTime);\r
339                 __pFileDetailList->Add(pDateAndTime);\r
340 \r
341                 pAppResource->GetString(L"IDS_COM_BODY_LOCATION", locationHeading);\r
342 \r
343                 pLocationHeading = new (std::nothrow) String(locationHeading);\r
344                 __pFileHeaderDetailList->Add(pLocationHeading);\r
345 \r
346                 pFilePath = new (std::nothrow) String(*(folderMediaMetaData->GetFilePath()));\r
347                 __pFileDetailList->Add(pFilePath);\r
348 \r
349                 //if (folderMediaMetaData != null)\r
350                 //{\r
351 \r
352                 delete folderMediaMetaData;\r
353                 folderMediaMetaData = null;\r
354                 //}\r
355 \r
356         }\r
357         break;\r
358 \r
359         case FILE_TYPE_IMAGE_TYPE:\r
360         {\r
361                 String nameHeading;\r
362                 String sizeHeading;\r
363                 String formatHeading;\r
364                 String resolutionHeading;\r
365                 String dateCreatedHeading;\r
366                 String locationHeading;\r
367                 String size;\r
368 \r
369                 ImageMediaMetaData* imageMediaMetaData = static_cast< ImageMediaMetaData* >(__pMediaMetaData);\r
370                 TryCatch(imageMediaMetaData != null, , "Failed to allocate Image Media Meta Data");\r
371 \r
372                 pAppResource->GetString(L"IDS_MF_OPT_LISTBY_NAME", nameHeading);\r
373                 pNameHeading = new (std::nothrow) String(nameHeading);\r
374                 __pFileHeaderDetailList->Add(pNameHeading);\r
375 \r
376 \r
377                 pFileName = new (std::nothrow) String(*(imageMediaMetaData->GetFileName()));\r
378                 __pFileDetailList->Add(pFileName);\r
379 \r
380 \r
381                 pAppResource->GetString(L"IDS_COM_BODY_SIZE", sizeHeading);\r
382                 pSizeHeading = new (std::nothrow) String(sizeHeading);\r
383 \r
384                 __pFileHeaderDetailList->Add(pSizeHeading);\r
385 \r
386                 size = MfUtility::ConvertFileSizeToString(imageMediaMetaData->GetFileSize());\r
387                 pSize = new (std::nothrow) String(size);\r
388                 __pFileDetailList->Add(pSize);\r
389 \r
390                 pAppResource->GetString(L"IDS_COM_BODY_FORMAT", formatHeading);\r
391                 pFormatHeading = new (std::nothrow) String(formatHeading);\r
392                 __pFileHeaderDetailList->Add(pFormatHeading);\r
393 \r
394                 pFormat = new (std::nothrow) String(*(imageMediaMetaData->GetFileFormat()));\r
395                 __pFileDetailList->Add(pFormat);\r
396 \r
397                 pAppResource->GetString(L"IDS_IDLE_BODY_RESOLUTION", resolutionHeading);\r
398                 pResolutionHeading = new (std::nothrow) String(resolutionHeading);\r
399                 __pFileHeaderDetailList->Add(pResolutionHeading);\r
400 \r
401 \r
402                 pResolution = new (std::nothrow) String(*(imageMediaMetaData->GetFileResolution()));\r
403                 __pFileDetailList->Add(pResolution);\r
404 \r
405 \r
406                 String dateAndTime = MfUtility::ConvertDateTimeToString(imageMediaMetaData->GetFileCreationTime());\r
407                 pAppResource->GetString(L"IDS_MF_BODY_CREATED_DATE", dateCreatedHeading);\r
408                 pDateCreateHeading = new (std::nothrow) String(dateCreatedHeading);\r
409                 __pFileHeaderDetailList->Add(pDateCreateHeading);\r
410 \r
411 \r
412                 pDateAndTime = new (std::nothrow) String(dateAndTime);\r
413                 __pFileDetailList->Add(pDateAndTime);\r
414 \r
415 \r
416                 pAppResource->GetString(L"IDS_COM_BODY_LOCATION", locationHeading);\r
417                 pLocationHeading = new (std::nothrow) String(locationHeading);\r
418                 __pFileHeaderDetailList->Add(pLocationHeading);\r
419 \r
420 \r
421                 pFilePath = new (std::nothrow) String(*(imageMediaMetaData->GetFilePath()));\r
422                 __pFileDetailList->Add(pFilePath);\r
423 \r
424                 //if (imageMediaMetaData != null)\r
425                 //{\r
426 \r
427                 delete imageMediaMetaData;\r
428                 imageMediaMetaData = null;\r
429                 //}\r
430 \r
431         }\r
432         break;\r
433 \r
434         case FILE_TYPE_AUDIO_TYPE:\r
435         {\r
436                 String nameHeading;\r
437                 String sizeHeading;\r
438                 String formatHeading;\r
439                 String dateCreatedHeading;\r
440                 String locationHeading;\r
441                 String size;\r
442 \r
443                 AudioMediaMetaData* audioMediaMetaData = static_cast< AudioMediaMetaData* >(__pMediaMetaData);\r
444                 TryCatch(audioMediaMetaData != null, , "Failed to allocate Audio Media Meta Data");\r
445 \r
446                 pAppResource->GetString(L"IDS_MF_OPT_LISTBY_NAME", nameHeading);\r
447                 pNameHeading = new (std::nothrow) String(nameHeading);\r
448                 __pFileHeaderDetailList->Add(pNameHeading);\r
449 \r
450                 pFileName = new (std::nothrow) String(*(audioMediaMetaData->GetFileName()));\r
451                 __pFileDetailList->Add(pFileName);\r
452 \r
453 \r
454                 size = MfUtility::ConvertFileSizeToString(audioMediaMetaData->GetFileSize());\r
455                 pAppResource->GetString(L"IDS_COM_BODY_SIZE", sizeHeading);\r
456                 pSizeHeading = new (std::nothrow) String(sizeHeading);\r
457                 __pFileHeaderDetailList->Add(pSizeHeading);\r
458 \r
459                 pSize = new (std::nothrow) String(size);\r
460                 __pFileDetailList->Add(pSize);\r
461 \r
462                 pAppResource->GetString(L"IDS_COM_BODY_FORMAT", formatHeading);\r
463                 pFormatHeading = new (std::nothrow) String(formatHeading);\r
464                 __pFileHeaderDetailList->Add(pFormatHeading);\r
465 \r
466                 pFormat = new (std::nothrow) String(*(audioMediaMetaData->GetFileFormat()));\r
467                 __pFileDetailList->Add(pFormat);\r
468 \r
469                 String dateAndTime = MfUtility::ConvertDateTimeToString(audioMediaMetaData->GetFileCreationTime());\r
470                 pAppResource->GetString(L"IDS_MF_BODY_CREATED_DATE", dateCreatedHeading);\r
471                 pDateCreateHeading = new (std::nothrow) String(dateCreatedHeading);\r
472                 __pFileHeaderDetailList->Add(pDateCreateHeading);\r
473 \r
474                 pDateAndTime = new (std::nothrow) String(dateAndTime);\r
475                 __pFileDetailList->Add(pDateAndTime);\r
476 \r
477                 pAppResource->GetString(L"IDS_COM_BODY_LOCATION", locationHeading);\r
478                 pLocationHeading = new (std::nothrow) String(locationHeading);\r
479                 __pFileHeaderDetailList->Add(pLocationHeading);\r
480 \r
481                 pFilePath = new (std::nothrow) String(*(audioMediaMetaData->GetFilePath()));\r
482                 __pFileDetailList->Add(pFilePath);\r
483 \r
484                 //if (audioMediaMetaData != null)\r
485                 //{\r
486 \r
487                 delete audioMediaMetaData;\r
488                 audioMediaMetaData = null;\r
489                 //}\r
490 \r
491         }\r
492         break;\r
493 \r
494         case FILE_TYPE_VIDEO_TYPE:\r
495         {\r
496                 String nameHeading;\r
497                 String sizeHeading;\r
498                 String formatHeading;\r
499                 String resolutionHeading;\r
500                 String dateCreatedHeading;\r
501                 String locationHeading;\r
502                 String size;\r
503 \r
504                 VideoMediaMetaData* videoMediaMetaData = static_cast< VideoMediaMetaData* >(__pMediaMetaData);\r
505                 TryCatch(videoMediaMetaData != null, , "Failed to allocate Video Media Meta Data");\r
506 \r
507                 pAppResource->GetString(L"IDS_MF_OPT_LISTBY_NAME", nameHeading);\r
508                 pNameHeading = new (std::nothrow) String(nameHeading);\r
509                 __pFileHeaderDetailList->Add(pNameHeading);\r
510 \r
511                 pFileName = new (std::nothrow) String(*(videoMediaMetaData->GetFileName()));\r
512                 __pFileDetailList->Add(pFileName);\r
513 \r
514 \r
515                 pAppResource->GetString(L"IDS_COM_BODY_SIZE", sizeHeading);\r
516                 pSizeHeading = new (std::nothrow) String(sizeHeading);\r
517                 __pFileHeaderDetailList->Add(pSizeHeading);\r
518 \r
519                 size = MfUtility::ConvertFileSizeToString(videoMediaMetaData->GetFileSize());\r
520                 pSize = new (std::nothrow) String(size);\r
521                 __pFileDetailList->Add(pSize);\r
522 \r
523 \r
524                 pAppResource->GetString(L"IDS_COM_BODY_FORMAT", formatHeading);\r
525                 pFormatHeading = new (std::nothrow) String(formatHeading);\r
526                 __pFileHeaderDetailList->Add(pFormatHeading);\r
527 \r
528                 pFormat = new (std::nothrow) String(*(videoMediaMetaData->GetFileFormat()));\r
529                 __pFileDetailList->Add(pFormat);\r
530 \r
531                 pAppResource->GetString(L"IDS_IDLE_BODY_RESOLUTION", resolutionHeading);\r
532                 pResolutionHeading = new (std::nothrow) String(resolutionHeading);\r
533                 __pFileHeaderDetailList->Add(pResolutionHeading);\r
534 \r
535                 pResolution = new (std::nothrow) String(*(videoMediaMetaData->GetFileResolution()));\r
536                 __pFileDetailList->Add(pResolution);\r
537 \r
538                 String dateAndTime = MfUtility::ConvertDateTimeToString(videoMediaMetaData->GetFileCreationTime());\r
539                 pAppResource->GetString(L"IDS_MF_BODY_CREATED_DATE", dateCreatedHeading);\r
540                 pDateCreateHeading = new (std::nothrow) String(dateCreatedHeading);\r
541                 __pFileHeaderDetailList->Add(pDateCreateHeading);\r
542 \r
543                 pDateAndTime = new (std::nothrow) String(dateAndTime);\r
544                 __pFileDetailList->Add(pDateAndTime);\r
545 \r
546                 pAppResource->GetString(L"IDS_COM_BODY_LOCATION", locationHeading);\r
547                 pLocationHeading = new (std::nothrow) String(locationHeading);\r
548                 __pFileHeaderDetailList->Add(pLocationHeading);\r
549 \r
550                 pFilePath = new (std::nothrow) String(*(videoMediaMetaData->GetFilePath()));\r
551                 __pFileDetailList->Add(pFilePath);\r
552 \r
553                 //if (videoMediaMetaData != null)\r
554                 //{\r
555 \r
556                 delete videoMediaMetaData;\r
557                 videoMediaMetaData = null;\r
558                 //}\r
559 \r
560         }\r
561         break;\r
562 \r
563         case FILE_TYPE_OTHER_TYPE:\r
564         {\r
565                 String nameHeading;\r
566                 String sizeHeading;\r
567                 String formatHeading;\r
568                 String dateCreatedHeading;\r
569                 String locationHeading;\r
570                 String size;\r
571                 OtherMediaMetaData* otherMediaMetaData = static_cast< OtherMediaMetaData* >(__pMediaMetaData);\r
572                 TryCatch(otherMediaMetaData != null, , "Failed to allocate Other Media Meta Data");\r
573 \r
574                 if (otherMediaMetaData != null)\r
575                 {\r
576                         pAppResource->GetString(L"IDS_MF_OPT_LISTBY_NAME", nameHeading);\r
577                         pNameHeading = new (std::nothrow) String(nameHeading);\r
578                         __pFileHeaderDetailList->Add(pNameHeading);\r
579 \r
580                         pFileName = new (std::nothrow) String(*(otherMediaMetaData->GetFileName()));\r
581                         __pFileDetailList->Add(pFileName);\r
582 \r
583                         size = MfUtility::ConvertFileSizeToString(otherMediaMetaData->GetFileSize());\r
584                         pAppResource->GetString(L"IDS_COM_BODY_SIZE", sizeHeading);\r
585                         pSizeHeading = new (std::nothrow) String(sizeHeading);\r
586                         __pFileHeaderDetailList->Add(pSizeHeading);\r
587 \r
588                         pSize = new (std::nothrow) String(size);\r
589                         __pFileDetailList->Add(pSize);\r
590 \r
591                         pAppResource->GetString(L"IDS_COM_BODY_FORMAT", formatHeading);\r
592                         pFormatHeading = new (std::nothrow) String(formatHeading);\r
593                         __pFileHeaderDetailList->Add(pFormatHeading);\r
594 \r
595                         pFormat = new (std::nothrow) String(*(otherMediaMetaData->GetFileFormat()));\r
596                         __pFileDetailList->Add(pFormat);\r
597 \r
598                         String dateAndTime = MfUtility::ConvertDateTimeToString(otherMediaMetaData->GetFileCreationTime());\r
599                         pAppResource->GetString(L"IDS_MF_BODY_CREATED_DATE", dateCreatedHeading);\r
600                         pDateCreateHeading = new (std::nothrow) String(dateCreatedHeading);\r
601                         __pFileHeaderDetailList->Add(pDateCreateHeading);\r
602 \r
603                         pDateAndTime = new (std::nothrow) String(dateAndTime);\r
604                         __pFileDetailList->Add(pDateAndTime);\r
605 \r
606                         pAppResource->GetString(L"IDS_COM_BODY_LOCATION", locationHeading);\r
607                         pLocationHeading = new (std::nothrow) String(locationHeading);\r
608                         __pFileHeaderDetailList->Add(pLocationHeading);\r
609 \r
610                         pFilePath = new (std::nothrow) String(*(otherMediaMetaData->GetFilePath()));\r
611                         __pFileDetailList->Add(pFilePath);\r
612 \r
613 \r
614                         delete otherMediaMetaData;\r
615                         otherMediaMetaData = null;\r
616                 }\r
617 \r
618         }\r
619         break;\r
620 \r
621         default:\r
622         {\r
623                 //Do Nothing.\r
624         }\r
625         break;\r
626         }\r
627         AppLogDebug("Exit %s", GetErrorMessage(GetLastResult()));\r
628         return;\r
629 \r
630 CATCH:\r
631         AppLogDebug("Exit");\r
632         return;\r
633 }\r
634 \r
635 \r
636 \r
637 void\r
638 DetailsForm::OnOrientationChanged(const Tizen::Ui::Control& source, Tizen::Ui::OrientationStatus orientationStatus)\r
639 {\r
640         Rectangle listViewBounds(GetClientAreaBounds().x, GetClientAreaBounds().y, GetClientAreaBounds().width, GetClientAreaBounds().height);\r
641 \r
642         switch (orientationStatus)\r
643         {\r
644         case ORIENTATION_STATUS_PORTRAIT:\r
645         {\r
646                 //Do Nothing\r
647         }\r
648         break;\r
649 \r
650         case ORIENTATION_STATUS_LANDSCAPE:\r
651         {\r
652                 //Do Nothing\r
653         }\r
654         break;\r
655 \r
656         default:\r
657                 //Do Nothing.\r
658                 break;\r
659         }\r
660 \r
661         Invalidate(true);\r
662 }\r
663 \r
664 int\r
665 DetailsForm::GetGroupCount(void)\r
666 {\r
667         return 1;\r
668 }\r
669 \r
670 int\r
671 DetailsForm::GetItemCount(int groupIndex)\r
672 {\r
673         if (__pFileDetailList != null)\r
674         {\r
675                 AppLogDebug("Exit %s", GetErrorMessage(GetLastResult()));\r
676                 return __pFileDetailList->GetCount();\r
677         }\r
678         else\r
679         {\r
680                 return 0;\r
681         }\r
682 }\r
683 \r
684 Tizen::Ui::Controls::GroupItem*\r
685 DetailsForm::CreateGroupItem(int groupIndex,\r
686                                                          int itemWidth)\r
687 {\r
688         GroupItem* pItem = new (std::nothrow) GroupItem();\r
689         pItem->Construct(Dimension(itemWidth, Y_DEFAULT));\r
690         pItem->SetElement(L"", null);\r
691 \r
692         return pItem;\r
693 }\r
694 \r
695 Tizen::Ui::Controls::ListItemBase*\r
696 DetailsForm::CreateItem(int groupIndex,\r
697                                                 int itemIndex,\r
698                                                 int itemWidth)\r
699 {\r
700 \r
701         result r = E_SUCCESS;\r
702         ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL;\r
703         String* pHeaderValue = null;\r
704         String* pValue = null;\r
705         CustomItem* pItem = null;\r
706         int w_Content = itemWidth - (2 * X_LISTVIEW);\r
707 \r
708         pItem = new (std::nothrow) CustomItem();\r
709         TryCatch(pItem != null, , "Failed to allocate Memory to pItem");\r
710 \r
711         pHeaderValue = static_cast< String* >(__pFileHeaderDetailList->GetAt(itemIndex));\r
712         pValue = static_cast< String* >(__pFileDetailList->GetAt(itemIndex));\r
713 \r
714         pItem->Construct(Dimension(itemWidth, H_DETAIL_LISTVIEW), style);\r
715         pItem->AddElement(Rectangle(X_LISTVIEW, Y_LISTVIEW, w_Content, H_LISTVIEW_ITEM_DESCRIPTION),\r
716                                           ID_FORMAT_DETAIL_TYPE,\r
717                                           pHeaderValue->GetPointer(),\r
718                                           ID_FONT_SIZE_32,\r
719                                           Color::GetColor(COLOR_ID_GREY),\r
720                                           Color::GetColor(COLOR_ID_GREY),\r
721                                           Color::GetColor(COLOR_ID_GREY),\r
722                                           true);\r
723         pItem->AddElement(Rectangle(X_LISTVIEW, Y_LISTVIEW + H_LISTVIEW_ITEM_DESCRIPTION, w_Content, H_LISTVIEW_ITEM_TITLE),\r
724                                           ID_FORMAT_DETAIL_VALUE,\r
725                                           pValue->GetPointer(),\r
726                                           ID_FONT_SIZE_44,\r
727                                           Color::GetColor(COLOR_ID_BLACK),\r
728                                           Color::GetColor(COLOR_ID_BLACK),\r
729                                           Color::GetColor(COLOR_ID_BLACK), true);\r
730 \r
731         pItem->SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_PRESSED,Color(246,249,239));\r
732         AppLogDebug("Exit %s", GetErrorMessage(r));\r
733         return pItem;\r
734 \r
735 CATCH:\r
736         AppLogDebug("Exit %s", GetErrorMessage(r));\r
737         return null;\r
738 }\r
739 \r
740 bool\r
741 DetailsForm::DeleteGroupItem(int groupIndex,\r
742                                                          Tizen::Ui::Controls::GroupItem* pItem,\r
743                                                          int itemWidth)\r
744 {\r
745         delete pItem;\r
746         pItem = null;\r
747         return true;\r
748 }\r
749 \r
750 bool\r
751 DetailsForm::DeleteItem(int groupIndex,\r
752                                                 int itemIndex,\r
753                                                 Tizen::Ui::Controls::ListItemBase* pItem,\r
754                                                 int itemWidth)\r
755 {\r
756         delete pItem;\r
757         pItem = null;\r
758         return true;\r
759 }\r
760 \r
761 void\r
762 DetailsForm::OnGroupedListViewContextItemStateChanged(Tizen::Ui::Controls::GroupedListView& listView, int groupIndex, int itemIndex, int elementId, Tizen::Ui::Controls::ListContextItemStatus state)\r
763 {\r
764         //Empty Implementation.\r
765 }\r
766 void\r
767 DetailsForm::OnGroupedListViewItemStateChanged(Tizen::Ui::Controls::GroupedListView& listView,\r
768                                                                                            int groupIndex,\r
769                                                                                            int itemIndex,\r
770                                                                                            int elementId,\r
771                                                                                            Tizen::Ui::Controls::ListItemStatus state)\r
772 {\r
773         //Empty Implementation.\r
774 }\r
775 void\r
776 DetailsForm::OnGroupedListViewItemSwept(Tizen::Ui::Controls::GroupedListView& listView,\r
777                                                                                 int groupIndex,\r
778                                                                                 int itemIndex,\r
779                                                                                 Tizen::Ui::Controls::SweepDirection direction)\r
780 {\r
781         //Empty Implementation.\r
782 }\r
783 \r
784 void\r
785 DetailsForm::OnGroupedListViewItemLongPressed(Tizen::Ui::Controls::GroupedListView& listView,\r
786                                                                                           int groupIndex,\r
787                                                                                           int itemIndex,\r
788                                                                                           int elementId,\r
789                                                                                           bool& invokeListViewItemCallback)\r
790 {\r
791         //Empty Implementation.\r
792 }\r
793 \r
794 void\r
795 DetailsForm::OnSceneTransitionCompleted(const Tizen::Ui::Scenes::SceneId &previousSceneId,\r
796                 const Tizen::Ui::Scenes::SceneId &currentSceneId)\r
797 {\r
798         SceneManager::GetInstance()->RemoveSceneManagerEventListener(*this);\r
799 \r
800         if (__pGroupedDetailListView != null)\r
801         {\r
802                 __pGroupedDetailListView->UpdateList();\r
803         }\r
804 }\r
805 \r
806 void\r
807 DetailsForm::OnSceneTransitionStarted(const Tizen::Ui::Scenes::SceneId &currentSceneId,\r
808                 const Tizen::Ui::Scenes::SceneId &nextSceneId)\r
809 {\r
810         //Empty Implementation.\r
811 }\r
812 \r
813 //void\r
814 //DetailsForm::OnDeviceChange(ComponentType deviceType, const Tizen::Base::String& state)\r
815 //{\r
816 //      bool setMediaPath = false;\r
817 //      bool searchHistoryStatus = false;\r
818 //      MemoryType currentMemoryType = MEMORY_TYPE_PHONE;\r
819 //      String unmounted = sdCardStatusUnmounted;\r
820 //      String removed = usbDeviceStatusRemoved;\r
821 //      String currentPath;\r
822 //      String searchScene;\r
823 //      SceneManager* pSceneManager = null;\r
824 //      IListT< SceneId >* pSceneList = null;\r
825 //      int itemCount = 0;\r
826 //\r
827 //      pSceneManager = SceneManager::GetInstance();\r
828 //\r
829 //      if (state == unmounted || state == removed)\r
830 //      {\r
831 //              currentPath = FolderNavigationPresentationModel::GetCurrentPath();\r
832 //              if (state == unmounted)\r
833 //              {\r
834 //                      if (currentPath.Contains(BasePresentationModel::GetSdCardPath()))\r
835 //                      {\r
836 //                              FolderNavigationPresentationModel::SetCurrentFilePath(BasePresentationModel::GetMediaPath());\r
837 //                              FolderNavigationPresentationModel::SetStorageType(currentMemoryType);\r
838 //                              setMediaPath = true;\r
839 //                      }\r
840 //              }\r
841 //\r
842 //              if (state == removed)\r
843 //              {\r
844 //                      if (currentPath.Contains(BasePresentationModel::GetUsbPath()))\r
845 //                      {\r
846 //                              FolderNavigationPresentationModel::SetCurrentFilePath(BasePresentationModel::GetMediaPath());\r
847 //                              FolderNavigationPresentationModel::SetStorageType(currentMemoryType);\r
848 //                              setMediaPath = true;\r
849 //                      }\r
850 //              }\r
851 //\r
852 //              if (setMediaPath)\r
853 //              {\r
854 //                      if (pSceneManager != null)\r
855 //                      {\r
856 //                              pSceneList = pSceneManager->GetSceneHistoryN();\r
857 //                      }\r
858 //\r
859 //                      if (pSceneList != null)\r
860 //                      {\r
861 //                              itemCount = pSceneList->GetCount() - 1;\r
862 //                              pSceneList->GetAt(itemCount, searchScene);\r
863 //                              while (searchScene != IDSCN_SEARCH_FORM && itemCount >= 0)\r
864 //                              {\r
865 //                                      itemCount--;\r
866 //                                      pSceneList->GetAt(itemCount, searchScene);\r
867 //                              }\r
868 //                      }\r
869 //\r
870 //                      if (searchScene == IDSCN_SEARCH_FORM)\r
871 //                      {\r
872 //                              AppLogDebug("Search scene present");\r
873 //                              searchHistoryStatus = true;\r
874 //                      }\r
875 //                      else\r
876 //                      {\r
877 //                              AppLogDebug("Search scene not present");\r
878 //                              searchHistoryStatus = false;\r
879 //                      }\r
880 //\r
881 //                      if(pSceneList)\r
882 //                      {\r
883 //                              pSceneList->RemoveAll();\r
884 //                              delete pSceneList;\r
885 //                              pSceneList = null;\r
886 //                      }\r
887 //\r
888 //                      if (searchHistoryStatus == true)\r
889 //                      {\r
890 //                              if (pSceneManager != null)\r
891 //                              {\r
892 //                                      pSceneManager->DestroyScene(IDSCN_SEARCH_FORM);\r
893 //                                      pSceneManager->ClearSceneHistory();\r
894 //                              }\r
895 //                      }\r
896 //\r
897 //                      if (pSceneManager != null)\r
898 //                      {\r
899 //                              pSceneManager->GoForward(ForwardSceneTransition(IDSCN_TEMP_FORM, SCENE_TRANSITION_ANIMATION_TYPE_NONE, SCENE_HISTORY_OPTION_NO_HISTORY, SCENE_DESTROY_OPTION_DESTROY), null);\r
900 //                      }\r
901 //              }\r
902 //      }\r
903 //}\r
904 \r
905 void\r
906 DetailsForm::OnDeviceStateChanged(Tizen::System::DeviceType deviceType, const Tizen::Base::String& state)\r
907 {\r
908         ComponentType currentDeviceType;\r
909         switch (deviceType)\r
910         {\r
911         case StorageCard:\r
912         {\r
913                 currentDeviceType = COMPONENT_TYPE_STORAGE_CARD;\r
914         }\r
915         break;\r
916 \r
917         case UsbClient:\r
918         {\r
919                 currentDeviceType = COMPONENT_TYPE_USB;\r
920         }\r
921         break;\r
922 \r
923         default:\r
924         {\r
925                 //Do Nothing.\r
926         }\r
927         break;\r
928         }\r
929 //      OnDeviceChange(currentDeviceType, state);\r
930 }\r