formeditorview.cpp 21 KB
Newer Older
hjk's avatar
hjk committed
1
/****************************************************************************
2
**
3
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
hjk's avatar
hjk committed
4
** Contact: http://www.qt-project.org/legal
5
**
hjk's avatar
hjk committed
6
** This file is part of Qt Creator.
7
**
hjk's avatar
hjk committed
8
9
10
11
12
13
14
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia.  For licensing terms and
** conditions see http://qt.digia.com/licensing.  For further information
** use the contact form at http://qt.digia.com/contact-us.
15
16
**
** GNU Lesser General Public License Usage
hjk's avatar
hjk committed
17
18
19
20
21
22
23
24
25
** 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, Digia gives you certain additional
** rights.  These rights are described in the Digia Qt LGPL Exception
con's avatar
con committed
26
27
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
hjk's avatar
hjk committed
28
****************************************************************************/
29

30
#include "formeditorview.h"
31
32
33
34
35
36
37
#include "selectiontool.h"
#include "movetool.h"
#include "resizetool.h"
#include "dragtool.h"
#include "formeditorwidget.h"
#include "formeditoritem.h"
#include "formeditorscene.h"
38
#include "abstractcustomtool.h"
39
40

#include <designmodecontext.h>
41
42
#include <modelnode.h>
#include <model.h>
hjk's avatar
hjk committed
43
#include <QDebug>
44
45
#include <QPair>
#include <QString>
46
#include <QTimer>
47
#include <zoomaction.h>
48
49
50
#include <nodeabstractproperty.h>
#include <nodelistproperty.h>

51
#include <coreplugin/icore.h>
52
53
54
55

