virtual void context_command(unsigned int p_index, metadb_handle_list_cref p_data, const GUID& p_caller) { if(p_index == 0 && p_data.get_count() == 1) AlsongLyricLinkDialog::OpenLyricLinkDialog(core_api::get_main_window(), p_data.get_item(0)); else if(p_index == 1 && p_data.get_count() == 1) LyricSyncDialog::Open(p_data.get_item(0), core_api::get_main_window()); }
virtual void context_command( unsigned int index, metadb_handle_list_cref tracks, const GUID& /*caller*/ ) { switch(index) { case Items::GetArtistTopTracks: { generateArtistPlaylist(tracks); break; } case Items::GetSimilarTracks: { if(tracks.get_count() > 0) { generateSimilarTracksPlaylist(tracks.get_item(0)); } break; } default: { uBugCheck(); } } }
double metadb_handle_list_helper::calc_total_duration(metadb_handle_list_cref p_list) { double ret = 0; t_size n, m = p_list.get_count(); for(n=0;n<m;n++) { double temp = p_list.get_item(n)->get_length(); if (temp > 0) ret += temp; } return ret; }
virtual bool context_get_display( unsigned int index, metadb_handle_list_cref tracks, pfc::string_base& out, unsigned int& displayflags, const GUID& /*caller*/ ) { switch(index) { case Items::GetArtistTopTracks: { const auto& mainArtist = getMainArtist(tracks); const t_size stringLength = mainArtist.length(); if(stringLength > 0) { // We have found a main artist; set the display of the item to be of the form: // "Artist's top tracks". out = mainArtist.c_str(); // Grammar alert! Artists ending with "s" get just a "'" rather than "'s". if(out[stringLength - 1] == 's') { out.add_string("' top tracks"); } else { out.add_string("'s top tracks"); } } else { // Failed to find a main artist; return the normal, non-custom name for the item. get_item_name(index, out); } return true; } case Items::GetSimilarTracks: { if(tracks.get_count() == 0) { displayflags = FLAG_DISABLED_GRAYED; get_item_name(index, out); } else { out = "Get tracks similar to "; out.add_string(getTitle(tracks.get_item(0)).c_str()); } return true; } default: { // Nothing wants to customise the display of the item; let the regular name be displayed. get_item_name(index, out); return true; } } }