1. Apply the new sort module to CSongLayout. 62/35162/5
authorKim Tae Soo <taesoo46.kim@samsung.com>
Tue, 10 Feb 2015 05:16:31 +0000 (14:16 +0900)
committerKim Tae Soo <taesoo46.kim@samsung.com>
Tue, 10 Feb 2015 06:25:13 +0000 (15:25 +0900)
2. Fix button ui issue

Change-Id: Ied1dd2bacf43630089083a8ccde6bd49fc2d40f9
Signed-off-by: Kim Tae Soo <taesoo46.kim@samsung.com>
include/common.h
include/song-layout.h
include/song_info.h
res/edc/widgets/button.edc
src/data/folder_info.cpp
src/data/song_info.cpp
src/main.cpp
src/views/entry-popup.cpp
src/views/folder-layout.cpp
src/views/song-layout.cpp

index 1d22aef..d0a76f8 100644 (file)
@@ -154,5 +154,10 @@ struct SParcel {
 #define KEY_BACK "Escape"
 #define KEY_MENU "Super_L"
 
+#define SORT_BY_ARTIST_AZ "SORT_BY_ARTIST_AZ"
+#define SORT_BY_ARTIST_ZA "SORT_BY_ARTIST_ZA"
+#define SORT_BY_ALBUM_AZ "SORT_BY_ALBUM_AZ"
+#define SORT_BY_ALBUM_ZA "SORT_BY_ALBUM_ZA"
+
 
 #endif /* __COMMON_H__ */
index 25e7d41..dba1312 100644 (file)
@@ -40,6 +40,11 @@ private:
        static void sm_CbItemSelect(void *data, Evas_Object *obj, void *event_info);
        void m_OnItemSelect(Evas_Object *obj, void *event_info);
 
+       static int sm_CbSortArtistAZ(const void *d1, const void *d2);
+       static int sm_CbSortArtistZA(const void *d1, const void *d2);
+       static int sm_CbSortAlbumAZ(const void *d1, const void *d2);
+       static int sm_CbSortAlbumZA(const void *d1, const void *d2);
+
 private:
        SSongItemInfo *m_FindItemInfoFromItem(Eina_List *list, Elm_Object_Item *item);
        void m_UpdateSongList(bool sort_flag);
index a9dd842..0e3a57e 100644 (file)
@@ -24,20 +24,11 @@ private:
        struct SSongInfo *m;
 
 public:
-       static int s_SortTitleAZ(const void *d1, const void *d2);
-       static int s_SortTitleZA(const void *d1, const void *d2);
-       static int s_SortArtistAZ(const void *d1, const void *d2);
-       static int s_SortArtistZA(const void *d1, const void *d2);
-       static int s_SortAlbumAZ(const void *d1, const void *d2);
-       static int s_SortAlbumZA(const void *d1, const void *d2);
-
-public:
        CSongInfo() : m(0) {}
        virtual ~CSongInfo() {}
 
        bool Create(void);
        virtual void Destroy(void);
-       bool FlagCreate(void);
 
        int MemberId(void);
        char *Artist(void);
index 192686d..6c881c2 100644 (file)
@@ -1685,7 +1685,7 @@ group {
                                min: 214 62;
                                image {
                                        normal: MUSIC_IMAGE_ADDBTN_BG_NORMAL;
-                                       border:  30 30 30 30;
+                                       border:  29 29 29 29;
                                        border_scale: 1;
                                }
                        }
index d25090e..3aa3c8d 100644 (file)
@@ -18,6 +18,7 @@
 #include <string.h>
 #include "dbg.h"
 #include "i18n.h"
+#include <NameInfo.h>
 #include "folder_info.h"
 
 struct folder_info *folder_info_create()
index 3305ee8..e239433 100644 (file)
@@ -34,120 +34,6 @@ struct SSongInfo {
 };
 
 
-int CSongInfo::s_SortTitleAZ(const void *d1, const void *d2)
-{
-       CSongInfo *sinfo1 = (CSongInfo *)d1;
-       CSongInfo *sinfo2 = (CSongInfo *)d2;
-       char *txt1;
-       char *txt2;
-
-       txt1 = sinfo1->Name();
-       txt2 = sinfo2->Name();
-
-       if (!txt1)
-               return 1;
-       if (!txt2)
-               return -1;
-
-       return strcasecmp(txt1, txt2);
-}
-
-
-int CSongInfo::s_SortTitleZA(const void *d1, const void *d2)
-{
-       CSongInfo *sinfo1 = (CSongInfo *)d1;
-       CSongInfo *sinfo2 = (CSongInfo *)d2;
-       char *txt1;
-       char *txt2;
-
-       txt1 = sinfo1->Name();
-       txt2 = sinfo2->Name();
-
-       if (!txt2)
-               return 1;
-       if (!txt1)
-               return -1;
-
-       return strcasecmp(txt2, txt1);
-}
-
-
-int CSongInfo::s_SortArtistAZ(const void *d1, const void *d2)
-{
-       CSongInfo *sinfo1 = (CSongInfo *)d1;
-       CSongInfo *sinfo2 = (CSongInfo *)d2;
-       char *txt1;
-       char *txt2;
-
-       txt1 = sinfo1->Artist();
-       txt2 = sinfo2->Artist();
-
-       if (!txt1)
-               return 1;
-       if (!txt2)
-               return -1;
-
-       return strcasecmp(txt1, txt2);
-}
-
-
-int CSongInfo::s_SortArtistZA(const void *d1, const void *d2)
-{
-       CSongInfo *sinfo1 = (CSongInfo *)d1;
-       CSongInfo *sinfo2 = (CSongInfo *)d2;
-       char *txt1;
-       char *txt2;
-
-       txt1 = sinfo1->Artist();
-       txt2 = sinfo2->Artist();
-
-       if (!txt2)
-               return 1;
-       if (!txt1)
-               return -1;
-
-       return strcasecmp(txt2, txt1);
-}
-
-
-int CSongInfo::s_SortAlbumAZ(const void *d1, const void *d2)
-{
-       CSongInfo *sinfo1 = (CSongInfo *)d1;
-       CSongInfo *sinfo2 = (CSongInfo *)d2;
-       char *txt1;
-       char *txt2;
-
-       txt1 = sinfo1->Album();
-       txt2 = sinfo2->Album();
-
-       if (!txt1)
-               return 1;
-       if (!txt2)
-               return -1;
-
-       return strcasecmp(txt1, txt2);
-}
-
-
-int CSongInfo::s_SortAlbumZA(const void *d1, const void *d2)
-{
-       CSongInfo *sinfo1 = (CSongInfo *)d1;
-       CSongInfo *sinfo2 = (CSongInfo *)d2;
-       char *txt1;
-       char *txt2;
-
-       txt1 = sinfo1->Album();
-       txt2 = sinfo2->Album();
-
-       if (!txt2)
-               return 1;
-       if (!txt1)
-               return -1;
-
-       return strcasecmp(txt2, txt1);
-}
-
-
 bool CSongInfo::Create(void)
 {
        if (m)
@@ -187,12 +73,6 @@ void CSongInfo::Destroy(void)
 }
 
 
-bool CSongInfo::FlagCreate(void)
-{
-       return !!m;
-}
-
-
 int CSongInfo::MemberId(void)
 {
        if (!m)
index f80c533..8110ca4 100644 (file)
@@ -18,6 +18,7 @@
 #include <Elementary.h>
 #include "dbg.h"
 #include <InputHandler.h>
+#include <SortMgr.h>
 #include "song_info.h"
 #include "music-controller.h"
 #include "define.h"
@@ -108,6 +109,7 @@ public:
        }
        virtual void OnTerminate(void)
        {
+               CSortMgr::Finalize();
                CViewMgr::Finalize();
                CMusicController::Finalize();
 
@@ -177,6 +179,8 @@ public:
                }
                _DBG("");
 
+               CSortMgr::Initialize();
+
                m_cBaseView = new CMusicBaseView(MUSIC_BASE_VIEW);
                m_cPlaybackView = new CPlaybackView(MUSIC_PLAYBACK_VIEW);
                m_cContextView = new CContextView(MUSIC_CONTEXT_VIEW);
index 8d88779..dda68f6 100644 (file)
@@ -61,17 +61,17 @@ bool CEntryPopup::Create(Evas_Object *base, const char *text, void(*cbEntryName)
        Evas_Object *layout, *entry;
 
        if (!base)
-               return NULL;
+               return false;
 
        m = new SEntryPopup;
        if (!m) {
-               return NULL;
+               return false;
        }
 
        layout = elm_layout_add(base);
        if (!layout) {
                delete m;
-               return NULL;
+               return false;
        }
 
        elm_layout_file_set(layout, EDJEFILE, MUSIC_ENTRY_POPUP_LAYOUT);
@@ -85,7 +85,7 @@ bool CEntryPopup::Create(Evas_Object *base, const char *text, void(*cbEntryName)
        if (!entry) {
                evas_object_del(layout);
                delete m;
-               return NULL;
+               return false;
        }
 
        elm_object_style_set(entry, MUSIC_STYLE_ENTRY);
@@ -109,6 +109,8 @@ bool CEntryPopup::Create(Evas_Object *base, const char *text, void(*cbEntryName)
        m->idler = ecore_idler_add(sm_CbFocusIdler, this);
 
        Connect(entry);
+
+       return true;
 }
 
 
index 6bbb78c..09f933b 100644 (file)
@@ -21,6 +21,8 @@
 #include "dbg.h"
 #include "i18n.h"
 #include "define.h"
+#include <SortMgr.h>
+#include <Sort.h>
 #include "folder_info.h"
 #include "song_info.h"
 
@@ -477,27 +479,28 @@ Elm_Object_Item *CFolderLayout::m_FindItemByInfo(Eina_List *list, folder_info *f
 
 void CFolderLayout::m_SortFolderGrid(void)
 {
-       int sort_type;
+       int sortType;
+
        int(*_sortfolders[])(const void *d1, const void *d2) = {
                sortfolders_az,
                sortfolders_za
        };
-       int(*_sortsongs[])(const void *d1, const void *d2) = {
-               CSongInfo::s_SortTitleAZ,
-               CSongInfo::s_SortTitleZA,
+
+       const char *songSortType[] = {
+               SORT_BY_NAME_AZ,
+               SORT_BY_NAME_ZA,
        };
 
        if (!m->flist)
                return;
 
-       sort_type = m->mhandle->SortType();
+       sortType = m->mhandle->SortType();
 
        if (m->depth == E_DEPTH_SONG)
-               m->flist = eina_list_sort(m->flist, 0,
-               _sortsongs[sort_type]);
+               m->flist = CSort::Sort(m->flist, songSortType[sortType]);
        else
                m->flist = eina_list_sort(m->flist, 0,
-               _sortfolders[sort_type]);
+               _sortfolders[sortType]);
 }
 
 
index e735962..0d697d6 100644 (file)
@@ -19,6 +19,8 @@
 #include <utilX.h>
 #include "AppCommon.h"
 #include "InputHandler.h"
+#include <SortMgr.h>
+#include <Sort.h>
 #include "dbg.h"
 #include "i18n.h"
 #include "define.h"
@@ -245,6 +247,82 @@ void CSongLayout::m_OnItemSelect(Evas_Object *obj, void *event_info)
 }
 
 
+int CSongLayout::sm_CbSortArtistAZ(const void *d1, const void *d2)
+{
+       CSongInfo *sinfo1 = (CSongInfo *)d1;
+       CSongInfo *sinfo2 = (CSongInfo *)d2;
+       char *txt1 = NULL;
+       char *txt2 = NULL;
+
+       txt1 = sinfo1->Artist();
+       if (!txt1)
+               return 1;
+
+       txt2 = sinfo2->Artist();
+       if (!txt2)
+               return -1;
+
+       return strcasecmp(txt1, txt2);
+}
+
+
+int CSongLayout::sm_CbSortArtistZA(const void *d1, const void *d2)
+{
+       CSongInfo *sinfo1 = (CSongInfo *)d1;
+       CSongInfo *sinfo2 = (CSongInfo *)d2;
+       char *txt1 = NULL;
+       char *txt2 = NULL;
+
+       txt1 = sinfo1->Artist();
+       if (!txt1)
+               return -1;
+
+       txt2 = sinfo2->Artist();
+       if (!txt2)
+               return 1;
+
+       return strcasecmp(txt2, txt1);
+}
+
+
+int CSongLayout::sm_CbSortAlbumAZ(const void *d1, const void *d2)
+{
+       CSongInfo *sinfo1 = (CSongInfo *)d1;
+       CSongInfo *sinfo2 = (CSongInfo *)d2;
+       char *txt1 = NULL;
+       char *txt2 = NULL;
+
+       txt1 = sinfo1->Album();
+       if (!txt1)
+               return 1;
+
+       txt2 = sinfo2->Album();
+       if (!txt2)
+               return -1;
+
+       return strcasecmp(txt1, txt2);
+}
+
+
+int CSongLayout::sm_CbSortAlbumZA(const void *d1, const void *d2)
+{
+       CSongInfo *sinfo1 = (CSongInfo *)d1;
+       CSongInfo *sinfo2 = (CSongInfo *)d2;
+       char *txt1 = NULL;
+       char *txt2 = NULL;
+
+       txt1 = sinfo1->Album();
+       if (!txt1)
+               return -1;
+
+       txt2 = sinfo2->Album();
+       if (!txt2)
+               return 1;
+
+       return strcasecmp(txt2, txt1);
+}
+
+
 SSongItemInfo *CSongLayout::m_FindItemInfoFromItem(Eina_List *list, Elm_Object_Item *item)
 {
        Eina_List *l;
@@ -302,20 +380,20 @@ void CSongLayout::m_UpdateSongList(bool sort_flag)
 
 void CSongLayout::m_SortSongList(void)
 {
-       int sort_type;
-
-       int(*_sort_fn[])(const void *d1, const void *d2) = {
-               CSongInfo::s_SortTitleAZ,
-               CSongInfo::s_SortTitleZA,
-               CSongInfo::s_SortArtistAZ,
-               CSongInfo::s_SortArtistZA,
-               CSongInfo::s_SortAlbumAZ,
-               CSongInfo::s_SortAlbumZA,
+       int sortType;
+
+       const char *sortFuncId[] = {
+               SORT_BY_NAME_AZ,
+               SORT_BY_NAME_ZA,
+               SORT_BY_ARTIST_AZ,
+               SORT_BY_ARTIST_ZA,
+               SORT_BY_ALBUM_AZ,
+               SORT_BY_ALBUM_ZA
        };
 
-       sort_type = m->mhandle->SortType();
+       sortType = m->mhandle->SortType();
 
-       m->slist = eina_list_sort(m->slist, 0, _sort_fn[sort_type]);
+       m->slist = CSort::Sort(m->slist, sortFuncId[sortType]);
 }
 
 void CSongLayout::m_EmptySongList(bool sort_flag)
@@ -462,6 +540,11 @@ bool CSongLayout::Create(CLayoutMgr *mgr, const char *uri)
                return false;
        }
 
+       CSortMgr::GetInstance()->RegisterSortFunction(SORT_BY_ARTIST_AZ, sm_CbSortArtistAZ);
+       CSortMgr::GetInstance()->RegisterSortFunction(SORT_BY_ARTIST_ZA, sm_CbSortArtistZA);
+       CSortMgr::GetInstance()->RegisterSortFunction(SORT_BY_ALBUM_AZ, sm_CbSortAlbumAZ);
+       CSortMgr::GetInstance()->RegisterSortFunction(SORT_BY_ALBUM_ZA, sm_CbSortAlbumZA);
+
        if (uri) {
                m->uri = new char[strlen(uri) + 1];
                strcpy(m->uri, uri);