Exemplo n.º 1
0
void SceneTree::ShowContextMenu(const QPoint &pos)
{
	QModelIndex index = indexAt(pos);
	DAVA::Entity *clickedEntity = treeModel->GetEntity(index);

	if(NULL != clickedEntity)
	{
		QMenu contextMenu;

		contextMenu.addAction(QIcon(":/QtIcons/zoom.png"), "Look at", this, SLOT(LookAtSelection()));
		contextMenu.addSeparator();
		contextMenu.addAction(QIcon(":/QtIcons/remove.png"), "Remove", this, SLOT(RemoveSelection()));
		contextMenu.addSeparator();
		QAction *lockAction = contextMenu.addAction(QIcon(":/QtIcons/lock_add.png"), "Lock", this, SLOT(LockEntities()));
		QAction *unlockAction = contextMenu.addAction(QIcon(":/QtIcons/lock_delete.png"), "Unlock", this, SLOT(UnlockEntities()));

		if(clickedEntity->GetLocked())
		{
			lockAction->setDisabled(true);
		}
		else
		{
			unlockAction->setDisabled(true);
		}

		contextMenu.exec(mapToGlobal(pos));
	}
}
Exemplo n.º 2
0
void SceneTreeDelegate::customDraw(QPainter *painter, QStyleOptionViewItem *option, const QModelIndex &index) const
{
	DAVA::Entity *entity = index.data(SceneTreeItem::TreeItemEntityRole).value<DAVA::Entity*>();

	if(NULL != entity && entity->GetLocked())
	{
		QRect owRect = option->rect;
		owRect.setLeft(owRect.right() - 16);

		lockedIcon.paint(painter, owRect);

		option->rect.setRight(owRect.left());
	}
}