예제 #1
0
void metadb_handle_list_helper::sort_by_relative_path_get_order_partial(const pfc::list_base_const_t<metadb_handle_ptr> & p_list,t_size base,t_size count,t_size* order)
{
	assert(base+count<=p_list.get_count());
	t_size n;
	pfc::array_t<custom_sort_data> data;
	data.set_size(count);
	static_api_ptr_t<library_manager> api;
	
	pfc::string8_fastalloc temp;
	temp.prealloc(512);
	for(n=0;n<count;n++)
	{
		metadb_handle_ptr item;
		p_list.get_item_ex(item,base+n);
		if (!api->get_relative_path(item,temp)) temp = "";
		data[n].index = n;
		data[n].text = uSortStringCreate(temp);
		//data[n].subsong = item->get_subsong_index();
	}

	pfc::sort_t(data,custom_sort_compare,count);
	//qsort(data.get_ptr(),count,sizeof(custom_sort_data),(int (__cdecl *)(const void *elem1, const void *elem2 ))custom_sort_compare);

	for(n=0;n<count;n++)
	{
		order[n]=data[n].index;
		uSortStringFree(data[n].text);
	}
}
예제 #2
0
void metadb_handle_list_helper::sort_by_format_get_order_partial(const pfc::list_base_const_t<metadb_handle_ptr> & p_list,t_size base,t_size count,t_size* order,const service_ptr_t<titleformat_object> & p_script,titleformat_hook * p_hook)
{
	assert(base+count<=p_list.get_count());
	t_size n;
	pfc::array_t<custom_sort_data> data;
	data.set_size(count);
	
	pfc::string8_fastalloc temp;
	pfc::string8_fastalloc temp2;
	temp.prealloc(512);
	for(n=0;n<count;n++)
	{
		metadb_handle_ptr item;
		p_list.get_item_ex(item,base+n);
		assert(item.is_valid());

		item->format_title(p_hook,temp,p_script,0);
		data[n].index = n;
		data[n].text = uSortStringCreate(temp);
		//data[n].subsong = item->get_subsong_index();
	}

	pfc::sort_t(data,custom_sort_compare,count);
	//qsort(data.get_ptr(),count,sizeof(custom_sort_data),(int (__cdecl *)(const void *elem1, const void *elem2 ))custom_sort_compare);

	for(n=0;n<count;n++)
	{
		order[n]=data[n].index;
		uSortStringFree(data[n].text);
	}
}
예제 #3
0
double metadb_handle_list_helper::calc_total_duration(const pfc::list_base_const_t<metadb_handle_ptr> & 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;
}
예제 #4
0
file_info_update_helper::file_info_update_helper(const pfc::list_base_const_t<metadb_handle_ptr> & p_data)
{
	const t_size count = p_data.get_count();
	m_data.add_items(p_data);

	m_infos.set_size(count);
	m_mask.set_size(count);
	for(t_size n=0;n<count;n++) m_mask[n] = false;
}
예제 #5
0
void cfg_layout_t::set_presets(const pfc::list_base_const_t<preset> & presets, t_size active)
{
	if (presets.get_count())
	{
		m_presets.remove_all();
		m_active = pfc_infinite;
		m_presets.add_items(presets);
		set_active_preset(active);
	}
}
예제 #6
0
void splitter_window_impl::get_supported_panels(const pfc::list_base_const_t<uie::window::ptr> & p_windows, bit_array_var & p_mask_unsupported)
{
	service_ptr_t<service_base> temp;
	g_splitter_host_vert.instance_create(temp);
	uie::window_host_ptr ptr;
	if (temp->service_query_t(ptr))
		(static_cast<splitter_host_impl*>(ptr.get_ptr()))->set_window_ptr(this);
	t_size i, count = p_windows.get_count();
	for (i = 0; i<count; i++)
		p_mask_unsupported.set(i, !p_windows[i]->is_available(ptr));
}
예제 #7
0
static bool run_context_command_internal(const GUID & p_command,const GUID & p_subcommand,const pfc::list_base_const_t<metadb_handle_ptr> & data,const GUID & caller) {
	if (data.get_count() == 0) return false;
	service_ptr_t<contextmenu_item> ptr; t_uint32 index;
	if (!menu_item_resolver::g_resolve_context_command(p_command, ptr, index)) return false;
	
	{
		TRACK_CALL_TEXT("menu_helpers::run_command(), by GUID");
		ptr->item_execute_simple(index, p_subcommand, data, caller);
	}
	
	return true;
}
예제 #8
0
t_size file_move_helper::g_filter_dead_files_sorted_make_mask(pfc::list_base_t<metadb_handle_ptr> & p_data,const pfc::list_base_const_t<const char*> & p_dead,bit_array_var & p_mask)
{
	t_size n, m = p_data.get_count();
	t_size found = 0;
	for(n=0;n<m;n++)
	{
		t_size dummy;
		bool dead = p_dead.bsearch_t(metadb::path_compare,p_data.get_item(n)->get_path(),dummy);
		if (dead) found++;
		p_mask.set(n,dead);
	}
	return found;
}
예제 #9
0
void file_info::merge(const pfc::list_base_const_t<const file_info*> & p_in)
{
	t_size in_count = p_in.get_count();
	if (in_count == 0)
	{
		meta_remove_all();
		return;
	}
	else if (in_count == 1)
	{
		const file_info * info = p_in[0];

		copy_meta(*info);

		set_replaygain(replaygain_info::g_merge(get_replaygain(),info->get_replaygain()));

		overwrite_info(*info);

		//copy_info_single_by_name(*info,"tagtype");
		
		return;
	}
	
	merge_meta(*this,p_in);

	{
		pfc::string8_fastalloc tagtype;
		replaygain_info rg = get_replaygain();
		t_size in_ptr;
		for(in_ptr = 0; in_ptr < in_count; in_ptr++ )
		{
			const file_info * info = p_in[in_ptr];
			rg = replaygain_info::g_merge(rg, info->get_replaygain());
			t_size field_ptr, field_max = info->info_get_count();
			for(field_ptr = 0; field_ptr < field_max; field_ptr++ )
			{
				const char * field_name = info->info_enum_name(field_ptr), * field_value = info->info_enum_value(field_ptr);
				if (*field_value)
				{
					if (!pfc::stricmp_ascii(field_name,"tagtype"))
					{
						if (!tagtype.is_empty()) tagtype += "|";
						tagtype += field_value;
					}
				}
			}
		}
		if (!tagtype.is_empty()) info_set("tagtype",tagtype);
		set_replaygain(rg);
	}
}
예제 #10
0
		virtual bool notify_create_inline_edit(const pfc::list_base_const_t<t_size> & indices, unsigned column, pfc::string_base & p_text, t_size & p_flags, mmh::comptr_t<IUnknown> & pAutocompleteEntries) 
		{
			t_size indices_count = indices.get_count();
			if (indices_count == 1 && indices[0] < filter_panel::cfg_field_list.get_count())
			{
				m_edit_index = indices[0];
				m_edit_column = column;

				p_text = m_edit_column ? filter_panel::cfg_field_list[m_edit_index].m_field : filter_panel::cfg_field_list[m_edit_index].m_name;

				return true;
			}
			return false;
		};
