forked from qt-creator/qt-creator
QmlDesigner: Remove QmlModelView
And use NodeInstanceView directly. There is still more cleanup required for the view handling. Change-Id: I62417644ceefb25fb9f3bb93a894b71ae0929cb0 Reviewed-by: Thomas Hartmann <Thomas.Hartmann@digia.com>
This commit is contained in:
@@ -32,7 +32,7 @@
|
||||
|
||||
#include <qmldesignercorelib_global.h>
|
||||
#include "abstractdesigneraction.h"
|
||||
#include "qmlmodelview.h"
|
||||
#include "abstractview.h"
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
|
@@ -37,7 +37,7 @@
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
ModelNodeContextMenu::ModelNodeContextMenu(QmlModelView *view) :
|
||||
ModelNodeContextMenu::ModelNodeContextMenu(AbstractView *view) :
|
||||
m_selectionContext(view)
|
||||
{
|
||||
}
|
||||
@@ -111,7 +111,7 @@ void ModelNodeContextMenu::setScenePos(const QPoint &position)
|
||||
m_scenePos = position;
|
||||
}
|
||||
|
||||
void ModelNodeContextMenu::showContextMenu(QmlModelView *view,
|
||||
void ModelNodeContextMenu::showContextMenu(AbstractView *view,
|
||||
const QPoint &globalPosition,
|
||||
const QPoint &scenePosition,
|
||||
bool showSelection)
|
||||
|
@@ -33,7 +33,7 @@
|
||||
#include <QPoint>
|
||||
#include <QCoreApplication>
|
||||
|
||||
#include <qmlmodelview.h>
|
||||
#include <abstractview.h>
|
||||
#include "selectioncontext.h"
|
||||
|
||||
namespace QmlDesigner {
|
||||
@@ -42,11 +42,11 @@ class ModelNodeContextMenu
|
||||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(QmlDesigner::ModelNodeContextMenu)
|
||||
public:
|
||||
ModelNodeContextMenu(QmlModelView *view);
|
||||
ModelNodeContextMenu(AbstractView *view);
|
||||
void execute(const QPoint &pos, bool selectionMenu);
|
||||
void setScenePos(const QPoint &pos);
|
||||
|
||||
static void showContextMenu(QmlModelView *view, const QPoint &globalPosition, const QPoint &scenePosition, bool showSelection);
|
||||
static void showContextMenu(AbstractView *view, const QPoint &globalPosition, const QPoint &scenePosition, bool showSelection);
|
||||
|
||||
private:
|
||||
QPoint m_scenePos;
|
||||
|
@@ -32,6 +32,7 @@
|
||||
|
||||
#include "modelnodeoperations.h"
|
||||
#include "defaultdesigneraction.h"
|
||||
#include "qmlitemnode.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QMenu>
|
||||
|
@@ -29,6 +29,8 @@
|
||||
|
||||
#include "selectioncontext.h"
|
||||
|
||||
#include <qmlstate.h>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
|
||||
|
@@ -28,7 +28,8 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include <qmldesignercorelib_global.h>
|
||||
#include <qmlmodelview.h>
|
||||
#include <abstractview.h>
|
||||
#include <QPoint>
|
||||
|
||||
#ifndef SELECTIONCONTEXT_H
|
||||
#define SELECTIONCONTEXT_H
|
||||
|
@@ -56,7 +56,7 @@ namespace QmlDesigner {
|
||||
|
||||
namespace Internal {
|
||||
|
||||
DebugView::DebugView(QObject *parent) : QmlModelView(parent),
|
||||
DebugView::DebugView(QObject *parent) : AbstractView(parent),
|
||||
m_debugViewWidget(new DebugViewWidget)
|
||||
{
|
||||
}
|
||||
@@ -70,13 +70,13 @@ void DebugView::modelAttached(Model *model)
|
||||
log(tr("Model attached"), tr("FileName %1").arg(model->fileUrl().toLocalFile()));
|
||||
m_debugViewWidget->setDebugViewEnabled(isDebugViewEnabled());
|
||||
qDebug() << "enabled: " << isDebugViewEnabled();
|
||||
QmlModelView::modelAttached(model);
|
||||
AbstractView::modelAttached(model);
|
||||
}
|
||||
|
||||
void DebugView::modelAboutToBeDetached(Model *model)
|
||||
{
|
||||
log(tr("Model detached"), tr("FileName %1").arg(model->fileUrl().toLocalFile()));
|
||||
QmlModelView::modelAboutToBeDetached(model);
|
||||
AbstractView::modelAboutToBeDetached(model);
|
||||
}
|
||||
|
||||
void DebugView::importsChanged(const QList<Import> &addedImports, const QList<Import> &removedImports)
|
||||
|
@@ -30,7 +30,7 @@
|
||||
#ifndef DEBUGVIEW_H
|
||||
#define DEBUGVIEW_H
|
||||
|
||||
#include <qmlmodelview.h>
|
||||
#include <abstractview.h>
|
||||
#include <QPointer>
|
||||
|
||||
namespace QmlDesigner {
|
||||
@@ -39,7 +39,7 @@ namespace Internal {
|
||||
|
||||
class DebugViewWidget;
|
||||
|
||||
class DebugView : public QmlModelView
|
||||
class DebugView : public AbstractView
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
@@ -53,7 +53,7 @@
|
||||
namespace QmlDesigner {
|
||||
|
||||
FormEditorView::FormEditorView(QObject *parent)
|
||||
: QmlModelView(parent),
|
||||
: AbstractView(parent),
|
||||
m_formEditorWidget(new FormEditorWidget(this)),
|
||||
m_scene(new FormEditorScene(m_formEditorWidget.data(), this)),
|
||||
m_moveTool(new MoveTool(this)),
|
||||
@@ -100,7 +100,7 @@ void FormEditorView::modelAttached(Model *model)
|
||||
{
|
||||
Q_ASSERT(model);
|
||||
|
||||
QmlModelView::modelAttached(model);
|
||||
AbstractView::modelAttached(model);
|
||||
|
||||
Q_ASSERT(m_scene->formLayerItem());
|
||||
|
||||
@@ -177,7 +177,7 @@ void FormEditorView::modelAboutToBeDetached(Model *model)
|
||||
|
||||
m_currentTool = m_selectionTool;
|
||||
|
||||
QmlModelView::modelAboutToBeDetached(model);
|
||||
AbstractView::modelAboutToBeDetached(model);
|
||||
}
|
||||
|
||||
void FormEditorView::importsChanged(const QList<Import> &/*addedImports*/, const QList<Import> &/*removedImports*/)
|
||||
@@ -456,7 +456,7 @@ void FormEditorView::nodeSlidedToIndex(const NodeListProperty &listProperty, int
|
||||
|
||||
void FormEditorView::auxiliaryDataChanged(const ModelNode &node, const PropertyName &name, const QVariant &data)
|
||||
{
|
||||
QmlModelView::auxiliaryDataChanged(node, name, data);
|
||||
AbstractView::auxiliaryDataChanged(node, name, data);
|
||||
if (name == "invisible" && m_scene->hasItemForQmlItemNode(QmlItemNode(node))) {
|
||||
FormEditorItem *item(m_scene->itemForQmlItemNode(QmlItemNode(node)));
|
||||
bool isInvisible = data.toBool();
|
||||
|
@@ -30,7 +30,7 @@
|
||||
#ifndef FORMEDITORVIEW_H
|
||||
#define FORMEDITORVIEW_H
|
||||
|
||||
#include <qmlmodelview.h>
|
||||
#include <abstractview.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QGraphicsScene;
|
||||
@@ -57,7 +57,7 @@ class DragTool;
|
||||
class ItemLibraryEntry;
|
||||
class QmlItemNode;
|
||||
|
||||
class QMLDESIGNERCORE_EXPORT FormEditorView : public QmlModelView
|
||||
class QMLDESIGNERCORE_EXPORT FormEditorView : public AbstractView
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
@@ -32,6 +32,8 @@
|
||||
|
||||
#include "formeditorview.h"
|
||||
|
||||
#include <QPointF>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
class SingleSelectionManipulator
|
||||
|
@@ -165,9 +165,9 @@ bool DesignDocument::loadInFileComponent(const ModelNode &componentNode)
|
||||
return true;
|
||||
}
|
||||
|
||||
QmlModelView *DesignDocument::qmlModelView()
|
||||
AbstractView *DesignDocument::view()
|
||||
{
|
||||
return viewManager().qmlModelView();
|
||||
return viewManager().nodeInstanceView();
|
||||
}
|
||||
|
||||
Model* DesignDocument::createInFileComponentModel()
|
||||
@@ -319,7 +319,7 @@ void DesignDocument::goIntoSelectedComponent()
|
||||
|
||||
QList<ModelNode> selectedNodes;
|
||||
if (rewriterView())
|
||||
selectedNodes = qmlModelView()->selectedModelNodes();
|
||||
selectedNodes = view()->selectedModelNodes();
|
||||
|
||||
if (selectedNodes.count() == 1) {
|
||||
viewManager().setComponentNode(selectedNodes.first());
|
||||
@@ -377,7 +377,7 @@ void DesignDocument::deleteSelected()
|
||||
|
||||
try {
|
||||
RewriterTransaction transaction(rewriterView());
|
||||
QList<ModelNode> toDelete = qmlModelView()->selectedModelNodes();
|
||||
QList<ModelNode> toDelete = view()->selectedModelNodes();
|
||||
foreach (ModelNode node, toDelete) {
|
||||
if (node.isValid() && !node.isRootNode() && QmlObjectNode::isValidQmlObjectNode(node))
|
||||
QmlObjectNode(node).destroy();
|
||||
|
@@ -57,7 +57,7 @@ class TextModifier;
|
||||
class QmlObjectNode;
|
||||
class CrumbleBarInfo;
|
||||
class ViewManager;
|
||||
class QmlModelView;
|
||||
class AbstractView;
|
||||
|
||||
class QMLDESIGNERCORE_EXPORT DesignDocument: public QObject
|
||||
{
|
||||
@@ -140,7 +140,7 @@ private: // functions
|
||||
|
||||
bool loadInFileComponent(const ModelNode &componentNode);
|
||||
|
||||
QmlModelView *qmlModelView();
|
||||
AbstractView *view();
|
||||
|
||||
Model *createInFileComponentModel();
|
||||
|
||||
|
@@ -34,11 +34,12 @@
|
||||
#include <nodeproperty.h>
|
||||
#include <variantproperty.h>
|
||||
#include <metainfo.h>
|
||||
#include <qmlmodelview.h>
|
||||
#include <abstractview.h>
|
||||
#include <rewriterview.h>
|
||||
#include <invalididexception.h>
|
||||
#include <rewritingexception.h>
|
||||
#include <modelnodecontextmenu.h>
|
||||
#include <qmlitemnode.h>
|
||||
|
||||
#include <QMimeData>
|
||||
#include <QMessageBox>
|
||||
@@ -380,7 +381,7 @@ NavigatorTreeModel::ItemRow NavigatorTreeModel::itemRowForNode(const ModelNode &
|
||||
return m_nodeItemHash.value(node);
|
||||
}
|
||||
|
||||
void NavigatorTreeModel::setView(QmlModelView *view)
|
||||
void NavigatorTreeModel::setView(AbstractView *view)
|
||||
{
|
||||
m_view = view;
|
||||
m_hiddenProperties.clear();
|
||||
|
@@ -39,7 +39,7 @@
|
||||
namespace QmlDesigner {
|
||||
|
||||
class Model;
|
||||
class QmlModelView;
|
||||
class AbstractView;
|
||||
class ModelNode;
|
||||
|
||||
class NavigatorTreeModel : public QStandardItemModel
|
||||
@@ -95,7 +95,7 @@ public:
|
||||
int column,
|
||||
const QModelIndex &parent);
|
||||
|
||||
void setView(QmlModelView *view);
|
||||
void setView(AbstractView *view);
|
||||
void clearView();
|
||||
|
||||
QModelIndex indexForNode(const ModelNode &node) const;
|
||||
@@ -140,7 +140,7 @@ private:
|
||||
private:
|
||||
QHash<ModelNode, ItemRow> m_nodeItemHash;
|
||||
QHash<uint, ModelNode> m_nodeHash;
|
||||
QWeakPointer<QmlModelView> m_view;
|
||||
QWeakPointer<AbstractView> m_view;
|
||||
|
||||
bool m_blockItemChangedSignal;
|
||||
|
||||
|
@@ -39,6 +39,7 @@
|
||||
#include <nodelistproperty.h>
|
||||
#include <variantproperty.h>
|
||||
#include <QHeaderView>
|
||||
#include <qmlitemnode.h>
|
||||
|
||||
static inline void setScenePos(const QmlDesigner::ModelNode &modelNode,const QPointF &pos)
|
||||
{
|
||||
@@ -53,7 +54,7 @@ static inline void setScenePos(const QmlDesigner::ModelNode &modelNode,const QPo
|
||||
namespace QmlDesigner {
|
||||
|
||||
NavigatorView::NavigatorView(QObject* parent) :
|
||||
QmlModelView(parent),
|
||||
AbstractView(parent),
|
||||
m_blockSelectionChangedSignal(false),
|
||||
m_widget(new NavigatorWidget(this)),
|
||||
m_treeModel(new NavigatorTreeModel(this))
|
||||
@@ -114,7 +115,7 @@ WidgetInfo NavigatorView::widgetInfo()
|
||||
|
||||
void NavigatorView::modelAttached(Model *model)
|
||||
{
|
||||
QmlModelView::modelAttached(model);
|
||||
AbstractView::modelAttached(model);
|
||||
|
||||
m_treeModel->setView(this);
|
||||
|
||||
@@ -133,7 +134,7 @@ void NavigatorView::modelAttached(Model *model)
|
||||
void NavigatorView::modelAboutToBeDetached(Model *model)
|
||||
{
|
||||
m_treeModel->clearView();
|
||||
QmlModelView::modelAboutToBeDetached(model);
|
||||
AbstractView::modelAboutToBeDetached(model);
|
||||
}
|
||||
|
||||
void NavigatorView::importsChanged(const QList<Import> &/*addedImports*/, const QList<Import> &/*removedImports*/)
|
||||
|
@@ -30,7 +30,7 @@
|
||||
#ifndef NAVIGATORVIEW_H
|
||||
#define NAVIGATORVIEW_H
|
||||
|
||||
#include <qmlmodelview.h>
|
||||
#include <abstractview.h>
|
||||
|
||||
#include <QWeakPointer>
|
||||
|
||||
@@ -48,7 +48,7 @@ class NavigatorTreeModel;
|
||||
class IconCheckboxItemDelegate;
|
||||
class IdItemDelegate;
|
||||
|
||||
class NavigatorView : public QmlModelView
|
||||
class NavigatorView : public AbstractView
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
@@ -333,7 +333,7 @@ void PropertyEditor::NodeType::initialSetup(const TypeName &typeName, const QUrl
|
||||
}
|
||||
|
||||
PropertyEditor::PropertyEditor(QWidget *parent) :
|
||||
QmlModelView(parent),
|
||||
AbstractView(parent),
|
||||
m_parent(parent),
|
||||
m_updateShortcut(0),
|
||||
m_timerId(0),
|
||||
@@ -814,7 +814,7 @@ void PropertyEditor::nodeAboutToBeRemoved(const ModelNode &removedNode)
|
||||
|
||||
void PropertyEditor::modelAttached(Model *model)
|
||||
{
|
||||
QmlModelView::modelAttached(model);
|
||||
AbstractView::modelAttached(model);
|
||||
|
||||
if (debug)
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
@@ -834,7 +834,7 @@ void PropertyEditor::modelAttached(Model *model)
|
||||
|
||||
void PropertyEditor::modelAboutToBeDetached(Model *model)
|
||||
{
|
||||
QmlModelView::modelAboutToBeDetached(model);
|
||||
AbstractView::modelAboutToBeDetached(model);
|
||||
m_currentType->m_propertyEditorTransaction->end();
|
||||
|
||||
resetView();
|
||||
|
@@ -30,7 +30,7 @@
|
||||
#ifndef PROPERTYEDITOR_H
|
||||
#define PROPERTYEDITOR_H
|
||||
|
||||
#include <qmlmodelview.h>
|
||||
#include <abstractview.h>
|
||||
#include <declarativewidgetview.h>
|
||||
#include <QHash>
|
||||
#include <QStackedWidget>
|
||||
@@ -55,7 +55,7 @@ class PropertyEditorTransaction;
|
||||
class CollapseButton;
|
||||
class StackedWidget;
|
||||
|
||||
class PropertyEditor: public QmlModelView
|
||||
class PropertyEditor: public AbstractView
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
@@ -41,6 +41,8 @@
|
||||
#include <variantproperty.h>
|
||||
#include <nodelistproperty.h>
|
||||
|
||||
#include <qmlitemnode.h>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
/**
|
||||
@@ -48,7 +50,7 @@ namespace QmlDesigner {
|
||||
the current state is the base state, we render the base state + all other states.
|
||||
*/
|
||||
StatesEditorView::StatesEditorView(QObject *parent) :
|
||||
QmlModelView(parent),
|
||||
AbstractView(parent),
|
||||
m_statesEditorModel(new StatesEditorModel(this)),
|
||||
m_statesEditorWidget(new StatesEditorWidget(this, m_statesEditorModel.data())),
|
||||
m_lastIndex(-1)
|
||||
@@ -304,11 +306,11 @@ void StatesEditorView::renameState(int nodeId, const QString &newName)
|
||||
|
||||
void StatesEditorView::modelAttached(Model *model)
|
||||
{
|
||||
if (model == QmlModelView::model())
|
||||
if (model == AbstractView::model())
|
||||
return;
|
||||
|
||||
Q_ASSERT(model);
|
||||
QmlModelView::modelAttached(model);
|
||||
AbstractView::modelAttached(model);
|
||||
|
||||
if (m_statesEditorWidget)
|
||||
m_statesEditorWidget->setNodeInstanceView(nodeInstanceView());
|
||||
@@ -318,7 +320,7 @@ void StatesEditorView::modelAttached(Model *model)
|
||||
|
||||
void StatesEditorView::modelAboutToBeDetached(Model *model)
|
||||
{
|
||||
QmlModelView::modelAboutToBeDetached(model);
|
||||
AbstractView::modelAboutToBeDetached(model);
|
||||
resetModel();
|
||||
}
|
||||
|
||||
|
@@ -30,7 +30,9 @@
|
||||
#ifndef STATESEDITORVIEW_H
|
||||
#define STATESEDITORVIEW_H
|
||||
|
||||
#include <qmlmodelview.h>
|
||||
#include <abstractview.h>
|
||||
|
||||
#include <qmlstate.h>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
@@ -38,7 +40,7 @@ namespace QmlDesigner {
|
||||
class StatesEditorModel;
|
||||
class StatesEditorWidget;
|
||||
|
||||
class StatesEditorView : public QmlModelView {
|
||||
class StatesEditorView : public AbstractView {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
@@ -74,7 +76,7 @@ public:
|
||||
void nodeOrderChanged(const NodeListProperty &listProperty, const ModelNode &movedNode, int oldIndex) QTC_OVERRIDE;
|
||||
|
||||
|
||||
// QmlModelView
|
||||
// AbstractView
|
||||
void actualStateChanged(const ModelNode &node) QTC_OVERRIDE;
|
||||
|
||||
void scriptFunctionsChanged(const ModelNode &node, const QStringList &scriptFunctionList) QTC_OVERRIDE;
|
||||
|
@@ -60,7 +60,6 @@ SOURCES += $$PWD/model/abstractview.cpp \
|
||||
$$PWD/model/plaintexteditmodifier.cpp \
|
||||
$$PWD/model/componenttextmodifier.cpp \
|
||||
$$PWD/model/textmodifier.cpp \
|
||||
$$PWD/model/qmlmodelview.cpp \
|
||||
$$PWD/model/qmlitemnode.cpp \
|
||||
$$PWD/model/qmlstate.cpp \
|
||||
$$PWD/model/qmlchangeset.cpp \
|
||||
@@ -129,7 +128,6 @@ HEADERS += $$PWD/include/qmldesignercorelib_global.h \
|
||||
$$PWD/include/textmodifier.h \
|
||||
$$PWD/model/modeltotextmerger.h \
|
||||
$$PWD/model/texttomodelmerger.h \
|
||||
$$PWD/include/qmlmodelview.h \
|
||||
$$PWD/include/qmlitemnode.h \
|
||||
$$PWD/include/qmlstate.h \
|
||||
$$PWD/include/qmlchangeset.h \
|
||||
|
@@ -55,7 +55,6 @@ namespace QmlDesigner {
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
class QmlModelView;
|
||||
class NodeInstanceView;
|
||||
class RewriterView;
|
||||
|
||||
@@ -228,7 +227,6 @@ public:
|
||||
|
||||
virtual void scriptFunctionsChanged(const ModelNode &node, const QStringList &scriptFunctionList) = 0;
|
||||
|
||||
QmlModelView *toQmlModelView();
|
||||
|
||||
void changeRootNodeType(const TypeName &type, int majorVersion, int minorVersion);
|
||||
|
||||
|
@@ -35,7 +35,8 @@
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
class QmlModelView;
|
||||
class AbstractView;
|
||||
class NodeInstanceView;
|
||||
|
||||
class QMLDESIGNERCORE_EXPORT QmlModelNodeFacade
|
||||
{
|
||||
@@ -48,9 +49,10 @@ public:
|
||||
virtual ~QmlModelNodeFacade();
|
||||
QmlModelNodeFacade();
|
||||
|
||||
bool isRootNode() const;
|
||||
static QmlModelView* qmlModelView();
|
||||
AbstractView *view() const;
|
||||
static NodeInstanceView *nodeInstanceView();
|
||||
|
||||
bool isRootNode() const;
|
||||
|
||||
protected:
|
||||
QmlModelNodeFacade(const ModelNode &modelNode);
|
||||
|
@@ -1,58 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** 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.
|
||||
**
|
||||
** 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QMLMODELVIEW_H
|
||||
#define QMLMODELVIEW_H
|
||||
|
||||
#include <qmldesignercorelib_global.h>
|
||||
#include <abstractview.h>
|
||||
#include "qmlitemnode.h"
|
||||
#include "qmlstate.h"
|
||||
#include "nodeinstanceview.h"
|
||||
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
class ItemLibraryEntry;
|
||||
|
||||
class QMLDESIGNERCORE_EXPORT QmlModelView : public AbstractView
|
||||
{
|
||||
Q_OBJECT
|
||||
friend class QmlObjectNode;
|
||||
friend class QmlModelNodeFacade;
|
||||
|
||||
public:
|
||||
QmlModelView(QObject *parent) ;
|
||||
|
||||
|
||||
};
|
||||
|
||||
} //QmlDesigner
|
||||
|
||||
#endif // QMLMODELVIEW_H
|
@@ -36,9 +36,9 @@
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
class QmlModelView;
|
||||
class QmlModelStateGroup;
|
||||
class AbstractViewAbstractVieweGroup;
|
||||
class QmlObjectNode;
|
||||
class QmlModelStateGroup;
|
||||
|
||||
class QMLDESIGNERCORE_EXPORT QmlModelState : public QmlModelNodeFacade
|
||||
{
|
||||
@@ -76,7 +76,7 @@ public:
|
||||
|
||||
protected:
|
||||
void addChangeSetIfNotExists(const ModelNode &node);
|
||||
static QmlModelState createBaseState(const QmlModelView *view);
|
||||
static QmlModelState createBaseState(const AbstractView *view);
|
||||
|
||||
};
|
||||
|
||||
|
@@ -83,8 +83,7 @@ public:
|
||||
void pushInFileComponentOnCrambleBar(const QString &componentId);
|
||||
void nextFileIsCalledInternally();
|
||||
|
||||
//used by DesignDocument ### find a better solution
|
||||
QmlModelView *qmlModelView();
|
||||
NodeInstanceView *nodeInstanceView();
|
||||
|
||||
private: // functions
|
||||
Q_DISABLE_COPY(ViewManager)
|
||||
|
@@ -32,7 +32,7 @@
|
||||
#include "model.h"
|
||||
#include "model_p.h"
|
||||
#include "internalnode_p.h"
|
||||
#include <qmlmodelview.h>
|
||||
#include "nodeinstanceview.h"
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
@@ -399,11 +399,6 @@ bool AbstractView::hasModelNodeForInternalId(qint32 internalId) const
|
||||
return model()->d->hasNodeForInternalId(internalId);
|
||||
}
|
||||
|
||||
QmlModelView *AbstractView::toQmlModelView()
|
||||
{
|
||||
return qobject_cast<QmlModelView*>(this);
|
||||
}
|
||||
|
||||
NodeInstanceView *AbstractView::nodeInstanceView() const
|
||||
{
|
||||
if (model())
|
||||
|
@@ -84,17 +84,15 @@ const QList<ModelNode> NodeListProperty::toModelNodeList() const
|
||||
|
||||
const QList<QmlObjectNode> NodeListProperty::toQmlObjectNodeList() const
|
||||
{
|
||||
QmlModelView *fxView = view()->toQmlModelView();
|
||||
|
||||
if (fxView == 0)
|
||||
if (model()->nodeInstanceView())
|
||||
return QList<QmlObjectNode>();
|
||||
|
||||
QList<QmlObjectNode> fxObjectNodeList;
|
||||
QList<QmlObjectNode> qmlObjectNodeList;
|
||||
|
||||
foreach (const ModelNode &modelNode, toModelNodeList())
|
||||
fxObjectNodeList.append(QmlObjectNode(modelNode));
|
||||
qmlObjectNodeList.append(QmlObjectNode(modelNode));
|
||||
|
||||
return fxObjectNodeList;
|
||||
return qmlObjectNodeList;
|
||||
}
|
||||
|
||||
void NodeListProperty::slide(int from, int to) const
|
||||
|
@@ -31,7 +31,7 @@
|
||||
#include "bindingproperty.h"
|
||||
#include "nodeabstractproperty.h"
|
||||
#include "rewritertransaction.h"
|
||||
#include "qmlmodelview.h"
|
||||
#include "nodeinstanceview.h"
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
@@ -128,7 +128,7 @@ void QmlAnchors::setAnchor(AnchorLine::Type sourceAnchorLine,
|
||||
const QmlItemNode &targetQmlItemNode,
|
||||
AnchorLine::Type targetAnchorLine)
|
||||
{
|
||||
RewriterTransaction transaction = qmlItemNode().qmlModelView()->beginRewriterTransaction();
|
||||
RewriterTransaction transaction = qmlItemNode().view()->beginRewriterTransaction();
|
||||
if (qmlItemNode().isInBaseState()) {
|
||||
if ((qmlItemNode().nodeInstance().hasAnchor("anchors.fill") && (sourceAnchorLine & AnchorLine::Fill))
|
||||
|| ((qmlItemNode().nodeInstance().hasAnchor("anchors.centerIn") && (sourceAnchorLine & AnchorLine::Center)))) {
|
||||
@@ -277,12 +277,12 @@ AnchorLine QmlAnchors::instanceAnchor(AnchorLine::Type sourceAnchorLine) const
|
||||
if (targetAnchorLinePair.second < 0) //there might be no node instance for the parent
|
||||
return AnchorLine();
|
||||
|
||||
return AnchorLine(QmlItemNode(qmlItemNode().nodeForInstance(qmlItemNode().qmlModelView()->nodeInstanceView()->instanceForId(targetAnchorLinePair.second))), targetAnchorLine);
|
||||
return AnchorLine(QmlItemNode(qmlItemNode().nodeForInstance(qmlItemNode().nodeInstanceView()->instanceForId(targetAnchorLinePair.second))), targetAnchorLine);
|
||||
}
|
||||
|
||||
void QmlAnchors::removeAnchor(AnchorLine::Type sourceAnchorLine)
|
||||
{
|
||||
RewriterTransaction transaction = qmlItemNode().qmlModelView()->beginRewriterTransaction();
|
||||
RewriterTransaction transaction = qmlItemNode().view()->beginRewriterTransaction();
|
||||
if (qmlItemNode().isInBaseState()) {
|
||||
const PropertyName propertyName = anchorPropertyName(sourceAnchorLine);
|
||||
if (qmlItemNode().nodeInstance().hasAnchor("anchors.fill") && (sourceAnchorLine & AnchorLine::Fill)) {
|
||||
@@ -304,7 +304,7 @@ void QmlAnchors::removeAnchor(AnchorLine::Type sourceAnchorLine)
|
||||
|
||||
void QmlAnchors::removeAnchors()
|
||||
{
|
||||
RewriterTransaction transaction = qmlItemNode().qmlModelView()->beginRewriterTransaction();
|
||||
RewriterTransaction transaction = qmlItemNode().view()->beginRewriterTransaction();
|
||||
if (qmlItemNode().nodeInstance().hasAnchor("anchors.fill"))
|
||||
qmlItemNode().modelNode().removeProperty("anchors.fill");
|
||||
if (qmlItemNode().nodeInstance().hasAnchor("anchors.centerIn"))
|
||||
@@ -492,7 +492,7 @@ void QmlAnchors::removeMargin(AnchorLine::Type sourceAnchorLineType)
|
||||
|
||||
void QmlAnchors::removeMargins()
|
||||
{
|
||||
RewriterTransaction transaction = qmlItemNode().qmlModelView()->beginRewriterTransaction();
|
||||
RewriterTransaction transaction = qmlItemNode().view()->beginRewriterTransaction();
|
||||
removeMargin(AnchorLine::Left);
|
||||
removeMargin(AnchorLine::Right);
|
||||
removeMargin(AnchorLine::Top);
|
||||
|
@@ -30,7 +30,7 @@
|
||||
#include "qmlchangeset.h"
|
||||
#include "bindingproperty.h"
|
||||
#include "variantproperty.h"
|
||||
#include "qmlmodelview.h"
|
||||
#include "abstractview.h"
|
||||
#include <metainfo.h>
|
||||
|
||||
namespace QmlDesigner {
|
||||
@@ -72,7 +72,7 @@ bool QmlModelStateOperation::isValidQmlModelStateOperation(const ModelNode &mode
|
||||
|
||||
void QmlPropertyChanges::removeProperty(const PropertyName &name)
|
||||
{
|
||||
RewriterTransaction transaction(qmlModelView()->beginRewriterTransaction());
|
||||
RewriterTransaction transaction(view()->beginRewriterTransaction());
|
||||
if (name == "name")
|
||||
return;
|
||||
modelNode().removeProperty(name);
|
||||
|
@@ -34,7 +34,6 @@
|
||||
#include "variantproperty.h"
|
||||
#include "qmlanchors.h"
|
||||
#include "invalidmodelnodeexception.h"
|
||||
#include "qmlmodelview.h"
|
||||
#include "itemlibraryinfo.h"
|
||||
|
||||
#include "plaintexteditmodifier.h"
|
||||
|
@@ -28,14 +28,27 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "qmlmodelnodefacade.h"
|
||||
#include "qmlmodelview.h"
|
||||
#include "nodeinstanceview.h"
|
||||
#include <qmldesignerplugin.h>
|
||||
#include <QDebug>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
QmlModelNodeFacade::QmlModelNodeFacade() : m_modelNode(ModelNode())
|
||||
{}
|
||||
|
||||
AbstractView *QmlModelNodeFacade::view() const
|
||||
{
|
||||
if (modelNode().isValid())
|
||||
return modelNode().view();
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
NodeInstanceView *QmlModelNodeFacade::nodeInstanceView()
|
||||
{
|
||||
return QmlDesignerPlugin::instance()->viewManager().nodeInstanceView();
|
||||
}
|
||||
|
||||
|
||||
QmlModelNodeFacade::QmlModelNodeFacade(const ModelNode &modelNode) : m_modelNode(modelNode)
|
||||
{}
|
||||
@@ -63,18 +76,12 @@ bool QmlModelNodeFacade::isValid() const
|
||||
return isValidQmlModelNodeFacade(m_modelNode);
|
||||
}
|
||||
|
||||
QmlModelView* QmlModelNodeFacade::qmlModelView()
|
||||
{
|
||||
return QmlDesignerPlugin::instance()->viewManager().qmlModelView();
|
||||
}
|
||||
|
||||
bool QmlModelNodeFacade::isValidQmlModelNodeFacade(const ModelNode &modelNode)
|
||||
{
|
||||
return modelNode.isValid()
|
||||
&& qmlModelView()
|
||||
&& qmlModelView()->nodeInstanceView()
|
||||
&& qmlModelView()->nodeInstanceView()->hasInstanceForNode(modelNode)
|
||||
&& qmlModelView()->nodeInstanceView()->instanceForModelNode(modelNode).isValid();
|
||||
&& nodeInstanceView()
|
||||
&& nodeInstanceView()->hasInstanceForNode(modelNode)
|
||||
&& nodeInstanceView()->instanceForModelNode(modelNode).isValid();
|
||||
}
|
||||
|
||||
bool QmlModelNodeFacade::isRootNode() const
|
||||
|
@@ -1,58 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** 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.
|
||||
**
|
||||
** 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qmlmodelview.h"
|
||||
#include "qmlobjectnode.h"
|
||||
#include "qmlitemnode.h"
|
||||
#include "itemlibraryinfo.h"
|
||||
#include "mathutils.h"
|
||||
#include "invalididexception.h"
|
||||
#include <QDir>
|
||||
#include <QFileInfo>
|
||||
#include <QDebug>
|
||||
#include <QMessageBox>
|
||||
#include <QPlainTextEdit>
|
||||
#include <utils/fileutils.h>
|
||||
#include "nodeabstractproperty.h"
|
||||
#include "variantproperty.h"
|
||||
#include "rewritingexception.h"
|
||||
#include "rewriterview.h"
|
||||
#include "plaintexteditmodifier.h"
|
||||
#include "modelmerger.h"
|
||||
#include "nodemetainfo.h"
|
||||
|
||||
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
QmlModelView::QmlModelView(QObject *parent)
|
||||
: AbstractView(parent)
|
||||
{
|
||||
}
|
||||
} //QmlDesigner
|
@@ -33,11 +33,12 @@
|
||||
#include "variantproperty.h"
|
||||
#include "nodeproperty.h"
|
||||
#include <invalidmodelnodeexception.h>
|
||||
#include "qmlmodelview.h"
|
||||
#include "abstractview.h"
|
||||
#include "nodeinstance.h"
|
||||
#include "nodemetainfo.h"
|
||||
#include "bindingproperty.h"
|
||||
#include "nodelistproperty.h"
|
||||
#include "nodeinstanceview.h"
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
@@ -76,7 +77,7 @@ void QmlObjectNode::setBindingProperty(const PropertyName &name, const QString &
|
||||
QmlModelState QmlObjectNode::currentState() const
|
||||
{
|
||||
if (isValid())
|
||||
return QmlModelState(qmlModelView()->actualStateNode());
|
||||
return QmlModelState(view()->actualStateNode());
|
||||
else
|
||||
return QmlModelState();
|
||||
}
|
||||
@@ -345,8 +346,8 @@ QList<QmlModelState> QmlObjectNode::allDefinedStates() const
|
||||
|
||||
QList<QmlItemNode> allQmlItems;
|
||||
|
||||
if (QmlItemNode::isValidQmlItemNode(qmlModelView()->rootModelNode()))
|
||||
allQmlItems.append(allQmlItemsRecursive(qmlModelView()->rootModelNode()));
|
||||
if (QmlItemNode::isValidQmlItemNode(view()->rootModelNode()))
|
||||
allQmlItems.append(allQmlItemsRecursive(view()->rootModelNode()));
|
||||
|
||||
foreach (const QmlItemNode &item, allQmlItems) {
|
||||
returnList.append(item.states().allStates());
|
||||
@@ -419,26 +420,22 @@ TypeName QmlObjectNode::instanceType(const PropertyName &name) const
|
||||
|
||||
bool QmlObjectNode::instanceHasBinding(const PropertyName &name) const
|
||||
{
|
||||
QmlModelView *modelView = qobject_cast<QmlModelView*>(modelNode().view());
|
||||
if (!modelView)
|
||||
throw new InvalidModelNodeException(__LINE__, __FUNCTION__, __FILE__);
|
||||
|
||||
return nodeInstance().hasBindingForProperty(name);
|
||||
}
|
||||
|
||||
NodeInstance QmlObjectNode::nodeInstance() const
|
||||
{
|
||||
return qmlModelView()->nodeInstanceView()->instanceForModelNode(modelNode());
|
||||
return nodeInstanceView()->instanceForModelNode(modelNode());
|
||||
}
|
||||
|
||||
QmlObjectNode QmlObjectNode::nodeForInstance(const NodeInstance &instance) const
|
||||
{
|
||||
return QmlObjectNode(ModelNode(instance.modelNode(), qmlModelView()));
|
||||
return QmlObjectNode(ModelNode(instance.modelNode(), view()));
|
||||
}
|
||||
|
||||
QmlItemNode QmlObjectNode::itemForInstance(const NodeInstance &instance) const
|
||||
{
|
||||
return QmlItemNode(ModelNode(instance.modelNode(), qmlModelView()));
|
||||
return QmlItemNode(ModelNode(instance.modelNode(), view()));
|
||||
}
|
||||
|
||||
QmlObjectNode::QmlObjectNode()
|
||||
@@ -468,14 +465,14 @@ bool QmlObjectNode::hasNodeParent() const
|
||||
|
||||
bool QmlObjectNode::hasInstanceParent() const
|
||||
{
|
||||
return nodeInstance().parentId() >= 0 && qmlModelView()->nodeInstanceView()->hasInstanceForId(nodeInstance().parentId());
|
||||
return nodeInstance().parentId() >= 0 && nodeInstanceView()->hasInstanceForId(nodeInstance().parentId());
|
||||
}
|
||||
|
||||
bool QmlObjectNode::hasInstanceParentItem() const
|
||||
{
|
||||
return nodeInstance().parentId() >= 0
|
||||
&& qmlModelView()->nodeInstanceView()->hasInstanceForId(nodeInstance().parentId())
|
||||
&& QmlItemNode::isItemOrWindow(qmlModelView()->modelNodeForInternalId(nodeInstance().parentId()));
|
||||
&& nodeInstanceView()->hasInstanceForId(nodeInstance().parentId())
|
||||
&& QmlItemNode::isItemOrWindow(view()->modelNodeForInternalId(nodeInstance().parentId()));
|
||||
}
|
||||
|
||||
|
||||
@@ -487,7 +484,7 @@ void QmlObjectNode::setParentProperty(const NodeAbstractProperty &parentProeprty
|
||||
QmlObjectNode QmlObjectNode::instanceParent() const
|
||||
{
|
||||
if (hasInstanceParent())
|
||||
return nodeForInstance(qmlModelView()->nodeInstanceView()->instanceForId(nodeInstance().parentId()));
|
||||
return nodeForInstance(nodeInstanceView()->instanceForId(nodeInstance().parentId()));
|
||||
|
||||
return QmlObjectNode();
|
||||
}
|
||||
@@ -495,7 +492,7 @@ QmlObjectNode QmlObjectNode::instanceParent() const
|
||||
QmlItemNode QmlObjectNode::instanceParentItem() const
|
||||
{
|
||||
if (hasInstanceParentItem())
|
||||
return itemForInstance(qmlModelView()->nodeInstanceView()->instanceForId(nodeInstance().parentId()));
|
||||
return itemForInstance(nodeInstanceView()->instanceForId(nodeInstance().parentId()));
|
||||
|
||||
return QmlItemNode();
|
||||
}
|
||||
|
@@ -28,12 +28,14 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "qmlstate.h"
|
||||
#include "qmlmodelview.h"
|
||||
#include "abstractview.h"
|
||||
#include <nodelistproperty.h>
|
||||
#include <variantproperty.h>
|
||||
#include <metainfo.h>
|
||||
#include <invalidmodelnodeexception.h>
|
||||
#include "bindingproperty.h"
|
||||
#include "qmlchangeset.h"
|
||||
#include "qmlitemnode.h"
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
@@ -180,7 +182,7 @@ void QmlModelState::addChangeSetIfNotExists(const ModelNode &node)
|
||||
return; //changeSet already there
|
||||
|
||||
ModelNode newChangeSet;
|
||||
if (qmlModelView()->majorQtQuickVersion() > 1)
|
||||
if (view()->majorQtQuickVersion() > 1)
|
||||
newChangeSet = modelNode().view()->createModelNode("QtQuick.PropertyChanges", 2, 0);
|
||||
else
|
||||
newChangeSet = modelNode().view()->createModelNode("QtQuick.PropertyChanges", 1, 0);
|
||||
@@ -295,9 +297,9 @@ QmlModelState QmlModelState::duplicate(const QString &name) const
|
||||
// QmlModelState newState(stateGroup().addState(name));
|
||||
PropertyListType propertyList;
|
||||
propertyList.append(qMakePair(PropertyName("name"), QVariant(name)));
|
||||
QmlModelState newState(createQmlState(qmlModelView(), propertyList));
|
||||
QmlModelState newState(createQmlState(view(), propertyList));
|
||||
foreach (const ModelNode &childNode, modelNode().nodeListProperty("changes").toModelNodeList()) {
|
||||
ModelNode newModelNode(qmlModelView()->createModelNode(childNode.type(), childNode.majorVersion(), childNode.minorVersion()));
|
||||
ModelNode newModelNode(view()->createModelNode(childNode.type(), childNode.majorVersion(), childNode.minorVersion()));
|
||||
foreach (const BindingProperty &bindingProperty, childNode.bindingProperties())
|
||||
newModelNode.bindingProperty(bindingProperty.name()).setExpression(bindingProperty.expression());
|
||||
foreach (const VariantProperty &variantProperty, childNode.variantProperties())
|
||||
@@ -326,11 +328,11 @@ ModelNode QmlModelState::createQmlState(AbstractView *view, const PropertyListTy
|
||||
return view->createModelNode("QtQuick.State", 1, 0, propertyList);
|
||||
}
|
||||
|
||||
QmlModelState QmlModelState::createBaseState(const QmlModelView *view)
|
||||
QmlModelState QmlModelState::createBaseState(const AbstractView *view)
|
||||
{
|
||||
QmlModelState fxState(view->rootModelNode());
|
||||
QmlModelState qmlModelState(view->rootModelNode());
|
||||
|
||||
return fxState;
|
||||
return qmlModelState;
|
||||
}
|
||||
|
||||
} // QmlDesigner
|
||||
|
@@ -223,9 +223,9 @@ void ViewManager::nextFileIsCalledInternally()
|
||||
m_formEditorView.formEditorWidget()->formEditorCrumbleBar()->nextFileIsCalledInternally();
|
||||
}
|
||||
|
||||
QmlModelView *ViewManager::qmlModelView()
|
||||
NodeInstanceView *ViewManager::nodeInstanceView()
|
||||
{
|
||||
return &m_formEditorView;
|
||||
return &m_nodeInstanceView;
|
||||
}
|
||||
|
||||
Model *ViewManager::currentModel() const
|
||||
|
Reference in New Issue
Block a user