17 #include <QFocusEvent>
18 #include <QHBoxLayout>
20 #include <QNonConstOverload>
23 #include "../../util/btassert.h"
24 #include "../../util/btconnect.h"
38 const Qt::FocusReason reason =
event->reason();
39 if (reason == Qt::OtherFocusReason)
41 QWidget::focusInEvent(event);
50 setFocusPolicy(Qt::WheelFocus);
53 installEventFilter(lineEdit());
57 if (e->type() == QEvent::FocusOut) {
58 QFocusEvent *
const f =
static_cast<QFocusEvent *
>(e);
60 if (o == lineEdit() && f->reason() == Qt::TabFocusReason) {
61 int index = findText(currentText());
64 setCurrentIndex(index);
69 if (f->reason() == Qt::PopupFocusReason)
72 if (f->reason() == Qt::ActiveWindowFocusReason) {
73 Q_EMIT textActivated(currentText());
77 if (f->reason() == Qt::MouseFocusReason) {
78 Q_EMIT textActivated(currentText());
83 Q_EMIT textActivated(currentText());
88 return QComboBox::eventFilter(o, e);
97 for (
int index = 1; index <= count; index++) {
98 m_list.append( QString::number(index) );
121 for (
int i = 1; i <= count; i++)
122 m_list.append(QString::number(i));
152 if (list && !list->empty()) {
178 setFocusPolicy(Qt::WheelFocus);
184 m_comboBox->setInsertPolicy(QComboBox::NoInsert);
218 const int old_index =
m_comboBox->currentIndex();
219 int new_index = old_index + n;
228 if (new_index != old_index) {
236 if (!updatesEnabled())
239 setUpdatesEnabled(
false);
241 const QString key(
m_comboBox->itemText(index));
247 setUpdatesEnabled(
true);
251 BT_ASSERT(m_comboBox->lineEdit());
253 const QString text(m_comboBox->lineEdit()->text());
254 for (int index = 0; index < m_comboBox->count(); ++index) {
255 if (m_comboBox->itemText(index) == text) {
259 Q_EMIT focusOut(index);
268 m_isResetting =
false;
273 const QString & nextEntryTip,
274 const QString & scrollButtonTip,
275 const QString & previousEntryTip)
285 for (
int i = 0; i < count; ++i) {
BtKeyLineEdit(QWidget *parent)
void focusInEvent(QFocusEvent *event) override
CKCComboBox(QWidget *parent=nullptr)
void focusOut(int itemIndex)
bool eventFilter(QObject *o, QEvent *e) override