namespace QmlDesigner {

FormEditorView::FormEditorView(QObject *parent)
Marco Bubke's avatar
Marco Bubke committed
56
    : AbstractView(parent),
57
58
59
60
61
62
      m_formEditorWidget(new FormEditorWidget(this)),
      m_scene(new FormEditorScene(m_formEditorWidget.data(), this)),
      m_moveTool(new MoveTool(this)),
      m_selectionTool(new SelectionTool(this)),
      m_resizeTool(new ResizeTool(this)),
      m_dragTool(new DragTool(this)),
63
64
      m_currentTool(m_selectionTool),
      m_transactionCounter(0)
65
{
66
67
68
    Internal::FormEditorContext *formEditorContext = new Internal::FormEditorContext(m_formEditorWidget.data());
    Core::ICore::addContextObject(formEditorContext);

Marco Bubke's avatar
Marco Bubke committed
69
70
71
    connect(formEditorWidget()->zoomAction(), SIGNAL(zoomLevelChanged(double)), SLOT(updateGraphicsIndicators()));
    connect(formEditorWidget()->showBoundingRectAction(), SIGNAL(toggled(bool)), scene(), SLOT(setShowBoundingRects(bool)));
    connect(formEditorWidget()->selectOnlyContentItemsAction(), SIGNAL(toggled(bool)), this, SLOT(setSelectOnlyContentItemsAction(bool)));
72

73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
}

FormEditorScene* FormEditorView::scene() const
{
    return m_scene.data();
}

FormEditorView::~FormEditorView()
{
    delete m_selectionTool;
    m_selectionTool = 0;
    delete m_moveTool;
    m_moveTool = 0;
    delete m_resizeTool;
    m_resizeTool = 0;
    delete m_dragTool;
    m_dragTool = 0;

91
    qDeleteAll(m_customToolList);
92
93
94
95
96
97
98
99
100
101
102

    // delete scene after tools to prevent double deletion
    // of items
    delete m_scene.data();
    delete m_formEditorWidget.data();
}

void FormEditorView::modelAttached(Model *model)
{
    Q_ASSERT(model);

Marco Bubke's avatar
Marco Bubke committed
103
    AbstractView::modelAttached(model);
104
105
106

    Q_ASSERT(m_scene->formLayerItem());

107
108
    if (QmlItemNode::isValidQmlItemNode(rootModelNode()))
        setupFormEditorItemTree(rootModelNode());
109
110

    m_formEditorWidget->updateActions();
111
112
113
}


Tobias Hunger's avatar
Tobias Hunger committed
114
//This method does the setup of the initial FormEditorItem tree in the scene
115
116
117
118
void FormEditorView::setupFormEditorItemTree(const QmlItemNode &qmlItemNode)
{
    m_scene->addFormEditorItem(qmlItemNode);

119
    foreach (const QmlObjectNode &nextNode, qmlItemNode.allDirectSubNodes()) //TODO instance children
120
121
        //If the node has source for components/custom parsers we ignore it.
        if (QmlItemNode(nextNode).isValid() && nextNode.modelNode().nodeSourceType() == ModelNode::NodeWithoutSource)
122
            setupFormEditorItemTree(nextNode.toQmlItemNode());
123
124
}

125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
void FormEditorView::removeNodeFromScene(const QmlItemNode &qmlItemNode)
{
    if (qmlItemNode.isValid()) {
        QList<QmlItemNode> nodeList;
        nodeList.append(qmlItemNode.allSubModelNodes());
        nodeList.append(qmlItemNode);

        QList<FormEditorItem*> removedItemList;
        removedItemList.append(scene()->itemsForQmlItemNodes(nodeList));
        m_currentTool->itemsAboutToRemoved(removedItemList);

        qDeleteAll(removedItemList);
    }
}

void FormEditorView::hideNodeFromScene(const QmlItemNode &qmlItemNode)
{
    if (qmlItemNode.isValid()) {

        FormEditorItem *item = m_scene->itemForQmlItemNode(qmlItemNode);

        QList<QmlItemNode> nodeList;
        nodeList.append(qmlItemNode.allSubModelNodes());
        nodeList.append(qmlItemNode);

        QList<FormEditorItem*> removedItemList;
        removedItemList.append(scene()->itemsForQmlItemNodes(nodeList));
        m_currentTool->itemsAboutToRemoved(removedItemList);
        item->setFormEditorVisible(false);
    }
}

157
158
159
void FormEditorView::nodeCreated(const ModelNode &createdNode)
{
    ModelNode node(createdNode);
160
    //If the node has source for components/custom parsers we ignore it.
161
    if (QmlItemNode::isValidQmlItemNode(node) && node.nodeSourceType() == ModelNode::NodeWithoutSource) //only setup QmlItems
162
163
164
165
166
167
168
169
170
        setupFormEditorItemTree(QmlItemNode(node));
}

void FormEditorView::modelAboutToBeDetached(Model *model)
{
    m_selectionTool->clear();
    m_moveTool->clear();
    m_resizeTool->clear();
    m_dragTool->clear();
171
172
    foreach (AbstractCustomTool *customTool, m_customToolList)
        customTool->clear();
173
    m_scene->clearFormEditorItems();
174
    m_formEditorWidget->updateActions();
Marco Bubke's avatar
Marco Bubke committed
175
176
    m_formEditorWidget->resetView();
    scene()->resetScene();
177

178
179
    m_currentTool = m_selectionTool;

Marco Bubke's avatar
Marco Bubke committed
180
    AbstractView::modelAboutToBeDetached(model);
181
182
}

183
void FormEditorView::importsChanged(const QList<Import> &/*addedImports*/, const QList<Import> &/*removedImports*/)
184
185
186
187
{
    reset();
}

188
189
190
191
void FormEditorView::nodeAboutToBeRemoved(const ModelNode &removedNode)
{
    QmlItemNode qmlItemNode(removedNode);

192
    removeNodeFromScene(qmlItemNode);
193
194
}

195
 void FormEditorView::rootNodeTypeChanged(const QString &/*type*/, int /*majorVersion*/, int /*minorVersion*/)
196
 {
197
198
199
200
     foreach (FormEditorItem *item, m_scene->allFormEditorItems()) {
         item->setParentItem(0);
         item->setParent(0);
     }
201

202
203
     foreach (FormEditorItem *item, m_scene->allFormEditorItems()) {
         m_scene->removeItemFromHash(item);
204
         delete item;
205
206
     }

207
     QmlItemNode newItemNode(rootModelNode());
208
209
     if (newItemNode.isValid()) //only setup QmlItems
         setupFormEditorItemTree(newItemNode);
210

211
     m_currentTool->setItems(scene()->itemsForQmlItemNodes(toQmlItemNodeList(selectedModelNodes())));
212
213
214
215
 }

void FormEditorView::propertiesAboutToBeRemoved(const QList<AbstractProperty>& propertyList)
{
216
    foreach (const AbstractProperty &property, propertyList) {
217
218
219
220
        if (property.isNodeAbstractProperty()) {
            NodeAbstractProperty nodeAbstractProperty = property.toNodeAbstractProperty();
            QList<FormEditorItem*> removedItemList;

221
            foreach (const ModelNode &modelNode, nodeAbstractProperty.allSubNodes()) {
222
223
                QmlItemNode qmlItemNode(modelNode);

224
                if (qmlItemNode.isValid() && m_scene->hasItemForQmlItemNode(qmlItemNode)) {
225
226
227
228
229
230
231
232
233
234
                    FormEditorItem *item = m_scene->itemForQmlItemNode(qmlItemNode);
                    removedItemList.append(item);

                    delete item;
                }
            }

            m_currentTool->itemsAboutToRemoved(removedItemList);
        }
    }
235
}
236
237
238

static inline bool hasNodeSourceParent(const ModelNode &node)
{
239
    if (node.hasParentProperty() && node.parentProperty().parentModelNode().isValid()) {
240
241
242
243
244
245
246
247
        ModelNode parent = node.parentProperty().parentModelNode();
        if (parent.nodeSourceType() != ModelNode::NodeWithoutSource)
            return true;
        return hasNodeSourceParent(parent);
    }
    return false;
}

248
void FormEditorView::nodeReparented(const ModelNode &node, const NodeAbstractProperty &/*newPropertyParent*/, const NodeAbstractProperty &/*oldPropertyParent*/, AbstractView::PropertyChangeFlags /*propertyChange*/)
249
{
250
251
    if (hasNodeSourceParent(node))
        hideNodeFromScene(node);
252
253
}

254
void FormEditorView::variantPropertiesChanged(const QList<VariantProperty> &/*propertyList*/, PropertyChangeFlags /*propertyChange*/)
255
256
257
{
}

258
void FormEditorView::bindingPropertiesChanged(const QList<BindingProperty> &/*propertyList*/, PropertyChangeFlags /*propertyChange*/)
259
260
261
{
}

262
263
264
265
void FormEditorView::signalHandlerPropertiesChanged(const QVector<SignalHandlerProperty> & /*propertyList*/, AbstractView::PropertyChangeFlags /*propertyChange*/)
{
}

266
267
WidgetInfo FormEditorView::widgetInfo()
{
268
    return createWidgetInfo(m_formEditorWidget.data(), 0, "FormEditor", WidgetInfo::CentralPane, 0, tr("Form Editor"));
269
270
}

Marco Bubke's avatar
Marco Bubke committed
271
FormEditorWidget *FormEditorView::formEditorWidget()
272
273
274
275
{
    return m_formEditorWidget.data();
}

276
void FormEditorView::nodeIdChanged(const ModelNode& node, const QString &/*newId*/, const QString &/*oldId*/)
277
{
278
279
    QmlItemNode itemNode(node);

Thomas Hartmann's avatar
Thomas Hartmann committed
280
    if (itemNode.isValid() && node.nodeSourceType() == ModelNode::NodeWithoutSource) {
281
282
283
        FormEditorItem *item = m_scene->itemForQmlItemNode(itemNode);
        item->update();
    }
284
285
286
}

void FormEditorView::selectedNodesChanged(const QList<ModelNode> &selectedNodeList,
287
                                          const QList<ModelNode> &/*lastSelectedNodeList*/)
288
289
290
291
292
293
{
    m_currentTool->setItems(scene()->itemsForQmlItemNodes(toQmlItemNodeList(selectedNodeList)));

    m_scene->update();
}

294
void FormEditorView::scriptFunctionsChanged(const ModelNode &/*node*/, const QStringList &/*scriptFunctionList*/)
Marco Bubke's avatar
Marco Bubke committed
295
296
297
{
}

298
299
300
void FormEditorView::propertiesRemoved(const QList<AbstractProperty> &/*propertyList*/)
{
}
Marco Bubke's avatar
Marco Bubke committed
301

302
303
304
305
306
AbstractFormEditorTool* FormEditorView::currentTool() const
{
    return m_currentTool;
}

307
bool FormEditorView::changeToMoveTool()
308
309
{
    if (m_currentTool == m_moveTool)
310
        return true;
311

312
    if (!isMoveToolAvailable())
313
        return false;
314

315
316
317
318
    m_scene->updateAllFormEditorItems();
    m_currentTool->clear();
    m_currentTool = m_moveTool;
    m_currentTool->clear();
319
    m_currentTool->setItems(scene()->itemsForQmlItemNodes(toQmlItemNodeList(selectedModelNodes())));
320
    return true;
321
322
323
324
325
326
327
328
329
330
331
}

void FormEditorView::changeToDragTool()
{
    if (m_currentTool == m_dragTool)
        return;

    m_scene->updateAllFormEditorItems();
    m_currentTool->clear();
    m_currentTool = m_dragTool;
    m_currentTool->clear();
332
    m_currentTool->setItems(scene()->itemsForQmlItemNodes(toQmlItemNodeList(selectedModelNodes())));
333
334
335
}


336
bool FormEditorView::changeToMoveTool(const QPointF &beginPoint)
337
338
{
    if (m_currentTool == m_moveTool)
339
        return true;
340

341
    if (!isMoveToolAvailable())
342
        return false;
343

344
345
346
347
    m_scene->updateAllFormEditorItems();
    m_currentTool->clear();
    m_currentTool = m_moveTool;
    m_currentTool->clear();
348
    m_currentTool->setItems(scene()->itemsForQmlItemNodes(toQmlItemNodeList(selectedModelNodes())));
349
    m_moveTool->beginWithPoint(beginPoint);
350
    return true;
351
352
353
354
355
356
357
358
359
360
361
}

void FormEditorView::changeToSelectionTool()
{
    if (m_currentTool == m_selectionTool)
        return;

    m_scene->updateAllFormEditorItems();
    m_currentTool->clear();
    m_currentTool = m_selectionTool;
    m_currentTool->clear();
362
    m_currentTool->setItems(scene()->itemsForQmlItemNodes(toQmlItemNodeList(selectedModelNodes())));
363
364
365
366
367
368
369
370
371
372
373
}

void FormEditorView::changeToSelectionTool(QGraphicsSceneMouseEvent *event)
{
    if (m_currentTool == m_selectionTool)
        return;

    m_scene->updateAllFormEditorItems();
    m_currentTool->clear();
    m_currentTool = m_selectionTool;
    m_currentTool->clear();
374
    m_currentTool->setItems(scene()->itemsForQmlItemNodes(toQmlItemNodeList(selectedModelNodes())));
375
376
377
378
379
380
381
382
383
384
385
386
387

    m_selectionTool->selectUnderPoint(event);
}

void FormEditorView::changeToResizeTool()
{
    if (m_currentTool == m_resizeTool)
        return;

    m_scene->updateAllFormEditorItems();
    m_currentTool->clear();
    m_currentTool = m_resizeTool;
    m_currentTool->clear();
388
    m_currentTool->setItems(scene()->itemsForQmlItemNodes(toQmlItemNodeList(selectedModelNodes())));
389
390
391
392
393
394
395
396
397
398
399
400
}

void FormEditorView::changeToTransformTools()
{
    if (m_currentTool == m_moveTool ||
       m_currentTool == m_resizeTool ||
       m_currentTool == m_selectionTool)
        return;

    changeToSelectionTool();
}

401
void FormEditorView::changeToCustomTool()
402
{
403
404
405
    if (hasSelectedModelNodes()) {
        int handlingRank = 0;
        AbstractCustomTool *selectedCustomTool;
406

407
        ModelNode selectedModelNode = selectedModelNodes().first();
408

409
410
411
412
413
        foreach (AbstractCustomTool *customTool, m_customToolList) {
            if (customTool->wantHandleItem(selectedModelNode) > handlingRank) {
                handlingRank = customTool->wantHandleItem(selectedModelNode);
                selectedCustomTool = customTool;
            }
414

415
416
417
418
419
420
421
        }

        if (handlingRank > 0) {
            m_scene->updateAllFormEditorItems();
            m_currentTool->clear();
            m_currentTool = selectedCustomTool;
            m_currentTool->clear();
422
            m_currentTool->setItems(scene()->itemsForQmlItemNodes(toQmlItemNodeList(selectedModelNodes())));
423
        }
424
425
426
    }
}

427
428
429
430
431
432
void FormEditorView::changeToCustomTool(AbstractCustomTool *customTool)
{
    m_scene->updateAllFormEditorItems();
    m_currentTool->clear();
    m_currentTool = customTool;
    m_currentTool->clear();
433
    m_currentTool->setItems(scene()->itemsForQmlItemNodes(toQmlItemNodeList(selectedModelNodes())));
434
435
}

436
437
void FormEditorView::registerTool(AbstractCustomTool *tool)
{
438
    tool->setView(this);
439
    m_customToolList.append(tool);
440
441
}

442
443
444
void FormEditorView::nodeSlidedToIndex(const NodeListProperty &listProperty, int /*newIndex*/, int /*oldIndex*/)
{
    QList<ModelNode> newOrderModelNodeList = listProperty.toModelNodeList();
445
    foreach (const ModelNode &node, newOrderModelNodeList) {
446
447
448
449
450
451
452
453
454
455
456
        FormEditorItem *item = m_scene->itemForQmlItemNode(QmlItemNode(node));
        if (item) {
            FormEditorItem *oldParentItem = item->parentItem();
            item->setParentItem(0);
            item->setParentItem(oldParentItem);
        }
    }

    m_currentTool->formEditorItemsChanged(scene()->allFormEditorItems());
}

457
void FormEditorView::auxiliaryDataChanged(const ModelNode &node, const PropertyName &name, const QVariant &data)
458
{
Marco Bubke's avatar
Marco Bubke committed
459
    AbstractView::auxiliaryDataChanged(node, name, data);
460
    if (name == "invisible" && m_scene->hasItemForQmlItemNode(QmlItemNode(node))) {
461
462
        FormEditorItem *item(m_scene->itemForQmlItemNode(QmlItemNode(node)));
        bool isInvisible = data.toBool();
463
464
        if (item->isFormEditorVisible())
            item->setVisible(!isInvisible);
465
466
467
468
469
470
        ModelNode newNode(node);
        if (isInvisible)
            newNode.deselectNode();
    }
}

471
472
void FormEditorView::instancesCompleted(const QVector<ModelNode> &completedNodeList)
{
473
474
475
476
477
478
479
480
481
    QList<FormEditorItem*> itemNodeList;
    foreach (const ModelNode &node, completedNodeList) {
        QmlItemNode qmlItemNode(node);
        if (qmlItemNode.isValid() && scene()->hasItemForQmlItemNode(qmlItemNode)) {
            scene()->synchronizeParent(qmlItemNode);
            itemNodeList.append(scene()->itemForQmlItemNode(qmlItemNode));
        }
    }
    currentTool()->instancesCompleted(itemNodeList);
482
483
}

484
void FormEditorView::instanceInformationsChange(const QMultiHash<ModelNode, InformationName> &informationChangeHash)
485
{
486
    QList<FormEditorItem*> itemNodeList;
487

488
    foreach (const ModelNode &node, informationChangeHash.keys()) {
489
490
491
        QmlItemNode qmlItemNode(node);
        if (qmlItemNode.isValid() && scene()->hasItemForQmlItemNode(qmlItemNode)) {
            scene()->synchronizeTransformation(qmlItemNode);
492
            if (qmlItemNode.isRootModelNode() && informationChangeHash.values(node).contains(Size)) {
Marco Bubke's avatar
Marco Bubke committed
493
494
                formEditorWidget()->setRootItemRect(qmlItemNode.instanceBoundingRect());
                formEditorWidget()->centerScene();
495
            }
496

497
            itemNodeList.append(scene()->itemForQmlItemNode(qmlItemNode));
498
499
500
        }
    }

501
502
    m_currentTool->formEditorItemsChanged(itemNodeList);
}
503

504
505
506
507
void FormEditorView::instancesRenderImageChanged(const QVector<ModelNode> &nodeList)
{
    foreach (const ModelNode &node, nodeList) {
        QmlItemNode qmlItemNode(node);
508
        if (qmlItemNode.isValid() && scene()->hasItemForQmlItemNode(qmlItemNode))
509
           scene()->itemForQmlItemNode(qmlItemNode)->update();
510
    }
511
}
512

513
514
void FormEditorView::instancesPreviewImageChanged(const QVector<ModelNode> &/*nodeList*/)
{
515

516
}
517

Marco Bubke's avatar
Marco Bubke committed
518
void FormEditorView::instancesToken(const QString &/*tokenName*/, int /*tokenNumber*/, const QVector<ModelNode> &/*nodeVector*/)
519
520
521
{
}

522
523
524
525
526
527
528
529
530
531
void FormEditorView::instancesChildrenChanged(const QVector<ModelNode> &nodeList)
{
    QList<FormEditorItem*> itemNodeList;

    foreach (const ModelNode &node, nodeList) {
        QmlItemNode qmlItemNode(node);
        if (qmlItemNode.isValid() && scene()->hasItemForQmlItemNode(qmlItemNode)) {
            scene()->synchronizeParent(qmlItemNode);
            itemNodeList.append(scene()->itemForQmlItemNode(qmlItemNode));
        }
532
533
    }

534
    m_currentTool->formEditorItemsChanged(itemNodeList);
535
    m_currentTool->instancesParentChanged(itemNodeList);
536
537
}

538
539
540
541
542
543
544
545
546
void FormEditorView::rewriterBeginTransaction()
{
    m_transactionCounter++;
}

void FormEditorView::rewriterEndTransaction()
{
    m_transactionCounter--;
}
547

548
double FormEditorView::containerPadding() const
549
{
550
    return m_formEditorWidget->containerPadding();
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
}

double FormEditorView::spacing() const
{
    return m_formEditorWidget->spacing();
}

QList<ModelNode> FormEditorView::adjustStatesForModelNodes(const QList<ModelNode> &nodeList) const
{
    QList<ModelNode> adjustedNodeList;
    foreach (const ModelNode &node, nodeList)
        adjustedNodeList.append(node);

    return adjustedNodeList;
}

QmlItemNode findRecursiveQmlItemNode(const QmlObjectNode &firstQmlObjectNode)
{
    QmlObjectNode qmlObjectNode = firstQmlObjectNode;

    while (true)  {
        QmlItemNode itemNode = qmlObjectNode.toQmlItemNode();
        if (itemNode.isValid())
            return itemNode;
        if (qmlObjectNode.hasInstanceParent())
            qmlObjectNode = qmlObjectNode.instanceParent();
        else
            break;
    }

    return QmlItemNode();
}

584
void FormEditorView::instancePropertyChange(const QList<QPair<ModelNode, PropertyName> > &propertyList)
585
{
586
    typedef QPair<ModelNode, PropertyName> NodePropertyPair;
587
588
    foreach (const NodePropertyPair &nodePropertyPair, propertyList) {
        const QmlItemNode itemNode(nodePropertyPair.first);
589
        const PropertyName propertyName = nodePropertyPair.second;
590
        if (itemNode.isValid() && scene()->hasItemForQmlItemNode(itemNode)) {
591
            static PropertyNameList skipList = PropertyNameList() << "x" << "y" << "width" << "height";
592
593
594
595
596
            if (!skipList.contains(propertyName)) {
                m_scene->synchronizeOtherProperty(itemNode, propertyName);
                m_currentTool->formEditorItemsChanged(QList<FormEditorItem*>() << m_scene->itemForQmlItemNode(itemNode));
            }
        }
597
598
599
600
601
602
603
604
    }
}

void FormEditorView::updateGraphicsIndicators()
{
    m_currentTool->formEditorItemsChanged(scene()->allFormEditorItems());
}

605
606
607
608
609

void FormEditorView::setSelectOnlyContentItemsAction(bool selectOnlyContentItems)
{
    m_selectionTool->setSelectOnlyContentItems(selectOnlyContentItems);
}
610
611
612

bool FormEditorView::isMoveToolAvailable() const
{
613
614
    if (hasSingleSelectedModelNode() && QmlItemNode::isValidQmlItemNode(singleSelectedModelNode())) {
        QmlItemNode selectedQmlItemNode(singleSelectedModelNode());
615
616
617
        return selectedQmlItemNode.instanceIsMovable()
                && selectedQmlItemNode.modelIsMovable()
                && !selectedQmlItemNode.instanceIsInLayoutable();
618
619
    }

620
621
    return true;
}
622

623
void FormEditorView::currentStateChanged(const ModelNode &/*node*/)
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
{
}

void FormEditorView::nodeRemoved(const ModelNode &/*removedNode*/, const NodeAbstractProperty &/*parentProperty*/, AbstractView::PropertyChangeFlags /*propertyChange*/)
{

}

void FormEditorView::nodeAboutToBeReparented(const ModelNode &/*node*/, const NodeAbstractProperty &/*newPropertyParent*/, const NodeAbstractProperty &/*oldPropertyParent*/, AbstractView::PropertyChangeFlags /*propertyChange*/)
{

}

void FormEditorView::nodeSourceChanged(const ModelNode &/*modelNode*/, const QString &/*newNodeSource*/)
{

}

void FormEditorView::nodeOrderChanged(const NodeListProperty &/*listProperty*/, const ModelNode &/*movedNode*/, int /*oldIndex*/)
643
{
Thomas Hartmann's avatar
Thomas Hartmann committed
644

645
646
}

647
648
649
650
651
652
653
654
655
656
657
658
void FormEditorView::reset()
{
   QTimer::singleShot(200, this, SLOT(delayedReset()));
}

void FormEditorView::delayedReset()
{
    m_selectionTool->clear();
    m_moveTool->clear();
    m_resizeTool->clear();
    m_dragTool->clear();
    m_scene->clearFormEditorItems();
659
660
    if (QmlItemNode::isValidQmlItemNode(rootModelNode()))
        setupFormEditorItemTree(rootModelNode());
661
662
}

663
664
665

}