From cc80770a30f3dfa43b29e14f83bf47deb5b50a92 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Fri, 17 Jan 2014 09:57:00 +0200 Subject: Adjust selection in item removal and insert MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Implements item 1) in QTRD-2645 Task-number: QTRD-2645 Change-Id: I5c1cec438089520592a3526e1ff6095cc30afd34 Reviewed-by: Tomi Korpipää --- .../engine/surface3dcontroller.cpp | 24 ++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'src/datavisualization/engine/surface3dcontroller.cpp') diff --git a/src/datavisualization/engine/surface3dcontroller.cpp b/src/datavisualization/engine/surface3dcontroller.cpp index cae97d90..984f65ba 100644 --- a/src/datavisualization/engine/surface3dcontroller.cpp +++ b/src/datavisualization/engine/surface3dcontroller.cpp @@ -392,6 +392,16 @@ void Surface3DController::handleRowsInserted(int startIndex, int count) adjustValueAxisRange(); m_isDataDirty = true; } + + if (series == m_selectedSeries) { + // If rows inserted to selected series before the selection, adjust the selection + int selectedRow = m_selectedPoint.x(); + if (startIndex <= selectedRow) { + selectedRow += count; + setSelectedPoint(QPoint(selectedRow, m_selectedPoint.y()), m_selectedSeries); + } + } + emitNeedRender(); } @@ -405,8 +415,18 @@ void Surface3DController::handleRowsRemoved(int startIndex, int count) m_isDataDirty = true; } - // Clear selection unless still valid - setSelectedPoint(m_selectedPoint, m_selectedSeries); + if (series == m_selectedSeries) { + // If rows removed from selected series before the selection, adjust the selection + int selectedRow = m_selectedPoint.x(); + if (startIndex <= selectedRow) { + if ((startIndex + count) > selectedRow) + selectedRow = -1; // Selected row removed + else + selectedRow -= count; // Move selected row down by amount of rows removed + + setSelectedPoint(QPoint(selectedRow, m_selectedPoint.y()), m_selectedSeries); + } + } emitNeedRender(); } -- cgit v1.2.3