| 784 | } |
| 785 | |
| 786 | void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override |
| 787 | { |
| 788 | if (widget >= WID_NCL_TEXTFILE && widget < WID_NCL_TEXTFILE + TFT_CONTENT_END) { |
| 789 | if (this->selected == nullptr || this->selected->state != ContentInfo::State::AlreadyHere) return; |
| 790 | |
| 791 | ShowContentTextfileWindow(this, (TextfileType)(widget - WID_NCL_TEXTFILE), this->selected); |
| 792 | return; |
| 793 | } |
| 794 | |
| 795 | switch (widget) { |
| 796 | case WID_NCL_MATRIX: { |
| 797 | auto it = this->vscroll->GetScrolledItemFromWidget(this->content, pt.y, this, WID_NCL_MATRIX); |
| 798 | if (it == this->content.end()) return; // click out of bounds |
| 799 | |
| 800 | const NWidgetBase *checkbox = this->GetWidget<NWidgetBase>(WID_NCL_CHECKBOX); |
| 801 | if (click_count > 1 || IsInsideBS(pt.x, checkbox->pos_x, checkbox->current_x)) { |
| 802 | _network_content_client.ToggleSelectedState(**it); |
| 803 | this->content.ForceResort(); |
| 804 | this->content.ForceRebuild(); |
| 805 | } else { |
| 806 | this->selected = *it; |
| 807 | this->list_pos = it - this->content.begin(); |
| 808 | } |
| 809 | |
| 810 | if (this->filter_data.types.Any()) { |
| 811 | this->content.ForceRebuild(); |
| 812 | } |
| 813 | |
| 814 | this->InvalidateData(); |
| 815 | break; |
| 816 | } |
| 817 | |
| 818 | case WID_NCL_CHECKBOX: |
| 819 | case WID_NCL_TYPE: |
| 820 | case WID_NCL_NAME: |
| 821 | if (this->content.SortType() == widget - WID_NCL_CHECKBOX) { |
| 822 | this->content.ToggleSortOrder(); |
| 823 | if (!this->content.empty()) this->list_pos = (int)this->content.size() - this->list_pos - 1; |
| 824 | } else { |
| 825 | this->content.SetSortType(widget - WID_NCL_CHECKBOX); |
| 826 | this->content.ForceResort(); |
| 827 | this->SortContentList(); |
| 828 | } |
| 829 | this->ScrollToSelected(); |
| 830 | this->InvalidateData(); |
| 831 | break; |
| 832 | |
| 833 | case WID_NCL_SELECT_ALL: |
| 834 | _network_content_client.SelectAll(); |
| 835 | this->InvalidateData(); |
| 836 | break; |
| 837 | |
| 838 | case WID_NCL_SELECT_UPDATE: |
| 839 | _network_content_client.SelectUpgrade(); |
| 840 | this->InvalidateData(); |
| 841 | break; |
| 842 | |
| 843 | case WID_NCL_UNSELECT: |
nothing calls this directly
no test coverage detected