Esempio n. 1
0
void CFileDetailDialog::OnBnClickedTakeOver(wxCommandEvent& WXUNUSED(evt))
{
	CFileDetailListCtrl* pmyListCtrl;
	pmyListCtrl = CastChild( IDC_LISTCTRLFILENAMES, CFileDetailListCtrl );
	if (pmyListCtrl->GetSelectedItemCount() > 0) {
		// get first selected item (there is only one)
		long pos = pmyListCtrl->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
		if (pos != -1) {	// shouldn't happen, we checked if something is selected
			setValueForFilenameTextEdit(pmyListCtrl->GetItemText(pos));
		}
	}
}
Esempio n. 2
0
void CFileDetailDialog::OnListClickedTakeOver(wxListEvent& WXUNUSED(evt))
{
	CFileDetailListCtrl* pmyListCtrl;
	pmyListCtrl = CastChild( IDC_LISTCTRLFILENAMES, CFileDetailListCtrl );
	if (pmyListCtrl->GetSelectedItemCount() > 0) {
		long pos=-1;
		for(;;) {
			pos=pmyListCtrl->GetNextItem(pos,wxLIST_NEXT_ALL,wxLIST_STATE_SELECTED);
			if(pos==-1) {
				break;
			}
			setValueForFilenameTextEdit(pmyListCtrl->GetItemText(pos));
		}
	}
}
Esempio n. 3
0
void CFileDetailDialog::FillSourcenameList()
{
	CFileDetailListCtrl* pmyListCtrl; 
	int itempos;
	int inserted = 0; 
	pmyListCtrl = CastChild(IDC_LISTCTRLFILENAMES, CFileDetailListCtrl ); 

	// reset
	for (int i=0;i<pmyListCtrl->GetItemCount();i++){
		SourcenameItem *item = reinterpret_cast<SourcenameItem *>(pmyListCtrl->GetItemData(i));
		item->count = 0;
	}

	// update
#ifdef CLIENT_GUI
	const SourcenameItemMap &sources = m_file->GetSourcenameItemMap();
	for (SourcenameItemMap::const_iterator it = sources.begin(); it != sources.end(); ++it) {
		const SourcenameItem &cur_src = it->second;
		itempos = pmyListCtrl->FindItem(-1,cur_src.name);
		if (itempos == -1) {
			int itemid = pmyListCtrl->InsertItem(0, cur_src.name);
			SourcenameItem *item = new SourcenameItem(cur_src.name, cur_src.count);
			pmyListCtrl->SetItemPtrData(0, reinterpret_cast<wxUIntPtr>(item));
			// background.. argh -- PA: was in old version - do we still need this?
			wxListItem tmpitem;
			tmpitem.m_itemId = itemid;
			tmpitem.SetBackgroundColour(CMuleColour(wxSYS_COLOUR_LISTBOX));
			pmyListCtrl->SetItem(tmpitem);
			inserted++;
		} else { 
			SourcenameItem *item = reinterpret_cast<SourcenameItem *>(pmyListCtrl->GetItemData(itempos));
			item->count = cur_src.count;
		} 
	}
#else // CLIENT_GUI
	const CPartFile::SourceSet& sources = m_file->GetSourceList();
	CPartFile::SourceSet::const_iterator it = sources.begin();
	for ( ; it != sources.end(); ++it ) {
		const CUpDownClient &cur_src = **it; 
		if (cur_src.GetRequestFile() != m_file ||
		    cur_src.GetClientFilename().Length() == 0) {
			continue;
		}

		itempos = pmyListCtrl->FindItem(-1,cur_src.GetClientFilename());
		if (itempos == -1) { 
			int itemid = pmyListCtrl->InsertItem(0, cur_src.GetClientFilename()); 
			SourcenameItem *item = new SourcenameItem(cur_src.GetClientFilename(), 1);
			pmyListCtrl->SetItemPtrData(0, reinterpret_cast<wxUIntPtr>(item));
			// background.. argh -- PA: was in old version - do we still need this?
			wxListItem tmpitem;
			tmpitem.m_itemId=itemid;
			tmpitem.SetBackgroundColour(CMuleColour(wxSYS_COLOUR_LISTBOX));
			pmyListCtrl->SetItem(tmpitem);
			inserted++;
		} else { 
			SourcenameItem *item = reinterpret_cast<SourcenameItem *>(pmyListCtrl->GetItemData(itempos));
			item->count++;
		} 
	}
#endif // CLIENT_GUI

	// remove 0'er and update counts
	for (int i = 0; i < pmyListCtrl->GetItemCount(); ++i) {
		SourcenameItem *item = reinterpret_cast<SourcenameItem *>(pmyListCtrl->GetItemData(i));
		if (item->count == 0) {
			delete item;
			pmyListCtrl->DeleteItem(i);
			i--;  // PA: one step back is enough, no need to go back to 0
		} else {
			pmyListCtrl->SetItem(i, 1, wxString::Format(wxT("%li"), item->count));
		}
	}

	if (inserted) {
		pmyListCtrl->SortList();
	}
	// no need to call Layout() here, it's called in UpdateData()
}