Skip to content

Commit 377a159

Browse files
committed
[WASimUI][DocImportsBrowser] Use source model for details view (removes sort indicator from section names); Improve how initial focus is placed when opened in popup mode.
1 parent 9b88ab9 commit 377a159

1 file changed

Lines changed: 5 additions & 9 deletions

File tree

src/WASimUI/DocImportsBrowser.h

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class DocImportsBrowser : public QWidget
8585
connect(ui.tableView->selectionModel(), &QItemSelectionModel::currentRowChanged, this, &DocImportsBrowser::onCurrentRowChanged);
8686

8787
connect(ui.tableView, &QTableView::doubleClicked, this, [=](const QModelIndex &idx) {
88-
emit itemSelected(ui.tableView->proxyModel()->mapToSource(idx));
88+
emit itemSelected(ui.tableView->mapToSource(idx));
8989
});
9090

9191
setRecordType(type);
@@ -113,6 +113,7 @@ public Q_SLOTS:
113113
ui.lblTitle->setText(
114114
tr("Double-click to select a record and return to the main window. Press <tt>Escape</tt> key to close. Use the filters to search.")
115115
);
116+
QMetaObject::invokeMethod(ui.tableView, "setFilterFocus", Qt::QueuedConnection, Q_ARG(int, 2));
116117
}
117118
}
118119

@@ -139,10 +140,11 @@ public Q_SLOTS:
139140
if (m_model->recordType() == RecordType::Unknown || !key.isValid())
140141
return;
141142

142-
const QAbstractItemModel *model = ui.tableView->model();
143+
const QAbstractItemModel *model = ui.tableView->sourceModel();
144+
const int srcRow = ui.tableView->mapToSource(key).row();
143145
QString sb(QStringLiteral("<dl>"));
144146
for (int i = 0; i < model->columnCount(); ++i) {
145-
const QVariant &d = model->data(model->index(key.row(), i), Qt::DisplayRole);
147+
const QVariant &d = model->data(model->index(srcRow, i), Qt::DisplayRole);
146148
if (d.isValid())
147149
sb.append(QStringLiteral("<dt>%1</dt><dd>%2</dd>").arg(model->headerData(i, Qt::Horizontal).toString(), toHtml(d.toString())));
148150
}
@@ -207,12 +209,6 @@ public Q_SLOTS:
207209
ev->accept();
208210
}
209211

210-
void showEvent(QShowEvent *ev) override {
211-
QWidget::showEvent(ev);
212-
if (m_viewMode == ViewMode::PopupViewMode)
213-
ui.tableView->setFilterFocus(2);
214-
}
215-
216212
private Q_SLOTS:
217213
void onCurrentRowChanged(const QModelIndex &sel, const QModelIndex &prev) {
218214
if (prev.isValid())

0 commit comments

Comments
 (0)