/* void NodeItem::mouseMoveEvent(QGraphicsSceneDragDropEvent *event) { event->setAccepted(true); } void ParameterItem::mousePressEvent(QGraphicsSceneDragDropEvent *event) { event->setAccepted(false); } */ void ParameterItem::mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ) { if (event->button() == Qt::LeftButton) { setColor(Qt::darkCyan); // force my box to snap to grid, just truncate the pixel number and // snap to the next lowest grid value if (fmod(_location.x(),_gridSpace) >_gridSpace/2) _location.setX( ( static_cast<int>(_location.x()+_gridSpace) / _gridSpace) * _gridSpace ); else _location.setX( ( static_cast<int>(_location.x()) / _gridSpace) * _gridSpace ); if (fmod(_location.y(),_gridSpace) >_gridSpace/2) _location.setY( ( static_cast<int>(_location.y()+_gridSpace) / _gridSpace) * _gridSpace ); else _location.setY( ( static_cast<int>(_location.y()) / _gridSpace) * _gridSpace ); foreach (QGraphicsItem *item, collidingItems()) { if (item->type() ==GroupItem::Type){ this->setPos(mapToItem(item,0,0)); setParentItem(item); } else { this->setPos(mapToScene(0,0)); this->setParentItem(0); } } if (scene()->itemAt(_location)){ switch (scene()->itemAt(_location)->type()){ case GroupItem::Type: //Group setParentItem(scene()->itemAt(_location)); this->setPos(_location-(this->parentItem()->pos())); break; case NodeItem::Type: //Node or Test NodeItem *node; node=qgraphicsitem_cast<NodeItem *>(scene()->itemAt(_location)); node->addParamItem(this); scene()->removeItem(this); break; case 8: //TextItem -> check for parent if (scene()->itemAt(_location)->parentItem()->type() ==NodeItem::Type){ //Node or Test NodeItem *node; node=qgraphicsitem_cast<NodeItem *>(scene()->itemAt(_location)->parentItem()); node->addParamItem(this); scene()->removeItem(this); } break; } } event->setAccepted(true);// tell the base class we are handling this event }
canvas_sort::canvas_sort(canvas_view *i_oGraphWidget, canvas_item *i_oFrom) : QGraphicsEllipseItem(), m_oGraph(i_oGraphWidget) { m_oFrom = i_oFrom; setZValue(123); //setRect(0, 0, 20, 20); //m_oColor = QColor("#FFFCD5"); //m_oColor = QColor("#ABFBC7"); hide(); QPen l_oPen; l_oPen.setWidth(1); setPen(l_oPen); QRectF l_oRect; l_oRect.setTopLeft(QPointF(0, 0)); l_oRect.setWidth(20); l_oRect.setHeight(20); setRect(l_oRect); setBrush(QColor(255, 255, 0)); setPos(QPointF(-30, 0)); setParentItem(m_oFrom); }
void MachineItem::mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ) { if (event->button() == Qt::LeftButton) { setColor(Qt::cyan); // force my box to snap to grid, just truncate the pixel number and // snap to the next lowest grid value if (fmod(_location.x(),_gridSpace) >_gridSpace/2) _location.setX( ( static_cast<int>(_location.x()+_gridSpace) / _gridSpace) * _gridSpace ); else _location.setX( ( static_cast<int>(_location.x()) / _gridSpace) * _gridSpace ); if (fmod(_location.y(),_gridSpace) >_gridSpace/2) _location.setY( ( static_cast<int>(_location.y()+_gridSpace) / _gridSpace) * _gridSpace ); else _location.setY( ( static_cast<int>(_location.y()) / _gridSpace) * _gridSpace ); foreach (QGraphicsItem *item, collidingItems()) { if (item->type() ==GroupItem::Type){ this->setPos(mapToItem(item,0,0)); setParentItem(item); } else { this->setPos(mapToScene(0,0)); this->setParentItem(0); } } event->setAccepted(true);// tell the base class we are handling this event }
DocBlock::DocBlock(QPointF pos, BlockGroup *parentgroup) //! manual creation : Block(new TreeElement("doc_comment", true, true), 0, parentgroup) { element->setFloating(true); // find arrow target Block *arrowTarget = group->selectedBlock(); setParentBlock(arrowTarget); //! set parent block // clean up removeLinks(); //! remove all "contacts with family" setParentItem(parentgroup); //! set group as parent item myTextItem->adaptToFloating(); //! disconnect all harmful signals // set flags docType = Generic; setFlag(QGraphicsItem::ItemIsMovable); setFlag(QGraphicsItem::ItemClipsChildrenToShape, false); myTextItem->setTextInteractionFlags(Qt::NoTextInteraction); setAcceptDrops(false); setZValue(1); backup = 0; setPos(pos); setVisible(true); locked = true; highlightFormat = group->docScene->getFormatFor(element->getType()); highlight(highlightFormat); // add arrow arrow = 0; addArrowTo(arrowTarget); }
Applet::Applet(PanelWindow* panelWindow) : m_panelWindow(panelWindow), m_highlightIntensity(0.0), m_interactive(false) { setZValue(-1.0); setAcceptedMouseButtons(Qt::RightButton); setParentItem(m_panelWindow->panelItem()); }
Line::Line(const Line &rhs, QGraphicsItem *parent) : GridSnap(rhs) { setParentItem(parent); copy(rhs); setFlag(ItemStacksBehindParent, true); }
MozQWidgetFast::MozQWidgetFast(nsWindow* aReceiver, QGraphicsItem* aParent) { setParentItem(aParent); char exePath[MAXPATHLEN]; QStringList arguments = qApp->arguments(); nsresult rv = mozilla::BinaryPath::Get(arguments.at(0).toLocal8Bit().constData(), exePath); if (NS_FAILED(rv)) { printf("Cannot read default path\n"); return; } char *lastSlash = strrchr(exePath, XPCOM_FILE_PATH_SEPARATOR[0]); if (!lastSlash || (lastSlash - exePath > int(MAXPATHLEN - sizeof(XPCOM_DLL) - 1))) { return; } strcpy(++lastSlash, "/"); QString resourcePath(QString((const char*)&exePath) + DRAWABLE_PATH); mToolbar.load(resourcePath + TOOLBAR_SPLASH); mIcon.load(resourcePath + FAVICON_SPLASH); for (int i = 1; i < arguments.size(); i++) { QUrl url = QUrl::fromUserInput(arguments.at(i)); if (url.isValid()) { mUrl = url.toString(); } } }
MultiStepRangeBackgroundItem::MultiStepRangeBackgroundItem( Steps *_steps, Range *_range, Meta *_meta, int _offset_x, int _offset_y, QGraphicsItem *parent) { meta = _meta; page = _steps; MultiStepMeta *multiStep = &_meta->LPub.multiStep; background = NULL; border = NULL; margin = &multiStep->margin; placement = &multiStep->placement; freeform = &multiStep->freeform; alloc = &multiStep->alloc; subModelFont = &multiStep->subModelFont; subModelFontColor = &multiStep->subModelFontColor; perStep = &multiStep->pli.perStep; relativeType = _steps->relativeType; int tx = _offset_x+_range->loc[XX]; int ty = _offset_y+_range->loc[YY]; setRect(tx,ty, _steps->size[XX], _steps->size[YY]); setPen(QPen(Qt::NoPen)); setBrush(QBrush(Qt::NoBrush)); setToolTip("Step Group - popup menu"); setParentItem(parent); setZValue(-2); }
GraphicsUnrootedBranchItem::GraphicsUnrootedBranchItem(QGraphicsItem* parent, qreal angle, GraphicsRectangularBranchItem* from, double nodeValue) : GraphicsBranchItem(true, nodeValue) { setParentItem(parent); qreal w = from->getWidth(); settings = from->getSettings(); setWidthW(w); setDist(from->getDist()); setPos(w, 0); angle = from->getDirection() == GraphicsBranchItem::up ? angle : -angle; setTransform(QTransform().translate(-w, 0).rotate(angle).translate(w, 0)); // setTransformOriginPoint(-w, 0); // setRotation(angle); if (from->getNameText() != NULL) { nameText = new QGraphicsSimpleTextItem(from->getNameText()->text(), this); nameText->setFont(from->getNameText()->font()); nameText->setBrush(from->getNameText()->brush()); } if (from->getDistanceText() != NULL) { distanceText = new QGraphicsSimpleTextItem(from->getDistanceText()->text(), this); distanceText->setFont(from->getDistanceText()->font()); distanceText->setBrush(from->getDistanceText()->brush()); } setLabelPositions(); setPen(from->pen()); }
Pin::Pin(const Pin &rhs, QGraphicsItem *parent) : GridSnap(rhs), pinname(this), pinnumber(this) { setParentItem(parent); copy(rhs); }
Line::Line(QGraphicsItem *parent) : GridSnap(GS10) { setParentItem(parent); setFlags(/*ItemIsMovable |ItemIsSelectable |*/ ItemSendsGeometryChanges | ItemUsesExtendedStyleOption); setPen(FreeSCH::standardPen); setFlag(ItemStacksBehindParent, true); }
Pinhead::Pinhead(QGraphicsItem *parent, QPoint p, int pointIndex, JunctionStyle style) : GridSnap(GS120), pointIndex(pointIndex), style(JunctionStyleUnknown) { setParentItem(parent); setPos(p.x(), p.y()); setJunction(style); // setFlags(ItemStacksBehindParent); setAcceptHoverEvents(true); }
Section::Section(const Section &rhs, QGraphicsItem *parent) : QGraphicsRectItem(rhs.rect()), GridSnap(rhs), attributes(rhs.attributes) { setParentItem(parent); graphic.setParentItem(this); copy(rhs); }
/*virtual*/ void AbstractItemContainer::setItemView(AbstractItemView *view) { m_itemView = view; if (m_itemView) { setParentItem(m_itemView); m_itemView->installEventFilter(this); } }
FriendItem::FriendItem(QGraphicsItem *parent) { mShade = 0; setParentItem(parent); mPanel = QImage(QDir::toNativeSeparators( PlexyDesk::Config::getInstance()->plexydeskBasePath() + "/share/plexy/theme/skins/default/widget/friendswidget/panel.png")); mIcon = QPixmap(QDir::toNativeSeparators( PlexyDesk::Config::getInstance()->plexydeskBasePath() + "/share/plexy/theme/skins/default/widget/friendswidget/face.png")); }
ProgressBarGraphicsItem::ProgressBarGraphicsItem(PortOwnerGraphicsItem* parent, const QPointF& center, qreal width, qreal height) : NWEBaseGraphicsItem(parent->getNetworkEditor()) , backgroundColor1_(3, 3, 3) , backgroundColor2_(21, 21, 21) { setParentItem(parent); resize(center, width, height); time_.start(); setProgressTier(0); }
PixButtonExtraHitArea::PixButtonExtraHitArea(PixButton& ownerButton,const QSize& area) : m_savedOwnerSize(ownerButton.geometry().size()) , m_qp_ownerButton(&ownerButton) { setFlag(ItemHasNoContents,true); QSize effArea = QSize(qMax(area.width(),ownerButton.geometry().size().toSize().width()), qMax(area.height(),ownerButton.geometry().size().toSize().height())); m_boundingRect = DimensionsGlobal::realRectAroundRealPoint(effArea); setParentItem(&ownerButton); }
MozQWidget::MozQWidget(nsWindow* aReceiver, QGraphicsItem* aParent) : mReceiver(aReceiver) { setParentItem(aParent); #if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 0)) setFlag(QGraphicsItem::ItemAcceptsInputMethod); setAcceptTouchEvents(true); #endif setAcceptHoverEvents(true); }
LinkDialogProcessorGraphicsItem::LinkDialogProcessorGraphicsItem(Side side, Processor* processor) : GraphicsItemData<Processor>(nullptr, side, processor) { setZValue(linkdialog::processorDepth); setFlags(ItemSendsGeometryChanges); setRect(-linkdialog::processorWidth / 2, -linkdialog::processorHeight / 2, linkdialog::processorWidth, linkdialog::processorHeight); auto identifier = new LabelGraphicsItem(this); identifier->setPos(rect().topLeft() + QPointF(linkdialog::offset, linkdialog::offset)); identifier->setDefaultTextColor(Qt::white); auto idFont = QFont("Segoe", linkdialog::processorLabelHeight, QFont::Bold, false); idFont.setPixelSize(linkdialog::processorLabelHeight); identifier->setFont(idFont); identifier->setCrop(20, 19); auto classIdentifier = new LabelGraphicsItem(this); classIdentifier->setDefaultTextColor(Qt::lightGray); auto classFont = QFont("Segoe", linkdialog::processorLabelHeight, QFont::Normal, true); classFont.setPixelSize(linkdialog::processorLabelHeight); classIdentifier->setFont(classFont); classIdentifier->setCrop(20, 19); auto offset = classIdentifier->boundingRect().height(); classIdentifier->setPos(rect().bottomLeft() + QPointF(linkdialog::offset, -linkdialog::offset - offset)); identifier->setText(QString::fromStdString(processor->getIdentifier())); classIdentifier->setText(QString::fromStdString(processor->getClassIdentifier())); for (auto& property : processor->getProperties()) { auto item = new LinkDialogPropertyGraphicsItem(this, property); properties_.push_back(item); item->hide(); item->setParentItem(this); } LinkDialogTreeItem* prev = this; std::function<void(LinkDialogPropertyGraphicsItem*)> connect = [this, &connect, &prev]( LinkDialogPropertyGraphicsItem* item) { prev->setNext(item); item->setPrev(prev); prev = item; for (auto i : item->getSubPropertyItemList()) { connect(i); } }; for (auto item : properties_) connect(item); LinkDialogTreeItem* item = this; while (item) { item->updatePositions(); item = item->next(); } }
DocBlock::DocBlock(QString text, TreeElement* el, Block* parentBlock, BlockGroup *parentgroup) // automatic creation : Block(el, parentBlock, parentgroup) { Q_ASSERT(el->isFloating()); //! automatic creation should be called for floating elements only // find arrow target Block *arrowTarget = 0; if (prevSib != 0) arrowTarget = prevSib; else if (parent != 0) arrowTarget = parent; // adjust linebreaks if (text.endsWith('\n')) { text.chop(1); if (nextSib == 0) parent->getElement()->setLineBreaking(true); else if (prevSib != 0) prevSib->getElement()->setLineBreaking(true); } else if (prevSib != 0 && nextSib == 0 && parent->getElement()->getAncestorWhereLast()->isLineBreaking()) { prevSib->getElement()->setLineBreaking(false); } // clean up removeLinks(); //! remove all "contacts with family" if (parentBlock != 0) setParentItem(parentBlock->blockGroup()); //! set group as parent item myTextItem->adaptToFloating(); //! disconnect all harmful signals // set flags docType = Generic; element->setFloating(true); element->setType("doc_comment"); setFlag(QGraphicsItem::ItemIsMovable); setFlag(QGraphicsItem::ItemClipsChildrenToShape, false); myTextItem->setTextInteractionFlags(Qt::NoTextInteraction); setAcceptDrops(false); setZValue(1); backup = 0; setVisible(true); locked = false; highlightFormat = group->docScene->getFormatFor(element->getType()); highlight(highlightFormat); // add arrow arrow = 0; addArrowTo(arrowTarget); setContent(text); }
void CardItem::setAttachedTo(CardItem *_attachedTo) { if (attachedTo) attachedTo->removeAttachedCard(this); gridPoint.setX(-1); attachedTo = _attachedTo; if (attachedTo) { setParentItem(attachedTo->getZone()); attachedTo->addAttachedCard(this); if (zone != attachedTo->getZone()) attachedTo->getZone()->reorganizeCards(); } else setParentItem(zone); if (zone) zone->reorganizeCards(); emit updateCardMenu(this); }
Section::Section(XmlStreamReader *reader, QGraphicsItem *parent) : GridSnap(GS120) { setParentItem(parent); setPen(blockPen); setRect(0, 0, 3 * grid(), 4 * grid()); // default size graphic.setParentItem(this); if (reader) readFromXml(reader); }
SchemaLink::SchemaLink(Database *source_node, Schema *destination_node) { database = source_node; schema = destination_node; database->addEdge(this); schema->addEdge(this); setParentItem(source_node); setFlag(QGraphicsItem::ItemStacksBehindParent); setZValue(-100); adjust(); }
FunctionLink::FunctionLink(Schema *source_node, Function *destination_node) { schema = source_node; function = destination_node; //schema->addEdge(this); //function->addEdge(this); setParentItem(source_node); setFlag(QGraphicsItem::ItemStacksBehindParent); setZValue(-100); adjust(); }
TableLink::TableLink(Schema *source_node, Table *destination_node) { schema = source_node; table = destination_node; //schema->addEdge(this); //table->addEdge(this); setParentItem(source_node); setFlag(QGraphicsItem::ItemStacksBehindParent); setZValue(-100); adjust(); }
void ObjectFoHandler::setParentObject(ObjectFoView * parent) { //save parent for events like mousepress m_parent=parent; //set parent to NULL is needed in some casees, becouse m_parentGroup->setHandlesChildEvents (true); //didn't work correctly setParentItem(0); //set parent fort graphicsitem setParentItem(m_parent); //set color for rect setColorState(m_parent->state()); //calculate size and position for rect QPointF scale=m_parent->mainView()->scale(); QPoint resizer=QPoint(qreal(EHandlerWidth)/scale.x(), qreal(EHandlerWidth)/scale.y()); QPoint br = parent->rect().topRight().toPoint(); //set rect setRect(QRect(br - resizer ,br + resizer)); }
canvas_flag::canvas_flag(canvas_view *i_oGraphWidget, canvas_item *i_oFrom) : QGraphicsRectItem(), m_oGraph(i_oGraphWidget) { setFlags(NULL); m_oItem = i_oFrom; setRect(0, 0, 19, 19); /* set the z value to 51 */ setZValue(51); i_oGraphWidget->scene()->addItem(this); setParentItem(m_oItem); setCacheMode(QGraphicsItem::DeviceCoordinateCache); }
void Item::restoreFromItemData( const ItemData &itemData ) { move( itemData.x, itemData.y ); if ( canResize() ) setSize( itemData.size ); Item *parentItem = p_itemDocument->itemWithID( itemData.parentId ); if (parentItem) setParentItem(parentItem); else m_baseZ = itemData.z; //BEGIN Restore data const QStringMap::const_iterator stringEnd = itemData.dataString.end(); for ( QStringMap::const_iterator it = itemData.dataString.begin(); it != stringEnd; ++it ) { if ( hasProperty(it.key()) ) property( it.key() )->setValue( it.value() ); } const DoubleMap::const_iterator numberEnd = itemData.dataNumber.end(); for ( DoubleMap::const_iterator it = itemData.dataNumber.begin(); it != numberEnd; ++it ) { if ( hasProperty(it.key()) ) property( it.key() )->setValue( it.value() ); } const QColorMap::const_iterator colorEnd = itemData.dataColor.end(); for ( QColorMap::const_iterator it = itemData.dataColor.begin(); it != colorEnd; ++it ) { if ( hasProperty(it.key()) ) property( it.key() )->setValue( it.value() ); } const BoolMap::const_iterator boolEnd = itemData.dataBool.end(); for ( BoolMap::const_iterator it = itemData.dataBool.begin(); it != boolEnd; ++it ) { if ( hasProperty(it.key()) ) property( it.key() )->setValue( QVariant( it.value() /*, 0*/ ) ); } const QBitArrayMap::const_iterator rawEnd = itemData.dataRaw.end(); for ( QBitArrayMap::const_iterator it = itemData.dataRaw.begin(); it != rawEnd; ++it ) { if ( hasProperty(it.key()) ) property( it.key() )->setValue( it.value() ); } //END Restore Data }
BlockRemoveButton::BlockRemoveButton(QGraphicsItem *parent) : m_Width(20), m_Height(20) { setParentItem(parent); setAcceptHoverEvents(true); m_Pen.setColor(Qt::white); m_Pen.setWidth(2); m_Brush.setColor(Qt::black); m_Brush.setStyle(Qt::SolidPattern); installSceneEventFilter(this); }
TriggerView::TriggerView(QGraphicsItem *parent): QGraphicsItem{parent} { setFlag(ItemStacksBehindParent, true); auto itm = new QGraphicsSvgItem(":/images/trigger.svg"); itm->setScale(1.5); itm->setParentItem(this); itm->setPos(-7.5, -25.); itm->setAcceptedMouseButtons(Qt::NoButton); itm->setActive(false); itm->setEnabled(false); setAcceptedMouseButtons(Qt::NoButton); setActive(false); setEnabled(false); }