MCPcopy Index your code
hub / github.com/DreamSourceLab/DSView / item_clicked

Method item_clicked

DSView/pv/dock/protocoldock.cpp:538–595  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

536}
537
538void ProtocolDock::item_clicked(const QModelIndex &index)
539{
540 pv::data::DecoderModel *decoder_model = _session->get_decoder_model();
541
542 auto decoder_stack = decoder_model->getDecoderStack();
543
544 if (decoder_stack) {
545 pv::data::decode::Annotation ann;
546 if (decoder_stack->list_annotation(&ann, index.column(), index.row())) {
547 const auto &decode_sigs = _session->get_decode_signals();
548
549 for(auto d : decode_sigs) {
550 d->decoder()->set_mark_index(-1);
551 }
552
553 decoder_stack->set_mark_index((ann.start_sample()+ann.end_sample())/2);
554 _session->show_region(ann.start_sample(), ann.end_sample(), false);
555 }
556 }
557
558 _table_view->resizeRowToContents(index.row());
559 if (index.column() != _model_proxy.filterKeyColumn()) {
560 _model_proxy.setFilterKeyColumn(index.column());
561 _model_proxy.setSourceModel(decoder_model);
562 search_done();
563 }
564 QModelIndex filterIndex = _model_proxy.mapFromSource(index);
565 if (filterIndex.isValid()) {
566 _cur_search_index = filterIndex.row();
567 } else {
568 if (_model_proxy.rowCount() == 0) {
569 _cur_search_index = -1;
570 } else {
571 uint64_t up = 0;
572 uint64_t dn = _model_proxy.rowCount() - 1;
573 do {
574 uint64_t md = (up + dn)/2;
575 QModelIndex curIndex = _model_proxy.mapToSource(_model_proxy.index(md,_model_proxy.filterKeyColumn()));
576 if (index.row() == curIndex.row()) {
577 _cur_search_index = md;
578 break;
579 } else if (md == up) {
580 if (curIndex.row() < index.row() && up < dn) {
581 QModelIndex nxtIndex = _model_proxy.mapToSource(_model_proxy.index(md+1,_model_proxy.filterKeyColumn()));
582 if (nxtIndex.row() < index.row())
583 md++;
584 }
585 _cur_search_index = md + ((curIndex.row() < index.row()) ? 0.5 : -0.5);
586 break;
587 } else if (curIndex.row() < index.row()) {
588 up = md;
589 } else if (curIndex.row() > index.row()) {
590 dn = md;
591 }
592 }while(1);
593 }
594 }
595}

Callers

nothing calls this directly

Calls 11

get_decoder_modelMethod · 0.80
getDecoderStackMethod · 0.80
list_annotationMethod · 0.80
rowMethod · 0.80
set_mark_indexMethod · 0.80
start_sampleMethod · 0.80
end_sampleMethod · 0.80
rowCountMethod · 0.80
indexMethod · 0.80
decoderMethod · 0.45
show_regionMethod · 0.45

Tested by

no test coverage detected