OSDN Git Service

ad47ae988d9b262c85fde6be74dc0b9e268add07
[qt-creator-jp/qt-creator-jp.git] / src / plugins / qmldesigner / designercore / include / nodeinstance.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 (qt-info@nokia.com)
8 **
9 ** No Commercial Usage
10 **
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
14 ** this package.
15 **
16 ** GNU Lesser General Public License Usage
17 **
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file.  Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Nokia gives you certain additional
26 ** rights.  These rights are described in the Nokia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** If you have questions regarding the use of this file, please contact
30 ** Nokia at qt-info@nokia.com.
31 **
32 **************************************************************************/
33
34 #ifndef PROXYNODEINSTANCE_H
35 #define PROXYNODEINSTANCE_H
36
37 #include <QSharedPointer>
38 #include <QTransform>
39 #include <QPointF>
40 #include <QSizeF>
41 #include <QPair>
42
43 #include "commondefines.h"
44
45 namespace QmlDesigner {
46
47 class ModelNode;
48 class NodeInstanceView;
49 class ProxyNodeInstanceData;
50
51 class NodeInstance
52 {
53     friend class NodeInstanceView;
54 public:
55     static NodeInstance create(const ModelNode &node);
56     NodeInstance();
57     ~NodeInstance();
58     NodeInstance(const NodeInstance &other);
59     NodeInstance& operator=(const NodeInstance &other);
60
61     ModelNode modelNode() const;
62     bool isValid() const;
63     void makeInvalid();
64     QRectF boundingRect() const;
65     bool hasContent() const;
66     bool isAnchoredBySibling() const;
67     bool isAnchoredByChildren() const;
68     bool isMovable() const;
69     bool isResizable() const;
70     QTransform transform() const;
71     QTransform sceneTransform() const;
72     bool isInPositioner() const;
73     QPointF position() const;
74     QSizeF size() const;
75     int penWidth() const;
76     void paint(QPainter *painter);
77
78     QVariant property(const QString &name) const;
79     bool hasBindingForProperty(const QString &name) const;
80     QPair<QString, qint32> anchor(const QString &name) const;
81     bool hasAnchor(const QString &name) const;
82     QString instanceType(const QString &name) const;
83
84     qint32 parentId() const;
85     qint32 instanceId() const;
86
87 protected:
88     void setProperty(const QString &name, const QVariant &value);
89     void setInformation(InformationName name,
90                         const QVariant &information,
91                         const QVariant &secondInformation,
92                         const QVariant &thirdInformation);
93
94     void setParentId(qint32 instanceId);
95     void setRenderImage(const QImage &image);
96     NodeInstance(ProxyNodeInstanceData *d);
97
98 private:
99     QSharedPointer<ProxyNodeInstanceData> d;
100 };
101
102 bool operator ==(const NodeInstance &first, const NodeInstance &second);
103
104 }
105
106 #endif // PROXYNODEINSTANCE_H