45979
[apps/osp/Gallery.git] / src / GlAlbumListPresentationModel.cpp
index 4d39e5f..63a048f 100644 (file)
@@ -68,7 +68,7 @@ static const int GAP = 10;
 static const int HEIGHT_OFFSET = 5;
 static const int Y_POS_CANVAS = 260;
 static const int FOLDER_NAME_WIDTH = 165;
-static const int FOLDER_NAME_HEIGHT = 38 ;
+static const int FOLDER_NAME_HEIGHT = 38;
 
 
 static const int ALPHA_BG = 110;
@@ -110,6 +110,8 @@ AlbumListPresentationModel::~AlbumListPresentationModel(void)
 {
        AppLogDebug("ENTER");
        DeviceManager::RemoveDeviceEventListener(DEVICE_TYPE_STORAGE_CARD, *this);
+       delete __pFolderBackgroundBitmap;
+       delete __pContentManager;
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 }
 
@@ -321,16 +323,19 @@ AlbumListPresentationModel::RenameAlbum(const String& orgPath, const String& new
        return r;
 }
 
-void AlbumListPresentationModel::OnContentScanCompleted (const Tizen::Base::String &scanPath)\r
+bool AlbumListPresentationModel::OnContentScanCompleted (const Tizen::Base::String &scanPath)\r
 {
        AppLogDebug("ENTER");\r
-       if (__pAlbumListener && ( scanPath == __renameNewPath))\r
+       if (__pAlbumListener && (scanPath == __renameNewPath))\r
        {
                InitializeAlbumInfoList(CONTENT_TYPE_ALL);
                __pAlbumListener->OnAlbumRenameComplete();
                __renameNewPath = L"";
+               AppLogDebug("EXIT");
+               return true;
        }
        AppLogDebug("EXIT");
+       return false;
 }
 
 void
@@ -440,12 +445,14 @@ AlbumListPresentationModel::DrawFontImage(Canvas& canvas, AlbumInfo* pAlbumInfo,
        enTextCount.SetTextAbbreviationEnabled(true);
        enTextCount.Add(textElementCount);
 
-       pointText = Point(CANVAS_MARGIN_LEFT + CANVAS_IMAGE_FOLDER_WIDTH + GAP + FOLDER_NAME_WIDTH , rectCanvas.y + HEIGHT_OFFSET);
+       pointText = Point(CANVAS_MARGIN_LEFT + CANVAS_IMAGE_FOLDER_WIDTH + GAP + FOLDER_NAME_WIDTH,
+                       rectCanvas.y + HEIGHT_OFFSET);
        canvas.SetFont(ftCnt);
        canvas.SetForegroundColor(Color::GetColor(COLOR_ID_WHITE));
        canvas.DrawText(pointText, enTextCount);
 
-       pointText = Point(CANVAS_MARGIN_LEFT + CANVAS_IMAGE_FOLDER_WIDTH + GAP , rectCanvas.y + GAP + HEIGHT_OFFSET);
+       pointText = Point(CANVAS_MARGIN_LEFT + CANVAS_IMAGE_FOLDER_WIDTH + GAP,
+                       rectCanvas.y + GAP + HEIGHT_OFFSET);
        canvas.SetForegroundColor(Color::GetColor(COLOR_ID_WHITE));
        canvas.DrawText(pointText, enText);
 
@@ -534,7 +541,7 @@ AlbumListPresentationModel::GetDirectoryName(String& directoryPath) const
 {
        AppLogDebug("ENTER");
        String directoryName;
-       int lastIndex = -1 ;
+       int lastIndex = -1;
 
        directoryPath.LastIndexOf(DIRECTORY_SEPARATOR, directoryPath.GetLength() - 1, lastIndex);
        directoryPath.SubString(lastIndex + 1, directoryName);
@@ -674,6 +681,8 @@ AlbumListPresentationModel::InitializeAlbumInfoList(const ContentType& contentTy
 
                                        pAllAlbumInfo->AppendDirectory(*pDirPath);
                                        pAllAlbumInfo->AppendContentIdList(*pContentIdList);
+
+                                       pContentIdList->RemoveAll(true);
                                        delete pContentIdList;
                                }
                        }
@@ -688,6 +697,8 @@ AlbumListPresentationModel::InitializeAlbumInfoList(const ContentType& contentTy
 
                                        pAllAlbumInfo->AppendDirectory(*pDirPath);
                                        pAllAlbumInfo->AppendContentIdList(*pContentIdList);
+
+                                       pContentIdList->RemoveAll(true);
                                        delete pContentIdList;
                                }
                        }
