Esempio n. 1
0
//-------------------------------------------------------------------------------
//
//-------------------------------------------------------------------------------
void tFilesTreeNodeBuilder::Run()
{
    DEBUG_TIMER_START();

    m_Lock.lock();

    QFileInfo fileInfo( m_Path );
    m_pTreeItem = new tFilesTreeItem( fileInfo, m_FriendlyName, m_Icon, m_pRootNode );
    m_pTreeItem->SetAllowOptionsColumn( true );   // if you don't all the options column here, the direct children do not get highlighted correctly.
    m_pTreeItem->SetOptionsIcon( qApp->style()->standardIcon( NIT(tNOSStyle::NIT_Options) ) ); // "My files" need menu options as well.

    if ( m_Quit )
    {
        delete m_pTreeItem;
        m_pTreeItem = 0;
        m_Lock.unlock();
        emit FilesTreeNodeComplete( m_Id );
        return;
    }

    unsigned long itemCount = 0;
    AppendDirContents( m_pTreeItem, m_Path, itemCount, m_DoTranslateNames );

    m_Lock.unlock();

    emit FilesTreeNodeComplete( m_Id );

    DEBUG_TIMER_FINISH();
}
void CGrannyListView::OnInitialUpdate()
{
	const UINT nMask = TVIF_TEXT | TVIF_PARAM;

	CTreeView::OnInitialUpdate();
	
	DEBUG_TIMER_START("CGrannyListView::OnInitialUpdate()");

	CTreeCtrl& tree=GetTreeCtrl();
	tree.DeleteAllItems();

	m_htItem[ROOT]     = tree.InsertItem("Models");
	m_htItem[MALE]     = tree.InsertItem("Male",         m_htItem[ROOT]); // animset id 0
	m_htItem[FEMALE]   = tree.InsertItem("Female",       m_htItem[ROOT]); // animset id 1
	m_htItem[ANIMAL]   = tree.InsertItem("Animals",      m_htItem[ROOT]); // animset id 2
	m_htItem[MONSTER]  = tree.InsertItem("Monsters",     m_htItem[ROOT]); // animset id 3
	m_htItem[SEACRET]  = tree.InsertItem("SeaCreatures", m_htItem[ROOT]); // animset id 4
	HTREEITEM htEquip  = tree.InsertItem("Equipments",   m_htItem[ROOT]);
	m_htItem[OTHER]	   = tree.InsertItem("Others",       m_htItem[ROOT]);
	m_htItem[ELEFT]	   = tree.InsertItem("Left",              htEquip);
	m_htItem[ERIGHT]   = tree.InsertItem("Right",             htEquip);
	m_htItem[EMCOL]	   = tree.InsertItem("Male Clothes",      htEquip);
	m_htItem[EFCOL]	   = tree.InsertItem("Female Clothes",    htEquip);
	m_htItem[EOTHER]   = tree.InsertItem("Other",             htEquip);
	
	CGrannyViewerDoc* pDoc = GetDocument(); ASSERT(pDoc);
	cGrannyLoader* pLoader = pDoc->GetGrannyLoader(); 
	if (!pLoader) 
	{
		DEBUG_TIMER_STOP("CGrannyListView::OnInitialUpdate()");
		return;
	}

	//InsertAnimation(tree, htAnim, pLoader);

	GrannyModelMap &models = pLoader->GetGrannyModels();
	
	std::map<Uint32, HTREEITEM> mapEquip;
	
	for (GrannyModelMapIter iter = models.begin(); iter != models.end(); iter++) 
	{
		Uint32 id = iter->first;
		Uint32 assign = GETASSIGN(id);
		if (!assign) 
		{
			// aos part model
			if (ISPART(id)) continue;

			// insert char model
			HTREEITEM htEquip;

			cGrannyModelTD *td = dynamic_cast<cGrannyModelTD*>(iter->second);
			if (td) 
			{
				htEquip = InsertModelTD(tree, GetHtItem(assign,td), id, td);
			}
			else
			{
				cGrannyModelAOS *aos = dynamic_cast<cGrannyModelAOS*>(iter->second);
				if (!aos) continue;
				htEquip = InsertModelAOS(tree,  GetHtItem(assign,aos), id, aos);
			}
		}
		else 
		{
			// insert equip item
			cGrannyModelTD* model = reinterpret_cast<cGrannyModelTD*>(iter->second);
			
			InsertEquipItem(tree, GetHtItem(id, model), id, model);
		}
	}

	tree.Expand(m_htItem[ROOT], TVE_EXPAND);

	DEBUG_TIMER_STOP("CGrannyListView::OnInitialUpdate()");
}