1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (qt-info@nokia.com)
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
16 ** GNU Lesser General Public License Usage
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.
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.
29 ** If you have questions regarding the use of this file, please contact
30 ** Nokia at qt-info@nokia.com.
32 **************************************************************************/
34 #ifndef FORMEDITORITEM_H
35 #define FORMEDITORITEM_H
37 #include <QWeakPointer>
38 #include <QGraphicsWidget>
39 #include <qmlitemnode.h>
40 #include "snappinglinecreator.h"
46 namespace QmlDesigner {
48 class FormEditorScene;
50 class AbstractFormEditorTool;
53 class GraphicItemResizer;
57 class FormEditorItem : public QGraphicsObject
61 friend class QmlDesigner::FormEditorScene;
65 void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0 );
67 bool isContainer() const;
68 QmlItemNode qmlItemNode() const;
71 enum { Type = UserType + 0xfffa };
75 static FormEditorItem* fromQGraphicsItem(QGraphicsItem *graphicsItem);
77 void updateSnappingLines(const QList<FormEditorItem*> &exceptionList,
78 FormEditorItem *transformationSpaceItem);
80 SnapLineMap topSnappingLines() const;
81 SnapLineMap bottomSnappingLines() const;
82 SnapLineMap leftSnappingLines() const;
83 SnapLineMap rightSnappingLines() const;
84 SnapLineMap horizontalCenterSnappingLines() const;
85 SnapLineMap verticalCenterSnappingLines() const;
87 SnapLineMap topSnappingOffsets() const;
88 SnapLineMap bottomSnappingOffsets() const;
89 SnapLineMap leftSnappingOffsets() const;
90 SnapLineMap rightSnappingOffsets() const;
92 QList<FormEditorItem*> childFormEditorItems() const;
93 FormEditorScene *scene() const;
94 FormEditorItem *parentItem() const;
96 QRectF boundingRect() const;
98 void updateGeometry();
99 void updateVisibilty();
101 void showAttention();
103 FormEditorView *formEditorView() const;
105 void setHighlightBoundingRect(bool highlight);
107 void setContentVisible(bool visible);
108 bool isContentVisible() const;
111 AbstractFormEditorTool* tool() const;
112 void paintBoundingRect(QPainter *painter) const;
115 void changeAttention(qreal value);
117 private: // functions
118 FormEditorItem(const QmlItemNode &qmlItemNode, FormEditorScene* scene);
120 void setAttentionScale(double scale);
121 void setAttentionHighlight(double value);
123 private: // variables
124 SnappingLineCreator m_snappingLineCreator;
125 QmlItemNode m_qmlItemNode;
126 QWeakPointer<QTimeLine> m_attentionTimeLine;
127 QTransform m_attentionTransform; // make item larger in anchor mode
128 QTransform m_inverseAttentionTransform;
129 QRectF m_boundingRect;
130 double m_borderWidth;
131 bool m_highlightBoundingRect;
132 bool m_isContentVisible;
136 inline int FormEditorItem::type() const
138 return UserType + 0xfffa;
143 #endif // FORMEDITORITEM_H