8 enum_items_callback_retrieve_item() : m_item(0) {}
22 enum_items_callback_retrieve_selection() : m_state(false) {}
28 inline bool get_state() {
return m_state;}
35 enum_items_callback_retrieve_selection_mask(
bit_array_var & p_out) : m_out(p_out) {}
38 m_out.
set(p_index,b_selected);
62 if (b_selected) m_out.
add_item(p_location);
71 enum_items_callback_count_selection(
t_size p_max) : m_max(p_max), m_counter(0) {}
76 if (++m_counter >= m_max)
return false;
81 inline t_size get_count() {
return m_counter;}
93 playlist_enum_items(p_playlist,enum_items_callback_retrieve_selected_items(out),
bit_array_true());
98 playlist_enum_items(p_playlist,enum_items_callback_retrieve_selection_mask(out),
bit_array_true());
103 enum_items_callback_retrieve_selection callback;
104 playlist_enum_items(p_playlist,callback,
bit_array_one(p_item));
105 return callback.get_state();
110 if (!playlist_get_item_handle(temp, playlist, item))
throw pfc::exception_invalid_params();
117 enum_items_callback_retrieve_item callback;
118 playlist_enum_items(p_playlist,callback,
bit_array_one(p_item));
119 p_out = callback.get_item();
128 if (p_delta==0)
return true;
130 t_size count = playlist_get_item_count(p_playlist);
137 return playlist_reorder_items(p_playlist,order.
get_ptr(),count);
143 t_size playlist = get_active_playlist();
144 if (playlist == pfc_infinite)
return 0;
145 else return playlist_get_item_count(playlist);
150 t_size playlist = get_active_playlist();
151 if (playlist != pfc_infinite) playlist_enum_items(playlist,p_callback,p_mask);
156 t_size playlist = get_active_playlist();
157 if (playlist == pfc_infinite)
return pfc_infinite;
158 else return playlist_get_focus_item(playlist);
163 t_size playlist = get_active_playlist();
164 if (playlist == pfc_infinite)
return false;
165 else return playlist_get_name(playlist,p_out);
171 t_size playlist = get_active_playlist();
172 if (playlist != pfc_infinite)
return playlist_reorder_items(playlist,order,count);
178 t_size playlist = get_active_playlist();
179 if (playlist != pfc_infinite) playlist_set_selection(playlist,affected,status);
184 t_size playlist = get_active_playlist();
185 if (playlist != pfc_infinite)
return playlist_remove_items(playlist,mask);
191 t_size playlist = get_active_playlist();
192 if (playlist != pfc_infinite)
return playlist_replace_item(playlist,p_item,p_new_item);
198 t_size playlist = get_active_playlist();
199 if (playlist != pfc_infinite) playlist_set_focus_item(playlist,p_item);
204 t_size playlist = get_active_playlist();
205 if (playlist != pfc_infinite)
return playlist_insert_items(playlist,p_base,data,p_selection);
206 else return pfc_infinite;
211 t_size playlist = get_active_playlist();
212 if (playlist != pfc_infinite) playlist_ensure_visible(playlist,p_item);
217 t_size playlist = get_active_playlist();
218 if (playlist != pfc_infinite)
return playlist_rename(playlist,p_name,p_name_len);
224 t_size playlist = get_active_playlist();
225 if (playlist != pfc_infinite)
return playlist_is_item_selected(playlist,p_item);
231 if (!activeplaylist_get_item_handle(temp, p_item))
throw pfc::exception_invalid_params();
237 t_size playlist = get_active_playlist();
238 if (playlist != pfc_infinite)
return playlist_get_item_handle(p_out,playlist,p_item);
244 t_size playlist = get_active_playlist();
245 if (playlist != pfc_infinite) playlist_move_selection(playlist,p_delta);
250 t_size playlist = get_active_playlist();
251 if (playlist != pfc_infinite) playlist_get_selection_mask(playlist,out);
256 t_size playlist = get_active_playlist();
257 if (playlist != pfc_infinite) playlist_get_all_items(playlist,out);
262 t_size playlist = get_active_playlist();
263 if (playlist != pfc_infinite) playlist_get_selected_items(playlist,out);
283 t_size playlist = get_active_playlist();
284 if (playlist != pfc_infinite) playlist_clear(playlist);
289 playlist_get_all_items(playlist, old);
291 if (content.
get_size() == 0)
return false;
292 if (bUndoBackup) playlist_undo_backup(playlist);
298 for(
t_size walk = 0; walk < old.
get_size(); ++walk) itemsOld += old[walk];
299 for(
t_size walk = 0; walk < content.
get_size(); ++walk) itemsNew += content[walk];
302 bool gotNew =
false, filterNew =
false, gotRemove =
false;
304 const bool state = !itemsOld.
have_item(content[walk]);
305 if (state) gotNew =
true;
306 else filterNew =
true;
307 filterMask.set(walk, state);
310 const bool state = !itemsNew.
have_item(old[walk]);
311 if (state) gotRemove =
true;
312 removeMask.set(walk, state);
314 if (!gotNew && !gotRemove)
return false;
315 if (bUndoBackup) playlist_undo_backup(playlist);
317 playlist_remove_items(playlist, removeMask);
330 playlist_get_all_items(playlist, old);
340 return playlist_insert_items(playlist,pfc_infinite,data,p_selection) != pfc_infinite;
345 t_size playlist = get_active_playlist();
346 if (playlist != pfc_infinite)
return playlist_add_items(playlist,data,p_selection);
354 if (!api->filter_items(p_data,temp))
356 return playlist_insert_items(p_playlist,p_base,temp,
bit_array_val(p_select)) != pfc_infinite;
361 t_size playlist = get_active_playlist();
362 if (playlist != pfc_infinite)
return playlist_insert_items_filter(playlist,p_base,p_data,p_select);
370 if (!api->process_locations(p_urls,temp,
true,0,0,p_parentwnd))
return false;
371 return playlist_insert_items(p_playlist,p_base,temp,
bit_array_val(p_select)) != pfc_infinite;
376 t_size playlist = get_active_playlist();
377 if (playlist != pfc_infinite)
return playlist_insert_locations(playlist,p_base,p_urls,p_select,p_parentwnd);
383 return playlist_insert_items_filter(p_playlist,pfc_infinite,p_data,p_select);
388 return activeplaylist_insert_items_filter(pfc_infinite,p_data,p_select);
393 return playlist_insert_locations(p_playlist,pfc_infinite,p_urls,p_select,p_parentwnd);
397 return activeplaylist_insert_locations(pfc_infinite,p_urls,p_select,p_parentwnd);
402 set_playing_playlist(get_active_playlist());
412 t_size playlist = get_active_playlist();
413 if (playlist != pfc_infinite) playlist_clear_selection(playlist);
418 t_size playlist = get_active_playlist();
419 if (playlist != pfc_infinite) playlist_undo_backup(playlist);
424 t_size playlist = get_active_playlist();
425 if (playlist != pfc_infinite)
return playlist_undo_restore(playlist);
431 t_size playlist = get_active_playlist();
432 if (playlist != pfc_infinite)
return playlist_redo_restore(playlist);
439 playlist_get_selection_mask(p_playlist,table);
440 if (p_crop) playlist_remove_items(p_playlist,
bit_array_not(table));
441 else playlist_remove_items(p_playlist,table);
446 t_size playlist = get_active_playlist();
447 if (playlist != pfc_infinite) playlist_remove_selection(playlist,p_crop);
452 t_size playlist = get_active_playlist();
453 if (playlist == pfc_infinite) out =
"NJET";
454 else playlist_item_format_title(playlist,p_item,p_hook,out,p_script,p_filter,p_playback_info_level);
464 t_size playlist = get_active_playlist();
465 if (playlist != pfc_infinite) playlist_set_selection_single(playlist,p_item,p_state);
470 enum_items_callback_count_selection callback(p_max);
472 return callback.get_count();
477 t_size playlist = get_active_playlist();
478 if (playlist != pfc_infinite)
return playlist_get_selection_count(playlist,p_max);
484 t_size index = playlist_get_focus_item(p_playlist);
485 if (index == pfc_infinite)
return false;
486 return playlist_get_item_handle(p_out,p_playlist,index);
491 t_size playlist = get_active_playlist();
492 if (playlist != pfc_infinite)
return playlist_get_focus_item_handle(p_out,playlist);
498 t_size n, m = get_playlist_count();
501 if (!playlist_get_name(n,temp))
break;
502 if (
stricmp_utf8_ex(temp,temp.length(),p_name,p_name_length) == 0)
return n;
508 t_size n, m = get_playlist_count();
511 if (!playlist_lock_is_present(n) && playlist_get_name(n,temp)) {
515 return create_playlist(p_name,p_name_length,pfc_infinite);
519 t_size index = find_playlist(p_name,p_name_length);
520 if (index != pfc_infinite)
return index;
521 return create_playlist(p_name,p_name_length,pfc_infinite);
525 static const char new_playlist_text[] =
"New Playlist";
526 if (find_playlist(new_playlist_text,pfc_infinite) == pfc_infinite)
return create_playlist(new_playlist_text,pfc_infinite,p_index);
527 for(
t_size walk = 2; ; walk++) {
529 namebuffer << new_playlist_text <<
" (" << walk <<
")";
530 if (find_playlist(namebuffer,pfc_infinite) == pfc_infinite)
return create_playlist(namebuffer,pfc_infinite,p_index);
536 t_size playlist = get_active_playlist();
537 if (playlist != pfc_infinite)
return playlist_sort_by_format(playlist,spec,p_sel_only);
544 if (!get_playing_item_location(&playlist,&item))
return false;
545 set_active_playlist(playlist);
546 playlist_set_focus_item(playlist,item);
548 playlist_ensure_visible(playlist,item);
554 playlist_enum_items(p_playlist,enum_items_callback_retrieve_all_items(out),p_mask);
559 t_size playlist = get_active_playlist();
560 if (playlist != pfc_infinite) playlist_get_items(playlist,out,p_mask);
566 t_size playlist = get_active_playlist();
567 if (playlist == pfc_infinite)
569 t_size max = get_playlist_count();
572 create_playlist_autoname();
574 set_active_playlist(0);
589 m_table.
set(p_index,found);
590 if (found) m_found++;
594 inline t_size get_found()
const {
return m_found;}
600 t_size playlist_num, playlist_max = get_playlist_count();
601 if (playlist_max != pfc_infinite)
606 for(playlist_num = 0; playlist_num < playlist_max; playlist_num++ )
608 t_size playlist_item_count = playlist_get_item_count(playlist_num);
609 if (playlist_item_count == pfc_infinite)
break;
611 enum_items_callback_remove_list callback(temp,table);
613 if (callback.get_found()>0)
614 playlist_remove_items(playlist_num,table);
621 t_size n, m = get_playlist_count();
622 if (m == pfc_infinite)
return false;
623 enum_items_callback_retrieve_all_items callback(out);
633 t_size playlist = get_active_playlist();
634 if (playlist == pfc_infinite)
return ~0;
635 else return playlist_lock_get_filter_mask(playlist);
640 t_size playlist = get_active_playlist();
641 if (playlist == pfc_infinite)
return false;
642 else return playlist_is_undo_available(playlist);
647 t_size playlist = get_active_playlist();
648 if (playlist == pfc_infinite)
return false;
649 else return playlist_is_redo_available(playlist);
654 bool need_switch = get_active_playlist() == idx;
655 if (remove_playlist(idx))
659 t_size total = get_playlist_count();
662 if (idx >= total) idx = total-1;
663 set_active_playlist(idx);
686 t_size idx = get_active_playlist();
687 if (idx == pfc_infinite)
return false;
688 else return playlist_execute_default_action(idx,p_item);
695 void on_completion(
unsigned p_code) {
698 m_notify->on_aborted();
701 m_notify->on_completion(m_data);
742 const t_size total = get_playlist_count();
744 t_size active = get_active_playlist();
748 p_delta = - ( (-p_delta) % (
t_ssize)total );
750 p_delta = p_delta % total;
753 if (active == pfc_infinite) {
756 active = (
t_size)(p_delta - 1);
758 active = (total + p_delta);
761 active = (
t_size) (active + total + p_delta) % total;
763 set_active_playlist(active % total);
770 enum_items_callback_get_selected_count() : m_found() {}
771 t_size get_count()
const {
return m_found;}
773 if (b_selected) m_found++;
781 enum_items_callback_get_selected_count callback;
782 playlist_enum_items(p_playlist,callback,p_mask);
783 return callback.get_count();
789 enum_items_callback_find_item(
metadb_handle_ptr p_lookingFor) : m_result(pfc_infinite), m_lookingFor(p_lookingFor) {}
790 t_size result()
const {
return m_result;}
792 if (p_location == m_lookingFor) {
805 enum_items_callback_find_item_selected(
metadb_handle_ptr p_lookingFor) : m_result(pfc_infinite), m_lookingFor(p_lookingFor) {}
806 t_size result()
const {
return m_result;}
808 if (b_selected && p_location == m_lookingFor) {
822 enum_items_callback_find_item callback(p_item);
824 t_size result = callback.result();
825 if (result == pfc_infinite)
return false;
830 enum_items_callback_find_item_selected callback(p_item);
832 t_size result = callback.result();
833 if (result == pfc_infinite)
return false;
839 if (!playlist_find_item(p_playlist,p_item,index)) index = pfc_infinite;
840 playlist_set_focus_item(p_playlist,index);
844 t_size playlist = get_active_playlist();
845 if (playlist == pfc_infinite)
return false;
846 return playlist_find_item(playlist,p_item,p_result);
849 t_size playlist = get_active_playlist();
850 if (playlist == pfc_infinite)
return pfc_infinite;
851 return playlist_set_focus_by_handle(playlist,p_item);
859 t_size which = recycler_find_by_id(
id);
860 if (which != ~0) recycler_restore(which);
864 const t_size total = recycler_get_count();
865 for(
t_size walk = 0; walk < total; ++walk) {
866 if (
id == recycler_get_id(walk))
return walk;
t_size playlist_get_selected_count(t_size p_playlist, bit_array const &p_mask)
t_size activeplaylist_get_item_count()
void to_handles_async_ex(t_uint32 p_op_flags, HWND p_parentwnd, service_ptr_t< process_locations_notify > p_notify)
Generic service for receiving notifications about async operation completion. Used by various other s...
metadb_handle_ptr m_handle
t_size recycler_find_by_id(t_uint32 id)
const t_item * get_ptr() const
void activeplaylist_item_format_title(t_size p_item, titleformat_hook *p_hook, pfc::string_base &out, const service_ptr_t< titleformat_object > &p_script, titleformat_text_filter *p_filter, play_control::t_display_level p_playback_info_level)
Template implementing reference-counting features of service_base. Intended for dynamic instantiation...
bool activeplaylist_redo_restore()
int SHARED_EXPORT stricmp_utf8_ex(const char *p1, t_size len1, const char *p2, t_size len2)
bool playlist_add_locations(t_size p_playlist, const pfc::list_base_const_t< const char * > &p_urls, bool p_select, HWND p_parentwnd)
bool highlight_playing_item()
Helper; highlights currently playing item; returns true on success or false on failure (not playing o...
t_size add_item(const T &item)
void activeplaylist_set_selection_single(t_size p_item, bool p_state)
void reset_playing_playlist()
bool playlist_insert_items_filter(t_size p_playlist, t_size p_base, const pfc::list_base_const_t< metadb_handle_ptr > &p_data, bool p_select)
Generic variable bit_array implementation. Needs to be initialized with requested array size before ...
void playlist_clear(t_size p_playlist)
Clears contents of specified playlist (removes all items from it).
void playlist_get_selected_items(t_size p_playlist, pfc::list_base_t< metadb_handle_ptr > &out)
bool playlist_insert_locations(t_size p_playlist, t_size p_base, const pfc::list_base_const_t< const char * > &p_urls, bool p_select, HWND p_parentwnd)
bool operator!=(const t_playback_queue_item &p_item) const
void playlist_get_items(t_size p_playlist, pfc::list_base_t< metadb_handle_ptr > &out, const bit_array &p_mask)
void add_items(const t_in &in)
bool activeplaylist_get_item_handle(metadb_handle_ptr &item, t_size p_item)
bool operator==(const t_playback_queue_item &p_item) const
bool playlist_is_item_selected(t_size p_playlist, t_size p_item)
Helper; returns whether specified item on specified playlist is selected or not.
Bit array interface class, constant version (you can only retrieve values). Range of valid indexes d...
t_size playlist_get_selection_count(t_size p_playlist, t_size p_max)
bool playlist_get_focus_item_handle(metadb_handle_ptr &p_item, t_size p_playlist)
t_size activeplaylist_set_focus_by_handle(metadb_handle_ptr p_item)
bit_array_table_t< bool > bit_array_table
bool activeplaylist_is_undo_available()
t_uint32 activeplaylist_lock_get_filter_mask()
t_size find_playlist(const char *p_name, t_size p_name_length=~0)
void filter_mask(const bit_array &mask)
bit_array_var_table_t< bool > bit_array_var_table
void activeplaylist_get_all_items(pfc::list_base_t< metadb_handle_ptr > &out)
Set this flag to make the progress dialog not steal focus on creation.
bool playlist_get_item_handle(metadb_handle_ptr &p_out, t_size p_playlist, t_size p_item)
Helper; retrieves metadb_handle of the specified playlist item. Returns true on success, false on failure (invalid parameters).
void activeplaylist_enum_items(enum_items_callback &p_callback, const bit_array &p_mask)
Set this to disable presorting (according to user settings) and duplicate removal in output list...
bool activeplaylist_undo_restore()
Negation of another array. Valid index range is the same as valid index range of the parameter array...
bool have_item(const t_param &p_item) const
Same as contains().
void playlist_get_selection_mask(t_size p_playlist, bit_array_var &out)
Retrieves selection map of specific playlist, using bit_array_var interface.
bool playlist_update_content(t_size playlist, metadb_handle_list_cref content, bool bUndoBackup)
Changes contents of the specified playlist to the specified items, trying to reuse existing playlist ...
bool activeplaylist_find_item(metadb_handle_ptr p_item, t_size &p_result)
bool activeplaylist_remove_items(const bit_array &mask)
void playlist_activate_delta(int p_delta)
bool get_all_items(pfc::list_base_t< metadb_handle_ptr > &out)
t_size create_playlist_autoname(t_size p_index=~0)
Set this flag to delay the progress dialog becoming visible, so it does not appear at all during shor...
t_size find_or_create_playlist_unlocked(const char *p_name, t_size p_name_length=~0)
t_size playlist_set_focus_by_handle(t_size p_playlist, metadb_handle_ptr p_item)
virtual void set(t_size n, bool val)=0
static void g_make_selection_move_permutation(t_size *p_output, t_size p_count, const bit_array &p_selection, int p_delta)
t_size activeplaylist_insert_items(t_size p_base, const pfc::list_base_const_t< metadb_handle_ptr > &data, const bit_array &p_selection)
void activeplaylist_get_items(pfc::list_base_t< metadb_handle_ptr > &out, const bit_array &p_mask)
bool activeplaylist_is_item_selected(t_size p_item)
string8_fastalloc string_formatter
void set_size(t_size p_size)
bool remove_playlist(t_size p_playlist)
Helper; removes single playlist of specified index.
bool activeplaylist_insert_items_filter(t_size p_base, const pfc::list_base_const_t< metadb_handle_ptr > &p_data, bool p_select)
bool activeplaylist_get_focus_item_handle(metadb_handle_ptr &item)
bool playlist_find_item(t_size p_playlist, metadb_handle_ptr p_item, t_size &p_result)
void activeplaylist_get_selection_mask(bit_array_var &out)
bool activeplaylist_rename(const char *p_name, t_size p_name_len)
void to_handles_async(bool p_filter, HWND p_parentwnd, service_ptr_t< process_locations_notify > p_notify)
void activeplaylist_ensure_visible(t_size p_item)
bool activeplaylist_replace_item(t_size p_item, const metadb_handle_ptr &p_new_item)
void playlist_get_all_items(t_size p_playlist, pfc::list_base_t< metadb_handle_ptr > &out)
void create_move_items_permutation(t_size *p_output, t_size p_count, const class bit_array &p_selection, int p_delta)
Creates a permutation that moves selected items in a list box by the specified delta-offset.
bool activeplaylist_add_items(const pfc::list_base_const_t< metadb_handle_ptr > &data, const bit_array &p_selection)
bool activeplaylist_reorder_items(const t_size *order, t_size count)
Bit array interface class, variable version (you can both set and retrieve values). As with the constant version, valid index range depends on the context.
bool playlist_find_item_selected(t_size p_playlist, metadb_handle_ptr p_item, t_size &p_result)
bool activeplaylist_get_name(pfc::string_base &p_out)
bool playlist_add_items_filter(t_size p_playlist, const pfc::list_base_const_t< metadb_handle_ptr > &p_data, bool p_select)
t_size activeplaylist_get_selection_count(t_size p_max)
t_display_level
Type used to indicate level of dynamic playback-related info displayed. Safe to use with <> opereator...
bool activeplaylist_sort_by_format(const char *spec, bool p_sel_only)
bool activeplaylist_add_items_filter(const pfc::list_base_const_t< metadb_handle_ptr > &p_data, bool p_select)
bool activeplaylist_insert_locations(t_size p_base, const pfc::list_base_const_t< const char * > &p_urls, bool p_select, HWND p_parentwnd)
bool playlist_move_selection(t_size p_playlist, int p_delta)
Moves selected items up/down in the playlist by specified offset.
Callback interface for playlist enumeration methods.
void activeplaylist_move_selection(int p_delta)
bool to_handles(pfc::list_base_t< metadb_handle_ptr > &p_out, bool p_filter, HWND p_parentwnd)
pfc::sized_int_t< sizeof(size_t) >::t_signed t_ssize
t_size activeplaylist_get_focus_item()
void activeplaylist_clear_selection()
void activeplaylist_clear()
void playlist_clear_selection(t_size p_playlist)
bool activeplaylist_is_redo_available()
void activeplaylist_set_selection(const bit_array &affected, const bit_array &status)
bool activeplaylist_add_locations(const pfc::list_base_const_t< const char * > &p_urls, bool p_select, HWND p_parentwnd)
void playlist_remove_selection(t_size p_playlist, bool p_crop=false)
virtual bool on_item(t_size p_index, const metadb_handle_ptr &p_location, bool b_selected)=0
bool remove_playlist_switch(t_size p_playlist)
Helper; removes single playlist of specified index, and switches to another playlist when possible...
bool activeplaylist_execute_default_action(t_size p_item)
void activeplaylist_get_selected_items(pfc::list_base_t< metadb_handle_ptr > &out)
pfc::com_ptr_t< interface IDataObject > create_dataobject_ex(metadb_handle_list_cref data)
Helper - returns a pfc::com_ptr_t<> rather than a raw pointer.
void activeplaylist_set_focus_item(t_size p_item)
void playlist_set_selection_single(t_size p_playlist, t_size p_item, bool p_state)
void activeplaylist_undo_backup()
static bool guess_reorder_pattern(pfc::array_t< t_size > &out, const t_list1 &from, const t_list2 &to)
Helper template used to easily access core services. Usage: static_api_ptr_t<myclass> api; api->doso...
t_size find_or_create_playlist(const char *p_name, t_size p_name_length=~0)
void active_playlist_fix()
void recycler_restore_by_id(t_uint32 id)
void activeplaylist_remove_selection(bool p_crop=false)
void remove_items_from_all_playlists(const pfc::list_base_const_t< metadb_handle_ptr > &p_data)
bool process_location(const char *url, pfc::list_base_t< metadb_handle_ptr > &out, bool filter, const char *p_mask, const char *p_exclude, HWND p_parentwnd)
Helper - calls process_locations() with a single URL. See process_locations() for more info...
bool playlist_add_items(t_size playlist, const pfc::list_base_const_t< metadb_handle_ptr > &data, const bit_array &p_selection)