| 139 | } |
| 140 | |
| 141 | QVariant SegmentPrivate::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant& value) { |
| 142 | if (change == QGraphicsItem::ItemSelectedChange && value == true) { |
| 143 | auto* datapicker = static_cast<Datapicker*>(q->m_image->parentAspect()); |
| 144 | if (datapicker->activeCurve()) { |
| 145 | int count = 0; |
| 146 | QList<QPointF> posList; |
| 147 | posList.clear(); |
| 148 | for (QLine* line : q->path) { |
| 149 | const int l = (line->y1() > line->y2()) ? line->y2() : line->y1(); |
| 150 | const int h = (line->y1() > line->y2()) ? line->y1() : line->y2(); |
| 151 | |
| 152 | for (int i = l; i <= h; ++i) { |
| 153 | if (count % q->m_image->pointSeparation() == 0) { |
| 154 | bool positionUsed = false; |
| 155 | const auto points = datapicker->activeCurve()->children<DatapickerPoint>(AbstractAspect::ChildIndexFlag::IncludeHidden); |
| 156 | for (const auto* point : points) { |
| 157 | if (point->position() == QPoint(line->x1(), i) * scaleFactor) |
| 158 | positionUsed = true; |
| 159 | } |
| 160 | |
| 161 | if (!positionUsed) |
| 162 | posList << QPoint(line->x1(), i) * scaleFactor; |
| 163 | } |
| 164 | count++; |
| 165 | } |
| 166 | } |
| 167 | |
| 168 | if (!posList.isEmpty()) { |
| 169 | auto* curve = datapicker->activeCurve(); |
| 170 | curve->beginMacro(i18n("%1: draw points over segment", datapicker->activeCurve()->name())); |
| 171 | curve->suppressUpdatePoint(true); |
| 172 | for (const QPointF& pos : posList) |
| 173 | datapicker->addNewPoint(pos, curve); |
| 174 | curve->suppressUpdatePoint(false); |
| 175 | curve->endMacro(); |
| 176 | } |
| 177 | } |
| 178 | |
| 179 | // no need to keep segment selected |
| 180 | return false; |
| 181 | } |
| 182 | |
| 183 | return QGraphicsItem::itemChange(change, value); |
| 184 | } |
nothing calls this directly
no test coverage detected