当前位置: 首页>>代码示例>>C++>>正文


C++ NodeElement::alignToGrid方法代码示例

本文整理汇总了C++中NodeElement::alignToGrid方法的典型用法代码示例。如果您正苦于以下问题:C++ NodeElement::alignToGrid方法的具体用法?C++ NodeElement::alignToGrid怎么用?C++ NodeElement::alignToGrid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NodeElement的用法示例。


在下文中一共展示了NodeElement::alignToGrid方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: handleNodeElementsForRowsInserted

void EditorViewMViface::handleNodeElementsForRowsInserted(
		const QList<QPair<NodeElement *, QPersistentModelIndex> > &nodes
		, const QModelIndex &parent
		)
{
	for (const QPair<NodeElement *, QPersistentModelIndex> &p : nodes) {
		NodeElement *elem = p.first;
		QPersistentModelIndex current = p.second;
		Id currentId = current.data(roles::idRole).value<Id>();
		bool needToProcessChildren = true;

		if (elem) {
			QPointF ePos = model()->data(current, roles::positionRole).toPointF();
			// setting position before parent definition 'itemChange' to work correctly
			elem->setPos(ePos);
			elem->setGeometry(mGraphicalAssistApi->configuration(elem->id()).boundingRect().translated(ePos.toPoint()));
			handleAddingSequenceForRowsInserted(parent, elem, current);
			handleElemDataForRowsInserted(elem, current);

			if (currentId.element() == "Class" && mGraphicalAssistApi->children(currentId).empty())
			{
				needToProcessChildren = false;
				for (int i = 0; i < 2; i++) {
					QString curChildElementType = (i == 0) ? "MethodsContainer" : "FieldsContainer";
					Id newUuid = Id("Kernel_metamodel", "Kernel", curChildElementType, QUuid::createUuid().toString());
					mGraphicalAssistApi->createElement(currentId, newUuid
							, false,  "(anonymous something)", QPointF(0, 0));
				}
			}
		}

		if (needToProcessChildren && model()->hasChildren(current)) {
			rowsInserted(current, 0, model()->rowCount(current) - 1);
		}

		if (elem) {
			elem->alignToGrid();
		}
	}
}
开发者ID:ZiminGrigory,项目名称:qreal,代码行数:40,代码来源:editorViewMVIface.cpp

示例2: rowsInserted

void EditorViewMViface::rowsInserted(QModelIndex const &parent, int start, int end)
{
	for (int row = start; row <= end; ++row) {
		mScene->setEnabled(true);

		QPersistentModelIndex current = model()->index(row, 0, parent);
		if (!isDescendentOf(current, rootIndex()))
			continue;
		Id currentId = current.data(roles::idRole).value<Id>();
		if (currentId == Id::rootId())
			continue;
		Id parentUuid;
		if (parent != rootIndex())
			parentUuid = parent.data(roles::idRole).value<Id>();
		if (!parent.isValid()) {
			setRootIndex(current);
			continue;
		}

		Element* elem = mScene->mainWindow()->manager()->graphicalObject(currentId);
		if (elem) {
			elem->setAssistApi(mGraphicalAssistApi, mLogicalAssistApi);
		}

		QPointF ePos = model()->data(current, roles::positionRole).toPointF();
		bool needToProcessChildren = true;
		if (elem) {
			elem->setPos(ePos);	//задаем позицию до определения родителя для того, чтобы правильно отработал itemChange
			elem->setId(currentId);

	/*commented out because of real sizes of elements are incorrectly changing here into initial sizes*/
//			NodeElement* nodeElement = dynamic_cast<NodeElement*>(elem);
//			if (nodeElement)
//				nodeElement->storeGeometry();

			if (item(parent) != NULL) {
				elem->setParentItem(item(parent));
				QModelIndex next = current.sibling(current.row() + 1, 0);
				if(next.isValid() && item(next) != NULL) {
					elem->stackBefore(item(next));
				}
			} else {
				mScene->addItem(elem);
			}
			setItem(current, elem);
			elem->updateData();
			elem->connectToPort();
			elem->checkConnectionsToPort();
			elem->initPossibleEdges();
			elem->initTitles();
//			elem->initEmbeddedControls();
			//todo: нужно привести в порядок всякие init~()

			bool isEdgeFromEmbeddedLinker = false;
			QList<QGraphicsItem*> selectedItems = mScene->selectedItems();
			if (selectedItems.size() == 1) {
				NodeElement* master = dynamic_cast<NodeElement*>(selectedItems.at(0));
				if (master && master->connectionInProgress()) {
					isEdgeFromEmbeddedLinker = true;
				}
			}

			if (!isEdgeFromEmbeddedLinker) {
				mScene->clearSelection();
				elem->setSelected(true);
			}

			NodeElement* nodeElem = dynamic_cast<NodeElement*>(elem);
			if (nodeElem && currentId.element() == "Class" &&
				mGraphicalAssistApi->children(currentId).empty())
			{
				needToProcessChildren = false;
				for (int i = 0; i < 2; i++) {
					QString curChildElementType;
					if (i == 0)
						curChildElementType = "MethodsContainer";
					else
						curChildElementType = "FieldsContainer";
					Id newUuid = Id("Kernel_metamodel", "Kernel",
							curChildElementType, QUuid::createUuid().toString());

					mGraphicalAssistApi->createElement(currentId, newUuid, false,  "(anonymous something)", QPointF(0, 0));
				}
			}
		}
		if (needToProcessChildren && model()->hasChildren(current))
			rowsInserted(current, 0, model()->rowCount(current) - 1);

		NodeElement * nodeElement = dynamic_cast<NodeElement*>(elem);
		if (nodeElement)
			nodeElement->alignToGrid();
	}
	QAbstractItemView::rowsInserted(parent, start, end);
}
开发者ID:ArtemKopylov,项目名称:qreal,代码行数:94,代码来源:editorViewMVIface.cpp


注:本文中的NodeElement::alignToGrid方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。