Example #1
0
void FolderTree::UpdateParentItems(HTREEITEM hItem)
{
	HTREEITEM hParent = GetParentItem(hItem);
	if(hParent != NULL && HasSharedParent(hParent) == NULL)
	{
		SetHasSharedChildren(hParent);
		UpdateParentItems(hParent);
	}
}
void FolderTree::UpdateParentItems(HTREEITEM hItem)
{
	HTREEITEM hParent = GetParentItem(hItem);
	if(hParent != NULL && HasSharedParent(hParent) == NULL)
	{
		SetHasSharedChildren(hParent, sp->getViewItems(sp->curProfile));
		UpdateParentItems(hParent);
	}
}
Example #3
0
HTREEITEM FolderTree::InsertFileItem(HTREEITEM hParent, FolderTreeItemInfo *pItem, bool bShared, int nIcon, int nSelIcon, bool bCheckForChildren)
{
	tstring sLabel;

	//Correct the label if need be
	if(IsDrive(pItem->m_sFQPath) && m_bShowDriveLabels)
		sLabel = GetDriveLabel(pItem->m_sFQPath);
	else
		sLabel = GetCorrectedLabel(pItem);

	//Add the actual item
	TV_INSERTSTRUCT tvis;
	memzero(&tvis, sizeof(TV_INSERTSTRUCT));
	tvis.hParent = hParent;
	tvis.hInsertAfter = TVI_LAST;
	tvis.item.mask = TVIF_CHILDREN | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_TEXT | TVIF_PARAM;
	tvis.item.iImage = nIcon;
	tvis.item.iSelectedImage = nSelIcon;

	tvis.item.lParam = (LPARAM) pItem;
	tvis.item.pszText = (LPWSTR)sLabel.c_str();
	if (bCheckForChildren)
		tvis.item.cChildren = HasGotSubEntries(pItem->m_sFQPath);
	else
		tvis.item.cChildren = true;

	if(bShared)
	{
		tvis.item.mask |= TVIF_STATE;
		tvis.item.stateMask |= TVIS_OVERLAYMASK;
		tvis.item.state |= INDEXTOOVERLAYMASK(1); //1 is the index for the shared overlay image
	}

	HTREEITEM hItem = InsertItem(&tvis);
	
	bool bChecked = false;
	if (!pItem->m_sFQPath.empty()) {
		string path = Text::fromT(pItem->m_sFQPath);
		if( path[ path.length() -1 ] != PATH_SEPARATOR )
			path += PATH_SEPARATOR;

		bChecked = sp->shareFolder(path);
		SetChecked(hItem, bChecked);
	}

	if(!bChecked)
		SetHasSharedChildren(hItem);

	return hItem;
}
Example #4
0
void FolderTree::Refresh() {
	//Just in case this will take some time
	//CWaitCursor wait;

	SetRedraw(FALSE);

	//Get the item which is currently selected
	HTREEITEM hSelItem = GetSelectedItem();
	tstring sItem;
	bool bExpanded = false;
	if (hSelItem)
	{
		sItem = ItemToPath(hSelItem);
		bExpanded = IsExpanded(hSelItem);
	}

	theSharedEnumerator.Refresh();

	//Remove all nodes that currently exist
	Clear();

	//Display the folder items in the tree
	if (m_sRootFolder.empty()) {
		//Should we insert a "My Computer" node
		if (m_bShowMyComputer) {
			FolderTreeItemInfo* pItem = new FolderTreeItemInfo;
			pItem->m_bNetworkNode = false;
			int nIcon = 0;
			int nSelIcon = 0;

			//Get the localized name and correct icons for "My Computer"
			LPITEMIDLIST lpMCPidl;
			if (SUCCEEDED(SHGetSpecialFolderLocation(NULL, CSIDL_DRIVES, &lpMCPidl))) {
				SHFILEINFO sfi;
				if (SHGetFileInfo((LPCTSTR)lpMCPidl, 0, &sfi, sizeof(sfi), SHGFI_PIDL | SHGFI_DISPLAYNAME))
				pItem->m_sRelativePath = sfi.szDisplayName;
				nIcon = GetIconIndex(lpMCPidl);
				nSelIcon = GetSelIconIndex(lpMCPidl);

				//Free up the pidl now that we are finished with it
				//ASSERT(m_pMalloc);
				m_pMalloc->Free(lpMCPidl);
				m_pMalloc->Release();
			}

			//Add it to the tree control
			m_hMyComputerRoot = InsertFileItem(TVI_ROOT, pItem, false, nIcon, nSelIcon, false);
			SetHasSharedChildren(m_hMyComputerRoot);
		}

		//Display all the drives
		if (!m_bShowMyComputer)
			DisplayDrives(TVI_ROOT, false);

		//Display homegroup
		/*if (m_bDisplayNetwork) {
			FolderTreeItemInfo* pItem = new FolderTreeItemInfo;
			//pItem-> = true;
			int nIcon = 0;
			int nSelIcon = 0;

			//Get the localized name and correct icons for "Network Neighborhood"
			LPITEMIDLIST lpNNPidl;
			//SHGetKnownFolderIDList(FOLDERID_HomeGroup, 0, NULL, &lpNNPidl);

			if (SUCCEEDED(SHGetKnownFolderIDList(FOLDERID_HomeGroup, 0, NULL, &lpNNPidl))) {
				SHFILEINFO sfi;
				if (SHGetFileInfo((LPCTSTR)lpNNPidl, 0, &sfi, sizeof(sfi), SHGFI_PIDL | SHGFI_DISPLAYNAME))
				pItem->m_sRelativePath = sfi.szDisplayName;
				nIcon = GetIconIndex(lpNNPidl);
				nSelIcon = GetSelIconIndex(lpNNPidl);

				//Free up the pidl now that we are finished with it
				//ASSERT(m_pMalloc);
				m_pMalloc->Free(lpNNPidl);
				m_pMalloc->Release();
			}

			//Add it to the tree control
			m_hHomegroupRoot = InsertFileItem(TVI_ROOT, pItem, false, nIcon, nSelIcon, false, shared);
			SetHasSharedChildren(m_hHomegroupRoot, shared);
			//checkRemovedDirs(Util::emptyStringT, TVI_ROOT, shared);
		}*/

		//Also add network neighborhood if requested to do so
		if (m_bDisplayNetwork) {
			FolderTreeItemInfo* pItem = new FolderTreeItemInfo;
			pItem->m_bNetworkNode = true;
			int nIcon = 0;
			int nSelIcon = 0;

			//Get the localized name and correct icons for "Network Neighborhood"
			LPITEMIDLIST lpNNPidl;
			if (SUCCEEDED(SHGetSpecialFolderLocation(NULL, CSIDL_NETWORK, &lpNNPidl))) {
				SHFILEINFO sfi;
				if (SHGetFileInfo((LPCTSTR)lpNNPidl, 0, &sfi, sizeof(sfi), SHGFI_PIDL | SHGFI_DISPLAYNAME))
				pItem->m_sRelativePath = sfi.szDisplayName;
				nIcon = GetIconIndex(lpNNPidl);
				nSelIcon = GetSelIconIndex(lpNNPidl);

				//Free up the pidl now that we are finished with it
				//ASSERT(m_pMalloc);
				m_pMalloc->Free(lpNNPidl);
				m_pMalloc->Release();
			}

			//Add it to the tree control
			m_hNetworkRoot = InsertFileItem(TVI_ROOT, pItem, false, nIcon, nSelIcon, false);
			SetHasSharedChildren(m_hNetworkRoot);
			//checkRemovedDirs(Util::emptyStringT, TVI_ROOT, shared);
		}
	} else {
		DisplayPath(m_sRootFolder, TVI_ROOT, false);
	}

	//Reselect the initially selected item
	if (hSelItem)
		SetSelectedPath(sItem, bExpanded);

	//Turn back on the redraw flag
	SetRedraw(true);
}
Example #5
0
void FolderTree::SetHasSharedChildren(HTREEITEM hItem)
{
	SetHasSharedChildren(hItem, GetHasSharedChildren(hItem));
}
void FolderTree::SetHasSharedChildren(HTREEITEM hItem, const ShareDirInfo::List& aShared)
{
	SetHasSharedChildren(hItem, GetHasSharedChildren(hItem, aShared));
}