コード例 #1
0
int CLibraryHeaderPanel::Update()
{
	CAlbumFolder* pFolder = GetSelectedAlbum();
	if ( pFolder == NULL || pFolder->m_pSchema == NULL ) return 0;

	m_nIcon32	= pFolder->m_pSchema->m_nIcon32;
	m_nIcon48	= pFolder->m_pSchema->m_nIcon48;

	m_sTitle	= pFolder->m_pSchema->m_sHeaderTitle;
	m_sSubtitle	= pFolder->m_pSchema->m_sHeaderSubtitle;

	if ( pFolder->GetParent() == NULL )
	{
		QWORD nTotalVolume;
		DWORD nTotalFiles;
		CString str;

		LibraryMaps.GetStatistics( &nTotalFiles, &nTotalVolume );
		str.Format( _T("%lu"), nTotalFiles );
		m_sSubtitle.Replace( _T("{totalFiles}"), str );
		str = Settings.SmartVolume( nTotalVolume, KiloBytes );
		m_sSubtitle.Replace( _T("{totalVolume}"), str );
	}

	pFolder->m_pSchema->ResolveTokens( m_sTitle, pFolder->m_pXML );
	pFolder->m_pSchema->ResolveTokens( m_sSubtitle, pFolder->m_pXML );

	if ( m_sTitle.IsEmpty() ) m_sTitle = pFolder->m_sName;

	m_pMetadata.Setup( pFolder->m_pSchema );
	m_pMetadata.Remove( pFolder->m_pSchema->GetFirstMemberName() );

	m_pMetadata.Combine( pFolder->m_pXML );

	m_pMetadata.CreateLinks();
	m_pMetadata.Clean( 54 );

	if ( m_pMetadata.GetCount() )
	{
		CClientDC dc( this );
		CFont* pFont = (CFont*)dc.SelectObject( &CoolInterface.m_fntNormal );
		m_nKeyWidth = m_nMetaWidth = 0;
		m_pMetadata.ComputeWidth( &dc, m_nKeyWidth, m_nMetaWidth );
		if ( m_nKeyWidth ) m_nKeyWidth += 8;
		m_nMetaWidth += m_nKeyWidth;
		dc.SelectObject( pFont );
	}

	if (m_hWnd) Invalidate();

	int nHeight = static_cast< int >( m_pMetadata.GetCount() * 12 + 8 );

	if ( pFolder->GetParent() )
	{
		nHeight = max( 64, nHeight );
	}
	else
	{
		nHeight = max( 56, nHeight );
	}

	return min( 80, nHeight );
}
コード例 #2
0
ファイル: CtrlLibraryTileView.cpp プロジェクト: GetEnvy/Envy
void CLibraryTileView::Update()
{
	CSingleLock oLock( &Library.m_pSection );
	if ( ! oLock.Lock( 250 ) )
	{
		Invalidate();
		return;
	}

	CLibraryTreeItem* pFolders	= GetFolderSelection();
	CAlbumFolder* pFolder		= NULL;

	if ( pFolders == NULL || pFolders->m_pVirtual == NULL )
	{
		pFolder = Library.GetAlbumRoot();
	}
	else
	{
		if ( pFolders->m_pSelNext != NULL || pFolders->m_pVirtual->GetFileCount() > 0 )
		{
			if ( ! empty() )
			{
				clear();
				Invalidate();
			}

			return;
		}

		pFolder = pFolders->m_pVirtual;
	}

	DWORD nCookie = GetFolderCookie();
	bool bChanged = false;

	for ( iterator pTile = begin(); pTile != end(); )
	{
		CAlbumFolder* pAlbum = (*pTile)->GetAlbum();
		if ( pAlbum && pAlbum->GetParent() == pFolder )
		{
			bChanged = (*pTile)->Update() || bChanged;
			pAlbum->m_nListCookie = nCookie;
			++pTile;
		}
		else
		{
			if ( (*pTile)->m_bSelected ) Select( pTile, TRI_FALSE );
			if ( pTile == m_pFocus ) m_pFocus = end();
			if ( pTile == m_pFirst ) m_pFirst = end();

			pTile = m_oList.erase( pTile );

			bChanged = true;
		}
	}

	if ( bChanged )
	{
		CRect rcClient;
		GetClientRect( &rcClient );
		int nMax	= (int)( ( size() + m_nColumns - 1 ) / m_nColumns ) * m_szBlock.cy;
		m_nScroll	= max( 0, min( m_nScroll, nMax - rcClient.Height() + 1 ) );
	}

	for ( POSITION pos = pFolder ? pFolder->GetFolderIterator() : NULL; pos; )
	{
		CAlbumFolder* pChild = pFolder->GetNextFolder( pos );

		if ( pChild->m_nListCookie != nCookie )
		{
			m_oList.push_back( new CLibraryTileItem( pChild ) );

			pChild->m_nListCookie = nCookie;
			bChanged = true;
		}
	}

	if ( bChanged )
	{
		// ToDo: Review if still necessary for modern libs, and no boost::ptr_list
		// Crude workaround broken std::list::sort (vc++7.1):
		// sort() may invalidate at the end iterator
		// As of Boost 1.33.0, ptr_list does not provide
		// iterator versions of sort, which might solve this problem just as well.
		BOOL bFocusAtEnd = m_pFocus == m_oList.end();
		BOOL bFirstAtEnd = m_pFirst == m_oList.end();

		m_oList.sort( SortList() );

		if ( bFocusAtEnd ) m_pFocus = m_oList.end();
		if ( bFirstAtEnd ) m_pFirst = m_oList.end();

		UpdateScroll();
	}
}