summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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
-rw-r--r--tests/barstest/chart.cpp2
-rw-r--r--tests/barstest/main.cpp2
8 files changed, 80 insertions, 8 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();
}
diff --git a/tests/barstest/chart.cpp b/tests/barstest/chart.cpp
index cbae8a6c..7f049645 100644
--- a/tests/barstest/chart.cpp
+++ b/tests/barstest/chart.cpp
@@ -543,7 +543,7 @@ void GraphModifier::removeRows()
// TODO Needs to be changed to account for data window offset once it is implemented.
int row = m_selectedBar.x();
if (row >= 0) {
- int startRow = qMax(row - 2, 0);
+ int startRow = qMax(row - 3, 0);
m_genericData->dataProxy()->removeRows(startRow, 3);
}
}
diff --git a/tests/barstest/main.cpp b/tests/barstest/main.cpp
index f582301b..a0f9d783 100644
--- a/tests/barstest/main.cpp
+++ b/tests/barstest/main.cpp
@@ -97,7 +97,7 @@ int main(int argc, char **argv)
removeRowButton->setEnabled(false);
QPushButton *removeRowsButton = new QPushButton(widget);
- removeRowsButton->setText(QStringLiteral("Remove three rows from selected"));
+ removeRowsButton->setText(QStringLiteral("Remove three rows before selected"));
removeRowsButton->setEnabled(false);
QPushButton *massiveArrayButton = new QPushButton(widget);