summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMiikka Heikkinen <miikka.heikkinen@digia.com>2014-01-17 09:57:00 +0200
committerMiikka Heikkinen <miikka.heikkinen@digia.com>2014-01-17 10:09:45 +0200
commitcc80770a30f3dfa43b29e14f83bf47deb5b50a92 (patch)
tree205c608d650f8917354c2cc8da1953f6b2d6f762 /src
parentb83dfb2537720492ebd62dfc9733035d5560dddd (diff)
Adjust selection in item removal and insert
Implements item 1) in QTRD-2645 Task-number: QTRD-2645 Change-Id: I5c1cec438089520592a3526e1ff6095cc30afd34 Reviewed-by: Tomi Korpipää <tomi.korpipaa@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/datavisualization/data/qbar3dseries.cpp4
-rw-r--r--src/datavisualization/data/qscatter3dseries.cpp4
-rw-r--r--src/datavisualization/data/qsurface3dseries.cpp4
-rw-r--r--src/datavisualization/engine/bars3dcontroller.cpp24
-rw-r--r--src/datavisualization/engine/scatter3dcontroller.cpp24
-rw-r--r--src/datavisualization/engine/surface3dcontroller.cpp24
6 files changed, 78 insertions, 6 deletions
diff --git a/src/datavisualization/data/qbar3dseries.cpp b/src/datavisualization/data/qbar3dseries.cpp
index 1597b7ba..e7c2e125 100644
--- a/src/datavisualization/data/qbar3dseries.cpp
+++ b/src/datavisualization/data/qbar3dseries.cpp
@@ -99,6 +99,8 @@ QT_BEGIN_NAMESPACE_DATAVISUALIZATION
* If this series is added to a graph, the graph can adjust the selection according to user
* interaction or if it becomes invalid. Selecting a bar on another added series will also
* clear the selection.
+ * Removing rows from or inserting rows to the series before the row of the selected bar
+ * will adjust the selection so that the same bar will stay selected.
*
* \sa AbstractGraph3D::clearSelection()
*/
@@ -172,6 +174,8 @@ QBarDataProxy *QBar3DSeries::dataProxy() const
* If this series is added to a graph, the graph can adjust the selection according to user
* interaction or if it becomes invalid. Selecting a bar on another added series will also
* clear the selection.
+ * Removing rows from or inserting rows to the series before the row of the selected bar
+ * will adjust the selection so that the same bar will stay selected.
*
* \sa QAbstract3DGraph::clearSelection()
*/
diff --git a/src/datavisualization/data/qscatter3dseries.cpp b/src/datavisualization/data/qscatter3dseries.cpp
index 78594272..2dd5fd3a 100644
--- a/src/datavisualization/data/qscatter3dseries.cpp
+++ b/src/datavisualization/data/qscatter3dseries.cpp
@@ -94,6 +94,8 @@ QT_BEGIN_NAMESPACE_DATAVISUALIZATION
* If this series is added to a graph, the graph can adjust the selection according to user
* interaction or if it becomes invalid. Selecting an item on another added series will also
* clear the selection.
+ * Removing items from or inserting items to the series before the selected item
+ * will adjust the selection so that the same item will stay selected.
*
* \sa AbstractGraph3D::clearSelection()
*/
@@ -174,6 +176,8 @@ QScatterDataProxy *QScatter3DSeries::dataProxy() const
* If this series is added to a graph, the graph can adjust the selection according to user
* interaction or if it becomes invalid. Selecting an item on another added series will also
* clear the selection.
+ * Removing items from or inserting items to the series before the selected item
+ * will adjust the selection so that the same item will stay selected.
*
* \sa QAbstract3DGraph::clearSelection()
*/
diff --git a/src/datavisualization/data/qsurface3dseries.cpp b/src/datavisualization/data/qsurface3dseries.cpp
index 78f72e02..85f43dad 100644
--- a/src/datavisualization/data/qsurface3dseries.cpp
+++ b/src/datavisualization/data/qsurface3dseries.cpp
@@ -99,6 +99,8 @@ QT_BEGIN_NAMESPACE_DATAVISUALIZATION
* To clear selection from this series, set invalidSelectionPosition as the \a position.
* If this series is added to a graph, the graph can adjust the selection according to user
* interaction or if it becomes invalid.
+ * Removing rows from or inserting rows to the series before the row of the selected point
+ * will adjust the selection so that the same point will stay selected.
*
* \sa AbstractGraph3D::clearSelection()
*/
@@ -210,6 +212,8 @@ QSurfaceDataProxy *QSurface3DSeries::dataProxy() const
* To clear selection from this series, set invalidSelectionPosition() as the \a position.
* If this series is added to a graph, the graph can adjust the selection according to user
* interaction or if it becomes invalid.
+ * Removing rows from or inserting rows to the series before the row of the selected point
+ * will adjust the selection so that the same point will stay selected.
*
* \sa QAbstract3DGraph::clearSelection()
*/
diff --git a/src/datavisualization/engine/bars3dcontroller.cpp b/src/datavisualization/engine/bars3dcontroller.cpp
index f91a74cc..5542b69b 100644
--- a/src/datavisualization/engine/bars3dcontroller.cpp
+++ b/src/datavisualization/engine/bars3dcontroller.cpp
@@ -141,8 +141,18 @@ void Bars3DController::handleRowsRemoved(int startIndex, int count)
m_isDataDirty = true;
}
- // Clear selection unless still valid
- setSelectedBar(m_selectedBar, m_selectedBarSeries);
+ if (series == m_selectedBarSeries) {
+ // If rows removed from selected series before the selection, adjust the selection
+ int selectedRow = m_selectedBar.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
+
+ setSelectedBar(QPoint(selectedRow, m_selectedBar.y()), m_selectedBarSeries);
+ }
+ }
emitNeedRender();
}
@@ -168,6 +178,16 @@ void Bars3DController::handleItemChanged(int rowIndex, int columnIndex)
adjustAxisRanges();
m_isDataDirty = true;
}
+
+ if (series == m_selectedBarSeries) {
+ // If rows inserted to selected series before the selection, adjust the selection
+ int selectedRow = m_selectedBar.x();
+ if (startIndex <= selectedRow) {
+ selectedRow += count;
+ setSelectedBar(QPoint(selectedRow, m_selectedBar.y()), m_selectedBarSeries);
+ }
+ }
+
emitNeedRender();
}
diff --git a/src/datavisualization/engine/scatter3dcontroller.cpp b/src/datavisualization/engine/scatter3dcontroller.cpp
index c3f03fb9..4527ac2a 100644
--- a/src/datavisualization/engine/scatter3dcontroller.cpp
+++ b/src/datavisualization/engine/scatter3dcontroller.cpp
@@ -162,8 +162,18 @@ void Scatter3DController::handleItemsRemoved(int startIndex, int count)
m_isDataDirty = true;
}
- // Clear selection unless it is still valid
- setSelectedItem(m_selectedItem, m_selectedItemSeries);
+ if (series == m_selectedItemSeries) {
+ // If items removed from selected series before the selection, adjust the selection
+ int selectedItem = m_selectedItem;
+ if (startIndex <= selectedItem) {
+ if ((startIndex + count) > selectedItem)
+ selectedItem = -1; // Selected item removed
+ else
+ selectedItem -= count; // Move selected item down by amount of item removed
+
+ setSelectedItem(selectedItem, m_selectedItemSeries);
+ }
+ }
emitNeedRender();
}
@@ -178,6 +188,16 @@ void Scatter3DController::handleItemsInserted(int startIndex, int count)
adjustValueAxisRange();
m_isDataDirty = true;
}
+
+ if (series == m_selectedItemSeries) {
+ // If items inserted to selected series before the selection, adjust the selection
+ int selectedItem = m_selectedItem;
+ if (startIndex <= selectedItem) {
+ selectedItem += count;
+ setSelectedItem(selectedItem, m_selectedItemSeries);
+ }
+ }
+
emitNeedRender();
}
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();
}