예제 #11
0
pfc::list_t<metadb_handle_ptr> get_sorted_playlist(const pfc::list_base_const_t<metadb_handle_ptr> &data, threaded_process_status &p_status, abort_callback &p_abort) {
	std::multimap<int, metadb_handle_ptr, std::greater<int>> temp;
	std::multimap<int, metadb_handle_ptr, std::greater<int>>::iterator it;
	pfc::list_t<metadb_handle_ptr> result;
	pfc::lores_timer timer;
	pfc::string8 message, msg;
	int size = data.get_count();

	for (int i = 0; i < size; i++) {
		message.reset();
		message << "Track " << i + 1 << " of " << size;
		p_status.set_item(message);
		p_status.set_progress(i + 1, size);

		timer.start();

		const metadb_handle_ptr track = data[i];
		int count = get_track_count(track, p_abort);

		msg.reset();
		msg << count;
		console::print(msg);

		// don't make more than 5 requests per second
		// (averaged over a 5 minute period)
		if (timer.query() < 0.2) {
			p_abort.sleep(0.2);
		}

		if (i && (i % 100 == 0)) {
			p_abort.sleep(10);
		}

		if (count > 0) {
			temp.insert(std::pair<int, metadb_handle_ptr>(count, track));
		} else {
			temp.insert(std::pair<int, metadb_handle_ptr>(0, track));
		}
	}

	for (it = temp.begin(); it != temp.end(); it++) {
		metadb_handle_ptr track = it->second;
		result.add_item(track);
	}

	return result;
}
bool fields_list_view_t::notify_create_inline_edit(const pfc::list_base_const_t<t_size> & indices, unsigned column, pfc::string_base & p_text, t_size & p_flags, mmh::comptr_t<IUnknown> & pAutocompleteEntries)
{
	t_size indices_count = indices.get_count();
	if (indices_count == 1 && indices[0] < m_fields.get_count())
	{
		m_edit_index = indices[0];
		m_edit_column = column;

		p_text = m_edit_column ? m_fields[m_edit_index].m_name : m_fields[m_edit_index].m_name_friendly;

		if (m_edit_column == 1)
			p_flags = inline_edit_uppercase;

		return true;
	}
	return false;
}
예제 #13
0
void file_move_callback_manager::on_hint(const pfc::list_base_const_t<metadb_handle_ptr> & p_list,const pfc::list_base_const_t<const file_info*> & p_infos,const pfc::list_base_const_t<t_filestats> & p_stats)
{
	m_hint_handles.add_items(p_list);
	m_hint_stats.add_items(p_stats);

	{
		t_size old_count = m_hint_infos.get_count(), delta = p_infos.get_count();
		m_hint_infos.set_count(old_count + delta);
		for(t_size n=0;n<delta;n++)
			m_hint_infos[old_count+n] = *p_infos[n];
	}
	
/*	metadb_handle_list m_hint_handles;
	list_t<file_info_impl_const> m_hint_infos;
	list_t<t_filestats> m_hint_stats;*/
	
}
static void merge_meta(file_info & p_out,const pfc::list_base_const_t<const file_info*> & p_in) {
	pfc::map_t<const char *,meta_merge_entry,pfc::comparator_stricmp_ascii> map;
	for(t_size in_walk = 0; in_walk < p_in.get_count(); in_walk++) {
		const file_info & in = * p_in[in_walk];
		for(t_size meta_walk = 0, meta_count = in.meta_get_count(); meta_walk < meta_count; meta_walk++ ) {
			meta_merge_entry & entry = map.find_or_add(in.meta_enum_name(meta_walk));
			t_size rating = merge_tags_calc_rating_by_index(in,meta_walk);
			if (rating > entry.m_rating) {
				entry.m_rating = rating;
				const t_size value_count = in.meta_enum_value_count(meta_walk);
				entry.m_data.set_size(value_count);
				for(t_size value_walk = 0; value_walk < value_count; value_walk++ ) {
					entry.m_data[value_walk] = in.meta_enum_value(meta_walk,value_walk);
				}
			}
		}
	}

	map.enumerate(meta_merge_map_enumerator(p_out));
}
예제 #15
0
		virtual bool notify_create_inline_edit(const pfc::list_base_const_t<t_size> & indices, unsigned column, pfc::string_base & p_text, t_size & p_flags, mmh::comptr_t<IUnknown> & pAutocompleteEntries) 
		{
			
			t_size indices_count = indices.get_count();
			if (indices_count == 1)
			{
				t_size index, subindex;
				if (get_separated_index(indices[0], index, subindex))
				{
					m_edit_index = index;
					m_edit_subindex = subindex;
					m_edit_combined_index = indices[0];

					p_text = g_artwork_sources[index].m_scripts->get_item(subindex);

					return true;
				}
			}
			return false;
		};
