blob: d0274206b43cd741d156482baffbabf7b493524a (
plain)
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
|
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
#pragma once
#include "utils_global.h"
#include <QComboBox>
#include <QTreeView>
namespace Utils {
class QTCREATOR_UTILS_EXPORT TreeViewComboBoxView : public QTreeView
{
Q_OBJECT
public:
TreeViewComboBoxView(QWidget *parent = nullptr);
void adjustWidth(int width);
};
class QTCREATOR_UTILS_EXPORT TreeViewComboBox : public QComboBox
{
Q_OBJECT
public:
TreeViewComboBox(QWidget *parent = nullptr);
void wheelEvent(QWheelEvent *e) override;
void keyPressEvent(QKeyEvent *e) override;
void setCurrentIndex(const QModelIndex &index);
bool eventFilter(QObject* object, QEvent* event) override;
void showPopup() override;
void hidePopup() override;
TreeViewComboBoxView *view() const;
private:
QModelIndex indexBelow(QModelIndex index);
QModelIndex indexAbove(QModelIndex index);
QModelIndex lastIndex(const QModelIndex &index);
TreeViewComboBoxView *m_view;
bool m_skipNextHide = false;
};
}
|