diff options
Diffstat (limited to 'src/plugins/qmltooling/declarativeobserver/editor/liveselectionindicator.cpp')
-rw-r--r-- | src/plugins/qmltooling/declarativeobserver/editor/liveselectionindicator.cpp | 148 |
1 files changed, 0 insertions, 148 deletions
diff --git a/src/plugins/qmltooling/declarativeobserver/editor/liveselectionindicator.cpp b/src/plugins/qmltooling/declarativeobserver/editor/liveselectionindicator.cpp deleted file mode 100644 index 96e9dbf0cb..0000000000 --- a/src/plugins/qmltooling/declarativeobserver/editor/liveselectionindicator.cpp +++ /dev/null @@ -1,148 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "liveselectionindicator_p.h" - -#include "../qdeclarativeviewobserver_p_p.h" -#include "../qmlobserverconstants_p.h" - -#include <QtCore/QDebug> - -#include <QtGui/QGraphicsPolygonItem> -#include <QtGui/QGraphicsObject> -#include <QtGui/QGraphicsScene> -#include <QtGui/QPen> - -#include <cmath> - -QT_BEGIN_NAMESPACE - -LiveSelectionIndicator::LiveSelectionIndicator(QDeclarativeViewObserver *editorView, - QGraphicsObject *layerItem) - : m_layerItem(layerItem), m_view(editorView) -{ -} - -LiveSelectionIndicator::~LiveSelectionIndicator() -{ - clear(); -} - -void LiveSelectionIndicator::show() -{ - foreach (QGraphicsPolygonItem *item, m_indicatorShapeHash.values()) - item->show(); -} - -void LiveSelectionIndicator::hide() -{ - foreach (QGraphicsPolygonItem *item, m_indicatorShapeHash.values()) - item->hide(); -} - -void LiveSelectionIndicator::clear() -{ - if (!m_layerItem.isNull()) { - QHashIterator<QGraphicsItem*, QGraphicsPolygonItem *> iter(m_indicatorShapeHash); - while (iter.hasNext()) { - iter.next(); - m_layerItem.data()->scene()->removeItem(iter.value()); - delete iter.value(); - } - } - - m_indicatorShapeHash.clear(); - -} - -QPolygonF LiveSelectionIndicator::addBoundingRectToPolygon(QGraphicsItem *item, QPolygonF &polygon) -{ - // ### remove this if statement when QTBUG-12172 gets fixed - if (item->boundingRect() != QRectF(0,0,0,0)) { - QPolygonF bounding = item->mapToScene(item->boundingRect()); - if (bounding.isClosed()) //avoid crashes if there is an infinite scale. - polygon = polygon.united(bounding); - } - - foreach (QGraphicsItem *child, item->childItems()) { - if (!QDeclarativeViewObserverPrivate::get(m_view)->isEditorItem(child)) - addBoundingRectToPolygon(child, polygon); - } - return polygon; -} - -void LiveSelectionIndicator::setItems(const QList<QWeakPointer<QGraphicsObject> > &itemList) -{ - clear(); - - // set selections to also all children if they are not editor items - - foreach (const QWeakPointer<QGraphicsObject> &object, itemList) { - if (object.isNull()) - continue; - - QGraphicsItem *item = object.data(); - - QGraphicsPolygonItem *newSelectionIndicatorGraphicsItem - = new QGraphicsPolygonItem(m_layerItem.data()); - if (!m_indicatorShapeHash.contains(item)) { - m_indicatorShapeHash.insert(item, newSelectionIndicatorGraphicsItem); - - QPolygonF boundingShapeInSceneSpace; - addBoundingRectToPolygon(item, boundingShapeInSceneSpace); - - QRectF boundingRect - = m_view->adjustToScreenBoundaries(boundingShapeInSceneSpace.boundingRect()); - QPolygonF boundingRectInLayerItemSpace = m_layerItem.data()->mapFromScene(boundingRect); - - QPen pen; - pen.setColor(QColor(108, 141, 221)); - newSelectionIndicatorGraphicsItem->setData(Constants::EditorItemDataKey, - QVariant(true)); - newSelectionIndicatorGraphicsItem->setFlag(QGraphicsItem::ItemIsSelectable, false); - newSelectionIndicatorGraphicsItem->setPolygon(boundingRectInLayerItemSpace); - newSelectionIndicatorGraphicsItem->setPen(pen); - } - } -} - -QT_END_NAMESPACE - |