| 31 | } |
| 32 | |
| 33 | void ProgramTableView::adjustColumnCount() { |
| 34 | QModelIndex idx; |
| 35 | |
| 36 | auto *m = dynamic_cast<ProgramModel *>(model()); |
| 37 | |
| 38 | if (m == nullptr) { return; } |
| 39 | |
| 40 | auto *delegate = dynamic_cast<HintTableDelegate *>(itemDelegate()); |
| 41 | if (delegate == nullptr) { return; } |
| 42 | |
| 43 | QStyleOptionViewItem viewOpts; |
| 44 | |
| 45 | initViewItemOption(&viewOpts); |
| 46 | |
| 47 | int totwidth = 0; |
| 48 | idx = m->index(0, 0); |
| 49 | auto cwidth_dh0 = delegate->sizeHintForText(viewOpts, idx, "BP").width() + 2; |
| 50 | horizontalHeader()->setSectionResizeMode(0, QHeaderView::Fixed); |
| 51 | horizontalHeader()->resizeSection(0, cwidth_dh0); |
| 52 | totwidth += cwidth_dh0; |
| 53 | |
| 54 | idx = m->index(0, 1); |
| 55 | auto cwidth_dh1 = delegate->sizeHintForText(viewOpts, idx, "0x00000000").width() + 2; |
| 56 | horizontalHeader()->setSectionResizeMode(1, QHeaderView::Fixed); |
| 57 | horizontalHeader()->resizeSection(1, cwidth_dh1); |
| 58 | totwidth += cwidth_dh1; |
| 59 | |
| 60 | idx = m->index(0, 2); |
| 61 | auto cwidth_dh2 = delegate->sizeHintForText(viewOpts, idx, "00000000").width() + 2; |
| 62 | horizontalHeader()->setSectionResizeMode(2, QHeaderView::Fixed); |
| 63 | horizontalHeader()->resizeSection(2, cwidth_dh2); |
| 64 | totwidth += cwidth_dh2; |
| 65 | |
| 66 | horizontalHeader()->setSectionResizeMode(3, QHeaderView::Stretch); |
| 67 | idx = m->index(0, 3); |
| 68 | totwidth += delegate->sizeHintForText(viewOpts, idx, "BEQ $18, $17, 0x00000258").width() + 2; |
| 69 | totwidth += verticalHeader()->width(); |
| 70 | setColumnHidden(2, totwidth > width()); |
| 71 | setColumnHidden(1, totwidth - cwidth_dh2 > width()); |
| 72 | setColumnHidden(0, totwidth - cwidth_dh2 - cwidth_dh1 > width()); |
| 73 | |
| 74 | if (!initial_address.is_null()) { |
| 75 | go_to_address(initial_address); |
| 76 | initial_address = machine::Address::null(); |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | void ProgramTableView::adjust_scroll_pos_check() { |
| 81 | if (!adjust_scroll_pos_in_progress) { |
nothing calls this directly
no test coverage detected