Commit 3353b0f2 authored by Thomas Hartmann's avatar Thomas Hartmann

QmlDesigner: refactoring PropertyEditor

* Renaming PropertyEditor to PropertyEditorView
* Adding PropertyEditorWidget
* Renaming DeclarativeWidgetView to QuickPropertyEditorView
* Renaming NodeType to PropertyEditorQmlBackend
* Moving PropertyEditorQmlBackend into separate file
* Cleaning up interface of PropertyEditorQmlBackend

Change-Id: I1291feb5880b01d1e2bac09f4eb1e0181ff04d5c
Reviewed-by: default avatarMarco Bubke <marco.bubke@digia.com>
parent 13033734
VPATH += $$PWD
SOURCES += propertyeditor.cpp \
SOURCES += propertyeditorview.cpp \
qmlanchorbindingproxy.cpp \
resetwidget.cpp \
qlayoutobject.cpp \
......@@ -15,10 +15,12 @@ SOURCES += propertyeditor.cpp \
siblingcombobox.cpp \
propertyeditortransaction.cpp \
propertyeditorcontextobject.cpp \
declarativewidgetview.cpp \
gradientlineqmladaptor.cpp
quickpropertyeditorview.cpp \
gradientlineqmladaptor.cpp \
propertyeditorqmlbackend.cpp \
propertyeditorwidget.cpp
HEADERS += propertyeditor.h \
HEADERS += propertyeditorview.h \
qmlanchorbindingproxy.h \
resetwidget.h \
qlayoutobject.h \
......@@ -34,8 +36,10 @@ HEADERS += propertyeditor.h \
propertyeditortransaction.h \
designerpropertymap.h \
propertyeditorcontextobject.h \
declarativewidgetview.h \
gradientlineqmladaptor.h
quickpropertyeditorview.h \
gradientlineqmladaptor.h \
propertyeditorqmlbackend.h \
propertyeditorwidget.h
QT += declarative
......
/****************************************************************************
**
** 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 PROPERTYEDITORQMLBACKEND_H
#define PROPERTYEDITORQMLBACKEND_H
#include "qmlanchorbindingproxy.h"
#include "designerpropertymap.h"
#include "propertyeditorvalue.h"
#include "propertyeditorcontextobject.h"
#include "quickpropertyeditorview.h"
class PropertyEditorValue;
namespace QmlDesigner {
class PropertyEditorTransaction;
class PropertyEditorView;
class PropertyEditorQmlBackend {
public:
PropertyEditorQmlBackend(PropertyEditorView *propertyEditor);
~PropertyEditorQmlBackend();
void setup(const QmlObjectNode &fxObjectNode, const QString &stateName, const QUrl &qmlSpecificsFile, PropertyEditorView *propertyEditor);
void initialSetup(const TypeName &typeName, const QUrl &qmlSpecificsFile, PropertyEditorView *propertyEditor);
void setValue(const QmlObjectNode &fxObjectNode, const PropertyName &name, const QVariant &value);
QDeclarativeContext *context();
PropertyEditorContextObject* contextObject();
QWidget *widget();
void setSource(const QUrl& url);
Internal::QmlAnchorBindingProxy &backendAnchorBinding();
DesignerPropertyMap<PropertyEditorValue> &backendValuesPropertyMap();
PropertyEditorTransaction *propertyEditorTransaction();
PropertyEditorValue *propertyValueForName(const QString &propertyName);
static QString propertyEditorResourcesPath();
private:
void createPropertyEditorValue(const QmlObjectNode &qmlObjectNode,
const PropertyName &name, const QVariant &value,
PropertyEditorView *propertyEditor);
void setupPropertyEditorValue(const PropertyName &name, PropertyEditorView *propertyEditor, const QString &type);
private:
QuickPropertyEditorView *m_view;
Internal::QmlAnchorBindingProxy m_backendAnchorBinding;
DesignerPropertyMap<PropertyEditorValue> m_backendValuesPropertyMap;
QScopedPointer<PropertyEditorTransaction> m_propertyEditorTransaction;
QScopedPointer<PropertyEditorValue> m_dummyPropertyEditorValue;
QScopedPointer<PropertyEditorContextObject> m_contextObject;
};
} //QmlDesigner
#endif //PROPERTYEDITORQMLBACKEND_H
......@@ -34,7 +34,7 @@
namespace QmlDesigner {
PropertyEditorTransaction::PropertyEditorTransaction(QmlDesigner::PropertyEditor *propertyEditor) : QObject(propertyEditor), m_propertyEditor(propertyEditor), m_timerId(-1)
PropertyEditorTransaction::PropertyEditorTransaction(QmlDesigner::PropertyEditorView *propertyEditor) : QObject(propertyEditor), m_propertyEditor(propertyEditor), m_timerId(-1)
{
}
......
......@@ -30,7 +30,7 @@
#ifndef PROPERTYEDITORTRANSACTION_H
#define PROPERTYEDITORTRANSACTION_H
#include "propertyeditor.h"
#include "propertyeditorview.h"
namespace QmlDesigner {
......@@ -38,7 +38,7 @@ class PropertyEditorTransaction : public QObject
{
Q_OBJECT
public:
PropertyEditorTransaction(QmlDesigner::PropertyEditor *propertyEditor);
PropertyEditorTransaction(QmlDesigner::PropertyEditorView *propertyEditor);
public slots:
void start();
......@@ -47,7 +47,7 @@ protected:
void timerEvent(QTimerEvent *event);
private:
QmlDesigner::PropertyEditor *m_propertyEditor;
QmlDesigner::PropertyEditorView *m_propertyEditor;
QmlDesigner::RewriterTransaction m_rewriterTransaction;
int m_timerId;
};
......
......@@ -27,19 +27,15 @@
**
****************************************************************************/
#ifndef PROPERTYEDITOR_H
#define PROPERTYEDITOR_H
#ifndef PROPERTYEDITORVIEW_H
#define PROPERTYEDITORVIEW_H
#include <abstractview.h>
#include <declarativewidgetview.h>
#include <QHash>
#include <QStackedWidget>
#include <QTimer>
#include "qmlanchorbindingproxy.h"
#include "designerpropertymap.h"
#include "propertyeditorvalue.h"
#include "propertyeditorcontextobject.h"
#include "propertyeditorqmlbackend.h"
#include "propertyeditorwidget.h"
QT_BEGIN_NAMESPACE
class QShortcut;
......@@ -47,38 +43,20 @@ class QStackedWidget;
class QTimer;
QT_END_NAMESPACE
class PropertyEditorValue;
namespace QmlDesigner {
class PropertyEditorTransaction;
class CollapseButton;
class StackedWidget;
class PropertyEditorWidget;
class PropertyEditorView;
class PropertyEditor: public AbstractView
class PropertyEditorView: public AbstractView
{
Q_OBJECT
class NodeType {
public:
NodeType(PropertyEditor *propertyEditor);
~NodeType();
void setup(const QmlObjectNode &fxObjectNode, const QString &stateName, const QUrl &qmlSpecificsFile, PropertyEditor *propertyEditor);
void initialSetup(const TypeName &typeName, const QUrl &qmlSpecificsFile, PropertyEditor *propertyEditor);
void setValue(const QmlObjectNode &fxObjectNode, const PropertyName &name, const QVariant &value);
DeclarativeWidgetView *m_view;
Internal::QmlAnchorBindingProxy m_backendAnchorBinding;
DesignerPropertyMap<PropertyEditorValue> m_backendValuesPropertyMap;
QScopedPointer<PropertyEditorTransaction> m_propertyEditorTransaction;
QScopedPointer<PropertyEditorValue> m_dummyPropertyEditorValue;
QScopedPointer<PropertyEditorContextObject> m_contextObject;
};
public:
PropertyEditor(QWidget *parent = 0);
~PropertyEditor();
PropertyEditorView(QWidget *parent = 0);
~PropertyEditorView();
void setQmlDir(const QString &qmlDirPath);
......@@ -149,38 +127,20 @@ private: //functions
void delayedResetView();
private: //variables
ModelNode m_selectedNode;
QWidget *m_parent;
QShortcut *m_updateShortcut;
int m_timerId;
StackedWidget* m_stackedWidget;
PropertyEditorWidget* m_stackedWidget;
QString m_qmlDir;
QHash<QString, NodeType *> m_typeHash;
NodeType *m_currentType;
QHash<QString, PropertyEditorQmlBackend *> m_typeHash;
PropertyEditorQmlBackend *m_currentType;
bool m_locked;
bool m_setupCompleted;
QTimer *m_singleShotTimer;
};
} //QmlDesigner
class StackedWidget : public QStackedWidget
{
Q_OBJECT
public:
StackedWidget(QWidget *parent = 0) : QStackedWidget(parent) {}
signals:
void resized();
protected:
void resizeEvent(QResizeEvent * event)
{
QStackedWidget::resizeEvent(event);
emit resized();
}
};
}
#endif // PROPERTYEDITOR_H
#endif // PROPERTYEDITORVIEW_H
/****************************************************************************
**
** 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 "propertyeditorwidget.h"
namespace QmlDesigner {
PropertyEditorWidget::PropertyEditorWidget(QWidget *parent) : QStackedWidget(parent)
{
}
void PropertyEditorWidget::resizeEvent(QResizeEvent * event)
{
QStackedWidget::resizeEvent(event);
emit resized();
}
}
/****************************************************************************
**
** 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 PROPERTYEDITORWIDGET_H
#define PROPERTYEDITORWIDGET_H
#include <QStackedWidget>
namespace QmlDesigner {
class PropertyEditorWidget : public QStackedWidget
{
Q_OBJECT
public:
PropertyEditorWidget(QWidget *parent = 0);
signals:
void resized();
protected:
void resizeEvent(QResizeEvent * event);
};
} //QmlDesigner
#endif //PROPERTYEDITORWIDGET_H
......@@ -27,7 +27,7 @@
**
****************************************************************************/
#include "declarativewidgetview.h"
#include "quickpropertyeditorview.h"
#include <QDeclarativeItem>
#include <QDeclarativeEngine>
......@@ -35,7 +35,7 @@
namespace QmlDesigner {
void DeclarativeWidgetView::execute()
void QuickPropertyEditorView::execute()
{
if (m_root)
delete m_root.data();
......@@ -52,47 +52,47 @@ void DeclarativeWidgetView::execute()
}
}
DeclarativeWidgetView::DeclarativeWidgetView(QWidget *parent) :
QuickPropertyEditorView::QuickPropertyEditorView(QWidget *parent) :
QWidget(parent)
{
}
QUrl DeclarativeWidgetView::source() const
QUrl QuickPropertyEditorView::source() const
{
return m_source;
}
void DeclarativeWidgetView::setSource(const QUrl& url)
void QuickPropertyEditorView::setSource(const QUrl& url)
{
m_source = url;
execute();
}
QDeclarativeEngine* DeclarativeWidgetView::engine()
QDeclarativeEngine* QuickPropertyEditorView::engine()
{
return &m_engine;
}
QWidget *DeclarativeWidgetView::rootWidget() const
QWidget *QuickPropertyEditorView::rootWidget() const
{
return m_root.data();
}
QDeclarativeContext* DeclarativeWidgetView::rootContext()
QDeclarativeContext* QuickPropertyEditorView::rootContext()
{
return m_engine.rootContext();
}
DeclarativeWidgetView::Status DeclarativeWidgetView::status() const
QuickPropertyEditorView::Status QuickPropertyEditorView::status() const
{
if (!m_component)
return DeclarativeWidgetView::Null;
return QuickPropertyEditorView::Null;
return DeclarativeWidgetView::Status(m_component->status());
return QuickPropertyEditorView::Status(m_component->status());
}
void DeclarativeWidgetView::continueExecute()
void QuickPropertyEditorView::continueExecute()
{
disconnect(m_component.data(), SIGNAL(statusChanged(QDeclarativeComponent::Status)), this, SLOT(continueExecute()));
......@@ -121,7 +121,7 @@ void DeclarativeWidgetView::continueExecute()
emit statusChanged(status());
}
void DeclarativeWidgetView::setRootWidget(QWidget *widget)
void QuickPropertyEditorView::setRootWidget(QWidget *widget)
{
if (m_root.data() == widget)
return;
......
......@@ -27,12 +27,13 @@
**
****************************************************************************/
#ifndef DECLARATIVEWIDGETVIEW_H
#define DECLARATIVEWIDGETVIEW_H
#ifndef QUICKPROERTYEDITORVIEW_H
#define QUICKPROERTYEDITORVIEW_H
#include <QWidget>
#include <QUrl>
#include <QDeclarativeEngine>
#include <QDeclarativeContext>
QT_BEGIN_NAMESPACE
class QDeclarativeContext;
......@@ -42,13 +43,13 @@ QT_END_NAMESPACE
namespace QmlDesigner {
class DeclarativeWidgetView : public QWidget
class QuickPropertyEditorView : public QWidget
{
Q_OBJECT
Q_PROPERTY(QUrl source READ source WRITE setSource DESIGNABLE true)
public:
explicit DeclarativeWidgetView(QWidget *parent = 0);
explicit QuickPropertyEditorView(QWidget *parent = 0);
QUrl source() const;
void setSource(const QUrl&);
......@@ -62,7 +63,7 @@ public:
Status status() const;
signals:
void statusChanged(DeclarativeWidgetView::Status);
void statusChanged(QuickPropertyEditorView::Status);
protected:
void setRootWidget(QWidget *);
......@@ -81,4 +82,4 @@ private:
} //QmlDesigner
#endif // DECLARATIVEWIDGETVIEW_H
#endif // QUICKPROERTYEDITORVIEW_H
......@@ -38,7 +38,7 @@
#include <navigatorview.h>
#include <stateseditorview.h>
#include <formeditorview.h>
#include <propertyeditor.h>
#include <propertyeditorview.h>
#include <componentview.h>
#include <debugview.h>
#include <QWidgetAction>
......@@ -111,7 +111,7 @@ private: // variables
FormEditorView m_formEditorView;
ItemLibraryView m_itemLibraryView;
NavigatorView m_navigatorView;
PropertyEditor m_propertyEditorView;
PropertyEditorView m_propertyEditorView;
StatesEditorView m_statesEditorView;
NodeInstanceView m_nodeInstanceView;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment