Skip to content

Commit

Permalink
[Refactor] Fix for bitflags with only one checked option
Browse files Browse the repository at this point in the history
Resolves #51.  Using setCurrentIndex on bitflag enums causes the
QComboBox to break when only one option is selected. It returns
something other than -1 and in doing so checked option's UI is inactive.
  • Loading branch information
hexabits committed May 12, 2014
1 parent 087ec84 commit 9ebcc17
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/nifdelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,18 @@ class NifDelegate : public QItemDelegate
}

cedit->setEditText( NifValue::enumOptionName( t, value ) );
cedit->setCurrentIndex( cedit->findText( NifValue::enumOptionName( t, value ) ) );

if ( eo.t == NifValue::eFlags ) {
// Using setCurrentIndex on bitflag enums causes the QComboBox
// to break when only one option is selected. It returns something
// other than -1 and in doing so checked option's UI is inactive.
// See: https://github.com/niftools/nifskope/issues/51
cedit->setCurrentIndex( -1 );
} else {
cedit->setCurrentIndex( cedit->findText( NifValue::enumOptionName( t, value ) ) );
}


} else if ( ledit ) {
ledit->setText( v.toString() );
}
Expand Down

0 comments on commit 9ebcc17

Please sign in to comment.