! \class TreeViewComboBox \brief Provides a QTreeView in a QComboBox. \ingroup backend/widgets */
| 31 | \ingroup backend/widgets |
| 32 | */ |
| 33 | TreeViewComboBox::TreeViewComboBox(QWidget* parent) |
| 34 | : QComboBox(parent) |
| 35 | , m_treeView(new QTreeView) |
| 36 | , m_groupBox(new QGroupBox) |
| 37 | , m_lineEdit(new QLineEdit) { |
| 38 | auto* layout = new QVBoxLayout(this); |
| 39 | layout->setContentsMargins(0, 0, 0, 0); |
| 40 | layout->setSpacing(0); |
| 41 | |
| 42 | layout->addWidget(m_lineEdit); |
| 43 | layout->addWidget(m_treeView); |
| 44 | |
| 45 | m_groupBox->setLayout(layout); |
| 46 | m_groupBox->setParent(parent, Qt::Popup); |
| 47 | m_groupBox->hide(); |
| 48 | m_groupBox->installEventFilter(this); |
| 49 | |
| 50 | m_treeView->header()->hide(); |
| 51 | m_treeView->setSelectionMode(QAbstractItemView::SingleSelection); |
| 52 | m_treeView->setUniformRowHeights(true); |
| 53 | |
| 54 | m_lineEdit->setPlaceholderText(i18n("Search/Filter text")); |
| 55 | m_lineEdit->setClearButtonEnabled(true); |
| 56 | m_lineEdit->setFocus(); |
| 57 | |
| 58 | addItem(QString()); |
| 59 | setCurrentIndex(0); |
| 60 | setEditText(m_currentText); |
| 61 | |
| 62 | // signal activated() is platform dependent |
| 63 | connect(m_treeView, &QTreeView::pressed, this, &TreeViewComboBox::treeViewIndexActivated); |
| 64 | connect(m_lineEdit, &QLineEdit::textChanged, this, &TreeViewComboBox::filterChanged); |
| 65 | } |
| 66 | |
| 67 | void TreeViewComboBox::setTopLevelClasses(const QList<AspectType>& list) { |
| 68 | m_topLevelClasses = list; |
nothing calls this directly
no test coverage detected