19 , m_filterModel(
new QSortFilterProxyModel(
this))
24 setFocusProxy(ui.lineEdit);
25 ui.lineEdit->installEventFilter(
this);
26 ui.lineEdit->setPlaceholderText(tr(
"Filter"));
27 ui.label->setText(tr(
"Choose a topic for <b>%1</b>:").arg(keyword));
29 QStandardItemModel *model =
new QStandardItemModel(
this);
30 m_filterModel->setSourceModel(model);
31 m_filterModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
33 for (
const auto &doc : docs) {
34 m_links.append(doc.url);
35 QStandardItem *item =
new QStandardItem(doc.title);
36 item->setToolTip(doc.url.toString());
37 model->appendRow(item);
40 ui.listWidget->setModel(m_filterModel);
41 ui.listWidget->setUniformItemSizes(
true);
42 ui.listWidget->setEditTriggers(QAbstractItemView::NoEditTriggers);
44 if (m_filterModel->rowCount() != 0)
45 ui.listWidget->setCurrentIndex(m_filterModel->index(0, 0));
47 connect(ui.buttonCancel, &QAbstractButton::clicked,
48 this, &QDialog::reject);
49 connect(ui.buttonDisplay, &QAbstractButton::clicked,
50 this, &TopicChooser::acceptDialog);
51 connect(ui.lineEdit, &QLineEdit::textChanged,
52 this, &TopicChooser::setFilter);
53 connect(ui.listWidget, &QAbstractItemView::activated,
54 this, &TopicChooser::activated);
56 const QByteArray ba = HelpEngineWrapper::instance().topicChooserGeometry();
99 if (object == ui.lineEdit && event->type() == QEvent::KeyPress) {
100 QKeyEvent *keyEvent =
static_cast<QKeyEvent*>(event);
101 switch (keyEvent->key()) {
105 case Qt::Key_PageDown:
106 QCoreApplication::sendEvent(ui.listWidget, event);
109 }
else if (ui.lineEdit && event->type() == QEvent::FocusIn
110 &&
static_cast<QFocusEvent *>(event)->reason() != Qt::MouseFocusReason) {
111 ui.lineEdit->selectAll();
112 ui.lineEdit->setFocus();
114 return QDialog::eventFilter(object, event);