@@ -709,13 +720,21 @@ AlbumListPresentationModel::InitializeAlbumInfoList(const ContentType& contentTy
 
                                                pAllAlbumInfo->AppendDirectory(*pDirPath);
                                                pAllAlbumInfo->AppendContentIdList(*pContentIdList);
+
+                                               pSubDirList->RemoveAll(true);
                                                delete pSubDirList;
                                        }
-                                       delete pContentIdList;
+
+                                       if (pContentIdList != NULL)
+                                       {
+                                               pContentIdList->RemoveAll(true);
+                                               delete pContentIdList;
+                                       }
                                }
                                if (pAlbumInfo != null && pAlbumInfo->GetContentIdCount() > 0)
                                {
                                        __pAlbumInfoList->Add(pAlbumInfo);
+                                       AppLog("Adding album");
                                }
                                else
                                {
@@ -774,32 +793,22 @@ AlbumListPresentationModel::InitializeAlbumInfoList(const ContentType& contentTy
 
        if (pContentDirectoryPathList != null)
        {
+               pContentDirectoryPathList->RemoveAll(true);
                delete pContentDirectoryPathList;
        }
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
        return;
 
 CATCH:
-       if (pContentDirectoryPathList != null)
-       {
-               delete pContentDirectoryPathList;
-       }
-       if (pAllAlbumInfo != null)
-       {
-               delete pAllAlbumInfo;
-       }
-       if (pCameraAlbumInfo != null)
-       {
-               delete pCameraAlbumInfo;
-       }
-       if (pDownloadAlbumInfo != null)
-       {
-               delete pDownloadAlbumInfo;
-       }
-       if (pNoNameAlbumInfo != null)
-       {
-               delete pNoNameAlbumInfo;
-       }
+if (pContentDirectoryPathList != null)
+{
+       pContentDirectoryPathList->RemoveAll(true);
+       delete pContentDirectoryPathList;
+}
+       delete pAllAlbumInfo;
+       delete pCameraAlbumInfo;
+       delete pDownloadAlbumInfo;
+       delete pNoNameAlbumInfo;
 }
 
 String
@@ -878,7 +887,13 @@ AlbumListPresentationModel::GetContentIdListInDirectoryN(const String& directory
                }
                delete pEnum;
        }
-       delete pContentInfoList;
+
+       if (pContentInfoList != NULL)
+       {
+               pContentInfoList->RemoveAll(true);
+               delete pContentInfoList;
+       }
+
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 
        return pContentIdList;
@@ -1020,12 +1035,10 @@ AlbumListPresentationModel::OnThumbnailReceivedN(IEventArg& eventArg)
                if (__pAlbumInfoList != null)
                {
                        int outterLoopCount = __pAlbumInfoList->GetCount();
-                       AppLogDebug("rashmi outterLoopCount(%d)", outterLoopCount);
                        for (int x = 0; x < outterLoopCount; ++x)
                        {
                                AlbumInfo* pAlbumInfo = static_cast<AlbumInfo*>(__pAlbumInfoList->GetAt(x));
                                int innerLoopCount = pAlbumInfo->GetContentIdCount();
-                               AppLogDebug("rashmi innerLoopCount(%d)", innerLoopCount);
                                for (int i = 0; i < innerLoopCount; ++i)
                                {
                                        if (i >= FOLDER_BITMAP_MAX)
@@ -1039,16 +1052,7 @@ AlbumListPresentationModel::OnThumbnailReceivedN(IEventArg& eventArg)
                                                {
                                                        pAlbumInfo->SetFolderThumnailBitmap(pThumbnailInfo->GetBitmapN());
                                                        pUpdateFolderIndex->Add(new (std::nothrow) Integer(x));
-                                                       AppLogDebug("rashmi adding(%d)", x);
                                                }
-                                               else
-                                               {
-                                                       AppLogDebug("rashmi GetFolderThumnailBitmap is not null(%d)", innerLoopCount);
-                                               }
-                                       }
-                                       else
-                                       {
-                                               AppLogDebug("rashmi contetentid not same(%d)", innerLoopCount);
                                        }
                                }
                        }
@@ -1063,8 +1067,6 @@ AlbumListPresentationModel::OnThumbnailReceivedN(IEventArg& eventArg)
                                pListener = static_cast<IAlbumEventListener*>(pEnum->GetCurrent());
 
                                int loopCount = pUpdateFolderIndex->GetCount();
-                               AppLogDebug("rashmi loopCount(%d)", loopCount);
-       //                      int loopCount = __pAlbumInfoList->GetCount();
                                for (int k = 0; k < loopCount; ++k)
                                {
                                        Integer *pIndex = (Integer*)pUpdateFolderIndex->GetAt(k);