From f5941e4f831975f50e818cca313a1730c97ed04e Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 27 Sep 2014 20:46:11 +0000 Subject: [PATCH] Simplify row selection function in the generic wxDataViewCtrl. No real changes, just don't make SelectRows() more complicated than necessary: it is always called with its arguments in order, so it doesn't need to reorder them and it is never called to deselect the items. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@77901 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/generic/datavgen.cpp | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/src/generic/datavgen.cpp b/src/generic/datavgen.cpp index 0b09eceee9..6d485b3365 100644 --- a/src/generic/datavgen.cpp +++ b/src/generic/datavgen.cpp @@ -778,7 +778,7 @@ public: void Select( const wxArrayInt& aSelections ); void SelectAllRows( bool on ); void SelectRow( unsigned int row, bool on ); - void SelectRows( unsigned int from, unsigned int to, bool on ); + void SelectRows( unsigned int from, unsigned int to ); void ReverseRowSelection( unsigned int row ); bool IsRowSelected( unsigned int row ); void SendSelectionChangedEvent( const wxDataViewItem& item); @@ -2791,27 +2791,13 @@ void wxDataViewMainWindow::SelectRow( unsigned int row, bool on ) } } -void wxDataViewMainWindow::SelectRows( unsigned int from, unsigned int to, bool on ) +void wxDataViewMainWindow::SelectRows( unsigned int from, unsigned int to ) { - if (from > to) - { - unsigned int tmp = from; - from = to; - to = tmp; - } - - unsigned int i; - for (i = from; i <= to; i++) + for (unsigned int i = from; i <= to; i++) { if (m_selection.Index( i ) == wxNOT_FOUND) { - if (on) - m_selection.Add( i ); - } - else - { - if (!on) - m_selection.Remove( i ); + m_selection.Add( i ); } } RefreshRows( from, to ); @@ -3899,7 +3885,7 @@ void wxDataViewMainWindow::OnVerticalNavigation(const wxKeyEvent& event, int del oldCurrent = m_currentRow; } - SelectRows( oldCurrent, newCurrent, true ); + SelectRows(oldCurrent, newCurrent); if (oldCurrent!=newCurrent) SendSelectionChangedEvent(GetItemByRow(m_selection[0])); } @@ -4450,7 +4436,7 @@ void wxDataViewMainWindow::OnMouse( wxMouseEvent &event ) lineFrom = m_currentRow; } - SelectRows(lineFrom, lineTo, true); + SelectRows(lineFrom, lineTo); SendSelectionChangedEvent(GetItemByRow(m_selection[0]) ); } else // !ctrl, !shift