Пример #1
0
void EmbeddedLinker::initTitle()
{
	EditorManager* editorManager = dynamic_cast<EditorViewScene*>(scene())->mainWindow()->manager();
	QString edgeTypeFriendly = editorManager->friendlyName(Id::loadFromString("qrm:/"+master->uuid().editor()+"/"+master->uuid().diagram()+"/"+edgeType.element()));

	float textWidth = edgeTypeFriendly.size()*10;
	float rectWidth = master->boundingRect().right() - master->boundingRect().left();
	float rectHeight = master->boundingRect().bottom() - master->boundingRect().top();

	int x = 0;
	int y = 0;
	if (scenePos().y() < master->scenePos().y() + rectHeight/3)
		y = -boundingRect().height() - 10;
	else if (scenePos().y() > master->scenePos().y() + 2*rectHeight/3)
		y = +boundingRect().height() - 10;

	if (scenePos().x() < master->scenePos().x() + rectWidth/3)
		x = -boundingRect().width() - textWidth + 20;
	else if (scenePos().x() > master->scenePos().x() + 2*rectWidth/3)
		x = +boundingRect().width() - 10;

	title = new ElementTitle(x,y,edgeTypeFriendly);
	title->setTextWidth(textWidth);
	title->setParentItem(this);
}
Пример #2
0
void PaletteToolbox::addSortedItemTypes(EditorManager &editman, const Id &diagram)
{
	mEditorManager = &editman;

	IdList list = editman.elements(diagram);

	qSort(list.begin(), list.end(), idLessThan);

	foreach (const Id element, list)
		addItemType(element, editman.friendlyName(element)
				, editman.description(element), editman.icon(element));
}