| 1117 | } |
| 1118 | |
| 1119 | void InfoElementPrivate::mouseMoveEvent(QGraphicsSceneMouseEvent* event) { |
| 1120 | const auto eventPos = mapToParent(event->pos()); |
| 1121 | // DEBUG("EventPos: " << eventPos.x() << " Y: " << eventPos.y()); |
| 1122 | const auto delta = eventPos - oldMousePos; |
| 1123 | if (delta == QPointF(0, 0)) |
| 1124 | return; |
| 1125 | |
| 1126 | if (!q->cSystem->isValid()) |
| 1127 | return; |
| 1128 | const auto eventLogicPos = q->cSystem->mapSceneToLogical(eventPos, AbstractCoordinateSystem::MappingFlag::SuppressPageClipping); |
| 1129 | const auto delta_logic = eventLogicPos - q->cSystem->mapSceneToLogical(oldMousePos); |
| 1130 | |
| 1131 | if (!q->m_title) |
| 1132 | return; |
| 1133 | if (q->markerpoints.isEmpty()) |
| 1134 | return; |
| 1135 | |
| 1136 | // TODO: find better method to do this. It's inefficient. |
| 1137 | // Finding which curve should be used to find the new values |
| 1138 | double x = positionLogical; |
| 1139 | int activeIndex = 0; |
| 1140 | for (int i = 1; i < q->markerPointsCount(); i++) { |
| 1141 | if (q->markerpoints[i].curve->name().compare(connectionLineCurveName) == 0) { |
| 1142 | // not possible to use index, because when the number of elements in the columns of the curves are not the same there is a problem |
| 1143 | x = q->markerpoints[i].customPoint->positionLogical().x(); // q->markerpoints[i].curve->xColumn()->valueAt(m_index) |
| 1144 | activeIndex = i; |
| 1145 | break; |
| 1146 | } |
| 1147 | } |
| 1148 | x += delta_logic.x(); |
| 1149 | auto xColumn = q->markerpoints[activeIndex].curve->xColumn(); |
| 1150 | if (!xColumn) |
| 1151 | return; |
| 1152 | int xindex = xColumn->indexForValue(x, false); |
| 1153 | double x_new = NAN; |
| 1154 | if (xColumn->isNumeric()) |
| 1155 | x_new = xColumn->valueAt(xindex); |
| 1156 | else |
| 1157 | x_new = xColumn->dateTimeAt(xindex).toMSecsSinceEpoch(); |
| 1158 | |
| 1159 | auto pointPos = q->markerpoints[activeIndex].customPoint->positionLogical().x(); |
| 1160 | if (abs(x_new - pointPos) > 0) { |
| 1161 | if ((xColumn->rowCount() - 1 == xindex && pointPos > x_new) || (xindex == 0 && pointPos < x_new)) { |
| 1162 | q->setPositionLogical(x_new); |
| 1163 | } else { |
| 1164 | oldMousePos = eventPos; |
| 1165 | q->setPositionLogical(x); |
| 1166 | } |
| 1167 | } |
| 1168 | } |
| 1169 | |
| 1170 | void InfoElementPrivate::keyPressEvent(QKeyEvent* event) { |
| 1171 | if (m_suppressKeyPressEvents) { |
nothing calls this directly
no test coverage detected