Skip to content

Commit

Permalink
Searchable QComboBox (#134)
Browse files Browse the repository at this point in the history
* Makes the packages combo box searchable

* Formatting
  • Loading branch information
GrantComm authored Sep 19, 2024
1 parent a279c98 commit 87a221b
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions ui/trace_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "trace_window.h"

#include <QComboBox>
#include <QCompleter>
#include <QDebug>
#include <QHBoxLayout>
#include <QLabel>
Expand All @@ -25,6 +26,7 @@
#include <QProgressDialog>
#include <QPushButton>
#include <QSizePolicy>
#include <QSortFilterProxyModel>
#include <QStandardItem>
#include <QStandardItemModel>
#include <QThread>
Expand Down Expand Up @@ -96,6 +98,13 @@ TraceDialog::TraceDialog(QWidget *parent)
m_pkg_box->setMinimumSize(m_dev_box->sizeHint());
m_pkg_box->setSizeAdjustPolicy(
QComboBox::SizeAdjustPolicy::AdjustToMinimumContentsLengthWithIcon);
m_pkg_box->setEditable(true);
QSortFilterProxyModel *filterModel = new QSortFilterProxyModel(m_pkg_box);
filterModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
filterModel->setSourceModel(m_pkg_box->model());
QCompleter *completer = new QCompleter(filterModel, m_pkg_box);
completer->setCompletionMode(QCompleter::UnfilteredPopupCompletion);
m_pkg_box->setCompleter(completer);

m_app_type_box->setModel(m_app_type_model);

Expand Down Expand Up @@ -147,6 +156,10 @@ TraceDialog::TraceDialog(QWidget *parent)
SIGNAL(currentIndexChanged(const QString &)),
this,
SLOT(OnPackageSelected(const QString &)));
QObject::connect(m_pkg_box->lineEdit(),
&QLineEdit::textEdited,
filterModel,
&QSortFilterProxyModel::setFilterFixedString);
QObject::connect(m_run_button, &QPushButton::clicked, this, &TraceDialog::OnStartClicked);
QObject::connect(m_capture_button, &QPushButton::clicked, this, &TraceDialog::OnTraceClicked);

Expand Down

0 comments on commit 87a221b

Please sign in to comment.