| 423 | std::function<void( const std::string&, bool )> onModelEnabledChange; |
| 424 | |
| 425 | std::function<UITextView*( UIPushButton* )> getCheckBoxFn( const ModelIndex& index, |
| 426 | const PluginsModel* model ) { |
| 427 | return [index, model, this]( UIPushButton* ) -> UITextView* { |
| 428 | UICheckBox* chk = UICheckBox::New(); |
| 429 | chk->setChecked( |
| 430 | model->data( model->index( index.row(), PluginsModel::Enabled ) ).asBool() ); |
| 431 | chk->setCheckMode( UICheckBox::Button ); |
| 432 | chk->on( Event::OnValueChange, [this, chk]( const Event* ) { |
| 433 | if ( mUpdatingEnabled ) |
| 434 | return; |
| 435 | BoolScopedOp op( mUpdatingEnabled, true ); |
| 436 | UITableCell* parent = chk->getParent()->asType<UITableCell>(); |
| 437 | auto index = parent->getCurIndex(); |
| 438 | UIPluginManagerTable* tableView = |
| 439 | parent->getParent()->getParent()->asType<UIPluginManagerTable>(); |
| 440 | auto model = static_cast<PluginsModel*>( tableView->getModel() ); |
| 441 | bool checked = chk->isChecked(); |
| 442 | std::string id( |
| 443 | model->data( model->index( index.row(), PluginsModel::Id ) ).asCStr() ); |
| 444 | model->getManager()->setEnabled( id, checked ); |
| 445 | if ( onModelEnabledChange ) |
| 446 | onModelEnabledChange( id, checked ); |
| 447 | } ); |
| 448 | return chk; |
| 449 | }; |
| 450 | } |
| 451 | |
| 452 | UIWidget* createCell( UIWidget* rowWidget, const ModelIndex& index ) { |
| 453 | if ( index.column() == PluginsModel::Title ) { |
nothing calls this directly
no test coverage detected