Replace IsItemMultivalued() with IsItemSingleValued()

This allows to simplify logic when calling it by avoiding negation.

No real changes.
This commit is contained in:
Vadim Zeitlin
2020-04-17 23:27:21 +02:00
parent 84fb5f38be
commit c80626d33a

View File

@@ -910,20 +910,23 @@ private:
// assumes that all columns were modified, otherwise just this one. // assumes that all columns were modified, otherwise just this one.
bool DoItemChanged(const wxDataViewItem& item, int view_column); bool DoItemChanged(const wxDataViewItem& item, int view_column);
// Return whether the item has more than one column that have values // Return whether the item has at most one column with a value.
bool IsItemMultivalued(const wxDataViewItem& item) const bool IsItemSingleValued(const wxDataViewItem& item) const
{ {
unsigned int numColsWithValue = 0; bool hadColumnWithValue = false;
unsigned int cols = GetOwner()->GetColumnCount(); unsigned int cols = GetOwner()->GetColumnCount();
const wxDataViewModel* model = GetModel(); const wxDataViewModel* model = GetModel();
for ( unsigned int i = 0; i < cols; i++ ) for ( unsigned int i = 0; i < cols; i++ )
{ {
if ( model->HasValue(item, i) ) if ( model->HasValue(item, i) )
numColsWithValue++; {
if ( numColsWithValue > 1 ) if ( hadColumnWithValue )
return true; return false;
hadColumnWithValue = true;
}
} }
return false;
return true;
} }
// find first column with value // find first column with value
@@ -2423,11 +2426,11 @@ void wxDataViewMainWindow::OnPaint( wxPaintEvent &WXUNUSED(event) )
{ {
renderColumnFocus = true; renderColumnFocus = true;
// If this is container node without columns, render full-row focus: // If there is just a single value, render full-row focus:
if ( !IsList() ) if ( !IsList() )
{ {
wxDataViewTreeNode *node = GetTreeNodeByRow(item); wxDataViewTreeNode *node = GetTreeNodeByRow(item);
if ( !IsItemMultivalued(node->GetItem()) ) if ( IsItemSingleValued(node->GetItem()) )
renderColumnFocus = false; renderColumnFocus = false;
} }
} }
@@ -4515,7 +4518,7 @@ bool wxDataViewMainWindow::TryAdvanceCurrentColumn(wxDataViewTreeNode *node, wxK
const bool wrapAround = event.GetKeyCode() == WXK_TAB; const bool wrapAround = event.GetKeyCode() == WXK_TAB;
// navigation shouldn't work in nodes with fewer than two columns // navigation shouldn't work in nodes with fewer than two columns
if ( node && !IsItemMultivalued(node->GetItem()) ) if ( node && IsItemSingleValued(node->GetItem()) )
return false; return false;
if ( m_currentCol == NULL || !m_currentColSetByKeyboard ) if ( m_currentCol == NULL || !m_currentColSetByKeyboard )