summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLarry Jr <larry.olj@gmail.com>2015-05-25 20:09:53 -0300
committerLarry Jr <larry.olj@gmail.com>2015-05-25 20:09:53 -0300
commitc47d9af3ae3dd6d58a7c511f493158ab69abdfd9 (patch)
tree7851a0a43570578a73d3c9befaf1509d49bf55fe
parent519d352be99eac78da79bb1d56fb4d33516e9e25 (diff)
fixed change audio playlistHEADmaster
-rw-r--r--src/audiolist.cc20
-rw-r--r--src/audiolistmodel.cc3
-rw-r--r--src/picture_resizer.cc6
-rw-r--r--src/playlistmodel.cc54
-rw-r--r--src/playlistmodel.hh11
-rw-r--r--src/settingsmodel.cc2
6 files changed, 60 insertions, 36 deletions
diff --git a/src/audiolist.cc b/src/audiolist.cc
index 99589a6..178145a 100644
--- a/src/audiolist.cc
+++ b/src/audiolist.cc
@@ -100,7 +100,7 @@ audiolist::audiolist(::emc::database &database, settingsmodel &_settings, const
100 std::bind([this] 100 std::bind([this]
101 { 101 {
102 std::cout << "playlist selected cb" << std::endl; 102 std::cout << "playlist selected cb" << std::endl;
103//XXX FIXME TODO view.model_set(playlist); 103 view.model_set(playlist);
104 } 104 }
105 )); 105 ));
106 106
@@ -177,13 +177,15 @@ audiolist::playback_update()
177 177
178 layout.signal_emit("audiolist.playlist.playing", ""); 178 layout.signal_emit("audiolist.playlist.playing", "");
179 auto track = playlist.curr(); 179 auto track = playlist.curr();
180 model.artist_get(track, [this, track](esql::model_row& artist) 180 if (track._eo_ptr() != NULL) {
181 { 181 model.artist_get(track, [this, track](esql::model_row& artist)
182 std::string artist_name, name; 182 {
183 emc::emodel_helpers::property_get(track, "name", name); 183 std::string artist_name, name;
184 emc::emodel_helpers::property_get(artist, "name", artist_name); 184 emc::emodel_helpers::property_get(track, "name", name);
185 layout.text_set("audiolist/track", name+" by "+artist_name); 185 emc::emodel_helpers::property_get(artist, "name", artist_name);
186 }); 186 layout.text_set("audiolist/track", name+" by "+artist_name);
187 });
188 }
187 189
188 const Eina_Value *value; 190 const Eina_Value *value;
189 if (track.property_get("artwork", &value)) { 191 if (track.property_get("artwork", &value)) {
@@ -225,9 +227,9 @@ audiolist::list_activated_cb()
225 efl::model::base m(nullptr); 227 efl::model::base m(nullptr);
226 view.model_get(&m); 228 view.model_get(&m);
227 auto l = emc::emodel_helpers::children_get<esql::model_row>(m); 229 auto l = emc::emodel_helpers::children_get<esql::model_row>(m);
228 m._release();
229 playlist.list_set(l); 230 playlist.list_set(l);
230 playlist.play(row_selected); 231 playlist.play(row_selected);
232 m._release();
231 } 233 }
232} 234}
233 235
diff --git a/src/audiolistmodel.cc b/src/audiolistmodel.cc
index fc7dba7..559db80 100644
--- a/src/audiolistmodel.cc
+++ b/src/audiolistmodel.cc
@@ -125,7 +125,6 @@ audiolistmodel::artist_get(esql::model_row& row, std::function<void(esql::model_
125 int64_t id_artist = emc::database::INVALID_ID; 125 int64_t id_artist = emc::database::INVALID_ID;
126 126
127 emodel_helpers::property_get(row, "id_artist", id_artist); 127 emodel_helpers::property_get(row, "id_artist", id_artist);
128
129 if (database::INVALID_ID != id_artist) 128 if (database::INVALID_ID != id_artist)
130 { 129 {
131 std::stringstream buffer; 130 std::stringstream buffer;
@@ -139,7 +138,7 @@ audiolistmodel::artist_get(esql::model_row& row, std::function<void(esql::model_
139 const Efl_Model_Load &st = *static_cast<Efl_Model_Load*>(info); 138 const Efl_Model_Load &st = *static_cast<Efl_Model_Load*>(info);
140 if (st.status & EFL_MODEL_LOAD_STATUS_LOADED) 139 if (st.status & EFL_MODEL_LOAD_STATUS_LOADED)
141 { 140 {
142 connection->disconnect(); 141 //FIXME connection->disconnect();
143 auto children = emodel_helpers::children_get<esql::model_row>(artists); 142 auto children = emodel_helpers::children_get<esql::model_row>(artists);
144 if (children.empty()) 143 if (children.empty())
145 return; 144 return;
diff --git a/src/picture_resizer.cc b/src/picture_resizer.cc
index e18162e..af6b5d4 100644
--- a/src/picture_resizer.cc
+++ b/src/picture_resizer.cc
@@ -229,6 +229,12 @@ picture_resizer::reset(size_t w, size_t h)
229bool 229bool
230picture_resizer::load(const std::vector<unsigned char> &buffer) 230picture_resizer::load(const std::vector<unsigned char> &buffer)
231{ 231{
232 if (buffer.size() == 0)
233 {
234 DBG << "Invalid buffer size.";
235 return false;
236 }
237
232 evas_object_image_load_orientation_set(img, EINA_TRUE); 238 evas_object_image_load_orientation_set(img, EINA_TRUE);
233 evas_object_image_memfile_set(img, 239 evas_object_image_memfile_set(img,
234 const_cast<unsigned char*>(buffer.data()), 240 const_cast<unsigned char*>(buffer.data()),
diff --git a/src/playlistmodel.cc b/src/playlistmodel.cc
index 7efe925..c04a3aa 100644
--- a/src/playlistmodel.cc
+++ b/src/playlistmodel.cc
@@ -46,11 +46,12 @@ playlist_open_done_cb(void *data, Evas_Object *obj, void *event_info)
46} 46}
47 47
48playlistmodel::playlistmodel(settingsmodel &_settings) 48playlistmodel::playlistmodel(settingsmodel &_settings)
49 // FIXME TODO XXX : inherit_base(efl::eo::args< ::efl::model::base>(efl::eo::parent = nullptr)), 49 : inherit_base(),
50 // : inherit_base(), 50 settings (_settings),
51 : settings (_settings),
52 player(settings.player) 51 player(settings.player)
53{ 52{
53
54 current_track == tracks.begin();
54 auto emotion = player.emotion_get(); 55 auto emotion = player.emotion_get();
55 if (emotion) 56 if (emotion)
56 evas_object_smart_callback_add(emotion._eo_ptr(), "playback_finished", playback_finished_cb, this); //FIXME 57 evas_object_smart_callback_add(emotion._eo_ptr(), "playback_finished", playback_finished_cb, this); //FIXME
@@ -64,6 +65,7 @@ playlistmodel::list_set(std::vector<esql::model_row> tracks_)
64 { 65 {
65 tracks.push_back(track); 66 tracks.push_back(track);
66 } 67 }
68 current_track == tracks.begin();
67} 69}
68 70
69void 71void
@@ -76,7 +78,6 @@ Efl_Model_Load_Status
76playlistmodel::children_slice_get(unsigned start, unsigned count, Eina_Accessor ** children_accessor) 78playlistmodel::children_slice_get(unsigned start, unsigned count, Eina_Accessor ** children_accessor)
77{ 79{
78 *children_accessor = eina_list_accessor_new(tracks.native_handle()); 80 *children_accessor = eina_list_accessor_new(tracks.native_handle());
79 //*children_accessor = NULL;
80 return EFL_MODEL_LOAD_STATUS_LOADED; 81 return EFL_MODEL_LOAD_STATUS_LOADED;
81} 82}
82 83
@@ -90,31 +91,46 @@ playlistmodel::children_count_get(unsigned* children_count)
90void 91void
91playlistmodel::play(esql::model_row track) 92playlistmodel::play(esql::model_row track)
92{ 93{
93 play(std::find(tracks.begin(), tracks.end(), track)); 94 auto itrack = std::find(tracks.begin(), tracks.end(), track);
95 if (itrack != tracks.end()) {
96 play(itrack);
97 return;
98 }
99
100 std::string path;
101 if (emc::emodel_helpers::property_get(track, "file", path)) {
102 auto emotion = player.emotion_get();
103 if (emotion)
104 evas_object_smart_callback_add(emotion._eo_ptr(), "open_done", playlist_open_done_cb, this); //FIXME
105 player.file_set(path, "");
106 }
94} 107}
95 108
96esql::model_row 109void
97playlistmodel::play(efl::eina::list<esql::model_row>::iterator track) 110playlistmodel::play(efl::eina::list<esql::model_row>::iterator track)
98{ 111{
99 std::string path; 112 std::string path;
113
114 if (track == tracks.end()) {
115 return;
116 }
117
118 current_track = track;
100 if (emc::emodel_helpers::property_get(*track, "file", path)) { 119 if (emc::emodel_helpers::property_get(*track, "file", path)) {
101 auto emotion = player.emotion_get(); 120 auto emotion = player.emotion_get();
102 if (emotion) 121 if (emotion)
103 evas_object_smart_callback_add(emotion._eo_ptr(), "open_done", playlist_open_done_cb, this); //FIXME 122 evas_object_smart_callback_add(emotion._eo_ptr(), "open_done", playlist_open_done_cb, this); //FIXME
104 player.file_set(path, ""); 123 player.file_set(path, "");
105 current_track = track;
106 } 124 }
107 return *current_track;
108} 125}
109 126
110esql::model_row 127void
111playlistmodel::play() 128playlistmodel::play()
112{ 129{
113 if (player.play_position_get() == 0) 130 if (player.play_position_get() == 0)
114 return play(current_track); 131 return play(current_track);
115 132
116 player.play(); 133 player.play();
117 return *current_track;
118} 134}
119 135
120void 136void
@@ -123,28 +139,30 @@ playlistmodel::pause()
123 player.pause(); 139 player.pause();
124} 140}
125 141
126esql::model_row 142void
127playlistmodel::play_next() 143playlistmodel::play_next()
128{ 144{
145 if (current_track == tracks.end())
146 return;
147
129 auto next = std::next(current_track); 148 auto next = std::next(current_track);
130 if (next != tracks.end()) 149 if (next != tracks.end())
131 return play(next); 150 play(next);
132
133 return *current_track;
134} 151}
135 152
136esql::model_row 153void
137playlistmodel::play_prev() 154playlistmodel::play_prev()
138{ 155{
139 if (current_track != tracks.begin()) 156 if (current_track != tracks.begin())
140 return play(std::prev(current_track)); 157 play(std::prev(current_track));
141
142 return *current_track;
143} 158}
144 159
145esql::model_row 160esql::model_row
146playlistmodel::curr() 161playlistmodel::curr()
147{ 162{
163 if (current_track == tracks.end())
164 return esql::model_row(nullptr);
165
148 return *current_track; 166 return *current_track;
149} 167}
150 168
diff --git a/src/playlistmodel.hh b/src/playlistmodel.hh
index 90ba7e3..26ef17d 100644
--- a/src/playlistmodel.hh
+++ b/src/playlistmodel.hh
@@ -19,8 +19,7 @@
19namespace emc { 19namespace emc {
20 20
21class playlistmodel 21class playlistmodel
22 //: public efl::eo::inherit<playlistmodel, ::eo::base, ::efl::model::base> 22 : public efl::eo::inherit<playlistmodel, ::eo::base, ::efl::model::base>
23 //: public efl::eo::inherit<playlistmodel, ::esql::model_database>
24{ 23{
25 efl::eina::list<esql::model_row> tracks; 24 efl::eina::list<esql::model_row> tracks;
26 efl::eina::list<esql::model_row>::iterator current_track; 25 efl::eina::list<esql::model_row>::iterator current_track;
@@ -49,10 +48,10 @@ class playlistmodel
49 void track_add(esql::model_row track); 48 void track_add(esql::model_row track);
50 void play(esql::model_row track); 49 void play(esql::model_row track);
51 void pause(); 50 void pause();
52 esql::model_row play(); 51 void play();
53 esql::model_row play(efl::eina::list<esql::model_row>::iterator track); 52 void play(efl::eina::list<esql::model_row>::iterator track);
54 esql::model_row play_next(); 53 void play_next();
55 esql::model_row play_prev(); 54 void play_prev();
56 esql::model_row curr(); 55 esql::model_row curr();
57 56
58 void opened_done_cb(); 57 void opened_done_cb();
diff --git a/src/settingsmodel.cc b/src/settingsmodel.cc
index 4aed503..d7df75f 100644
--- a/src/settingsmodel.cc
+++ b/src/settingsmodel.cc
@@ -41,7 +41,7 @@ settingsmodel::settingsmodel(::emc::database &database,
41{ 41{
42 layout.size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 42 layout.size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
43 win.resize_object_add(layout); 43 win.resize_object_add(layout);
44// win.size_set(WIDTH, HEIGHT); 44 win.eo_cxx::efl::gfx::base::size_set(WIDTH, HEIGHT);
45 win.visible_set(true); 45 win.visible_set(true);
46 layout.visible_set(true); 46 layout.visible_set(true);
47 47