Exemplo n.º 1
0
bool KWidget::itemPanel() const
{
    QGraphicsItem::GraphicsItemFlags vals = QGraphicsWidget::flags();
    return vals.testFlag(QGraphicsItem::ItemIsPanel) && acceptHoverEvents();
}
Exemplo n.º 2
0
void CodeAtlas::LodManager::computeChildLod(SymbolNode::Ptr& parent, 
											LodStatus parentStatus, 
											float parentProjD, 
											float parentClassD,
											int depth)
{
	for (SymbolNode::ChildIterator pChild = parent->childBegin();
		pChild != parent->childEnd(); ++pChild)
	{
		const SymbolInfo& childInfo = pChild.key();
		SymbolNode::Ptr& child = pChild.value();
		if (childInfo.elementType() & SymbolInfo::Block)
			continue;

		// determine node lod status
		NodeUIItem::Ptr uiItem = UIUtility::getUIItem(child);
		LodStatus lodStatus = parentStatus;
		float projD = parentProjD, classD = parentClassD;
		if (uiItem.isNull())
		{
			lodStatus = parentStatus;
		}
		else if (!uiItem->mapRectToScene(uiItem->boundingRect()).intersects(m_viewRect))
		{
			lodStatus = parentStatus;
		}
		// hide all childs
		else if (parentStatus & (LOD_INVISIBLE | LOD_FOLDED))
		{
			lodStatus = LOD_INVISIBLE;
			uiItem->setLodStatus(LOD_INVISIBLE);
		}
		else
		{
			SymbolInfo::ElementType type = childInfo.elementType();
			float viewDiam = uiItem->getEntityRadius() * m_lod * 2;
						
			if (type & (SymbolInfo::Class | SymbolInfo::Enum | SymbolInfo::Namespace))
			{
				classD = viewDiam;
				if (m_lod < 0.01 && parentProjD < 150)
					lodStatus = LOD_INVISIBLE;
				else if (m_lod > 0.1 || viewDiam > 200)
					lodStatus = LOD_EXPANDED;
				else
					lodStatus = LOD_FOLDED;
			}
			else if (type & (SymbolInfo::FunctionSignalSlot | SymbolInfo::Variable | SymbolInfo::Enumerator | SymbolInfo::Macro))
			{ 
				if (m_lod > 0.4  || viewDiam > 10)
					lodStatus = LOD_EXPANDED;
				else if (m_lod < 0.1 && parentProjD < 150)
					lodStatus = LOD_INVISIBLE;
				else
					lodStatus = LOD_FOLDED;
			}
			else if (type & (SymbolInfo::Project))
			{
				projD = viewDiam;
// 				if (m_lod < 0.01)
// 					lodStatus = LOD_INVISIBLE;
				if (m_lod > 0.01 || viewDiam > 150)
					lodStatus = LOD_EXPANDED;
				else
					lodStatus = LOD_FOLDED;
			}
			else
			{
				// always expanded
				lodStatus = LOD_EXPANDED;
			}
			uiItem->setLodStatus(lodStatus);
			
		}

		if (uiItem)
		{
			bool newSelectableFlag = lodStatus != LOD_INVISIBLE;
			QGraphicsItem::GraphicsItemFlags flags = uiItem->flags();
			if (flags.testFlag(QGraphicsItem::ItemIsSelectable) != newSelectableFlag)
				uiItem->setFlag(QGraphicsItem::ItemIsSelectable, lodStatus != LOD_INVISIBLE);
		}
		computeChildLod(child, lodStatus, projD, classD, depth + 1);
	}
}