summaryrefslogtreecommitdiff
path: root/src/plugins/scxmleditor/common/treeview.h
blob: 99f4632920128dd146d49d641e50ecb7a161289e (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
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

#pragma once

#include "scxmltypes.h"

#include <QTreeView>

QT_FORWARD_DECLARE_CLASS(QEvent)
QT_FORWARD_DECLARE_CLASS(QMouseEvent)

namespace ScxmlEditor {

namespace Common {

/**
 * @brief The TreeView class provides a default model/view implementation of a tree view.
 *
 * It extend the normal QTreeView by adding the signals mouseExited, currentIndexChanged and rightButtonClicked.
 */
class TreeView : public QTreeView
{
    Q_OBJECT

public:
    TreeView(QWidget *parent = nullptr);

signals:
    void mouseExited();
    void currentIndexChanged(const QModelIndex &index);
    void rightButtonClicked(const QModelIndex &index, const QPoint &globalPos);

protected:
    void leaveEvent(QEvent *e) override;
    void currentChanged(const QModelIndex &index, const QModelIndex &prev) override;
    void mousePressEvent(QMouseEvent *event) override;
};

} // namespace Common
} // namespace ScxmlEditor