| 263 | } |
| 264 | |
| 265 | void SidepanelReplay::onRowChanged(int current_row) |
| 266 | { |
| 267 | current_row = std::min( current_row, _table_model->rowCount() -1 ); |
| 268 | current_row = std::max( current_row, 0 ); |
| 269 | |
| 270 | if( _prev_row == current_row) |
| 271 | { |
| 272 | // nothing to do |
| 273 | return; |
| 274 | } |
| 275 | |
| 276 | // disable section resize, otherwise it will be SUPER slow |
| 277 | // We will refresh this in the callback of _layout_update_timer -> onTimerUpdate |
| 278 | ui->tableView->horizontalHeader()->setSectionResizeMode (QHeaderView::Fixed); |
| 279 | ui->tableView->verticalHeader()->setSectionResizeMode (QHeaderView::Fixed); |
| 280 | |
| 281 | const auto selected_color = QColor::fromRgb(210, 210, 210); |
| 282 | const auto unselected_color = QColor::fromRgb(255, 255, 255); |
| 283 | |
| 284 | for (int row = std::max(0,_prev_row); row <= current_row; row++) |
| 285 | { |
| 286 | _table_model->item(row, 0)->setBackground( selected_color ); |
| 287 | _table_model->item(row, 1)->setBackground( selected_color ); |
| 288 | } |
| 289 | for (int row = current_row+1; row <= _prev_row; row++) |
| 290 | { |
| 291 | _table_model->item(row, 0)->setBackground( unselected_color ); |
| 292 | _table_model->item(row, 1)->setBackground( unselected_color ); |
| 293 | } |
| 294 | |
| 295 | // cancel the refresh of the layout refresh |
| 296 | if( !_layout_update_timer->isActive() ) |
| 297 | { |
| 298 | _layout_update_timer->stop(); |
| 299 | } |
| 300 | _layout_update_timer->start(100); |
| 301 | |
| 302 | const QString bt_name("BehaviorTree"); |
| 303 | |
| 304 | std::vector<std::pair<int, NodeStatus>> node_status; |
| 305 | for(size_t index = 0; index < _loaded_tree.nodes().size(); index++ ) |
| 306 | { |
| 307 | node_status.push_back( { index, NodeStatus::IDLE} ); |
| 308 | } |
| 309 | |
| 310 | // THIS CAN BE OPTIMIZED, but it is so fast that I don't even care... for the time being. |
| 311 | for (int t = 0; t <= current_row; t++) |
| 312 | { |
| 313 | auto& trans = _transitions[t]; |
| 314 | node_status[ trans.index ].second = trans.status; |
| 315 | //qDebug() << trans.index << " : " << tr(toStr(trans.status)); |
| 316 | } |
| 317 | |
| 318 | emit changeNodeStyle( bt_name, node_status ); |
| 319 | |
| 320 | _prev_row = current_row; |
| 321 | } |
| 322 |
nothing calls this directly
no outgoing calls
no test coverage detected