#include "define.h"
#include <InputHandler.h>
+#include <SortMgr.h>
+#include <Sort.h>
#include "category_info.h"
#include "album_info.h"
#include "song_info.h"
#define GENGRID_ITEM_SIZE_H (359+20)
+enum EObjectType {
+ CATEGORY_LAYOUT,
+ CATEGORY_LAYOUT_GENGRID,
+ CATEGORY_LAYOUT_GENLIST,
+ CATEGORY_LAYOUT_PLAY_BUTTON,
+ CATEGORY_LAYOUT_NEXT_BUTTON,
+ CATEGORY_LAYOUT_LAST_BUTTON,
+ CATEGORY_LAYOUT_SELECT_ALL_BUTTON,
+ CATEGORY_LAYOUT_DONE_BUTTON,
+ CATEGORY_LAYOUT_CANCEL_BUTTON
+};
+
enum EAddBtns {
ABTN_PLAY,
ABTN_NEXT,
const char *part;
const char *style;
const char *icon;
- Evas_Smart_Cb cb;
+ EObjectType type;
};
struct SCategoryLayout {
CMusicController *pMusicController;
CLayoutMgr *lmgr;
CViewMgr *vmgr;
- SSongInfo *c_sinfo;
+ CSongInfo *c_sinfo;
int total_duration;
int count;
idlist = m_GetSelectedList(m->it_infolist, (int)ID_TYPE_MEDIA);
str = strdup(name);
- destroy_entry_popup(t.epopup);
- t.epopup = NULL;
+ t.epopup->Destroy();
if (!strcmp(str, MUSIC_STR_EMPTY)) {
_create_message_box(Layout(), MUSIC_TEXT_EMPTY_NAME);
}
-void CCategoryLayout::sm_CbSelectAllClicked(void *dt, Evas_Object *obj, void *ev)
-{
- CCategoryLayout *root = (CCategoryLayout *)dt;
- if (root)
- root->m_OnSelectAllClicked(obj, ev);
-}
-
-
-void CCategoryLayout::m_OnSelectAllClicked(Evas_Object *obj, void *ev)
-{
- Eina_List *l = NULL;
- SCatItemInfo *itinfo = NULL;
- void *list_obj = NULL;
- int tc;
-
- tc = eina_list_count(m->it_infolist);
-
- if (m->count == tc) {
- elm_object_text_set(m->select_btn[SBTN_SELECT_ALL],
- _(MUSIC_TEXT_SELECT_ALL));
- m->count = 0;
- EINA_LIST_FOREACH(m->it_infolist, l, list_obj) {
- itinfo = (SCatItemInfo *)list_obj;
- itinfo->check_status = false;
- }
- elm_genlist_realized_items_update(m->glist);
-
- return;
- }
-
- elm_object_text_set(m->select_btn[SBTN_SELECT_ALL],
- _(MUSIC_TEXT_DESELECT_ALL));
- m->count = tc;
- EINA_LIST_FOREACH(m->it_infolist, l, list_obj) {
- itinfo = (SCatItemInfo *)list_obj;
- itinfo->check_status = true;
- }
- elm_genlist_realized_items_update(m->glist);
-}
-
-
-void CCategoryLayout::sm_CbDoneBtnClicked(void *dt, Evas_Object *obj, void *ev)
-{
- CCategoryLayout *root = (CCategoryLayout *)dt;
- if (root)
- root->m_OnDoneBtnClicked(obj, ev);
-}
-
-
-void CCategoryLayout::m_OnDoneBtnClicked(Evas_Object *obj, void *ev)
-{
- if (t.sel_type == SELECT_ADD) {
- m_AddSelectedSongs();
- return;
- }
- else if (t.sel_type == SELECT_REMOVE) {
- m_RemoveSelectedSongs();
- return;
- }
-
- if (t.epopup)
- destroy_entry_popup(t.epopup);
-
- t.epopup = create_entry_popup(t.base, MUSIC_STR_EMPTY,
- sm_CbEntrynameSet, this);
-}
-
-
-void CCategoryLayout::sm_CbCancelBtnClicked(void *dt, Evas_Object *obj, void *ev)
-{
- CCategoryLayout *root = (CCategoryLayout *)dt;
- if (root)
- root->m_OnCancelBtnClicked(obj, ev);
-}
-
-
-void CCategoryLayout::m_OnCancelBtnClicked(Evas_Object *obj, void *ev)
-{
- t.depth = E_DEPTH_CATEGORY;
- t_UpdateLayoutWithFocus();
-}
-
-
-void CCategoryLayout::sm_CbPlayBtnClicked(void *dt, Evas_Object *obj, void *ev)
-{
- CCategoryLayout *root = (CCategoryLayout *)dt;
- if (root)
- root->m_OnPlayBtnClicked(obj, ev);
-}
-
-
-void CCategoryLayout::m_OnPlayBtnClicked(Evas_Object *obj, void *ev)
-{
- m_GotoPlayback(ADD_TYPE_FRESH, NULL);
-}
-
-
-void CCategoryLayout::sm_CbNextBtnClicked(void *dt, Evas_Object *obj, void *ev)
-{
- CCategoryLayout *root = (CCategoryLayout *)dt;
- if (root)
- root->m_OnNextBtnClicked(obj, ev);
-}
-
-
-void CCategoryLayout::m_OnNextBtnClicked(Evas_Object *obj, void *ev)
-{
- m_GotoPlayback(ADD_TYPE_NEXT, NULL);
-}
-
-
-void CCategoryLayout::sm_CbLastBtnClicked(void *dt, Evas_Object *obj, void *ev)
-{
- CCategoryLayout *root = (CCategoryLayout *)dt;
- if (root)
- root->m_OnLastBtnClicked(obj, ev);
-}
-
-
-void CCategoryLayout::m_OnLastBtnClicked(Evas_Object *obj, void *ev)
-{
- m_GotoPlayback(ADD_TYPE_END, NULL);
-}
-
-
char *CCategoryLayout::sm_CbGetSelectlistItemText(void *data, Evas_Object *obj, const char *part)
{
SCatItemInfo *itinfo = (SCatItemInfo *)data;
return NULL;
if (!strcmp(part, "elm.text")) {
- str = song_info_get_title(itinfo->sinfo);
+ str = itinfo->sinfo->Name();
index = elm_genlist_item_index_get(itinfo->item);
if ((index & 1) == 1)
MUSIC_SIGNAL_CHECK_OFF, MUSIC_BASE_VIEW);
}
else if (!strcmp(part, "elm.text1")) {
- str = song_info_get_artist(itinfo->sinfo);
+ str = itinfo->sinfo->Artist();
}
else if (!strcmp(part, "elm.text2")) {
- str = song_info_get_album(itinfo->sinfo);
+ str = itinfo->sinfo->Album();
}
if (str)
char *CCategoryLayout::sm_CbGetListItemText(void *data, Evas_Object *obj, const char *part)
{
SCatItemInfo *itinfo = (SCatItemInfo *)data;
- SSongInfo *sinfo = NULL;
+ CSongInfo *sinfo = NULL;
char buf[MAX_LENGTH];
char *timestr = NULL;
int duration;
elm_object_item_signal_emit(itinfo->item,
MUSIC_SIGNAL_ODD_ROW, MUSIC_BASE_VIEW);
}
- snprintf(buf, sizeof(buf), "%d", index + 1);
+ snprintf(buf, sizeof(buf), "%d", index);
}
else if (!strcmp(part, "elm.text1")) {
- snprintf(buf, sizeof(buf), "%s", song_info_get_title(sinfo));
+ snprintf(buf, sizeof(buf), "%s", sinfo->Name());
}
else if (!strcmp(part, "elm.text2")) {
- snprintf(buf, sizeof(buf), "%s", song_info_get_artist(sinfo));
+ snprintf(buf, sizeof(buf), "%s", sinfo->Artist());
}
else if (!strcmp(part, "elm.text3")) {
- if (song_info_get_duration(sinfo, &duration)) {
- timestr = _get_timestr_from_milseconds(duration);
- if (timestr) {
- snprintf(buf, sizeof(buf), "%s", timestr);
- free(timestr);
- }
+ duration = sinfo->Duration();
+ timestr = _get_timestr_from_milseconds(duration);
+ if (timestr) {
+ snprintf(buf, sizeof(buf), "%s", timestr);
+ free(timestr);
}
}
return;
}
- if (m->c_sinfo) {
- song_info_destroy(m->c_sinfo);
- m->c_sinfo = NULL;
+ if (!m->c_sinfo) {
+ m->c_sinfo = new CSongInfo;
+ }
+
+ if (!m->c_sinfo->FlagCreate()) {
+ m->c_sinfo->Create();
}
- m->c_sinfo = song_info_duplicate(itinfo->sinfo);
+
+ m->c_sinfo->Duplicate(itinfo->sinfo);
if (!m->c_sinfo)
return;
- id = song_info_get_media_id(m->c_sinfo);
+ id = m->c_sinfo->Id();
if (!id) {
- song_info_destroy(m->c_sinfo);
+ m->c_sinfo->Destroy();
+ delete m->c_sinfo;
m->c_sinfo = NULL;
return;
}
}
-void CCategoryLayout::m_OnSelectlistItemSelect(Evas_Object *obj, void *event_info)
+void CCategoryLayout::m_OnSelectlistItemSelect(Evas_Object *obj, Elm_Object_Item *event_info)
{
SCatItemInfo *itinfo = NULL;
int tc;
{
Eina_List *list = NULL;
Eina_List *alist = NULL, *slist = NULL, *l = NULL, *sl = NULL;
- SSongInfo *sinfo = NULL;
- album_info *alinfo = NULL;
+ CSongInfo *sinfo = NULL;
+ CAlbumInfo *alinfo = NULL;
void *obj = NULL;
EAddType mode;
mode = ADD_TYPE_END;
if (t.depth == E_DEPTH_SONG) {
- sinfo = (SSongInfo *)t.ctxtinfo->context;
+ sinfo = (CSongInfo *)t.ctxtinfo->context;
list = eina_list_append(list, sinfo);
}
else if (t.depth == E_DEPTH_ALBUM) {
m->pMusicController->MediaGetList(LIST_TYPE_ALBUM_SONG,
t.ctxtinfo->context, &list);
- sinfo = (SSongInfo *)eina_list_data_get(list);
+ sinfo = (CSongInfo *)eina_list_data_get(list);
}
else {
- alist = category_info_get_albumlist((category_info *)t.ctxtinfo->context);
+ alist = ((CCategoryInfo *)t.ctxtinfo->context)->AlbumList();
EINA_LIST_FOREACH(alist, l, obj) {
- alinfo = (album_info *)obj;
+ alinfo = (CAlbumInfo *)obj;
slist = NULL;
if (!m->pMusicController->MediaGetList(LIST_TYPE_ALBUM_SONG, (void *)alinfo, &slist)) {
_ERR(" Failed to get album songlist ");
continue;
}
EINA_LIST_FOREACH(slist, sl, obj) {
- sinfo = (SSongInfo *)obj;
- list = eina_list_append(list,
- song_info_duplicate((SSongInfo *)sinfo));
+ sinfo = (CSongInfo *)obj;
+ CSongInfo *dupSongInfo = new CSongInfo;
+ dupSongInfo->Create();
+ dupSongInfo->Duplicate(sinfo);
+ list = eina_list_append(list, dupSongInfo);
}
eina_list_free(slist);
}
- sinfo = (SSongInfo *)eina_list_data_get(list);
+ sinfo = (CSongInfo *)eina_list_data_get(list);
}
if (type == ACTION_TYPE_ADDTO) {
if (t.depth == E_DEPTH_CATEGORY) {
EINA_LIST_FREE(list, obj) {
- sinfo = (SSongInfo *)obj;
- song_info_destroy(sinfo);
+ sinfo = (CSongInfo *)obj;
+ sinfo->Destroy();
+ delete sinfo;
}
}
m->pMusicController->UpdatePlaylist(list, mode);
if (type == ACTION_TYPE_PLAY) {
m->pMusicController->Stop();
- m->pMusicController->SetCurrentSong(song_info_get_media_id((SSongInfo *)sinfo));
+ m->pMusicController->SetCurrentSong(sinfo->Id());
}
if (t.depth == E_DEPTH_CATEGORY) {
EINA_LIST_FREE(list, obj) {
- sinfo = (SSongInfo *)obj;
- song_info_destroy(sinfo);
+ sinfo = (CSongInfo *)obj;
+ sinfo->Destroy();
+ delete sinfo;
}
}
else {
if (itinfo->type == CAT_TYPE_PLAYLIST_NEW)
return strdup(_(MUSIC_TEXT_CREATE_PLAYLIST));
- txt = category_info_get_name(itinfo->catinfo);
+ txt = itinfo->catinfo->Name();
if (txt)
return strdup(txt);
}
return NULL;
}
else if (itinfo->type == CAT_TYPE_PLAYLISTS) {
- scount = category_info_get_songcount(itinfo->catinfo);
+ scount = itinfo->catinfo->SongCount();
snprintf(buf, sizeof(buf), "%d %s", scount, _("Songs"));
}
else {
- acount = category_info_get_albumcount(itinfo->catinfo);
- scount = category_info_get_songcount(itinfo->catinfo);
+ acount = itinfo->catinfo->AlbumCount();
+ scount = itinfo->catinfo->SongCount();
snprintf(buf, sizeof(buf), "%d %s, %d %s", acount,
_("Albums"), scount, _("Songs"));
}
char *CCategoryLayout::sm_CbGetGridAlbumItemText(void *data, Evas_Object *obj, const char *part)
{
SCatItemInfo *itinfo = (SCatItemInfo *)data;
- album_info *alinfo = NULL;
+ CAlbumInfo *alinfo = NULL;
char *txt = NULL;
if (!itinfo || !obj || !part)
alinfo = itinfo->alinfo;
if (!strcmp(part, "elm.text")) {
- txt = album_info_get_name(alinfo);
+ txt = alinfo->Name();
if (txt)
return strdup(txt);
}
else if (!strcmp(part, "elm.text1")) {
if (itinfo->type == CAT_TYPE_ARTIST)
- txt = album_info_get_artist(alinfo);
+ txt = alinfo->Artist();
else
- txt = album_info_get_genre(alinfo);
+ txt = alinfo->Genre();
if (txt)
return strdup(txt);
}
Evas_Object *CCategoryLayout::sm_CbGetGridItemContent(void *data, Evas_Object *obj, const char *part)
{
SCatItemInfo *itinfo = (SCatItemInfo *)data;
- album_info *alinfo = NULL;
+ CAlbumInfo *alinfo = NULL;
void *list_obj = NULL;
Eina_List *l = NULL, *alist = NULL;
Evas_Object *img = NULL;
path = NULL;
if (itinfo->type == CAT_TYPE_ARTIST || itinfo->type == CAT_TYPE_GENRE) {
- alist = category_info_get_albumlist(itinfo->catinfo);
+ alist = itinfo->catinfo->AlbumList();
if (alist) {
EINA_LIST_FOREACH(alist, l, list_obj) {
- alinfo = (album_info *)list_obj;
- path = album_info_get_thumb(alinfo);
+ alinfo = (CAlbumInfo *)list_obj;
+ path = alinfo->ThumbnailPath();
if (path)
break;
}
}
}
else if (itinfo->type == CAT_TYPE_PLAYLISTS) {
- path = category_info_get_thumb(itinfo->catinfo);
+ path = itinfo->catinfo->ThumbnailPath();
}
if (!path) {
Evas_Object *CCategoryLayout::sm_CbGetGridAlbumitemContent(void *data, Evas_Object *obj, const char *part)
{
SCatItemInfo *itinfo = (SCatItemInfo *)data;
- album_info *alinfo = NULL;
+ CAlbumInfo *alinfo = NULL;
char *path = NULL;
Evas_Object *img = NULL;
char buf[MAX_LENGTH];
if (!img)
return NULL;
- path = album_info_get_thumb(alinfo);
+ path = alinfo->ThumbnailPath();
if (!path) {
snprintf(buf, sizeof(buf), "%s/%s", IMAGEDIR,
MUSIC_IMAGE_DEFAULT_THUMB_126);
}
if (t.depth == E_DEPTH_ALBUM) {
- if (t.c_alinfo) {
- album_info_destroy(t.c_alinfo);
- t.c_alinfo = NULL;
+ if (!t.c_alinfo) {
+ t.c_alinfo = new CAlbumInfo;
}
- t.c_alinfo = album_info_duplicate(itinfo->alinfo);
+
+ if (!t.c_alinfo->FlagCreate()) {
+ t.c_alinfo->Create();
+ }
+ t.c_alinfo->Duplicate(itinfo->alinfo);
t.depth = E_DEPTH_SONG;
}
else {
- if (t.c_catinfo) {
- category_info_destroy(t.c_catinfo);
- t.c_catinfo = NULL;
- }
+ if (t.c_catinfo && t.c_catinfo->FlagCreate())
+ t.c_catinfo->Destroy();
+
+ delete t.c_catinfo;
+ t.c_catinfo = NULL;
t_HandleItemSelect(itinfo);
}
}
-void CCategoryLayout::sm_CbGengridRealized(void *data, Evas_Object *obj, void *event_info)
-{
- if (!data || !obj || !event_info)
- return;
-
- elm_object_item_signal_callback_add((Elm_Object_Item *)event_info,
- MUSIC_SIGNAL_BTN_CLICKED, MUSIC_BASE_VIEW,
- sm_CbItemSelect, data);
-}
-
-
-void CCategoryLayout::sm_CbGengridUnrealized(void *data, Evas_Object *obj, void *event_info)
-{
- if (!data || !obj || !event_info)
- return;
-
- elm_object_item_signal_callback_del((Elm_Object_Item *)event_info,
- MUSIC_SIGNAL_BTN_CLICKED, MUSIC_BASE_VIEW,
- sm_CbItemSelect);
-}
-
-
-void CCategoryLayout::sm_CbKeyDown(void *dt, Evas *e, Evas_Object *obj, void *ei)
-{
- CCategoryLayout *root = (CCategoryLayout *)dt;
-
- if (root)
- root->m_OnKeyDown(e, obj, (Evas_Event_Key_Down*)ei);
-}
-
-
-void CCategoryLayout::m_OnKeyDown(Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev)
-{
- Elm_Object_Item *it = NULL;
- SContentInfo *ctxtinfo = NULL;
- SCatItemInfo *itinfo = NULL;
-
- if (!obj)
- return;
-
- if (strcmp(ev->keyname, KEY_MENU) || t.depth ==
- E_DEPTH_SELECT_LIST || t.depth ==
- E_DEPTH_SHOW_LIST)
- return;
-
- it = elm_object_focused_item_get(obj);
- if (!it) {
- _ERR(" unable to get focused item ");
- return;
- }
- t.focused_item = it;
-
- if (t.ctxtinfo) {
- free(t.ctxtinfo);
- t.ctxtinfo = NULL;
- }
-
- ctxtinfo = (SContentInfo *)calloc(1, sizeof(*ctxtinfo));
- if (!ctxtinfo)
- return;
-
- itinfo = m_FindItemInfo(m->it_infolist, it);
- if (!itinfo || itinfo->type == CAT_TYPE_PLAYLIST_NEW) {
- free(ctxtinfo);
- return;
- }
-
- ctxtinfo->cbdata = this;
- ctxtinfo->update = sm_CbCtxtUpdate;
- ctxtinfo->close = sm_CbCtxtClose;
- if (t.depth == E_DEPTH_SONG) {
- ctxtinfo->type = CONTEXT_TYPE_SONG;
- ctxtinfo->context = itinfo->sinfo;
- }
- else if (t.depth == E_DEPTH_ALBUM) {
- ctxtinfo->type = CONTEXT_TYPE_ALBUM;
- ctxtinfo->context = itinfo->alinfo;
- }
- else {
- ctxtinfo->type = t_ContextType();
- ctxtinfo->context = itinfo->catinfo;
- }
-
- t.ctxtinfo = ctxtinfo;
-
- SParcel parcel;
- parcel.ctxtInfo = ctxtinfo;
- if (!m->vmgr->PushView(MUSIC_CONTEXT_VIEW, &parcel))
- _ERR("viewmgr push view MUSIC_CONTEXT_VIEW failed");
-}
-
-
int CCategoryLayout::m_ConvertToMin(int milsec)
{
int min;
if (!itinfo->catinfo)
continue;
- id = category_info_get_category_id(itinfo->catinfo);
- if (id == category_info_get_category_id((category_info *)info))
+ id = itinfo->catinfo->CategoryId();
+ if (id == ((CCategoryInfo *)info)->CategoryId())
return itinfo->item;
}
continue;
if (eType == ID_TYPE_MEDIA) {
- id = song_info_get_media_id(itinfo->sinfo);
+ id = itinfo->sinfo->Id();
if (id)
idlist = eina_list_append(idlist, id);
}
Eina_List *idlist = NULL;
int lid;
- if (!t.c_catinfo)
+ if (!t.c_catinfo || !t.c_catinfo->FlagCreate())
return;
- lid = category_info_get_category_id(t.c_catinfo);
+ lid = t.c_catinfo->CategoryId();
idlist = m_GetSelectedList(m->it_infolist, (int)ID_TYPE_MEDIA);
if (!lid || !idlist)
Eina_List *idlist = NULL;
int lid;
- if (!t.c_catinfo)
+ if (!t.c_catinfo || !t.c_catinfo->FlagCreate())
return;
- lid = category_info_get_category_id(t.c_catinfo);
+ lid = t.c_catinfo->CategoryId();
idlist = m_GetSelectedList(m->it_infolist, (int)ID_TYPE_MEMBER);
if (!lid || !idlist)
Eina_List *l = NULL, *sl = NULL;
Eina_List *slist = NULL;
Eina_List *list = NULL;
- SSongInfo *sinfo = NULL;
+ CSongInfo *sinfo = NULL;
SCatItemInfo *itinfo = NULL;
void *obj = NULL;
Eina_List *infolist = m->it_infolist;
}
EINA_LIST_FOREACH(slist, sl, obj) {
- sinfo = (SSongInfo *)obj;
- list = eina_list_append(list,
- song_info_duplicate(sinfo));
+ sinfo = (CSongInfo *)obj;
+ CSongInfo *dupSongInfo = new CSongInfo;
+ dupSongInfo->Create();
+ dupSongInfo->Duplicate(sinfo);
+ list = eina_list_append(list, dupSongInfo);
}
eina_list_free(slist);
pMusicController->UpdatePlaylist(list, mode);
EINA_LIST_FREE(list, obj) {
- sinfo = (SSongInfo *)obj;
- song_info_destroy(sinfo);
+ sinfo = (CSongInfo *)obj;
+ sinfo->Destroy();
+ delete sinfo;
}
}
evas_object_size_hint_weight_set(grid,
EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_gengrid_align_set(grid, 0, 0);
- evas_object_event_callback_add(grid, EVAS_CALLBACK_MOUSE_MOVE, _gengrid_mouse_moved, this);
- evas_object_smart_callback_add(grid, MUSIC_SIGNAL_REALIZED, sm_CbGengridRealized, this);
- evas_object_smart_callback_add(grid, MUSIC_SIGNAL_UNREALIZED, sm_CbGengridUnrealized, this);
- evas_object_event_callback_add(grid, EVAS_CALLBACK_KEY_DOWN, sm_CbKeyDown, this);
+
+ Connect(grid, CATEGORY_LAYOUT_GENGRID, TYPE_MOUSE_MOVE | TYPE_KEY_DOWN | TYPE_REALIZED | TYPE_UNREALIZED | TYPE_ACTIVATED);
+
elm_gengrid_item_size_set(grid,
elm_config_scale_get() * GENGRID_ITEM_SIZE_W,
elm_config_scale_get() * GENGRID_ITEM_SIZE_H);
if (!itinfo)
return;
- itinfo->catinfo = (category_info *)info;
+ itinfo->catinfo = (CCategoryInfo *)info;
itinfo->type = type;
item = elm_gengrid_item_append(t.grid,
grid_item, itinfo, NULL, m);
btninfo[ABTN_PLAY].part = MUSIC_PART_CATEGORY_PLAYBTN;
btninfo[ABTN_PLAY].style = MUSIC_STYLE_ADD_PLAY_BTN;
btninfo[ABTN_PLAY].icon = MUSIC_IMAGE_ADD_PLAY;
- btninfo[ABTN_PLAY].cb = sm_CbPlayBtnClicked;
+ btninfo[ABTN_PLAY].type = CATEGORY_LAYOUT_PLAY_BUTTON;
btninfo[ABTN_NEXT].name = MUSIC_STR_ADDNEXT;
btninfo[ABTN_NEXT].part = MUSIC_PART_CATEGORY_NEXTBTN;
btninfo[ABTN_NEXT].style = MUSIC_STYLE_ADD_NEXT_BTN;
btninfo[ABTN_NEXT].icon = MUSIC_IMAGE_ADD_NEXT;
- btninfo[ABTN_NEXT].cb = sm_CbNextBtnClicked;
+ btninfo[ABTN_NEXT].type = CATEGORY_LAYOUT_NEXT_BUTTON;
btninfo[ABTN_LAST].name = MUSIC_STR_ADDLAST;
btninfo[ABTN_LAST].part = MUSIC_PART_CATEGORY_LASTBTN;
btninfo[ABTN_LAST].style = MUSIC_STYLE_ADD_LAST_BTN;
btninfo[ABTN_LAST].icon = MUSIC_IMAGE_ADD_LAST;
- btninfo[ABTN_LAST].cb = sm_CbLastBtnClicked;
+ btninfo[ABTN_LAST].type = CATEGORY_LAYOUT_LAST_BUTTON;
if (t.depth == E_DEPTH_SHOW_LIST) {
btninfo[ABTN_PLAY].part = MUSIC_PART_ALBUM_PLAYBTN;
EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_object_text_set(m->add_btn[i], _(btninfo[i].name));
elm_object_style_set(m->add_btn[i], btninfo[i].style);
- evas_object_smart_callback_add(m->add_btn[i],
- MUSIC_SIGNAL_CLICKED, btninfo[i].cb, this);
- evas_object_event_callback_add(m->add_btn[i],
- EVAS_CALLBACK_MOUSE_MOVE, _object_mouse_moved, this);
+
+ Connect(m->add_btn[i], btninfo[ABTN_LAST].type, TYPE_CLICKED | TYPE_MOUSE_MOVE);
img = elm_image_add(m->add_btn[i]);
if (img) {
btninfo[SBTN_SELECT_ALL].name = MUSIC_TEXT_SELECT_ALL;
btninfo[SBTN_SELECT_ALL].part = MUSIC_PART_LIST_SELECT_ALL;
btninfo[SBTN_SELECT_ALL].style = MUSIC_STYLE_LIST_BTN;
- btninfo[SBTN_SELECT_ALL].cb = sm_CbSelectAllClicked;
+ btninfo[SBTN_SELECT_ALL].type = CATEGORY_LAYOUT_SELECT_ALL_BUTTON;
btninfo[SBTN_DONE].name = MUSIC_TEXT_LIST_DONE;
btninfo[SBTN_DONE].part = MUSIC_PART_LIST_DONE_BTN;
btninfo[SBTN_DONE].style = MUSIC_STYLE_LIST_BTN;
- btninfo[SBTN_DONE].cb = sm_CbDoneBtnClicked;
+ btninfo[SBTN_DONE].type = CATEGORY_LAYOUT_DONE_BUTTON;
btninfo[SBTN_CANCEL].name = MUSIC_TEXT_LIST_CANCEL;
btninfo[SBTN_CANCEL].part = MUSIC_PART_LIST_CANCEL_BTN;
btninfo[SBTN_CANCEL].style = MUSIC_STYLE_LIST_BTN;
- btninfo[SBTN_CANCEL].cb = sm_CbCancelBtnClicked;
+ btninfo[SBTN_CANCEL].type = CATEGORY_LAYOUT_CANCEL_BUTTON;
if (t.sel_type == SELECT_CREATE) {
elm_object_part_text_set(Layout(), MUSIC_PART_LIST_MSG,
EVAS_HINT_EXPAND);
elm_object_text_set(btn, _(btninfo[i].name));
elm_object_style_set(btn, btninfo[i].style);
- evas_object_smart_callback_add(btn, MUSIC_SIGNAL_CLICKED,
- btninfo[i].cb, this);
- evas_object_event_callback_add(btn, EVAS_CALLBACK_MOUSE_MOVE,
- _object_mouse_moved, this);
+
+ Connect(btn, btninfo[i].type, TYPE_MOUSE_MOVE | TYPE_CLICKED);
elm_object_part_content_set(Layout(), btninfo[i].part, btn);
m->select_btn[i] = btn;
return;
if (t.depth == E_DEPTH_SHOW_LIST)
- path = category_info_get_thumb(t.c_catinfo);
+ path = t.c_catinfo->ThumbnailPath();
else
- path = album_info_get_thumb(t.c_alinfo);
+ path = t.c_alinfo->ThumbnailPath();
if (path) {
elm_image_file_set(m->albumCover, path, NULL);
if (t.depth == E_DEPTH_SHOW_LIST) {
elm_object_part_text_set(Layout(), MUSIC_PART_ALBUM_NAME,
- category_info_get_name(t.c_catinfo));
+ t.c_catinfo->Name());
}
else {
elm_object_part_text_set(Layout(),
MUSIC_PART_CATEGORY_NAME,
- category_info_get_name(t.c_catinfo));
+ t.c_catinfo->Name());
elm_object_part_text_set(Layout(), MUSIC_PART_ALBUM_NAME,
- album_info_get_name(t.c_alinfo));
+ t.c_alinfo->Name());
elm_object_part_text_set(Layout(), MUSIC_PART_ALBUM_ARTIST,
- album_info_get_artist(t.c_alinfo));
+ t.c_alinfo->Artist());
}
snprintf(buf, sizeof(buf), "%d %s",
Evas_Object *genlist = NULL;
Elm_Genlist_Item_Class *list_item = NULL;
bool r;
- struct SSongInfo *sinfo = NULL;
+ CSongInfo *sinfo = NULL;
void *obj = NULL;
Eina_List *l = NULL;
- struct SCatItemInfo *itinfo = NULL;
+ SCatItemInfo *itinfo = NULL;
Elm_Object_Item *item = NULL;
int dur;
void (*item_select_fn)(void *, Evas_Object *, void *) = NULL;
evas_object_size_hint_weight_set(genlist,
EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_object_part_content_set(Layout(), MUSIC_PART_SONGLIST, genlist);
- evas_object_event_callback_add(genlist, EVAS_CALLBACK_MOUSE_MOVE, _genlist_mouse_moved, this);
- evas_object_event_callback_add(genlist, EVAS_CALLBACK_KEY_DOWN, sm_CbKeyDown, this);
+
+ Connect(genlist, CATEGORY_LAYOUT_GENLIST, TYPE_MOUSE_MOVE | TYPE_KEY_DOWN | TYPE_ACTIVATED);
+
m->glist = genlist;
list_item = elm_genlist_item_class_new();
}
EINA_LIST_FOREACH(m->songlist, l, obj) {
- sinfo = (SSongInfo *)obj;
+ sinfo = (CSongInfo *)obj;
itinfo = (SCatItemInfo *)calloc(1, sizeof(*itinfo));
if (!itinfo)
return;
item_select_fn, this);
itinfo->item = item;
m->it_infolist = eina_list_append(m->it_infolist, itinfo);
- dur = 0;
- song_info_get_duration(sinfo, &dur);
+ dur = sinfo->Duration();
m->total_duration = m->total_duration + dur;
}
elm_genlist_item_class_free(list_item);
void CCategoryLayout::m_CreateAlbumgrid(void)
{
- album_info *alinfo = NULL;
+ CAlbumInfo *alinfo = NULL;
void *obj = NULL;
Eina_List *l = NULL;
SCatItemInfo *itinfo = NULL;
grid_item->func.state_get = NULL;
grid_item->func.del = sm_CbRemoveGridItem;
- m->alblist = category_info_get_albumlist(t.c_catinfo);
+ m->alblist = t.c_catinfo->AlbumList();
if (!m->alblist || eina_list_count(m->alblist) == 0) {
_ERR(" Fetching album list failed ");
evas_object_del(t.grid);
}
EINA_LIST_FOREACH(m->alblist, l, obj) {
- alinfo = (album_info *)obj;
+ alinfo = (CAlbumInfo *)obj;
itinfo = (SCatItemInfo *)calloc(1, sizeof(*itinfo));
if (!itinfo)
return;
elm_object_part_text_set(Layout(),
MUSIC_PART_CATEGORY_NAME,
- category_info_get_name(t.c_catinfo));
+ t.c_catinfo->Name());
snprintf(buf, sizeof(buf), "%d",
- category_info_get_albumcount(t.c_catinfo));
+ t.c_catinfo->AlbumCount());
elm_object_part_text_set(Layout(),
MUSIC_PART_CATEGORY_ALBUMCOUNT, buf);
snprintf(buf, sizeof(buf), "%d",
- category_info_get_songcount(t.c_catinfo));
+ t.c_catinfo->SongCount());
elm_object_part_text_set(Layout(),
MUSIC_PART_CATEGORY_SONGCOUNT, buf);
elm_object_part_content_set(Layout(),
void CCategoryLayout::m_SortCatgrid(void)
{
- int(*_sort[])(const void *d1, const void *d2) = {
- sortcategorys_az,
- sortcategorys_za
+ char *sortFuncType[] = {
+ SORT_BY_NAME_AZ,
+ SORT_BY_NAME_ZA
};
- int sort_type;
if (!m->catlist)
return;
- sort_type = m->pMusicController->SortType();
- m->catlist = eina_list_sort(m->catlist, 0,
- _sort[sort_type]);
+ int sortType;
+
+ sortType = m->pMusicController->SortType();
+ m->catlist = CSort::Sort(m->catlist, sortFuncType[sortType]);
}
void CCategoryLayout::m_EmptyLayout(bool sort_flag)
{
- if (t.grid)
+ if (t.grid) {
elm_gengrid_clear(t.grid);
+ evas_object_del(t.grid);
+ t.grid = NULL;
+ }
- if (m->glist)
+ if (m->glist) {
elm_genlist_clear(m->glist);
+ evas_object_del(m->glist);
+ m->glist = NULL;
+ }
if (!sort_flag) {
if (m->catlist) {
return false;
}
+ t.epopup = new CEntryPopup;
+ if (!t.epopup) {
+ _ERR(" CEntryPopup creation failed ");
+ CExtBaseLayout::Destroy();
+ evas_object_del(layout);
+ delete m;
+ m = NULL;
+ return false;
+ }
+
m->win = win;
t.base = base;
m->vmgr = vmgr;
t.depth = E_DEPTH_CATEGORY;
t_UpdateLayout(false);
- Connect(Layout());
+
+ Connect(Layout(), CATEGORY_LAYOUT, TYPE_KEY_DOWN);
return true;
}
ASSERT(m);
Disconnect(Layout());
- if (t.epopup)
- destroy_entry_popup(t.epopup);
+ if (t.epopup->FlagCreate())
+ t.epopup->Destroy();
m_RemoveFocusIdler();
m_EmptyLayout(false);
- category_info_destroy(t.c_catinfo);
- album_info_destroy(t.c_alinfo);
- song_info_destroy(m->c_sinfo);
+
+ if (t.c_catinfo && t.c_catinfo->FlagCreate())
+ t.c_catinfo->Destroy();
+ delete t.c_catinfo;
+
+ if (t.c_alinfo && t.c_alinfo->FlagCreate())
+ t.c_alinfo->Destroy();
+ delete t.c_alinfo;
+
+ if (m->c_sinfo && m->c_sinfo->FlagCreate())
+ m->c_sinfo->Destroy();
+ delete m->c_sinfo;
+
+ delete t.epopup;
CExtBaseLayout::Destroy();
evas_object_del(Layout());
if (t.depth != E_DEPTH_CATEGORY)
return;
t_UpdateLayout(true);
+ elm_object_part_content_set(t.base, MUSIC_PART_CONTENT, Layout());
+ evas_object_show(Layout());
return;
}
void CCategoryLayout::OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev)
{
- int count;
- Eina_List *alist = NULL;
+ switch (id) {
+ case CATEGORY_LAYOUT:
+ {
+ int count;
+ Eina_List *alist = NULL;
+
+ if (!strcmp(ev->keyname, KEY_BACK)) {
+ if (t.depth == E_DEPTH_CATEGORY) {
+ SParcel parcel;
+ parcel.ctxtInfo = NULL;
+ parcel.updateType = E_FOCUS_UPDATE;
+ parcel.layoutId = NULL;
+ parcel.keyEvent = NULL;
+ m->vmgr->UpdateView((const char *)MUSIC_BASE_VIEW, &parcel);
+ return;
+ }
+ else if (t.depth == E_DEPTH_ALBUM) {
+ t.depth = E_DEPTH_CATEGORY;
+ }
+ else if (t.depth == E_DEPTH_SELECT_LIST) {
+ t.depth = E_DEPTH_CATEGORY;
+ }
+ else if (t.depth == E_DEPTH_SHOW_LIST) {
+ t.depth = E_DEPTH_CATEGORY;
+ }
+ else if (t.depth == E_DEPTH_SONG) {
+ count = 0;
+ alist = t.c_catinfo->AlbumList();
+ if (alist)
+ count = eina_list_count(alist);
+ if (count == 1)
+ t.depth = E_DEPTH_CATEGORY;
+ else
+ t.depth = E_DEPTH_ALBUM;
+ }
+
+ t_UpdateLayoutWithFocus();
+ }
+ }
+ break;
+
+ case CATEGORY_LAYOUT_GENGRID:
+ case CATEGORY_LAYOUT_GENLIST:
+ {
+ Elm_Object_Item *it = NULL;
+ SContentInfo *ctxtinfo = NULL;
+ SCatItemInfo *itinfo = NULL;
+
+ if (!obj)
+ return;
+
+ if (strcmp(ev->keyname, KEY_MENU) || t.depth ==
+ E_DEPTH_SELECT_LIST || t.depth ==
+ E_DEPTH_SHOW_LIST)
+ return;
+
+ it = elm_object_focused_item_get(obj);
+ if (!it) {
+ _ERR(" unable to get focused item ");
+ return;
+ }
+ t.focused_item = it;
+
+ if (t.ctxtinfo) {
+ free(t.ctxtinfo);
+ t.ctxtinfo = NULL;
+ }
+
+ ctxtinfo = (SContentInfo *)calloc(1, sizeof(*ctxtinfo));
+ if (!ctxtinfo)
+ return;
+
+ itinfo = m_FindItemInfo(m->it_infolist, it);
+ if (!itinfo || itinfo->type == CAT_TYPE_PLAYLIST_NEW) {
+ free(ctxtinfo);
+ return;
+ }
+
+ ctxtinfo->cbdata = this;
+ ctxtinfo->update = sm_CbCtxtUpdate;
+ ctxtinfo->close = sm_CbCtxtClose;
+ if (t.depth == E_DEPTH_SONG) {
+ ctxtinfo->type = CONTEXT_TYPE_SONG;
+ ctxtinfo->context = itinfo->sinfo;
+ }
+ else if (t.depth == E_DEPTH_ALBUM) {
+ ctxtinfo->type = CONTEXT_TYPE_ALBUM;
+ ctxtinfo->context = itinfo->alinfo;
+ }
+ else {
+ ctxtinfo->type = t_ContextType();
+ ctxtinfo->context = itinfo->catinfo;
+ }
+
+ t.ctxtinfo = ctxtinfo;
- if (!strcmp(ev->keyname, KEY_BACK)) {
- if (t.depth == E_DEPTH_CATEGORY) {
SParcel parcel;
- parcel.ctxtInfo = NULL;
- parcel.updateType = E_FOCUS_UPDATE;
- parcel.layoutId = NULL;
- parcel.keyEvent = NULL;
- m->vmgr->UpdateView((const char *)MUSIC_BASE_VIEW, &parcel);
- return;
+ parcel.ctxtInfo = ctxtinfo;
+ if (!m->vmgr->PushView(MUSIC_CONTEXT_VIEW, &parcel))
+ _ERR("viewmgr push view MUSIC_CONTEXT_VIEW failed");
}
- else if (t.depth == E_DEPTH_ALBUM) {
- t.depth = E_DEPTH_CATEGORY;
+ break;
+
+ default:
+ break;
+ }
+}
+
+
+void CCategoryLayout::OnMouseMove(int id, Evas *e, Evas_Object *obj, Evas_Event_Mouse_Move *ev)
+{
+ switch (id) {
+ case CATEGORY_LAYOUT_GENGRID:
+ {
+ Elm_Object_Item *item;
+
+ if (!obj)
+ return;
+
+ item = elm_gengrid_at_xy_item_get(obj, ev->cur.canvas.x,
+ ev->cur.canvas.y, NULL, NULL);
+ if (!item)
+ return;
+
+ if (!elm_object_item_focus_get(item))
+ elm_object_item_focus_set(item, EINA_TRUE);
}
- else if (t.depth == E_DEPTH_SELECT_LIST) {
- t.depth = E_DEPTH_CATEGORY;
+ break;
+
+ case CATEGORY_LAYOUT_GENLIST:
+ {
+ Elm_Object_Item *item;
+
+ if (!obj)
+ return;
+
+ item = elm_genlist_at_xy_item_get(obj, ev->cur.canvas.x,
+ ev->cur.canvas.y, NULL);
+
+ if (!elm_object_item_focus_get(item))
+ elm_object_item_focus_set(item, EINA_TRUE);
+ }
+ break;
+
+ case CATEGORY_LAYOUT_PLAY_BUTTON:
+ case CATEGORY_LAYOUT_NEXT_BUTTON:
+ case CATEGORY_LAYOUT_LAST_BUTTON:
+ case CATEGORY_LAYOUT_SELECT_ALL_BUTTON:
+ case CATEGORY_LAYOUT_DONE_BUTTON:
+ case CATEGORY_LAYOUT_CANCEL_BUTTON:
+ if (!elm_object_focus_get(obj))
+ elm_object_focus_set(obj, EINA_TRUE);
+ break;
+
+ default:
+ break;
+ }
+}
+
+
+void CCategoryLayout::OnMouseClicked(int id, Evas_Object *obj)
+{
+ switch (id) {
+ case CATEGORY_LAYOUT_PLAY_BUTTON:
+ m_GotoPlayback(ADD_TYPE_FRESH, NULL);
+ break;
+
+ case CATEGORY_LAYOUT_NEXT_BUTTON:
+ m_GotoPlayback(ADD_TYPE_NEXT, NULL);
+ break;
+
+ case CATEGORY_LAYOUT_LAST_BUTTON:
+ m_GotoPlayback(ADD_TYPE_END, NULL);
+ break;
+
+ case CATEGORY_LAYOUT_SELECT_ALL_BUTTON:
+ {
+ Eina_List *l = NULL;
+ SCatItemInfo *itinfo = NULL;
+ void *list_obj = NULL;
+ int tc;
+
+ tc = eina_list_count(m->it_infolist);
+
+ if (m->count == tc) {
+ elm_object_text_set(m->select_btn[SBTN_SELECT_ALL],
+ _(MUSIC_TEXT_SELECT_ALL));
+ m->count = 0;
+ EINA_LIST_FOREACH(m->it_infolist, l, list_obj) {
+ itinfo = (SCatItemInfo *)list_obj;
+ itinfo->check_status = false;
+ }
+ elm_genlist_realized_items_update(m->glist);
+
+ return;
+ }
+
+ elm_object_text_set(m->select_btn[SBTN_SELECT_ALL],
+ _(MUSIC_TEXT_DESELECT_ALL));
+ m->count = tc;
+ EINA_LIST_FOREACH(m->it_infolist, l, list_obj) {
+ itinfo = (SCatItemInfo *)list_obj;
+ itinfo->check_status = true;
+ }
+ elm_genlist_realized_items_update(m->glist);
+ }
+ break;
+
+ case CATEGORY_LAYOUT_DONE_BUTTON:
+ {
+ if (t.sel_type == SELECT_ADD) {
+ m_AddSelectedSongs();
+ return;
+ }
+ else if (t.sel_type == SELECT_REMOVE) {
+ m_RemoveSelectedSongs();
+ return;
+ }
+
+ if (t.epopup->FlagCreate())
+ t.epopup->Destroy();
+
+ t.epopup->Create(t.base, MUSIC_STR_EMPTY, sm_CbEntrynameSet, this);
}
- else if (t.depth == E_DEPTH_SHOW_LIST) {
+ break;
+
+ case CATEGORY_LAYOUT_CANCEL_BUTTON:
+ {
t.depth = E_DEPTH_CATEGORY;
+ t_UpdateLayoutWithFocus();
}
- else if (t.depth == E_DEPTH_SONG) {
- count = 0;
- alist = category_info_get_albumlist(t.c_catinfo);
- if (alist)
- count = eina_list_count(alist);
- if (count == 1)
- t.depth = E_DEPTH_CATEGORY;
+ break;
+
+ default:
+ break;
+ }
+}
+
+
+void CCategoryLayout::OnRealized(int id, Evas_Object *obj, Elm_Object_Item *item)
+{
+ switch (id) {
+ case CATEGORY_LAYOUT_GENGRID:
+ elm_object_item_signal_callback_add(item,
+ MUSIC_SIGNAL_BTN_CLICKED, MUSIC_BASE_VIEW,
+ sm_CbItemSelect, this);
+ break;
+
+ default:
+ break;
+ }
+}
+
+
+void CCategoryLayout::OnUnrealized(int id, Evas_Object *obj, Elm_Object_Item *item)
+{
+ switch (id) {
+ case CATEGORY_LAYOUT_GENGRID:
+ elm_object_item_signal_callback_del(item,
+ MUSIC_SIGNAL_BTN_CLICKED, MUSIC_BASE_VIEW,
+ sm_CbItemSelect);
+ break;
+
+ default:
+ break;
+ }
+}
+
+
+void CCategoryLayout::OnActivated(int id, Evas_Object *obj, Elm_Object_Item *item)
+{
+ switch (id) {
+ case CATEGORY_LAYOUT_GENGRID:
+ m_OnItemSelect(item, NULL, NULL);
+ break;
+
+ case CATEGORY_LAYOUT_GENLIST:
+ {
+ if (t.depth == E_DEPTH_SELECT_LIST)
+ m_OnSelectlistItemSelect(obj, item);
else
- t.depth = E_DEPTH_ALBUM;
+ m_OnSongItemSelect(obj, item);
}
+ break;
- t_UpdateLayoutWithFocus();
+ default:
+ break;
}
-}
+}
\ No newline at end of file