aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/qmldesigner/components/curveeditor/detail/selectionmodel.h
blob: 4c485eba26fa99041d68c3d14168a4fea39f3415 (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
45
46
47
// Copyright (C) 2019 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 "curveitem.h"
#include "treeitem.h"

#include <QItemSelectionModel>

namespace QmlDesigner {

class TreeItem;
class NodeTreeItem;
class PropertyTreeItem;

class SelectionModel : public QItemSelectionModel
{
    Q_OBJECT

signals:
    void curvesSelected();

public:
    SelectionModel(QAbstractItemModel *model = nullptr);

    void select(const QItemSelection &selection, QItemSelectionModel::SelectionFlags command) override;

    bool isSelected(TreeItem *item) const;

    std::vector<TreeItem::Path> selectedPaths() const;

    std::vector<CurveItem *> selectedCurveItems() const;

    std::vector<TreeItem *> selectedTreeItems() const;

    std::vector<NodeTreeItem *> selectedNodeItems() const;

    std::vector<PropertyTreeItem *> selectedPropertyItems() const;

    void selectPaths(const std::vector<TreeItem::Path> &selection);

private:
    void changeSelection(const QItemSelection &selected, const QItemSelection &deselected);
};

} // End namespace QmlDesigner.