Example #1
0
bool nuiTreeBase::SetChild(uint32 Index, nuiTreePtr pChild)
{
  pChild->Acquire();
  if (mpChildren.size() < Index+1)
    mpChildren.resize(Index+1);
  if (mpChildren[Index])
    mpChildren[Index]->Release();
  else if (mpChildren[Index])
  {
    mTreeNodeEventSink.DisconnectSource(mpChildren[Index]->Changed);
    mpChildren[Index]->SetParent(NULL);
  }
  mpChildren[Index] = pChild;  
  mTreeNodeEventSink.Connect(pChild->Changed, &nuiTreeBase::OnChildChanged, pChild);
  mTreeNodeEventSink.Connect(pChild->ChildAdded, &nuiTreeBase::OnChildAdded, pChild);
  mTreeNodeEventSink.Connect(pChild->ChildDeleted, &nuiTreeBase::OnChildRemoved, pChild);
  mTreeNodeEventSink.Connect(pChild->Deleted, &nuiTreeBase::OnChildDeleted, pChild);
  
  pChild->SetParent(this);

  AutoSort();
  Changed();
  ChildAdded(this, pChild);
  return true;
}
Example #2
0
bool nuiTreeBase::InsertChild(uint32 Index, nuiTreePtr pChild)
{
  if (mpAutoSort)
    return AddChild(pChild);

  if (mpChildren.size() < Index+1)
    mpChildren.resize(Index+1);
  std::vector<nuiTreePtr>::iterator it = mpChildren.begin();
  it+=Index;
  if (it == mpChildren.end())
  {
    mpChildren.resize(mpChildren.size() - 1);
    return false;    
  }
  mpChildren.insert(it, pChild);
  pChild->Acquire();
  mTreeNodeEventSink.Connect(pChild->Changed, &nuiTreeBase::OnChildChanged, pChild);
  mTreeNodeEventSink.Connect(pChild->ChildAdded, &nuiTreeBase::OnChildAdded, pChild);
  mTreeNodeEventSink.Connect(pChild->ChildDeleted, &nuiTreeBase::OnChildRemoved, pChild);
  mTreeNodeEventSink.Connect(pChild->Deleted, &nuiTreeBase::OnChildDeleted, pChild);

  pChild->SetParent(this);

  AutoSort();
  Changed();
  ChildAdded(this, pChild);
  return true;
}
Example #3
0
void HaliteDialog::DialogListView::uiUpdate(const hal::torrent_details_manager& tD) 
{	
	if (hal::try_update_lock<list_class_t> lock{ this })
	{		
		selection_from_listview();
		
		peer_details_.clear();
		
		BOOST_FOREACH (const hal::uuid& id, tD.selected_uuids())
		{
			if (const hal::torrent_details_ptr t = tD.get(id))
				std::copy(t->get_peer_details().begin(), t->get_peer_details().end(), 
					std::inserter(peer_details_, peer_details_.begin()));
		}
		
		std::set<std::wstring> ip_set;
		BOOST_FOREACH (const hal::peer_detail& pd,  peer_details_)
			ip_set.insert(pd.ip_address);
		
		erase_based_on_set(ip_set, true);

		if (IsSortOnce() || AutoSort())
		{
			if (GetSecondarySortColumn() != -1)
			{
				int index = GetColumnSortType(GetSecondarySortColumn());					
				if (index > WTL::LVCOLSORT_LAST)
					sort(index - (WTL::LVCOLSORT_LAST+1+hal::peer_detail::ip_address_e), IsSecondarySortDescending());
			}

			if (GetSortColumn() != -1)
			{		
				int index = GetColumnSortType(GetSortColumn());				
				if (index > WTL::LVCOLSORT_LAST)
					sort(index - (WTL::LVCOLSORT_LAST+1+hal::peer_detail::ip_address_e), IsSortDescending());
			}
		}
		
		set_keys(ip_set);		
		InvalidateRect(NULL,true);
	}