| 834 | model->setParent(dialog->widget()); |
| 835 | } |
| 836 | void finish() |
| 837 | { |
| 838 | //Select the declaration that contains the cursor |
| 839 | if (cursorDecl.isValid() && dialog) { |
| 840 | auto it = std::find_if(items.constBegin(), items.constEnd(), |
| 841 | [this](const DUChainItem& item) { return item.m_item == cursorDecl; }); |
| 842 | if (it != items.constEnd()) { |
| 843 | // Need to invoke the scrolling later. If we did it now, then it wouldn't have any effect, |
| 844 | // apparently because the widget internals aren't initialized yet properly (although we've |
| 845 | // already called 'widget->show()'. |
| 846 | auto list = dialog->widget()->ui.list; |
| 847 | const auto num = std::distance(items.constBegin(), it); |
| 848 | QTimer::singleShot(0, list, [list, num]() { |
| 849 | const auto index = list->model()->index(num, 0, {}); |
| 850 | list->setCurrentIndex(index); |
| 851 | list->scrollTo(index, QAbstractItemView::PositionAtCenter); |
| 852 | }); |
| 853 | } |
| 854 | } |
| 855 | } |
| 856 | QPointer<QuickOpenWidgetDialog> dialog; |
| 857 | IndexedDeclaration cursorDecl; |
| 858 | QVector<DUChainItem> items; |
no test coverage detected