QString CDoodGroupItem::setSection(const QString §ion) { if(mSection == section) { return section; } mSection = section; emit sectionChanged(); return mSection; }
void ActivityInfo::setSection(const QString §ion) { m_section = section; emit sectionChanged(); }
QVariant Pin::itemChange(GraphicsItemChange change, const QVariant &value) { // Note that pins are only movable within the symbol editor. PageScene *pageScene = dynamic_cast<PageScene *>(scene()); if (ItemPositionChange == change && pageScene) { QPointF p = value.toPointF() + pageScene->reparentOffset(this); // p is now the position relative to the current parent. SymbolEditor *se = dynamic_cast<SymbolEditor *>(pageScene->parent()); if (se) { QGraphicsItem *anchor = se->closestPinAnchor(parentItem()->mapToScene(p), this); if (parentItem() != anchor) { pageScene->reparentWhileDragging(this, anchor); p = value.toPointF() + pageScene->reparentOffset(this); setData(FreeSCH::SectionChanged, true); } if (QGraphicsLineItem::Type == anchor->type()) { p.setX(anchor->pos().x()); if (position.side() != PinPosition::Right) { position.setSide(PinPosition::Right); attributes.setValue("side", PinPosition::sideNames.at(PinPosition::Right)); reorient(); } } else if (Section::Type == anchor->type()) { Section *section = qgraphicsitem_cast<Section *>(anchor); if (section) { QRectF r = QRectF(QPointF(0,0), section->rect().size()); PinPosition::PinSide newside = PinPosition::sideIndex(r, p); switch (newside) { case PinPosition::Right: p.setX(r.right()); break; case PinPosition::Bottom: p.setY(r.bottom()); break; case PinPosition::Left: p.setX(r.left()); break; default: // top p.setY(r.top()); break; } if (p.x() < 0) p.setX(0); if (p.x() > r.width()) p.setX(r.width()); if (p.y() < 0) p.setY(0); if (p.y() > r.height()) p.setY(r.height()); if (position.side() != newside) { position.setSide(newside); attributes.setValue("side", PinPosition::sideNames.at(newside)); updateOffset(snap(p).toPoint()); reorient(); // As the pin moves around a corner of a section, it can switch sides without its pos() changing. // In that case the ItemPositionHasChanged event doesn't occur. So we need to emit the moved signal here. emit moved(); } } } } return snap(p); } if (ItemPositionHasChanged == change && pageScene) { updateOffset(pos().toPoint()); if (data(FreeSCH::SectionChanged).toBool()) { setData(FreeSCH::SectionChanged, false); emit sectionChanged(this, parentItem()); } emit moved(); } return QGraphicsItem::itemChange(change, value); }