예제 #16
0
bool selection_properties_t::notify_create_inline_edit(const pfc::list_base_const_t<t_size> & indices, unsigned column, pfc::string_base & p_text, t_size & p_flags, mmh::comptr_t<IUnknown> & pAutocompleteEntries)
{
	t_size indices_count = indices.get_count();
	if (m_handles.get_count() && column == 1 && indices_count == 1 && indices[0] < m_fields.get_count())
	{
		m_edit_index = indices[0];
		m_edit_column = column;
		m_edit_field = m_fields[m_edit_index].m_name;
		m_edit_handles = m_handles;

		pfc::string8_fast_aggressive text, temp;
		{
			in_metadb_sync sync;
			const file_info * p_info = NULL;
			if (m_edit_handles[0]->get_info_locked(p_info))
				g_print_field(m_edit_field, *p_info, text);
			t_size i, count = m_handles.get_count();
			for (i = 1; i < count; i++)
			{
				temp.reset();
				if (m_edit_handles[i]->get_info_locked(p_info))
					g_print_field(m_edit_field, *p_info, temp);
				if (strcmp(temp, text))
				{
					text = "<mixed values>";
					break;
				}
			}
		}

		p_text = text;

		return true;
	}
	return false;
}
예제 #17
0
bool selection_properties_t::notify_before_create_inline_edit(const pfc::list_base_const_t<t_size> & indices, unsigned column, bool b_source_mouse)
{
	if (m_handles.get_count() && column == 1 && indices.get_count() == 1 && indices[0] < m_fields.get_count())
		return true;
	return false;
}
예제 #18
0
void t_list_view::create_inline_edit(const pfc::list_base_const_t<t_size> & indices, unsigned column)
{
	t_size indices_count = indices.get_count();
	if (!indices_count) return;
	if (!(column < m_columns.get_count()) || m_selecting)
	{
		//console::print("internal error - edit column index out of range");
		return;
	}

	{
		t_size item_count = m_items.get_count();
		for (t_size j = 0; j < indices_count; j++)
		{
			if (indices[j] >= item_count) return;
		}
	}

	t_size indices_spread = indices[indices_count-1] - indices[0] +1;
	t_size indices_total_height = get_item_position_bottom(indices[indices_count-1]) - get_item_position(indices[0]);

	t_size active_count = m_items.get_count();

	if (m_timer_inline_edit)
	{
		KillTimer(get_wnd(), EDIT_TIMER_ID);
		m_timer_inline_edit = false;
	}

	t_size median = indices[0] + indices_spread/2;//indices[(indices_count/2)];

	bool start_visible = is_visible(indices[0]);
	bool end_visible = is_visible(indices[indices_count-1]);

	if (!start_visible || !end_visible)
	{
		SCROLLINFO si;
		memset(&si, 0, sizeof(SCROLLINFO));
		si.cbSize = sizeof(si);
		si.fMask = SIF_POS|SIF_TRACKPOS|SIF_PAGE|SIF_RANGE;
		GetScrollInfo(get_wnd(), SB_VERT, &si);
		t_size target;
		if (indices_count > si.nPage)
		{
			target = median;
			scroll(false, get_item_position(target) + m_item_height/2 - ((si.nPage>1?si.nPage-1:0)/2));
		}
		else
		{
			target = get_item_position(indices[0]) > (t_size)m_scroll_position ? indices[indices_count-1] : indices[0];
			scroll(false, get_item_position(target) -(get_item_position(target) > (t_size)m_scroll_position ? (si.nPage>1?si.nPage-1:0) - m_item_height : 0));
		}
	}

	int x = 0;
	{
		
		{
			x = get_total_indentation();
		}
		
		{
			unsigned n, count = m_columns.get_count();
			for (n=0; n<count && n<column; n++)
			{
				x += m_columns[n].m_display_size;
			}
		}
	}

	RECT rc_playlist, rc_items;
	GetClientRect(get_wnd(), &rc_playlist);
	get_items_rect(&rc_items);

	int font_height = uGetFontHeight(m_font);
	int header_height = rc_items.top;//get_header_height();

	int y = (get_item_position(indices[0])-m_scroll_position) + header_height;
	if (y < header_height) y= header_height;
	int cx = m_columns[column].m_display_size;
	//if (column == 0)
	//	cx -= min(x,cx);
	int cy = min (indices_total_height, t_size(rc_items.bottom-rc_items.top));

	if (!m_autosize && ( (x - m_horizontal_scroll_position < 0) || x + cx - m_horizontal_scroll_position > rc_items.right))
	{
		/*SCROLLINFO si;
		memset(&si, 0, sizeof(SCROLLINFO));
		si.cbSize = sizeof(si);
		si.fMask = SIF_POS|SIF_TRACKPOS|SIF_PAGE|SIF_RANGE;
		GetScrollInfo(get_wnd(), SB_HORZ, &si);*/
		if (x - m_horizontal_scroll_position < 0)
		{
			scroll(false, x, true);
		}
		else if (x + cx - m_horizontal_scroll_position > rc_items.right)
		{
			const int x_right = x + cx - rc_items.right;
			scroll(false, cx > rc_items.right ? x : x_right, true);
		}
	}

	x -= m_horizontal_scroll_position;

	/*int horizontal_offset = 0;
	if (x-horizontal_offset + cx > rc_playlist.right)
		scroll(scroll_horizontally, scroll_position_delta, x-horizontal_offset + (cx>rc_playlist.right?0:cx-rc_playlist.right));
	else if (x-horizontal_offset < 0)
		scroll(scroll_horizontally, scroll_position_delta, x-horizontal_offset);

	x-=horizontal_offset;*/

	if (m_wnd_inline_edit)
	{
		save_inline_edit();

		//NEW
		m_inline_edit_prevent_kill = true;
		DestroyWindow(m_wnd_inline_edit);
		m_wnd_inline_edit=0;
		m_inline_edit_autocomplete.release();
		m_inline_edit_prevent_kill = false;
		//END NEW
	}

	//m_inline_edit_field.set_string(pfc::empty_string_t<char>());
	//m_inline_edit_items.remove_all();
	//m_inline_edit_items.set_count(indices_count);
	//pfc::list_t<bool> mask;

	pfc::string8 text;
	t_size flags = 0;
	mmh::comptr_t<IUnknown> pAutoCompleteEntries;
	if (!notify_create_inline_edit(indices, column, text, flags, pAutoCompleteEntries))
	{
		m_inline_edit_save = false;
		exit_inline_edit();
		return;
	}

	if (!m_wnd_inline_edit)
	{
		m_inline_edit_save = true;
		m_wnd_inline_edit = CreateWindowEx(0, WC_EDIT, pfc::stringcvt::string_os_from_utf8(text).get_ptr(), WS_CHILD|WS_CLIPSIBLINGS|WS_VISIBLE|ES_LEFT|
			ES_AUTOHSCROLL|ES_MULTILINE|ES_AUTOVSCROLL|WS_BORDER|WS_CLIPCHILDREN|((flags & inline_edit_uppercase) ? ES_UPPERCASE : 0), x, 
			y,
			cx, cy, get_wnd(), HMENU(667),
			core_api::get_my_instance(), 0);

		m_proc_original_inline_edit = (WNDPROC)GetWindowLongPtr(m_wnd_inline_edit,GWLP_WNDPROC);

		if (/*flags & inline_edit_autocomplete && */pAutoCompleteEntries.is_valid())
		{
			if (SUCCEEDED(m_inline_edit_autocomplete.instantiate(CLSID_AutoComplete)))
			{
				if (pAutoCompleteEntries.is_valid())
					m_inline_edit_autocomplete->Init(m_wnd_inline_edit, pAutoCompleteEntries, NULL, NULL);

				mmh::comptr_t<IAutoComplete2> pA2 = m_inline_edit_autocomplete;
				mmh::comptr_t<IAutoCompleteDropDown> pAutoCompleteDropDown = m_inline_edit_autocomplete;
				if (pA2.is_valid())
				{
					pA2->SetOptions(ACO_AUTOSUGGEST|ACO_UPDOWNKEYDROPSLIST);
				}
			}
		}

		SetWindowLongPtr(m_wnd_inline_edit,GWL_USERDATA,(LPARAM)(this));
		m_proc_inline_edit = (WNDPROC)SetWindowLongPtr(m_wnd_inline_edit,GWL_WNDPROC,(LPARAM)(g_on_inline_edit_message));

		SetWindowPos(m_wnd_inline_edit,HWND_TOP,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);

		SendMessage(m_wnd_inline_edit, WM_SETFONT, (WPARAM)m_font.get(), MAKELONG(TRUE,0));
	}
#if 0
	else
	{
		if (m_inline_edit_autocomplete.is_valid())
			m_inline_edit_autocomplete->Enable(FALSE);
		SetWindowLongPtr(m_wnd_inline_edit, GWL_STYLE, (GetWindowLongPtr (m_wnd_inline_edit, GWL_STYLE) & ~ES_UPPERCASE) | ((flags & inline_edit_uppercase)  ? ES_UPPERCASE  : 0));
		SendMessage(m_wnd_inline_edit, WM_SETTEXT, 0, (LPARAM)_T(""));
		SetWindowPos(m_wnd_inline_edit, NULL, x, y,	cx, cy, SWP_NOZORDER);
		uSendMessageText(m_wnd_inline_edit, WM_SETTEXT, 0, text);

		if (m_inline_edit_autocomplete.is_valid())
		{
			if (pAutoCompleteEntries.is_valid())
			{
				m_inline_edit_autocomplete->Init(m_wnd_inline_edit, pAutoCompleteEntries, NULL, NULL);
				m_inline_edit_autocomplete->Enable(TRUE);
			}
		}
	}
#endif


	RECT rc;
	rc.left = x+2;
	rc.top = y + (cy-font_height)/2;
	rc.right = x+(cx>0?cx-2:0);
	rc.bottom = rc.top + font_height;
	MapWindowPoints(get_wnd(), m_wnd_inline_edit, (LPPOINT)&rc, 2);

	SendMessage(m_wnd_inline_edit, EM_SETRECT, NULL, (LPARAM)&rc);

	SendMessage(m_wnd_inline_edit, EM_SETSEL, 0, -1);
	SetFocus(m_wnd_inline_edit);

	m_inline_edit_indices.remove_all();
	m_inline_edit_indices.add_items(indices);
	m_inline_edit_column = column;
}
예제 #19
0
bool keyboard_shortcut_manager::on_keydown_context(const pfc::list_base_const_t<metadb_handle_ptr> & data,WPARAM wp,const GUID & caller)
{
	if (data.get_count()==0) return false;
	return process_keydown_ex(TYPE_CONTEXT,data,get_key_code(wp),caller);
}
예제 #20
0
		virtual bool notify_before_create_inline_edit(const pfc::list_base_const_t<t_size> & indices, unsigned column, bool b_source_mouse) 
		{
			if (column <= 1 && indices.get_count() ==1)
				return true;
			return false;
		};
