Ejemplo n.º 1
0
bool wxGxContentView::AddObject(wxGxObject* const pObject)
{
    wxCriticalSectionLocker locker(m_CritSectCont);
    if(pObject == NULL)
		return false;

    //check doubles
	for(long i = 0; i < GetItemCount(); ++i)
	{
		LPITEMDATA pItemData = (LPITEMDATA)GetItemData(i);
		if(pItemData == NULL)
			continue;
        if(pItemData->nObjectID == pObject->GetId())
			return false;
    }

    //wxLogDebug(wxT("wxGxContentView::AddObject %d '%s'"), pObject->GetId(), pObject->GetFullName());
    IGxObjectUI* pObjUI =  dynamic_cast<IGxObjectUI*>(pObject);
	wxIcon icon_small, icon_large;
	if(pObjUI != NULL)
	{
		icon_small = pObjUI->GetSmallImage();
		icon_large = pObjUI->GetLargeImage();
	}

	int pos = GetIconPos(icon_small, icon_large);

	LPITEMDATA pData = new _itemdata;
	pData->nObjectID = pObject->GetId();
	pData->iImageIndex = pos;

    wxString sName;
    if(m_pCatalog->GetShowExt())
        sName = pObject->GetName();
    else
        sName = pObject->GetBaseName();

	wxString sType = pObject->GetCategory();

	long ListItemID = InsertItem(0, sName, pos);
	if(m_current_style == enumGISCVReport)
	{
		SetItem(ListItemID, 1, sType);
        IGxDataset* pDSet = dynamic_cast<IGxDataset*>(pObject);
        if(pDSet)
        {
            wxCriticalSectionLocker locker(m_CritSectFillMeta);
            m_anFillMetaIDs.Add(pObject->GetId());
        }
	}
	SetItemPtrData(ListItemID, (wxUIntPtr) pData);

    return true;
}
Ejemplo n.º 2
0
void wxGxContentView::OnObjectChanged(wxGxCatalogEvent& event)
{
    //wxLogDebug(wxT("ContentView Object %d Change"), event.GetObjectID());
    if(event.GetObjectID() == m_nParentGxObjectID)
	{
        wxGxObject* pGxObject = m_pCatalog->GetRegisterObject(event.GetObjectID());
		wxGxObjectContainer* pObjectContainer = wxDynamicCast(pGxObject, wxGxObjectContainer);
		if(pObjectContainer != NULL)
		{
			wxBusyCursor wait;
			if(GetItemCount() > 0 && !pObjectContainer->HasChildren())
			{
			    ResetContents();
			}
			else if(GetItemCount() == 0 && pObjectContainer->HasChildren())
			{
				RefreshAll();
				return;
			}
		}
	}

    bool bItemsHaveChanges = false;

	for(long i = 0; i < GetItemCount(); ++i)
	{
		LPITEMDATA pItemData = (LPITEMDATA)GetItemData(i);
		if(pItemData == NULL)
			continue;
		if(pItemData->nObjectID != event.GetObjectID())
			continue;

        wxGxObject* pGxObject = m_pCatalog->GetRegisterObject(event.GetObjectID());
		IGxObjectUI* pObjUI =  dynamic_cast<IGxObjectUI*>(pGxObject);
		wxIcon icon_small, icon_large;
		if(pObjUI != NULL)
		{
			icon_small = pObjUI->GetSmallImage();
			icon_large = pObjUI->GetLargeImage();
		}

        bool bChangeIcon = false;
        int pos = GetIconPos(icon_small, icon_large);
        bChangeIcon = pItemData->iImageIndex != pos;
		pItemData->iImageIndex = pos;

		wxString sName;
		if(m_pCatalog->GetShowExt())
			sName = pGxObject->GetName();
		else
			sName = pGxObject->GetBaseName();

		wxString sType = pGxObject->GetCategory();

        if (GetItemText(i, 0) != sName)
        {
		    SetItem(i, 0, sName, pos);
            if (m_currentSortCol == 0)
            {
                bItemsHaveChanges = true;
            }
        }
        else if(bChangeIcon)
        {
            SetItemImage(i, pos);
        }

        if(m_current_style == enumGISCVReport)
	    {
            if (GetItemText(i, 1) != sType)
            {
		        SetItem(i, 1, sType);
                if (m_currentSortCol == 1)
                {
                    bItemsHaveChanges = true;
                }
            }
            IGxDataset* pDSet = dynamic_cast<IGxDataset*>(pGxObject);
            if(pDSet)
            {
                if (pDSet->IsMetadataFilled())
                {
                    if (pDSet->GetSize() > 0)
                        SetItem(i, 2, wxFileName::GetHumanReadableSize(pDSet->GetSize()));
                    if (pDSet->GetModificationDate().IsValid())
                        SetItem(i, 3, pDSet->GetModificationDate().Format());
                }
                else
                {
                    wxCriticalSectionLocker locker(m_CritSectFillMeta);
                    m_anFillMetaIDs.Add(pGxObject->GetId());
                }
            }
	    }
	}

    if(bItemsHaveChanges)
    {
        SORTDATA sortdata = {m_bSortAsc, m_currentSortCol};
	    SortItems(GxObjectCVCompareFunction, (long)&sortdata);
    	SetColumnImage(m_currentSortCol, m_bSortAsc ? 0 : 1);
    }

//	wxListCtrl::Refresh();

}