OSDN Git Service

Update license.
[qt-creator-jp/qt-creator-jp.git] / src / plugins / qmldesigner / components / formeditor / anchorlinecontroller.h
1 /**************************************************************************
2 **
3 ** This file is part of Qt Creator
4 **
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
6 **
7 ** Contact: Nokia Corporation (info@qt.nokia.com)
8 **
9 **
10 ** GNU Lesser General Public License Usage
11 **
12 ** This file may be used under the terms of the GNU Lesser General Public
13 ** License version 2.1 as published by the Free Software Foundation and
14 ** appearing in the file LICENSE.LGPL included in the packaging of this file.
15 ** Please review the following information to ensure the GNU Lesser General
16 ** Public License version 2.1 requirements will be met:
17 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
18 **
19 ** In addition, as a special exception, Nokia gives you certain additional
20 ** rights. These rights are described in the Nokia Qt LGPL Exception
21 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
22 **
23 ** Other Usage
24 **
25 ** Alternatively, this file may be used in accordance with the terms and
26 ** conditions contained in a signed written agreement between you and Nokia.
27 **
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
30 **
31 **************************************************************************/
32
33 #ifndef ANCHORLINECONTROLLER_H
34 #define ANCHORLINECONTROLLER_H
35
36 #include <QWeakPointer>
37 #include <QSharedPointer>
38 #include <qmlanchors.h>
39
40 namespace QmlDesigner {
41
42 class FormEditorItem;
43 class LayerItem;
44 class AnchorLineHandleItem;
45
46 class AnchorLineControllerData
47 {
48 public:
49     AnchorLineControllerData(LayerItem *layerItem,
50                          FormEditorItem *formEditorItem);
51     AnchorLineControllerData(const AnchorLineControllerData &other);
52     ~AnchorLineControllerData();
53
54     QWeakPointer<LayerItem> layerItem;
55     FormEditorItem *formEditorItem;
56
57     AnchorLineHandleItem *topItem;
58     AnchorLineHandleItem *leftItem;
59     AnchorLineHandleItem *rightItem;
60     AnchorLineHandleItem *bottomItem;
61 };
62
63
64 class AnchorLineController
65 {
66  public:
67     AnchorLineController();
68     AnchorLineController(LayerItem *layerItem, FormEditorItem *formEditorItem);
69     AnchorLineController(const QSharedPointer<AnchorLineControllerData> &data);
70
71     void show(AnchorLine::Type anchorLineMask);
72     void hide();
73
74     void updatePosition();
75
76     bool isValid() const;
77
78     QWeakPointer<AnchorLineControllerData> weakPointer() const;
79
80
81     FormEditorItem *formEditorItem() const;
82
83     bool isTopHandle(const AnchorLineHandleItem *handle) const;
84     bool isLeftHandle(const AnchorLineHandleItem *handle) const;
85     bool isRightHandle(const AnchorLineHandleItem *handle) const;
86     bool isBottomHandle(const AnchorLineHandleItem *handle) const;
87
88     void clearHighlight();
89
90 private:
91     QSharedPointer<AnchorLineControllerData> m_data;
92 };
93
94 } // namespace QmlDesigner
95
96 #endif // ANCHORLINECONTROLLER_H