From 035823e41408a587043805de50e030fcc1e3131c Mon Sep 17 00:00:00 2001 From: Jonathan White Date: Sun, 3 Nov 2019 21:21:21 -0500 Subject: [PATCH] Hide Auto-Type sequences column when unnecessary * Fix #3688 - hide the sequences column if all of the entry matches return the same sequence. This cleans up redundent data in the Auto-Type selection dialog introduced in 2.5.0. --- src/gui/entry/AutoTypeMatchView.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/gui/entry/AutoTypeMatchView.cpp b/src/gui/entry/AutoTypeMatchView.cpp index 180473fd3..72ee32fde 100644 --- a/src/gui/entry/AutoTypeMatchView.cpp +++ b/src/gui/entry/AutoTypeMatchView.cpp @@ -35,7 +35,7 @@ AutoTypeMatchView::AutoTypeMatchView(QWidget* parent) m_sortModel->setDynamicSortFilter(true); m_sortModel->setSortLocaleAware(true); m_sortModel->setSortCaseSensitivity(Qt::CaseInsensitive); - QTreeView::setModel(m_sortModel); + setModel(m_sortModel); setUniformRowHeights(true); setRootIsDecorated(false); @@ -90,12 +90,26 @@ void AutoTypeMatchView::keyPressEvent(QKeyEvent* event) void AutoTypeMatchView::setMatchList(const QList& matches) { m_model->setMatchList(matches); + + bool sameSequences = true; + if (matches.count() > 1) { + QString sequenceTest = matches[0].sequence; + for (const auto& match : matches) { + if (match.sequence != sequenceTest) { + sameSequences = false; + break; + } + } + } + setColumnHidden(AutoTypeMatchModel::Sequence, sameSequences); + for (int i = 0; i < m_model->columnCount(); ++i) { resizeColumnToContents(i); if (columnWidth(i) > 250) { setColumnWidth(i, 250); } } + setFirstMatchActive(); }