예제 #21
0
void t_list_view::__replace_items_v2(t_size index_start, const pfc::list_base_const_t<t_item_insert> & items)
{
	pfc::list_t<t_item_ptr> items_prev(m_items);
	t_size l, countl = items.get_count(), countitems = m_items.get_count();
	t_size newgroupcount = 0, oldgroupcount=0;

// Calculate old group count
	{
		t_size countl2 = index_start + countl < countitems ? countl+1 : countl;
		for (l=0; l<countl2; l++)
		{
			t_size i, count = m_group_count;
			t_size index = l + index_start;
			for (i=0; i<count; i++)
			{
				if ( (!index || m_items[index-1]->m_groups[i] != m_items[index]->m_groups[i])
					)
					oldgroupcount++;
			}
			//oldgroupcount += get_item_display_group_count(index);
		}
	}

	{
		for (l=0; l<countl; l++)
		{
			t_size i, count = m_group_count;
			t_size index = l + index_start;
			t_item_ptr item, item_old;
			item_old = m_items[index];
			{
				item = storage_create_item();
				item->m_selected = m_items[index]->m_selected;
				item->m_subitems = items[l].m_subitems;
				m_items[index] = item;
				item->m_display_index = index ? m_items[index-1]->m_display_index + 1 : 0;
				item->m_groups.set_size(count);
			}
			bool b_new = false;

			bool b_left_same_above = true;
			bool b_right_same_above = true;
			bool b_self_same_above = true;
			for (i=0; i<count; i++)
			{
				bool b_left_same = false;
				bool b_right_same = false;
				bool b_self_same = false;
				if (!b_new && index)
				{
					b_left_same = b_left_same_above && !GROUP_STRING_COMPARE(items[l].m_groups[i], m_items[index-1]->m_groups[i]->m_text);
				}
				if (!b_new && index+1<countitems && l+1>=countl)
				{
					b_right_same = b_right_same_above && !GROUP_STRING_COMPARE(items[l].m_groups[i], m_items[index+1]->m_groups[i]->m_text);
				}
				if (!b_new && item_old.is_valid())
				{
					b_self_same = b_self_same_above && !GROUP_STRING_COMPARE(items[l].m_groups[i], item_old->m_groups[i]->m_text);
				}
				if (b_new || (!b_left_same && !b_right_same && !b_self_same))
				{
					item->m_groups[i] = storage_create_group(); 
					item->m_groups[i]->m_text = items[l].m_groups[i];
					b_new = true;
					item->m_display_index++;
				}
				if (b_left_same && b_right_same)
				{
					item->m_groups[i] = m_items[index-1]->m_groups[i];
					t_group_ptr test;
					{
						test = m_items[index+1]->m_groups[i];
						t_size j=index+1;
						while (j < countitems && test == m_items[j]->m_groups[i])
						{
							m_items[j]->m_groups[i] = item->m_groups[i];
							j++;
						}
					}
				}
				else if (b_left_same)
					item->m_groups[i] = m_items[index-1]->m_groups[i];
				else if (b_right_same)
				{
					item->m_display_index++;
					item->m_groups[i] = m_items[index+1]->m_groups[i];
				}
				else if (b_self_same)
				{
					item->m_groups[i] = item_old->m_groups[i];
					item->m_display_index++;
				}
				b_right_same_above = b_right_same;
				b_left_same_above = b_left_same;
				b_self_same_above = b_self_same;
			}
			if (l + 1 == countl && index + 1 < countitems)
			{
				for (i=0; i<count; i++)
				{
					{
						if ( items_prev[index]->m_groups[i] == items_prev[index+1]->m_groups[i])
						{
							if (m_items[index+1]->m_groups[i] != m_items[index]->m_groups[i])
							{
								t_group_ptr newgroup = storage_create_group();
								newgroup->m_text = (items_prev[index]->m_groups[i]->m_text);
								t_size j = index+1;
								while (j < countitems && items_prev[index]->m_groups[i] == items_prev[j]->m_groups[i])
								{
									m_items[j]->m_groups[i] = newgroup;
									j++;
								};
							}
						}
					}
				}
			}
		}
	}
	{
		t_size countl2 = index_start + countl < countitems ? countl+1 : countl;
		for (l=0; l<countl2; l++)
		{
			t_size i, count = m_group_count;
			t_size index = l + index_start;
			for (i=0; i<count; i++)
			{
				if ( (!index || m_items[index-1]->m_groups[i] != m_items[index]->m_groups[i])
					)
					newgroupcount++;
			}
		}
	}
	{
		t_size j = index_start+countl;

		//console::formatter() << newgroupcount << " " << oldgroupcount;

		while (j < countitems)
		{
			m_items[j]->m_display_index += ((newgroupcount-oldgroupcount));
			j++;
		}
	}
}
예제 #22
0
void t_list_view::__insert_items_v2(t_size index_start, const pfc::list_base_const_t<t_item_insert> & items)
{
	t_size l, countl = items.get_count();
	{
		pfc::list_t<t_item_ptr> itemsinsert;
		itemsinsert.set_count(countl);
		m_items.insert_items(itemsinsert, index_start);
	}


	pfc::list_t<t_item_ptr> items_prev(m_items);
	t_size countitems = m_items.get_count();
	t_size newgroupcount = 0, oldgroupcount=0;

// Calculate old group count
	{
		t_size index = index_start + countl ;
		if (index < countitems)
		{
			t_size i, count = m_group_count;
			for (i=0; i<count; i++)
			{
				if ( (!index_start || m_items[index_start - 1]->m_groups[i] != m_items[index]->m_groups[i])
					)
					oldgroupcount++;
			}
		}
	}

// Determine grouping
	{
		t_item_ptr * p_items = m_items.get_ptr();
		for (l=0; l<countl; l++)
		{
			t_size i, count = m_group_count;
			t_size index = l + index_start;
			t_item * item;
			{
				item = storage_create_item();
				p_items[index] = item;
				item->m_subitems = items[l].m_subitems;
				item->m_display_index = index ? p_items[index-1]->m_display_index + 1 : 0;
				item->m_groups.set_size(count);

			}
			bool b_new = false;

			bool b_left_same_above = true;
			bool b_right_same_above = true;
			for (i=0; i<count; i++)
			{
				bool b_left_same = false;
				bool b_right_same = false;
				if (!b_new && index)
				{
					b_left_same = b_left_same_above && !GROUP_STRING_COMPARE(items[l].m_groups[i], m_items[index-1]->m_groups[i]->m_text);
				}
				if (!b_new && index+1<countitems && l+1>=countl)
				{
					b_right_same = b_right_same_above && !GROUP_STRING_COMPARE(items[l].m_groups[i], m_items[index+1]->m_groups[i]->m_text);
				}
				if (b_new || (!b_left_same && !b_right_same))
				{
					item->m_groups[i] = storage_create_group();
					item->m_groups[i]->m_text = (items[l].m_groups[i]);
					b_new = true;
					item->m_display_index++;
				}
				if (b_left_same && b_right_same)
				{
					item->m_groups[i] = m_items[index-1]->m_groups[i];
					t_group_ptr test;
					{
						test = m_items[index+1]->m_groups[i];
						t_size j=index+1;
						while (j < countitems && test == m_items[j]->m_groups[i])
						{
							m_items[j]->m_groups[i] = item->m_groups[i];
							j++;
						}
					}
				}
				else if (b_left_same)
					item->m_groups[i] = m_items[index-1]->m_groups[i];
				else if (b_right_same)
				{
					item->m_display_index++;
					item->m_groups[i] = m_items[index+1]->m_groups[i];
				}
				b_right_same_above = b_right_same;
				b_left_same_above = b_left_same;
			}
		}
	}
	{
		t_size index = index_start + countl;
		if (index_start && index < countitems)
		{
			t_size index_prev = index_start - 1;
			t_size i, count = m_group_count;
			for (i=0; i<count; i++)
			{
				{
					if ( items_prev[index_prev]->m_groups[i] == items_prev[index]->m_groups[i])
					{
						if (m_items[index]->m_groups[i] != m_items[index-1]->m_groups[i])
						{
							t_group_ptr newgroup = storage_create_group();
							newgroup->m_text = (items_prev[index_prev]->m_groups[i]->m_text);
							t_size j = index;
							while (j < countitems && items_prev[index_prev]->m_groups[i] == items_prev[j]->m_groups[i])
							{
								m_items[j]->m_groups[i] = newgroup;
								j++;
							};
						}
					}
				}
			}
		}
	}
// Determine new group count
	{
		t_size countl2 = index_start + countl < countitems ? countl+1 : countl;
		for (l=0; l<countl2; l++)
		{
			t_size i, count = m_group_count;
			t_size index = l + index_start;
			for (i=0; i<count; i++)
			{
				if ( (!index || m_items[index-1]->m_groups[i] != m_items[index]->m_groups[i])
					)
					newgroupcount++;
			}
		}
	}
//Correct subsequent items
	{
		t_size j = index_start+countl;

		//console::formatter() << newgroupcount << " " << oldgroupcount;

		while (j < countitems)
		{
			m_items[j]->m_display_index += ((countl + newgroupcount-oldgroupcount));
			j++;
		}
	}
}
예제 #23
0
t_size metadb_handle_list_helper::bsearch_by_pointer(const pfc::list_base_const_t<metadb_handle_ptr> & p_list,const metadb_handle_ptr & val)
{
	t_size blah;
	if (p_list.bsearch_t(pfc::compare_t<metadb_handle_ptr,metadb_handle_ptr>,val,blah)) return blah;
	else return ~0;
}