From 801c8bb6d4141d6dbb70e933a7dc6ddf135c8327 Mon Sep 17 00:00:00 2001 From: Kai Koehne <kai.koehne@nokia.com> Date: Wed, 1 Dec 2010 11:46:49 +0100 Subject: [PATCH] QmlJSDebugger: Code cleanup Fix indentation + line length. --- .../editor/abstractformeditortool.cpp | 13 +- .../editor/boundingrecthighlighter.cpp | 6 +- .../editor/boundingrecthighlighter.h | 3 +- .../qmljsdebugger/editor/colorpickertool.cpp | 2 +- .../qml/qmljsdebugger/editor/layeritem.cpp | 5 +- .../qml/qmljsdebugger/editor/layeritem.h | 5 +- .../qml/qmljsdebugger/editor/qmltoolbar.cpp | 30 +++-- .../editor/rubberbandselectionmanipulator.cpp | 52 ++++---- .../editor/rubberbandselectionmanipulator.h | 5 +- .../editor/selectionindicator.cpp | 12 +- .../editor/selectionrectangle.cpp | 8 +- .../qmljsdebugger/editor/selectiontool.cpp | 105 +++++++++------ .../qml/qmljsdebugger/editor/selectiontool.h | 4 +- .../editor/singleselectionmanipulator.cpp | 54 ++++---- .../editor/singleselectionmanipulator.h | 3 +- .../editor/subcomponenteditortool.cpp | 21 +-- .../editor/subcomponentmasklayeritem.cpp | 3 +- .../editor/subcomponentmasklayeritem.h | 3 +- .../qmljsdebugger/editor/toolbarcolorbox.cpp | 10 +- .../qml/qmljsdebugger/editor/zoomtool.cpp | 35 +++-- .../qml/qmljsdebugger/editor/zoomtool.h | 2 +- .../qmljsdebugger/include/jsdebuggeragent.h | 8 +- .../qml/qmljsdebugger/jsdebuggeragent.cpp | 25 ++-- .../qdeclarativeobserverservice.cpp | 6 +- .../qdeclarativeviewobserver.cpp | 122 +++++++++--------- 25 files changed, 309 insertions(+), 233 deletions(-) diff --git a/share/qtcreator/qml/qmljsdebugger/editor/abstractformeditortool.cpp b/share/qtcreator/qml/qmljsdebugger/editor/abstractformeditortool.cpp index 27a6c55ddb8..10e026072bd 100644 --- a/share/qtcreator/qml/qmljsdebugger/editor/abstractformeditortool.cpp +++ b/share/qtcreator/qml/qmljsdebugger/editor/abstractformeditortool.cpp @@ -86,7 +86,8 @@ bool AbstractFormEditorTool::topItemIsMovable(const QList<QGraphicsItem*> & item if (firstSelectableItem == 0) return false; - QDeclarativeItem *declarativeItem = dynamic_cast<QDeclarativeItem*>(firstSelectableItem->toGraphicsObject()); + QDeclarativeItem *declarativeItem + = dynamic_cast<QDeclarativeItem*>(firstSelectableItem->toGraphicsObject()); if (declarativeItem != 0) return true; @@ -102,8 +103,8 @@ bool AbstractFormEditorTool::topSelectedItemIsMovable(const QList<QGraphicsItem* foreach (QGraphicsItem *item, itemList) { QDeclarativeItem *declarativeItem = toQDeclarativeItem(item); if (declarativeItem - && selectedItems.contains(declarativeItem) - /*&& (declarativeItem->qmlItemNode().hasShowContent() || selectNonContentItems)*/) + && selectedItems.contains(declarativeItem) + /*&& (declarativeItem->qmlItemNode().hasShowContent() || selectNonContentItems)*/) return true; } @@ -130,7 +131,8 @@ QGraphicsItem *AbstractFormEditorTool::topMovableGraphicsItem(const QList<QGraph return 0; } -QDeclarativeItem *AbstractFormEditorTool::topMovableDeclarativeItem(const QList<QGraphicsItem*> &itemList) +QDeclarativeItem *AbstractFormEditorTool::topMovableDeclarativeItem(const QList<QGraphicsItem*> + &itemList) { foreach (QGraphicsItem *item, itemList) { QDeclarativeItem *declarativeItem = toQDeclarativeItem(item); @@ -141,7 +143,8 @@ QDeclarativeItem *AbstractFormEditorTool::topMovableDeclarativeItem(const QList< return 0; } -QList<QGraphicsObject*> AbstractFormEditorTool::toGraphicsObjectList(const QList<QGraphicsItem*> &itemList) +QList<QGraphicsObject*> AbstractFormEditorTool::toGraphicsObjectList(const QList<QGraphicsItem*> + &itemList) { QList<QGraphicsObject*> gfxObjects; foreach(QGraphicsItem *item, itemList) { diff --git a/share/qtcreator/qml/qmljsdebugger/editor/boundingrecthighlighter.cpp b/share/qtcreator/qml/qmljsdebugger/editor/boundingrecthighlighter.cpp index dcd53903481..ccdebda3c25 100644 --- a/share/qtcreator/qml/qmljsdebugger/editor/boundingrecthighlighter.cpp +++ b/share/qtcreator/qml/qmljsdebugger/editor/boundingrecthighlighter.cpp @@ -43,7 +43,8 @@ const qreal AnimDelta = 0.025f; const int AnimInterval = 30; const int AnimFrames = 10; -BoundingBox::BoundingBox(QGraphicsObject *itemToHighlight, QGraphicsItem *parentItem, QObject *parent) +BoundingBox::BoundingBox(QGraphicsObject *itemToHighlight, QGraphicsItem *parentItem, + QObject *parent) : QObject(parent), highlightedObject(itemToHighlight), highlightPolygon(0), @@ -243,7 +244,8 @@ void BoundingRectHighlighter::highlightAll(bool animate) QPolygonF boundingRectInSceneSpace(item->mapToScene(itemAndChildRect)); QPolygonF boundingRectInLayerItemSpace = mapFromScene(boundingRectInSceneSpace); - QRectF bboxRect = m_view->adjustToScreenBoundaries(boundingRectInLayerItemSpace.boundingRect()); + QRectF bboxRect + = m_view->adjustToScreenBoundaries(boundingRectInLayerItemSpace.boundingRect()); QRectF edgeRect = bboxRect; edgeRect.adjust(-1, -1, 1, 1); diff --git a/share/qtcreator/qml/qmljsdebugger/editor/boundingrecthighlighter.h b/share/qtcreator/qml/qmljsdebugger/editor/boundingrecthighlighter.h index f24c300df18..cb7e7866656 100644 --- a/share/qtcreator/qml/qmljsdebugger/editor/boundingrecthighlighter.h +++ b/share/qtcreator/qml/qmljsdebugger/editor/boundingrecthighlighter.h @@ -84,7 +84,8 @@ class BoundingBox : public QObject { Q_OBJECT public: - explicit BoundingBox(QGraphicsObject *itemToHighlight, QGraphicsItem *parentItem, QObject *parent = 0); + explicit BoundingBox(QGraphicsObject *itemToHighlight, QGraphicsItem *parentItem, + QObject *parent = 0); ~BoundingBox(); QWeakPointer<QGraphicsObject> highlightedObject; QGraphicsPolygonItem *highlightPolygon; diff --git a/share/qtcreator/qml/qmljsdebugger/editor/colorpickertool.cpp b/share/qtcreator/qml/qmljsdebugger/editor/colorpickertool.cpp index 7063daa1519..cd01e0de01e 100644 --- a/share/qtcreator/qml/qmljsdebugger/editor/colorpickertool.cpp +++ b/share/qtcreator/qml/qmljsdebugger/editor/colorpickertool.cpp @@ -41,7 +41,7 @@ namespace QmlJSDebugger { ColorPickerTool::ColorPickerTool(QDeclarativeViewObserver *view) : - AbstractFormEditorTool(view) + AbstractFormEditorTool(view) { m_selectedColor.setRgb(0,0,0); } diff --git a/share/qtcreator/qml/qmljsdebugger/editor/layeritem.cpp b/share/qtcreator/qml/qmljsdebugger/editor/layeritem.cpp index 285b3e3074e..26d0b99a874 100644 --- a/share/qtcreator/qml/qmljsdebugger/editor/layeritem.cpp +++ b/share/qtcreator/qml/qmljsdebugger/editor/layeritem.cpp @@ -35,7 +35,7 @@ namespace QmlJSDebugger { LayerItem::LayerItem(QGraphicsScene* scene) - : QGraphicsObject() + : QGraphicsObject() { scene->addItem(this); setZValue(1); @@ -46,7 +46,8 @@ LayerItem::~LayerItem() { } -void LayerItem::paint(QPainter * /*painter*/, const QStyleOptionGraphicsItem * /*option*/, QWidget * /*widget*/) +void LayerItem::paint(QPainter * /*painter*/, const QStyleOptionGraphicsItem * /*option*/, + QWidget * /*widget*/) { } diff --git a/share/qtcreator/qml/qmljsdebugger/editor/layeritem.h b/share/qtcreator/qml/qmljsdebugger/editor/layeritem.h index c699cb8bc99..f036d9f2023 100644 --- a/share/qtcreator/qml/qmljsdebugger/editor/layeritem.h +++ b/share/qtcreator/qml/qmljsdebugger/editor/layeritem.h @@ -40,9 +40,10 @@ class FormEditorScene; class LayerItem : public QGraphicsObject { public: - LayerItem(QGraphicsScene* scene); + LayerItem(QGraphicsScene *scene); ~LayerItem(); - void paint ( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0 ); + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, + QWidget *widget = 0); QRectF boundingRect() const; int type() const; diff --git a/share/qtcreator/qml/qmljsdebugger/editor/qmltoolbar.cpp b/share/qtcreator/qml/qmljsdebugger/editor/qmltoolbar.cpp index 24bd5c4a1d0..50406ae6a7e 100644 --- a/share/qtcreator/qml/qmljsdebugger/editor/qmltoolbar.cpp +++ b/share/qtcreator/qml/qmljsdebugger/editor/qmltoolbar.cpp @@ -50,14 +50,19 @@ QmlToolbar::QmlToolbar(QWidget *parent) ui->playIcon = QIcon(QLatin1String(":/qml/images/play-24.png")); ui->pauseIcon = QIcon(QLatin1String(":/qml/images/pause-24.png")); - ui->designmode = new QAction(QIcon(QLatin1String(":/qml/images/observermode-24.png")), tr("Observer Mode"), this); + ui->designmode = new QAction(QIcon(QLatin1String(":/qml/images/observermode-24.png")), + tr("Observer Mode"), this); ui->play = new QAction(ui->pauseIcon, tr("Play/Pause Animations"), this); ui->select = new QAction(QIcon(QLatin1String(":/qml/images/select-24.png")), tr("Select"), this); - ui->selectMarquee = new QAction(QIcon(QLatin1String(":/qml/images/select-marquee-24.png")), tr("Select (Marquee)"), this); + ui->selectMarquee = new QAction(QIcon(QLatin1String(":/qml/images/select-marquee-24.png")), + tr("Select (Marquee)"), this); ui->zoom = new QAction(QIcon(QLatin1String(":/qml/images/zoom-24.png")), tr("Zoom"), this); - ui->colorPicker = new QAction(QIcon(QLatin1String(":/qml/images/color-picker-24.png")), tr("Color Picker"), this); - ui->toQml = new QAction(QIcon(QLatin1String(":/qml/images/to-qml-24.png")), tr("Apply Changes to QML Viewer"), this); - ui->fromQml = new QAction(QIcon(QLatin1String(":/qml/images/from-qml-24.png")), tr("Apply Changes to Document"), this); + ui->colorPicker = new QAction(QIcon(QLatin1String(":/qml/images/color-picker-24.png")), + tr("Color Picker"), this); + ui->toQml = new QAction(QIcon(QLatin1String(":/qml/images/to-qml-24.png")), + tr("Apply Changes to QML Viewer"), this); + ui->fromQml = new QAction(QIcon(QLatin1String(":/qml/images/from-qml-24.png")), + tr("Apply Changes to Document"), this); ui->designmode->setCheckable(true); ui->designmode->setChecked(false); @@ -94,24 +99,29 @@ QmlToolbar::QmlToolbar(QWidget *parent) playSpeedMenuActions->setExclusive(true); playSpeedMenu->addAction(tr("Animation Speed")); playSpeedMenu->addSeparator(); - ui->defaultAnimSpeedAction = playSpeedMenu->addAction(tr("1x"), this, SLOT(changeToDefaultAnimSpeed())); + ui->defaultAnimSpeedAction = playSpeedMenu->addAction(tr("1x"), this, + SLOT(changeToDefaultAnimSpeed())); ui->defaultAnimSpeedAction->setCheckable(true); ui->defaultAnimSpeedAction->setChecked(true); playSpeedMenuActions->addAction(ui->defaultAnimSpeedAction); - ui->halfAnimSpeedAction = playSpeedMenu->addAction(tr("0.5x"), this, SLOT(changeToHalfAnimSpeed())); + ui->halfAnimSpeedAction = playSpeedMenu->addAction(tr("0.5x"), this, + SLOT(changeToHalfAnimSpeed())); ui->halfAnimSpeedAction->setCheckable(true); playSpeedMenuActions->addAction(ui->halfAnimSpeedAction); - ui->fourthAnimSpeedAction = playSpeedMenu->addAction(tr("0.25x"), this, SLOT(changeToFourthAnimSpeed())); + ui->fourthAnimSpeedAction = playSpeedMenu->addAction(tr("0.25x"), this, + SLOT(changeToFourthAnimSpeed())); ui->fourthAnimSpeedAction->setCheckable(true); playSpeedMenuActions->addAction(ui->fourthAnimSpeedAction); - ui->eighthAnimSpeedAction = playSpeedMenu->addAction(tr("0.125x"), this, SLOT(changeToEighthAnimSpeed())); + ui->eighthAnimSpeedAction = playSpeedMenu->addAction(tr("0.125x"), this, + SLOT(changeToEighthAnimSpeed())); ui->eighthAnimSpeedAction->setCheckable(true); playSpeedMenuActions->addAction(ui->eighthAnimSpeedAction); - ui->tenthAnimSpeedAction = playSpeedMenu->addAction(tr("0.1x"), this, SLOT(changeToTenthAnimSpeed())); + ui->tenthAnimSpeedAction = playSpeedMenu->addAction(tr("0.1x"), this, + SLOT(changeToTenthAnimSpeed())); ui->tenthAnimSpeedAction->setCheckable(true); playSpeedMenuActions->addAction(ui->tenthAnimSpeedAction); diff --git a/share/qtcreator/qml/qmljsdebugger/editor/rubberbandselectionmanipulator.cpp b/share/qtcreator/qml/qmljsdebugger/editor/rubberbandselectionmanipulator.cpp index 43e3575470c..a477067a9b5 100644 --- a/share/qtcreator/qml/qmljsdebugger/editor/rubberbandselectionmanipulator.cpp +++ b/share/qtcreator/qml/qmljsdebugger/editor/rubberbandselectionmanipulator.cpp @@ -34,11 +34,12 @@ namespace QmlJSDebugger { -RubberBandSelectionManipulator::RubberBandSelectionManipulator(QGraphicsObject *layerItem, QDeclarativeViewObserver *editorView) +RubberBandSelectionManipulator::RubberBandSelectionManipulator(QGraphicsObject *layerItem, + QDeclarativeViewObserver *editorView) : m_selectionRectangleElement(layerItem), - m_editorView(editorView), - m_beginFormEditorItem(0), - m_isActive(false) + m_editorView(editorView), + m_beginFormEditorItem(0), + m_isActive(false) { m_selectionRectangleElement.hide(); } @@ -52,7 +53,8 @@ void RubberBandSelectionManipulator::clear() m_oldSelectionList.clear(); } -QGraphicsItem *RubberBandSelectionManipulator::topFormEditorItem(const QList<QGraphicsItem*> &itemList) +QGraphicsItem *RubberBandSelectionManipulator::topFormEditorItem(const QList<QGraphicsItem*> + &itemList) { if (itemList.isEmpty()) return 0; @@ -66,7 +68,9 @@ void RubberBandSelectionManipulator::begin(const QPointF& beginPoint) m_selectionRectangleElement.setRect(m_beginPoint, m_beginPoint); m_selectionRectangleElement.show(); m_isActive = true; - m_beginFormEditorItem = topFormEditorItem(QDeclarativeViewObserverPrivate::get(m_editorView)->selectableItems(beginPoint)); + QDeclarativeViewObserverPrivate *observerPrivate + = QDeclarativeViewObserverPrivate::get(m_editorView); + m_beginFormEditorItem = topFormEditorItem(observerPrivate->selectableItems(beginPoint)); m_oldSelectionList = m_editorView->selectedItems(); } @@ -84,16 +88,19 @@ void RubberBandSelectionManipulator::end() void RubberBandSelectionManipulator::select(SelectionType selectionType) { - QList<QGraphicsItem*> itemList = QDeclarativeViewObserverPrivate::get(m_editorView)->selectableItems(m_selectionRectangleElement.rect(), - Qt::IntersectsItemShape); + QDeclarativeViewObserverPrivate *observerPrivate + = QDeclarativeViewObserverPrivate::get(m_editorView); + QList<QGraphicsItem*> itemList + = observerPrivate->selectableItems(m_selectionRectangleElement.rect(), + Qt::IntersectsItemShape); QList<QGraphicsItem*> newSelectionList; foreach (QGraphicsItem* item, itemList) { if (item - && item->parentItem() - && !newSelectionList.contains(item) - //&& m_beginFormEditorItem->childItems().contains(item) // TODO activate this test - ) + && item->parentItem() + && !newSelectionList.contains(item) + //&& m_beginFormEditorItem->childItems().contains(item) // TODO activate this test + ) { newSelectionList.append(item); } @@ -106,19 +113,19 @@ void RubberBandSelectionManipulator::select(SelectionType selectionType) switch(selectionType) { case AddToSelection: { - resultList.append(m_oldSelectionList); - resultList.append(newSelectionList); - } + resultList.append(m_oldSelectionList); + resultList.append(newSelectionList); + } break; case ReplaceSelection: { - resultList.append(newSelectionList); - } + resultList.append(newSelectionList); + } break; case RemoveFromSelection: { - QSet<QGraphicsItem*> oldSelectionSet(m_oldSelectionList.toSet()); - QSet<QGraphicsItem*> newSelectionSet(newSelectionList.toSet()); - resultList.append(oldSelectionSet.subtract(newSelectionSet).toList()); - } + QSet<QGraphicsItem*> oldSelectionSet(m_oldSelectionList.toSet()); + QSet<QGraphicsItem*> newSelectionSet(newSelectionList.toSet()); + resultList.append(oldSelectionSet.subtract(newSelectionSet).toList()); + } } m_editorView->setSelectedItems(resultList); @@ -138,7 +145,6 @@ QPointF RubberBandSelectionManipulator::beginPoint() const bool RubberBandSelectionManipulator::isActive() const { return m_isActive; - } -} +} // namespace QmlJSDebugger diff --git a/share/qtcreator/qml/qmljsdebugger/editor/rubberbandselectionmanipulator.h b/share/qtcreator/qml/qmljsdebugger/editor/rubberbandselectionmanipulator.h index e6815695775..062284d13d3 100644 --- a/share/qtcreator/qml/qmljsdebugger/editor/rubberbandselectionmanipulator.h +++ b/share/qtcreator/qml/qmljsdebugger/editor/rubberbandselectionmanipulator.h @@ -46,8 +46,8 @@ public: RemoveFromSelection }; - - RubberBandSelectionManipulator(QGraphicsObject *layerItem, QDeclarativeViewObserver *editorView); + RubberBandSelectionManipulator(QGraphicsObject *layerItem, + QDeclarativeViewObserver *editorView); void setItems(const QList<QGraphicsItem*> &itemList); @@ -66,7 +66,6 @@ public: protected: QGraphicsItem *topFormEditorItem(const QList<QGraphicsItem*> &itemList); - private: QList<QGraphicsItem*> m_itemList; QList<QGraphicsItem*> m_oldSelectionList; diff --git a/share/qtcreator/qml/qmljsdebugger/editor/selectionindicator.cpp b/share/qtcreator/qml/qmljsdebugger/editor/selectionindicator.cpp index d15eca8ff52..0bdcdfd9aec 100644 --- a/share/qtcreator/qml/qmljsdebugger/editor/selectionindicator.cpp +++ b/share/qtcreator/qml/qmljsdebugger/editor/selectionindicator.cpp @@ -38,7 +38,8 @@ namespace QmlJSDebugger { -SelectionIndicator::SelectionIndicator(QDeclarativeViewObserver *editorView, QGraphicsObject *layerItem) +SelectionIndicator::SelectionIndicator(QDeclarativeViewObserver *editorView, + QGraphicsObject *layerItem) : m_layerItem(layerItem), m_view(editorView) { } @@ -103,19 +104,22 @@ void SelectionIndicator::setItems(const QList<QWeakPointer<QGraphicsObject> > &i QGraphicsItem *item = object.data(); - QGraphicsPolygonItem *newSelectionIndicatorGraphicsItem = new QGraphicsPolygonItem(m_layerItem.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()); + 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->setData(Constants::EditorItemDataKey, + QVariant(true)); newSelectionIndicatorGraphicsItem->setFlag(QGraphicsItem::ItemIsSelectable, false); newSelectionIndicatorGraphicsItem->setPolygon(boundingRectInLayerItemSpace); newSelectionIndicatorGraphicsItem->setPen(pen); diff --git a/share/qtcreator/qml/qmljsdebugger/editor/selectionrectangle.cpp b/share/qtcreator/qml/qmljsdebugger/editor/selectionrectangle.cpp index 24a4a764416..0f73d4fc5bb 100644 --- a/share/qtcreator/qml/qmljsdebugger/editor/selectionrectangle.cpp +++ b/share/qtcreator/qml/qmljsdebugger/editor/selectionrectangle.cpp @@ -47,7 +47,7 @@ public: SelectionRectangle::SelectionRectangle(QGraphicsObject *layerItem) : m_controlShape(new SelectionRectShape(layerItem)), - m_layerItem(layerItem) + m_layerItem(layerItem) { m_controlShape->setPen(QPen(Qt::black)); m_controlShape->setBrush(QColor(128, 128, 128, 50)); @@ -85,8 +85,10 @@ void SelectionRectangle::setRect(const QPointF &firstPoint, double firstY = std::floor(firstPoint.y()) + 0.5; double secondX = std::floor(secondPoint.x()) + 0.5; double secondY = std::floor(secondPoint.y()) + 0.5; - QPointF topLeftPoint(firstX < secondX ? firstX : secondX, firstY < secondY ? firstY : secondY); - QPointF bottomRightPoint(firstX > secondX ? firstX : secondX, firstY > secondY ? firstY : secondY); + QPointF topLeftPoint(firstX < secondX ? firstX : secondX, + firstY < secondY ? firstY : secondY); + QPointF bottomRightPoint(firstX > secondX ? firstX : secondX, + firstY > secondY ? firstY : secondY); QRectF rect(topLeftPoint, bottomRightPoint); m_controlShape->setRect(rect); diff --git a/share/qtcreator/qml/qmljsdebugger/editor/selectiontool.cpp b/share/qtcreator/qml/qmljsdebugger/editor/selectiontool.cpp index cae9a86f054..376d8b439a1 100644 --- a/share/qtcreator/qml/qmljsdebugger/editor/selectiontool.cpp +++ b/share/qtcreator/qml/qmljsdebugger/editor/selectiontool.cpp @@ -48,12 +48,14 @@ namespace QmlJSDebugger { -SelectionTool::SelectionTool(QDeclarativeViewObserver *editorView) - : AbstractFormEditorTool(editorView), +SelectionTool::SelectionTool(QDeclarativeViewObserver *editorView) : + AbstractFormEditorTool(editorView), m_rubberbandSelectionMode(false), - m_rubberbandSelectionManipulator(QDeclarativeViewObserverPrivate::get(editorView)->manipulatorLayer, editorView), + m_rubberbandSelectionManipulator( + QDeclarativeViewObserverPrivate::get(editorView)->manipulatorLayer, editorView), m_singleSelectionManipulator(editorView), - m_selectionIndicator(editorView, QDeclarativeViewObserverPrivate::get(editorView)->manipulatorLayer), + m_selectionIndicator(editorView, + QDeclarativeViewObserverPrivate::get(editorView)->manipulatorLayer), //m_resizeIndicator(editorView->manipulatorLayer()), m_selectOnlyContentItems(true) { @@ -69,9 +71,11 @@ void SelectionTool::setRubberbandSelectionMode(bool value) m_rubberbandSelectionMode = value; } -SingleSelectionManipulator::SelectionType SelectionTool::getSelectionType(Qt::KeyboardModifiers modifiers) +SingleSelectionManipulator::SelectionType SelectionTool::getSelectionType(Qt::KeyboardModifiers + modifiers) { - SingleSelectionManipulator::SelectionType selectionType = SingleSelectionManipulator::ReplaceSelection; + SingleSelectionManipulator::SelectionType selectionType + = SingleSelectionManipulator::ReplaceSelection; if (modifiers.testFlag(Qt::ControlModifier)) { selectionType = SingleSelectionManipulator::RemoveFromSelection; } else if (modifiers.testFlag(Qt::ShiftModifier)) { @@ -82,7 +86,9 @@ SingleSelectionManipulator::SelectionType SelectionTool::getSelectionType(Qt::Ke bool SelectionTool::alreadySelected(const QList<QGraphicsItem*> &itemList) const { - const QList<QGraphicsItem*> selectedItems = QDeclarativeViewObserverPrivate::get(observer())->selectedItems(); + QDeclarativeViewObserverPrivate *observerPrivate + = QDeclarativeViewObserverPrivate::get(observer()); + const QList<QGraphicsItem*> selectedItems = observerPrivate->selectedItems(); if (selectedItems.isEmpty()) return false; @@ -98,7 +104,9 @@ bool SelectionTool::alreadySelected(const QList<QGraphicsItem*> &itemList) const void SelectionTool::mousePressEvent(QMouseEvent *event) { - QList<QGraphicsItem*> itemList = QDeclarativeViewObserverPrivate::get(observer())->selectableItems(event->pos()); + QDeclarativeViewObserverPrivate *observerPrivate + = QDeclarativeViewObserverPrivate::get(observer()); + QList<QGraphicsItem*> itemList = observerPrivate->selectableItems(event->pos()); SingleSelectionManipulator::SelectionType selectionType = getSelectionType(event->modifiers()); if (event->buttons() & Qt::LeftButton) { @@ -121,7 +129,8 @@ void SelectionTool::createContextMenu(QList<QGraphicsItem*> itemList, QPoint glo return; QMenu contextMenu; - connect(&contextMenu, SIGNAL(hovered(QAction*)), this, SLOT(contextMenuElementHovered(QAction*))); + connect(&contextMenu, SIGNAL(hovered(QAction*)), + this, SLOT(contextMenuElementHovered(QAction*))); m_contextMenuItemList = itemList; @@ -133,7 +142,8 @@ void SelectionTool::createContextMenu(QList<QGraphicsItem*> itemList, QPoint glo foreach(QGraphicsItem * const item, itemList) { QString itemTitle = titleForItem(item); - QAction *elementAction = contextMenu.addAction(itemTitle, this, SLOT(contextMenuElementSelected())); + QAction *elementAction = contextMenu.addAction(itemTitle, this, + SLOT(contextMenuElementSelected())); if (observer()->selectedItems().contains(item)) { QFont boldFont = elementAction->font(); @@ -152,9 +162,9 @@ void SelectionTool::createContextMenu(QList<QGraphicsItem*> itemList, QPoint glo ++i; } // add root item separately -// QString itemTitle = QString(tr("%1")).arg(titleForItem(view()->currentRootItem())); -// contextMenu.addAction(itemTitle, this, SLOT(contextMenuElementSelected())); -// m_contextMenuItemList.append(view()->currentRootItem()); + // QString itemTitle = QString(tr("%1")).arg(titleForItem(view()->currentRootItem())); + // contextMenu.addAction(itemTitle, this, SLOT(contextMenuElementSelected())); + // m_contextMenuItemList.append(view()->currentRootItem()); contextMenu.exec(globalPos); m_contextMenuItemList.clear(); @@ -192,7 +202,7 @@ void SelectionTool::mouseMoveEvent(QMouseEvent *event) QPointF mouseMovementVector = m_singleSelectionManipulator.beginPoint() - event->pos(); if ((mouseMovementVector.toPoint().manhattanLength() > Constants::DragStartDistance) - && (m_mousePressTimer.elapsed() > Constants::DragStartTime)) + && (m_mousePressTimer.elapsed() > Constants::DragStartTime)) { m_singleSelectionManipulator.end(event->pos()); //view()->changeToMoveTool(m_singleSelectionManipulator.beginPoint()); @@ -202,15 +212,18 @@ void SelectionTool::mouseMoveEvent(QMouseEvent *event) QPointF mouseMovementVector = m_rubberbandSelectionManipulator.beginPoint() - event->pos(); if ((mouseMovementVector.toPoint().manhattanLength() > Constants::DragStartDistance) - && (m_mousePressTimer.elapsed() > Constants::DragStartTime)) { + && (m_mousePressTimer.elapsed() > Constants::DragStartTime)) { m_rubberbandSelectionManipulator.update(event->pos()); if (event->modifiers().testFlag(Qt::ControlModifier)) - m_rubberbandSelectionManipulator.select(RubberBandSelectionManipulator::RemoveFromSelection); + m_rubberbandSelectionManipulator.select( + RubberBandSelectionManipulator::RemoveFromSelection); else if (event->modifiers().testFlag(Qt::ShiftModifier)) - m_rubberbandSelectionManipulator.select(RubberBandSelectionManipulator::AddToSelection); + m_rubberbandSelectionManipulator.select( + RubberBandSelectionManipulator::AddToSelection); else - m_rubberbandSelectionManipulator.select(RubberBandSelectionManipulator::ReplaceSelection); + m_rubberbandSelectionManipulator.select( + RubberBandSelectionManipulator::ReplaceSelection); } } } @@ -232,7 +245,10 @@ void SelectionTool::hoverMoveEvent(QMouseEvent * event) // if (topSelectedItemIsMovable(itemList)) // view()->changeTool(Constants::MoveToolMode); // } - QList<QGraphicsItem*> selectableItemList = QDeclarativeViewObserverPrivate::get(observer())->selectableItems(event->pos()); + QDeclarativeViewObserverPrivate *observerPrivate + = QDeclarativeViewObserverPrivate::get(observer()); + + QList<QGraphicsItem*> selectableItemList = observerPrivate->selectableItems(event->pos()); if (!selectableItemList.isEmpty()) { QGraphicsObject *item = selectableItemList.first()->toGraphicsObject(); if (item) @@ -256,22 +272,28 @@ void SelectionTool::mouseReleaseEvent(QMouseEvent *event) m_singleSelectionManipulator.begin(event->pos()); if (event->modifiers().testFlag(Qt::ControlModifier)) - m_singleSelectionManipulator.select(SingleSelectionManipulator::RemoveFromSelection, m_selectOnlyContentItems); + m_singleSelectionManipulator.select(SingleSelectionManipulator::RemoveFromSelection, + m_selectOnlyContentItems); else if (event->modifiers().testFlag(Qt::ShiftModifier)) - m_singleSelectionManipulator.select(SingleSelectionManipulator::AddToSelection, m_selectOnlyContentItems); + m_singleSelectionManipulator.select(SingleSelectionManipulator::AddToSelection, + m_selectOnlyContentItems); else - m_singleSelectionManipulator.select(SingleSelectionManipulator::InvertSelection, m_selectOnlyContentItems); + m_singleSelectionManipulator.select(SingleSelectionManipulator::InvertSelection, + m_selectOnlyContentItems); m_singleSelectionManipulator.end(event->pos()); } else { m_rubberbandSelectionManipulator.update(event->pos()); if (event->modifiers().testFlag(Qt::ControlModifier)) - m_rubberbandSelectionManipulator.select(RubberBandSelectionManipulator::RemoveFromSelection); + m_rubberbandSelectionManipulator.select( + RubberBandSelectionManipulator::RemoveFromSelection); else if (event->modifiers().testFlag(Qt::ShiftModifier)) - m_rubberbandSelectionManipulator.select(RubberBandSelectionManipulator::AddToSelection); + m_rubberbandSelectionManipulator.select( + RubberBandSelectionManipulator::AddToSelection); else - m_rubberbandSelectionManipulator.select(RubberBandSelectionManipulator::ReplaceSelection); + m_rubberbandSelectionManipulator.select( + RubberBandSelectionManipulator::ReplaceSelection); m_rubberbandSelectionManipulator.end(); } @@ -286,14 +308,14 @@ void SelectionTool::mouseDoubleClickEvent(QMouseEvent * /*event*/) void SelectionTool::keyPressEvent(QKeyEvent *event) { switch(event->key()) { - case Qt::Key_Left: - case Qt::Key_Right: - case Qt::Key_Up: - case Qt::Key_Down: - // disabled for now, cannot move stuff yet. - //view()->changeTool(Constants::MoveToolMode); - //view()->currentTool()->keyPressEvent(event); - break; + case Qt::Key_Left: + case Qt::Key_Right: + case Qt::Key_Up: + case Qt::Key_Down: + // disabled for now, cannot move stuff yet. + //view()->changeTool(Constants::MoveToolMode); + //view()->currentTool()->keyPressEvent(event); + break; } } @@ -307,7 +329,9 @@ void SelectionTool::wheelEvent(QWheelEvent *event) if (event->orientation() == Qt::Horizontal || m_rubberbandSelectionMode) return; - QList<QGraphicsItem*> itemList = QDeclarativeViewObserverPrivate::get(observer())->selectableItems(event->pos()); + QDeclarativeViewObserverPrivate *observerPrivate + = QDeclarativeViewObserverPrivate::get(observer()); + QList<QGraphicsItem*> itemList = observerPrivate->selectableItems(event->pos()); if (itemList.isEmpty()) return; @@ -353,7 +377,7 @@ void SelectionTool::clear() { view()->setCursor(Qt::ArrowCursor); m_rubberbandSelectionManipulator.clear(), - m_singleSelectionManipulator.clear(); + m_singleSelectionManipulator.clear(); m_selectionIndicator.clear(); //m_resizeIndicator.clear(); } @@ -396,13 +420,16 @@ void SelectionTool::selectUnderPoint(QMouseEvent *event) m_singleSelectionManipulator.begin(event->pos()); if (event->modifiers().testFlag(Qt::ControlModifier)) - m_singleSelectionManipulator.select(SingleSelectionManipulator::RemoveFromSelection, m_selectOnlyContentItems); + m_singleSelectionManipulator.select(SingleSelectionManipulator::RemoveFromSelection, + m_selectOnlyContentItems); else if (event->modifiers().testFlag(Qt::ShiftModifier)) - m_singleSelectionManipulator.select(SingleSelectionManipulator::AddToSelection, m_selectOnlyContentItems); + m_singleSelectionManipulator.select(SingleSelectionManipulator::AddToSelection, + m_selectOnlyContentItems); else - m_singleSelectionManipulator.select(SingleSelectionManipulator::InvertSelection, m_selectOnlyContentItems); + m_singleSelectionManipulator.select(SingleSelectionManipulator::InvertSelection, + m_selectOnlyContentItems); m_singleSelectionManipulator.end(event->pos()); } -} +} // namespace QmlJSDebugger diff --git a/share/qtcreator/qml/qmljsdebugger/editor/selectiontool.h b/share/qtcreator/qml/qmljsdebugger/editor/selectiontool.h index 63461da296d..ab96e4a6bc4 100644 --- a/share/qtcreator/qml/qmljsdebugger/editor/selectiontool.h +++ b/share/qtcreator/qml/qmljsdebugger/editor/selectiontool.h @@ -64,8 +64,8 @@ public: void keyReleaseEvent(QKeyEvent *keyEvent); void wheelEvent(QWheelEvent *event); - void itemsAboutToRemoved(const QList<QGraphicsItem*> &itemList); - // QVariant itemChange(const QList<QGraphicsItem*> &itemList, + void itemsAboutToRemoved(const QList<QGraphicsItem*> &itemList); +// QVariant itemChange(const QList<QGraphicsItem*> &itemList, // QGraphicsItem::GraphicsItemChange change, // const QVariant &value ); diff --git a/share/qtcreator/qml/qmljsdebugger/editor/singleselectionmanipulator.cpp b/share/qtcreator/qml/qmljsdebugger/editor/singleselectionmanipulator.cpp index e982385650c..717dce58648 100644 --- a/share/qtcreator/qml/qmljsdebugger/editor/singleselectionmanipulator.cpp +++ b/share/qtcreator/qml/qmljsdebugger/editor/singleselectionmanipulator.cpp @@ -36,7 +36,7 @@ namespace QmlJSDebugger { SingleSelectionManipulator::SingleSelectionManipulator(QDeclarativeViewObserver *editorView) : m_editorView(editorView), - m_isActive(false) + m_isActive(false) { } @@ -66,7 +66,9 @@ void SingleSelectionManipulator::end(const QPointF &/*updatePoint*/) m_isActive = false; } -void SingleSelectionManipulator::select(SelectionType selectionType, const QList<QGraphicsItem*> &items, bool /*selectOnlyContentItems*/) +void SingleSelectionManipulator::select(SelectionType selectionType, + const QList<QGraphicsItem*> &items, + bool /*selectOnlyContentItems*/) { QGraphicsItem *selectedItem = 0; @@ -74,8 +76,8 @@ void SingleSelectionManipulator::select(SelectionType selectionType, const QList { //FormEditorItem *formEditorItem = FormEditorItem::fromQGraphicsItem(item); if (item - /*&& !formEditorItem->qmlItemNode().isRootNode() - && (formEditorItem->qmlItemNode().hasShowContent() || !selectOnlyContentItems)*/) + /*&& !formEditorItem->qmlItemNode().isRootNode() + && (formEditorItem->qmlItemNode().hasShowContent() || !selectOnlyContentItems)*/) { selectedItem = item; break; @@ -85,38 +87,40 @@ void SingleSelectionManipulator::select(SelectionType selectionType, const QList QList<QGraphicsItem*> resultList; switch(selectionType) { - case AddToSelection: { - resultList.append(m_oldSelectionList); - if (selectedItem && !m_oldSelectionList.contains(selectedItem)) - resultList.append(selectedItem); - } + case AddToSelection: { + resultList.append(m_oldSelectionList); + if (selectedItem && !m_oldSelectionList.contains(selectedItem)) + resultList.append(selectedItem); + } break; - case ReplaceSelection: { - if (selectedItem) - resultList.append(selectedItem); - } + case ReplaceSelection: { + if (selectedItem) + resultList.append(selectedItem); + } break; - case RemoveFromSelection: { - resultList.append(m_oldSelectionList); - if (selectedItem) - resultList.removeAll(selectedItem); - } + case RemoveFromSelection: { + resultList.append(m_oldSelectionList); + if (selectedItem) + resultList.removeAll(selectedItem); + } break; - case InvertSelection: { - if (selectedItem + case InvertSelection: { + if (selectedItem && !m_oldSelectionList.contains(selectedItem)) - { - resultList.append(selectedItem); - } + { + resultList.append(selectedItem); } } + } m_editorView->setSelectedItems(resultList); } void SingleSelectionManipulator::select(SelectionType selectionType, bool selectOnlyContentItems) { - QList<QGraphicsItem*> itemList = QDeclarativeViewObserverPrivate::get(m_editorView)->selectableItems(m_beginPoint); + QDeclarativeViewObserverPrivate *observerPrivate = + QDeclarativeViewObserverPrivate::get(m_editorView); + QList<QGraphicsItem*> itemList = observerPrivate->selectableItems(m_beginPoint); select(selectionType, itemList, selectOnlyContentItems); } @@ -131,4 +135,4 @@ QPointF SingleSelectionManipulator::beginPoint() const return m_beginPoint; } -} +} // namespace QmlJSDebugger diff --git a/share/qtcreator/qml/qmljsdebugger/editor/singleselectionmanipulator.h b/share/qtcreator/qml/qmljsdebugger/editor/singleselectionmanipulator.h index e4ff0f346ac..2898a71763c 100644 --- a/share/qtcreator/qml/qmljsdebugger/editor/singleselectionmanipulator.h +++ b/share/qtcreator/qml/qmljsdebugger/editor/singleselectionmanipulator.h @@ -55,7 +55,8 @@ public: void update(const QPointF& updatePoint); void end(const QPointF& updatePoint); - void select(SelectionType selectionType, const QList<QGraphicsItem*> &items, bool selectOnlyContentItems); + void select(SelectionType selectionType, const QList<QGraphicsItem*> &items, + bool selectOnlyContentItems); void select(SelectionType selectionType, bool selectOnlyContentItems); void clear(); diff --git a/share/qtcreator/qml/qmljsdebugger/editor/subcomponenteditortool.cpp b/share/qtcreator/qml/qmljsdebugger/editor/subcomponenteditortool.cpp index 8ee336687eb..30ecea24fe5 100644 --- a/share/qtcreator/qml/qmljsdebugger/editor/subcomponenteditortool.cpp +++ b/share/qtcreator/qml/qmljsdebugger/editor/subcomponenteditortool.cpp @@ -47,10 +47,12 @@ const qreal MaxOpacity = 0.5f; SubcomponentEditorTool::SubcomponentEditorTool(QDeclarativeViewObserver *view) : AbstractFormEditorTool(view), - m_animIncrement(0.05f), - m_animTimer(new QTimer(this)) + m_animIncrement(0.05f), + m_animTimer(new QTimer(this)) { - m_mask = new SubcomponentMaskLayerItem(view, QDeclarativeViewObserverPrivate::get(view)->manipulatorLayer); + QDeclarativeViewObserverPrivate *observerPrivate = + QDeclarativeViewObserverPrivate::get(view); + m_mask = new SubcomponentMaskLayerItem(view, observerPrivate->manipulatorLayer); connect(m_animTimer, SIGNAL(timeout()), SLOT(animate())); m_animTimer->setInterval(20); } @@ -76,7 +78,8 @@ bool SubcomponentEditorTool::containsCursor(const QPoint &mousePos) const return false; QPointF scenePos = view()->mapToScene(mousePos); - QRectF itemRect = m_currentContext.top()->boundingRect() | m_currentContext.top()->childrenBoundingRect(); + QRectF itemRect = m_currentContext.top()->boundingRect() + | m_currentContext.top()->childrenBoundingRect(); QRectF polyRect = m_currentContext.top()->mapToScene(itemRect).boundingRect(); return polyRect.contains(scenePos); @@ -90,8 +93,8 @@ void SubcomponentEditorTool::mouseReleaseEvent(QMouseEvent * /*event*/) void SubcomponentEditorTool::mouseDoubleClickEvent(QMouseEvent *event) { if (event->buttons() & Qt::LeftButton - && !containsCursor(event->pos()) - && m_currentContext.size() > 1) + && !containsCursor(event->pos()) + && m_currentContext.size() > 1) { aboutToPopContext(); } @@ -178,7 +181,7 @@ void SubcomponentEditorTool::setCurrentItem(QGraphicsItem* contextItem) bool containsSelectableItems = false; foreach(QGraphicsItem *item, gfxObject->childItems()) { if (item->type() == Constants::EditorItemType - || item->type() == Constants::ResizeHandleItemType) + || item->type() == Constants::ResizeHandleItemType) { continue; } @@ -310,7 +313,8 @@ QGraphicsObject *SubcomponentEditorTool::currentRootItem() const void SubcomponentEditorTool::contextDestroyed(QObject *contextToDestroy) { - disconnect(contextToDestroy, SIGNAL(destroyed(QObject*)), this, SLOT(contextDestroyed(QObject*))); + disconnect(contextToDestroy, SIGNAL(destroyed(QObject*)), + this, SLOT(contextDestroyed(QObject*))); // pop out the whole context - it might not be safe anymore. while (m_currentContext.size() > 1) { @@ -345,5 +349,4 @@ int SubcomponentEditorTool::contextIndex() const return m_currentContext.size() - 1; } - } // namespace QmlJSDebugger diff --git a/share/qtcreator/qml/qmljsdebugger/editor/subcomponentmasklayeritem.cpp b/share/qtcreator/qml/qmljsdebugger/editor/subcomponentmasklayeritem.cpp index dfa822096ce..30301a88dd3 100644 --- a/share/qtcreator/qml/qmljsdebugger/editor/subcomponentmasklayeritem.cpp +++ b/share/qtcreator/qml/qmljsdebugger/editor/subcomponentmasklayeritem.cpp @@ -34,7 +34,8 @@ namespace QmlJSDebugger { -SubcomponentMaskLayerItem::SubcomponentMaskLayerItem(QDeclarativeViewObserver *observer, QGraphicsItem *parentItem) : +SubcomponentMaskLayerItem::SubcomponentMaskLayerItem(QDeclarativeViewObserver *observer, + QGraphicsItem *parentItem) : QGraphicsPolygonItem(parentItem), m_observer(observer), m_currentItem(0), diff --git a/share/qtcreator/qml/qmljsdebugger/editor/subcomponentmasklayeritem.h b/share/qtcreator/qml/qmljsdebugger/editor/subcomponentmasklayeritem.h index ea312ba3ce7..22754780625 100644 --- a/share/qtcreator/qml/qmljsdebugger/editor/subcomponentmasklayeritem.h +++ b/share/qtcreator/qml/qmljsdebugger/editor/subcomponentmasklayeritem.h @@ -39,7 +39,8 @@ class QDeclarativeViewObserver; class SubcomponentMaskLayerItem : public QGraphicsPolygonItem { public: - explicit SubcomponentMaskLayerItem(QDeclarativeViewObserver *observer, QGraphicsItem *parentItem = 0); + explicit SubcomponentMaskLayerItem(QDeclarativeViewObserver *observer, + QGraphicsItem *parentItem = 0); int type() const; void setCurrentItem(QGraphicsItem *item); void setBoundingBox(const QRectF &boundingBox); diff --git a/share/qtcreator/qml/qmljsdebugger/editor/toolbarcolorbox.cpp b/share/qtcreator/qml/qmljsdebugger/editor/toolbarcolorbox.cpp index c7ad17ad45c..407cab13c12 100644 --- a/share/qtcreator/qml/qmljsdebugger/editor/toolbarcolorbox.cpp +++ b/share/qtcreator/qml/qmljsdebugger/editor/toolbarcolorbox.cpp @@ -48,7 +48,8 @@ namespace QmlJSDebugger { ToolBarColorBox::ToolBarColorBox(QWidget *parent) : QLabel(parent) { - m_copyHexColor = new QAction(QIcon(QLatin1String(":/qml/images/color-picker-hicontrast.png")), tr("Copy"), this); + m_copyHexColor = new QAction(QIcon(QLatin1String(":/qml/images/color-picker-hicontrast.png")), + tr("Copy"), this); connect(m_copyHexColor, SIGNAL(triggered()), SLOT(copyColorToClipboard())); setScaledContents(false); } @@ -70,9 +71,11 @@ void ToolBarColorBox::mousePressEvent(QMouseEvent *event) void ToolBarColorBox::mouseMoveEvent(QMouseEvent *event) { + if (event->buttons() & Qt::LeftButton - && QPoint(event->pos() - m_dragBeginPoint).manhattanLength() > Constants::DragStartDistance - && !m_dragStarted) + && (QPoint(event->pos() - m_dragBeginPoint).manhattanLength() + > Constants::DragStartDistance) + && !m_dragStarted) { m_dragStarted = true; QDrag *drag = new QDrag(this); @@ -121,5 +124,4 @@ void ToolBarColorBox::copyColorToClipboard() clipboard->setText(m_color.name()); } - } // namespace QmlJSDebugger diff --git a/share/qtcreator/qml/qmljsdebugger/editor/zoomtool.cpp b/share/qtcreator/qml/qmljsdebugger/editor/zoomtool.cpp index 4a3b0ff3dc3..11c9199f78c 100644 --- a/share/qtcreator/qml/qmljsdebugger/editor/zoomtool.cpp +++ b/share/qtcreator/qml/qmljsdebugger/editor/zoomtool.cpp @@ -42,10 +42,10 @@ namespace QmlJSDebugger { ZoomTool::ZoomTool(QDeclarativeViewObserver *view) : - AbstractFormEditorTool(view), - m_rubberbandManipulator(reinterpret_cast<QGraphicsObject *>(QDeclarativeViewObserverPrivate::get(view)->manipulatorLayer), view), - m_smoothZoomMultiplier(0.05f), - m_currentScale(1.0f) + AbstractFormEditorTool(view), + m_rubberbandManipulator(), + m_smoothZoomMultiplier(0.05f), + m_currentScale(1.0f) { m_zoomTo100Action = new QAction(tr("Zoom to &100%"), this); m_zoomInAction = new QAction(tr("Zoom In"), this); @@ -53,6 +53,12 @@ ZoomTool::ZoomTool(QDeclarativeViewObserver *view) : m_zoomInAction->setShortcut(QKeySequence(Qt::Key_Plus)); m_zoomOutAction->setShortcut(QKeySequence(Qt::Key_Minus)); + + LayerItem *layerItem = QDeclarativeViewObserverPrivate::get(view)->manipulatorLayer; + QGraphicsObject *layerObject = reinterpret_cast<QGraphicsObject *>(layerItem); + m_rubberbandManipulator = new RubberBandSelectionManipulator(layerObject, view); + + connect(m_zoomTo100Action, SIGNAL(triggered()), SLOT(zoomTo100())); connect(m_zoomInAction, SIGNAL(triggered()), SLOT(zoomIn())); connect(m_zoomOutAction, SIGNAL(triggered()), SLOT(zoomOut())); @@ -60,7 +66,7 @@ ZoomTool::ZoomTool(QDeclarativeViewObserver *view) : ZoomTool::~ZoomTool() { - + delete m_rubberbandManipulator; } void ZoomTool::mousePressEvent(QMouseEvent *event) @@ -89,16 +95,17 @@ void ZoomTool::mouseMoveEvent(QMouseEvent *event) QPointF scenePos = view()->mapToScene(event->pos()); if (event->buttons() & Qt::LeftButton - && QPointF(scenePos - m_dragBeginPos).manhattanLength() > Constants::DragStartDistance / 3 - && !m_dragStarted) + && (QPointF(scenePos - m_dragBeginPos).manhattanLength() + > Constants::DragStartDistance / 3) + && !m_dragStarted) { m_dragStarted = true; - m_rubberbandManipulator.begin(m_dragBeginPos); + m_rubberbandManipulator->begin(m_dragBeginPos); return; } if (m_dragStarted) - m_rubberbandManipulator.update(scenePos); + m_rubberbandManipulator->update(scenePos); } @@ -108,12 +115,12 @@ void ZoomTool::mouseReleaseEvent(QMouseEvent *event) QPointF scenePos = view()->mapToScene(event->pos()); if (m_dragStarted) { - m_rubberbandManipulator.end(); + m_rubberbandManipulator->end(); - int x1 = qMin(scenePos.x(), m_rubberbandManipulator.beginPoint().x()); - int x2 = qMax(scenePos.x(), m_rubberbandManipulator.beginPoint().x()); - int y1 = qMin(scenePos.y(), m_rubberbandManipulator.beginPoint().y()); - int y2 = qMax(scenePos.y(), m_rubberbandManipulator.beginPoint().y()); + int x1 = qMin(scenePos.x(), m_rubberbandManipulator->beginPoint().x()); + int x2 = qMax(scenePos.x(), m_rubberbandManipulator->beginPoint().x()); + int y1 = qMin(scenePos.y(), m_rubberbandManipulator->beginPoint().y()); + int y2 = qMax(scenePos.y(), m_rubberbandManipulator->beginPoint().y()); QPointF scenePosTopLeft = QPoint(x1, y1); QPointF scenePosBottomRight = QPoint(x2, y2); diff --git a/share/qtcreator/qml/qmljsdebugger/editor/zoomtool.h b/share/qtcreator/qml/qmljsdebugger/editor/zoomtool.h index e341e725350..94cba7b919c 100644 --- a/share/qtcreator/qml/qmljsdebugger/editor/zoomtool.h +++ b/share/qtcreator/qml/qmljsdebugger/editor/zoomtool.h @@ -82,7 +82,7 @@ private: QAction *m_zoomTo100Action; QAction *m_zoomInAction; QAction *m_zoomOutAction; - RubberBandSelectionManipulator m_rubberbandManipulator; + RubberBandSelectionManipulator *m_rubberbandManipulator; qreal m_smoothZoomMultiplier; qreal m_currentScale; diff --git a/share/qtcreator/qml/qmljsdebugger/include/jsdebuggeragent.h b/share/qtcreator/qml/qmljsdebugger/include/jsdebuggeragent.h index 521ad0522e9..774102f0feb 100644 --- a/share/qtcreator/qml/qmljsdebugger/include/jsdebuggeragent.h +++ b/share/qtcreator/qml/qmljsdebugger/include/jsdebuggeragent.h @@ -69,8 +69,8 @@ namespace QmlJSDebugger { class JSDebuggerAgentPrivate; class QMLJSDEBUGGER_EXPORT JSDebuggerAgent - : public QDeclarativeDebugService - , public QScriptEngineAgent + : public QDeclarativeDebugService + , public QScriptEngineAgent { Q_OBJECT @@ -106,11 +106,9 @@ public: void messageReceived(const QByteArray &); void statusChanged(Status status); - void baseMessageReceived(const QByteArray &message) - { QDeclarativeDebugService::messageReceived(message); } + void baseMessageReceived(const QByteArray &message); public slots: -// void pauses(); private: JSDebuggerAgentPrivate *d; diff --git a/share/qtcreator/qml/qmljsdebugger/jsdebuggeragent.cpp b/share/qtcreator/qml/qmljsdebugger/jsdebuggeragent.cpp index db314d587fe..2af9df33f11 100644 --- a/share/qtcreator/qml/qmljsdebugger/jsdebuggeragent.cpp +++ b/share/qtcreator/qml/qmljsdebugger/jsdebuggeragent.cpp @@ -75,7 +75,7 @@ struct JSAgentWatchData QDataStream &operator<<(QDataStream &s, const JSAgentWatchData &data) { return s << data.exp << data.name << data.value - << data.type << data.hasChildren << data.objectId; + << data.type << data.hasChildren << data.objectId; } struct JSAgentStackData @@ -173,12 +173,12 @@ private: }; static JSAgentWatchData fromScriptValue(const QString &expression, - const QScriptValue &value) + const QScriptValue &value) { static const QString arrayStr = QCoreApplication::translate - ("Debugger::JSAgentWatchData", "[Array of length %1]"); + ("Debugger::JSAgentWatchData", "[Array of length %1]"); static const QString undefinedStr = QCoreApplication::translate - ("Debugger::JSAgentWatchData", "<undefined>"); + ("Debugger::JSAgentWatchData", "<undefined>"); JSAgentWatchData data; data.exp = expression.toUtf8(); @@ -360,14 +360,12 @@ void JSDebuggerAgent::functionExit(qint64 scriptId, const QScriptValue &returnVa /*! \reimp */ -void JSDebuggerAgent::positionChange - (qint64 scriptId, int lineNumber, int columnNumber) +void JSDebuggerAgent::positionChange(qint64 scriptId, int lineNumber, int columnNumber) { d->positionChange(scriptId, lineNumber, columnNumber); } -void JSDebuggerAgentPrivate::positionChange - (qint64 scriptId, int lineNumber, int columnNumber) +void JSDebuggerAgentPrivate::positionChange(qint64 scriptId, int lineNumber, int columnNumber) { Q_UNUSED(columnNumber); @@ -422,8 +420,8 @@ void JSDebuggerAgentPrivate::positionChange \reimp */ void JSDebuggerAgent::exceptionThrow(qint64 scriptId, - const QScriptValue &exception, - bool hasHandler) + const QScriptValue &exception, + bool hasHandler) { Q_UNUSED(scriptId); Q_UNUSED(exception); @@ -629,7 +627,7 @@ void JSDebuggerAgentPrivate::stopped() QByteArray reply; QDataStream rs(&reply, QIODevice::WriteOnly); rs << QByteArray("STOPPED") << backtrace << watches << locals - << becauseOfException << exception.toString(); + << becauseOfException << exception.toString(); sendMessage(reply); loop.exec(QEventLoop::ExcludeUserInputEvents); @@ -645,4 +643,9 @@ void JSDebuggerAgent::statusChanged(Status status) engine()->setAgent((status == QDeclarativeDebugService::Enabled) ? this : 0); } +void JSDebuggerAgent::baseMessageReceived(const QByteArray &message) +{ + QDeclarativeDebugService::messageReceived(message); +} + } // namespace QmlJSDebugger diff --git a/share/qtcreator/qml/qmljsdebugger/qdeclarativeobserverservice.cpp b/share/qtcreator/qml/qmljsdebugger/qdeclarativeobserverservice.cpp index 5b052119f9b..38feafd29e6 100644 --- a/share/qtcreator/qml/qmljsdebugger/qdeclarativeobserverservice.cpp +++ b/share/qtcreator/qml/qmljsdebugger/qdeclarativeobserverservice.cpp @@ -127,9 +127,9 @@ void QDeclarativeObserverService::messageReceived(const QByteArray &message) if (QObject* obj = objectForId(debugId)) obj->deleteLater(); } else if (type == "MOVE_OBJECT") { - int debugId, newParent; - ds >> debugId >> newParent; - emit objectReparentRequested(objectForId(debugId), objectForId(newParent)); + int debugId, newParent; + ds >> debugId >> newParent; + emit objectReparentRequested(objectForId(debugId), objectForId(newParent)); } else if (type == "OBJECT_ID_LIST") { int itemCount; ds >> itemCount; diff --git a/share/qtcreator/qml/qmljsdebugger/qdeclarativeviewobserver.cpp b/share/qtcreator/qml/qmljsdebugger/qdeclarativeviewobserver.cpp index 7063bec07a8..52f0f3ba03b 100644 --- a/share/qtcreator/qml/qmljsdebugger/qdeclarativeviewobserver.cpp +++ b/share/qtcreator/qml/qmljsdebugger/qdeclarativeviewobserver.cpp @@ -176,66 +176,66 @@ void QDeclarativeViewObserverPrivate::clearEditorItems() } bool QDeclarativeViewObserver::eventFilter(QObject *obj, QEvent *event) - { - if (obj == data->view) { - // Event from view - if (event->type() == QEvent::ChildRemoved) { - // Might mean that viewport has changed - if (data->view->viewport() != data->viewport.data()) - data->setViewport(data->view->viewport()); - } - return QObject::eventFilter(obj, event); - } - - //Event from viewport - switch (event->type()) { - case QEvent::Leave: { - if (leaveEvent(event)) - return true; - break; - } - case QEvent::MouseButtonPress: { - if (mousePressEvent(static_cast<QMouseEvent*>(event))) +{ + if (obj == data->view) { + // Event from view + if (event->type() == QEvent::ChildRemoved) { + // Might mean that viewport has changed + if (data->view->viewport() != data->viewport.data()) + data->setViewport(data->view->viewport()); + } + return QObject::eventFilter(obj, event); + } + + //Event from viewport + switch (event->type()) { + case QEvent::Leave: { + if (leaveEvent(event)) + return true; + break; + } + case QEvent::MouseButtonPress: { + if (mousePressEvent(static_cast<QMouseEvent*>(event))) + return true; + break; + } + case QEvent::MouseMove: { + if (mouseMoveEvent(static_cast<QMouseEvent*>(event))) + return true; + break; + } + case QEvent::MouseButtonRelease: { + if (mouseReleaseEvent(static_cast<QMouseEvent*>(event))) + return true; + break; + } + case QEvent::KeyPress: { + if (keyPressEvent(static_cast<QKeyEvent*>(event))) + return true; + break; + } + case QEvent::KeyRelease: { + if (keyReleaseEvent(static_cast<QKeyEvent*>(event))) return true; - break; - } - case QEvent::MouseMove: { - if (mouseMoveEvent(static_cast<QMouseEvent*>(event))) - return true; - break; - } - case QEvent::MouseButtonRelease: { - if (mouseReleaseEvent(static_cast<QMouseEvent*>(event))) - return true; - break; - } - case QEvent::KeyPress: { - if (keyPressEvent(static_cast<QKeyEvent*>(event))) - return true; - break; - } - case QEvent::KeyRelease: { - if (keyReleaseEvent(static_cast<QKeyEvent*>(event))) - return true; - break; - } - case QEvent::MouseButtonDblClick: { - if (mouseDoubleClickEvent(static_cast<QMouseEvent*>(event))) - return true; - break; - } - case QEvent::Wheel: { - if (wheelEvent(static_cast<QWheelEvent*>(event))) - return true; - break; - } - default: { - break; - } - } //switch - - // standard event processing - return QObject::eventFilter(obj, event); + break; + } + case QEvent::MouseButtonDblClick: { + if (mouseDoubleClickEvent(static_cast<QMouseEvent*>(event))) + return true; + break; + } + case QEvent::Wheel: { + if (wheelEvent(static_cast<QWheelEvent*>(event))) + return true; + break; + } + default: { + break; + } + } //switch + + // standard event processing + return QObject::eventFilter(obj, event); } bool QDeclarativeViewObserver::leaveEvent(QEvent * /*event*/) @@ -789,8 +789,8 @@ QList<QGraphicsItem*> QDeclarativeViewObserverPrivate::filterForCurrentContext( bool QDeclarativeViewObserverPrivate::isEditorItem(QGraphicsItem *item) const { return (item->type() == Constants::EditorItemType - || item->type() == Constants::ResizeHandleItemType - || item->data(Constants::EditorItemDataKey).toBool()); + || item->type() == Constants::ResizeHandleItemType + || item->data(Constants::EditorItemDataKey).toBool()); } void QDeclarativeViewObserverPrivate::_q_onStatusChanged(QDeclarativeView::Status status) -- GitLab