aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/qmldesigner/components/componentcore/selectioncontext.h
blob: fee7922d3705314a35008460696bf495acc40ab3 (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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// 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

#include <abstractview.h>
#include <QPointF>
#include <QPointer>
#include <qmldesignercomponents_global.h>

#pragma once

namespace QmlDesigner {

class QMLDESIGNERCOMPONENTS_EXPORT SelectionContext
{
public:
    enum class UpdateMode {
        Normal,
        Fast,
        Properties,
        NodeCreated,
        NodeHierachy,
        Selection
    };

    SelectionContext();
    SelectionContext(AbstractView *view);

    void setTargetNode(const ModelNode &modelNode);
    ModelNode targetNode() const;
    ModelNode rootNode() const;

    bool singleNodeIsSelected() const;
    bool isInBaseState() const;

    ModelNode currentSingleSelectedNode() const;
    ModelNode firstSelectedModelNode() const;
    QList<ModelNode> selectedModelNodes() const;
    bool hasSingleSelectedModelNode() const;

    AbstractView *view() const;

    void setShowSelectionTools(bool show);
    bool showSelectionTools() const;

    void setScenePosition(const QPointF &postition);
    QPointF scenePosition() const;

    void setToggled(bool toggled);
    bool toggled() const;

    bool isValid() const;

    bool fastUpdate() const;
    void setUpdateMode(UpdateMode mode);

    UpdateMode updateReason() const;

private:
    QPointer<AbstractView> m_view;
    ModelNode m_targetNode;
    QPointF m_scenePosition;
    bool m_showSelectionTools = false;
    bool m_toggled = false;
    UpdateMode m_updateReason = UpdateMode::Normal;
};

} //QmlDesigner