-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpicker.hh
47 lines (38 loc) · 931 Bytes
/
picker.hh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#pragma once
#include <QDialog>
#include <QKeyEvent>
#include <QLineEdit>
#include <QSortFilterProxyModel>
class PickerLineEdit final : public QLineEdit
{
Q_OBJECT
public:
PickerLineEdit(QWidget* parent)
: QLineEdit(parent)
{}
virtual void keyPressEvent(QKeyEvent* event) override
{
if (event->key() == Qt::Key_Up)
emit up_key_pressed();
else if (event->key() == Qt::Key_Down)
emit down_key_pressed();
else
QLineEdit::keyPressEvent(event);
}
signals:
void up_key_pressed();
void down_key_pressed();
};
class Picker : public QDialog
{
Q_OBJECT
public:
Picker(QAbstractItemModel*, int, QWidget*);
~Picker() = default;
public slots:
void select_buffer(QModelIndex const&);
int result_row() const { return m_result_row; }
private:
QSortFilterProxyModel* m_filter_model;
int m_result_row { -1 };
};