summaryrefslogtreecommitdiff
path: root/src/plugins/qmldesigner
diff options
context:
space:
mode:
authorOrgad Shaneh <orgad.shaneh@audiocodes.com>2016-11-14 11:15:40 +0200
committerOrgad Shaneh <orgad.shaneh@audiocodes.com>2016-11-14 11:17:13 +0200
commit9c09ca9e42c7a7f39bf279adcb14ae1691a409bc (patch)
tree4a3e10324aa97692fb57e13d4a9870edc7d3e35b /src/plugins/qmldesigner
parent1a2f649b70c67380d29cdececbce3fad1b97dfca (diff)
parentb5f587efb540cff5f51052a6e30be3139d8b930d (diff)
downloadqt-creator-9c09ca9e42c7a7f39bf279adcb14ae1691a409bc.tar.gz
Merge remote-tracking branch 'origin/4.2'
Change-Id: Ia98031eb87f1859c3736faa0cdd8b655e8a50689
Diffstat (limited to 'src/plugins/qmldesigner')
-rw-r--r--src/plugins/qmldesigner/components/componentcore/theming.cpp26
-rw-r--r--src/plugins/qmldesigner/components/componentcore/theming.h2
-rw-r--r--src/plugins/qmldesigner/components/itemlibrary/itemlibrarywidget.cpp7
-rw-r--r--src/plugins/qmldesigner/components/itemlibrary/itemlibrarywidget.h1
-rw-r--r--src/plugins/qmldesigner/components/propertyeditor/propertyeditorqmlbackend.cpp3
-rw-r--r--src/plugins/qmldesigner/components/propertyeditor/propertyeditorqmlbackend.h1
-rw-r--r--src/plugins/qmldesigner/components/stateseditor/stateseditorwidget.cpp3
-rw-r--r--src/plugins/qmldesigner/components/stateseditor/stateseditorwidget.h1
-rw-r--r--src/plugins/qmldesigner/designercore/include/componenttextmodifier.h4
-rw-r--r--src/plugins/qmldesigner/designercore/instances/nodeinstanceview.cpp2
-rw-r--r--src/plugins/qmldesigner/designercore/model/componenttextmodifier.cpp28
-rw-r--r--src/plugins/qmldesigner/qtquickplugin/source/pathviewv2.qml28
12 files changed, 60 insertions, 46 deletions
diff --git a/src/plugins/qmldesigner/components/componentcore/theming.cpp b/src/plugins/qmldesigner/components/componentcore/theming.cpp
index d1429ff45b..e74a0561e8 100644
--- a/src/plugins/qmldesigner/components/componentcore/theming.cpp
+++ b/src/plugins/qmldesigner/components/componentcore/theming.cpp
@@ -33,11 +33,13 @@
namespace QmlDesigner {
-void Theming::insertTheme(QQmlPropertyMap *map)
+const QVariantMap &Theming::theme()
{
- const QVariantHash creatorTheme = Utils::creatorTheme()->values();
- for (auto it = creatorTheme.constBegin(); it != creatorTheme.constEnd(); ++it)
- map->insert(it.key(), it.value());
+ static QVariantMap map;
+ if (!map.isEmpty())
+ return map;
+
+ map = Utils::creatorTheme()->values();
/* Define QmlDesigner colors and remove alpha channels */
const QColor backgroundColor = Utils::creatorTheme()->color(Utils::Theme::QmlDesigner_BackgroundColor);
@@ -58,18 +60,18 @@ void Theming::insertTheme(QQmlPropertyMap *map)
tabDark = tabDark.darker(260);
}
- map->insert("QmlDesignerBackgroundColorDarker", darkerBackground);
- map->insert("QmlDesignerBackgroundColorDarkAlternate", backgroundColor);
- map->insert("QmlDesignerTabLight", tabLight);
- map->insert("QmlDesignerTabDark", tabDark);
- map->insert("QmlDesignerButtonColor", buttonColor);
- map->insert("QmlDesignerBorderColor", Utils::creatorTheme()->color(Utils::Theme::SplitterColor));
+ map.insert("QmlDesignerBackgroundColorDarker", darkerBackground);
+ map.insert("QmlDesignerBackgroundColorDarkAlternate", backgroundColor);
+ map.insert("QmlDesignerTabLight", tabLight);
+ map.insert("QmlDesignerTabDark", tabDark);
+ map.insert("QmlDesignerButtonColor", buttonColor);
+ map.insert("QmlDesignerBorderColor", Utils::creatorTheme()->color(Utils::Theme::SplitterColor));
+ return map;
}
QString Theming::replaceCssColors(const QString &input)
{
- QQmlPropertyMap map;
- insertTheme(&map);
+ const QVariantMap &map = theme();
QRegExp rx("creatorTheme\\.(\\w+);");
int pos = 0;
diff --git a/src/plugins/qmldesigner/components/componentcore/theming.h b/src/plugins/qmldesigner/components/componentcore/theming.h
index cb582994bf..d9a11ce7b5 100644
--- a/src/plugins/qmldesigner/components/componentcore/theming.h
+++ b/src/plugins/qmldesigner/components/componentcore/theming.h
@@ -33,7 +33,7 @@ namespace QmlDesigner {
class Theming
{
public:
- static void insertTheme(QQmlPropertyMap *map);
+ static const QVariantMap &theme();
static QString replaceCssColors(const QString &input);
static void registerIconProvider(QQmlEngine *engine);
};
diff --git a/src/plugins/qmldesigner/components/itemlibrary/itemlibrarywidget.cpp b/src/plugins/qmldesigner/components/itemlibrary/itemlibrarywidget.cpp
index 039a2be448..ad59291fe6 100644
--- a/src/plugins/qmldesigner/components/itemlibrary/itemlibrarywidget.cpp
+++ b/src/plugins/qmldesigner/components/itemlibrary/itemlibrarywidget.cpp
@@ -83,8 +83,7 @@ ItemLibraryWidget::ItemLibraryWidget(QWidget *parent) :
rootContext->setContextProperty(QStringLiteral("itemLibraryIconWidth"), m_itemIconSize.width());
rootContext->setContextProperty(QStringLiteral("itemLibraryIconHeight"), m_itemIconSize.height());
rootContext->setContextProperty(QStringLiteral("rootView"), this);
- Theming::insertTheme(&m_themeProperties);
- rootContext->setContextProperty(QLatin1String("creatorTheme"), &m_themeProperties);
+ rootContext->setContextProperty(QLatin1String("creatorTheme"), Theming::theme());
m_itemViewQuickWidget->rootContext()->setContextProperty(QStringLiteral("highlightColor"), Utils::StyleHelper::notTooBrightHighlightColor());
@@ -170,8 +169,7 @@ void ItemLibraryWidget::setItemLibraryInfo(ItemLibraryInfo *itemLibraryInfo)
if (itemLibraryInfo)
connect(m_itemLibraryInfo.data(), SIGNAL(entriesChanged()),
this, SLOT(delayedUpdateModel()));
-
- updateModel();
+ delayedUpdateModel();
}
void ItemLibraryWidget::updateImports()
@@ -229,7 +227,6 @@ void ItemLibraryWidget::setModel(Model *model)
if (!model)
return;
setItemLibraryInfo(model->metaInfo().itemLibraryInfo());
- updateModel();
}
void ItemLibraryWidget::setCurrentIndexOfStackedWidget(int index)
diff --git a/src/plugins/qmldesigner/components/itemlibrary/itemlibrarywidget.h b/src/plugins/qmldesigner/components/itemlibrary/itemlibrarywidget.h
index ca8cd82c31..148b0b90dc 100644
--- a/src/plugins/qmldesigner/components/itemlibrary/itemlibrarywidget.h
+++ b/src/plugins/qmldesigner/components/itemlibrary/itemlibrarywidget.h
@@ -132,7 +132,6 @@ private:
QPointer<Model> m_model;
FilterChangeFlag m_filterFlag;
ItemLibraryEntry m_currentitemLibraryEntry;
- QQmlPropertyMap m_themeProperties;
};
}
diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorqmlbackend.cpp b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorqmlbackend.cpp
index 3d4884d9bd..ff299af870 100644
--- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorqmlbackend.cpp
+++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorqmlbackend.cpp
@@ -103,8 +103,7 @@ PropertyEditorQmlBackend::PropertyEditorQmlBackend(PropertyEditorView *propertyE
m_contextObject->setModel(propertyEditor->model());
m_contextObject->insertInQmlContext(context());
- Theming::insertTheme(&m_themeProperties);
- context()->setContextProperty(QLatin1String("creatorTheme"), &m_themeProperties);
+ context()->setContextProperty(QLatin1String("creatorTheme"), Theming::theme());
QObject::connect(&m_backendValuesPropertyMap, &DesignerPropertyMap::valueChanged, propertyEditor, &PropertyEditorView::changeValue);
}
diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorqmlbackend.h b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorqmlbackend.h
index 0e073b20be..a272b35aef 100644
--- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorqmlbackend.h
+++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorqmlbackend.h
@@ -103,7 +103,6 @@ private:
QScopedPointer<PropertyEditorTransaction> m_propertyEditorTransaction;
QScopedPointer<PropertyEditorValue> m_dummyPropertyEditorValue;
QScopedPointer<PropertyEditorContextObject> m_contextObject;
- QQmlPropertyMap m_themeProperties;
};
} //QmlDesigner
diff --git a/src/plugins/qmldesigner/components/stateseditor/stateseditorwidget.cpp b/src/plugins/qmldesigner/components/stateseditor/stateseditorwidget.cpp
index ae869763cd..a9a96cf05d 100644
--- a/src/plugins/qmldesigner/components/stateseditor/stateseditorwidget.cpp
+++ b/src/plugins/qmldesigner/components/stateseditor/stateseditorwidget.cpp
@@ -99,8 +99,7 @@ StatesEditorWidget::StatesEditorWidget(StatesEditorView *statesEditorView, State
rootContext()->setContextProperty(QLatin1String("canAddNewStates"), true);
- Theming::insertTheme(&m_themeProperties);
- rootContext()->setContextProperty(QLatin1String("creatorTheme"), &m_themeProperties);
+ rootContext()->setContextProperty(QLatin1String("creatorTheme"), Theming::theme());
Theming::registerIconProvider(engine());
diff --git a/src/plugins/qmldesigner/components/stateseditor/stateseditorwidget.h b/src/plugins/qmldesigner/components/stateseditor/stateseditorwidget.h
index eb0c26ce04..fc78ecb450 100644
--- a/src/plugins/qmldesigner/components/stateseditor/stateseditorwidget.h
+++ b/src/plugins/qmldesigner/components/stateseditor/stateseditorwidget.h
@@ -67,7 +67,6 @@ private:
QPointer<StatesEditorView> m_statesEditorView;
Internal::StatesEditorImageProvider *m_imageProvider;
QShortcut *m_qmlSourceUpdateShortcut;
- QQmlPropertyMap m_themeProperties;
};
}
diff --git a/src/plugins/qmldesigner/designercore/include/componenttextmodifier.h b/src/plugins/qmldesigner/designercore/include/componenttextmodifier.h
index 01b8f63e53..fc9821864f 100644
--- a/src/plugins/qmldesigner/designercore/include/componenttextmodifier.h
+++ b/src/plugins/qmldesigner/designercore/include/componenttextmodifier.h
@@ -56,8 +56,8 @@ public:
bool renameId(const QString & /* oldId */, const QString & /* newId */) override
{ return false; }
- QStringList autoComplete(QTextDocument * /*textDocument*/, int /*position*/, bool /*explicitComplete*/) override
- { return QStringList(); }
+ QStringList autoComplete(QTextDocument * textDocument, int position, bool explicitComplete) override
+ { return m_originalModifier->autoComplete(textDocument, position, explicitComplete); }
bool moveToComponent(int /* nodeOffset */) override
{ return false; }
diff --git a/src/plugins/qmldesigner/designercore/instances/nodeinstanceview.cpp b/src/plugins/qmldesigner/designercore/instances/nodeinstanceview.cpp
index e32c95685d..6f1fd6ec77 100644
--- a/src/plugins/qmldesigner/designercore/instances/nodeinstanceview.cpp
+++ b/src/plugins/qmldesigner/designercore/instances/nodeinstanceview.cpp
@@ -1231,7 +1231,7 @@ void NodeInstanceView::childrenChanged(const ChildrenChangedCommand &command)
foreach (qint32 instanceId, command.childrenInstances()) {
if (hasInstanceForId(instanceId)) {
NodeInstance instance = instanceForId(instanceId);
- if (!instance.directUpdates()) {
+ if (instance.parentId() == -1 || !instance.directUpdates()) {
instance.setParentId(command.parentInstanceId());
childNodeVector.append(instance.modelNode());
}
diff --git a/src/plugins/qmldesigner/designercore/model/componenttextmodifier.cpp b/src/plugins/qmldesigner/designercore/model/componenttextmodifier.cpp
index a91e47e61e..257c6e67f7 100644
--- a/src/plugins/qmldesigner/designercore/model/componenttextmodifier.cpp
+++ b/src/plugins/qmldesigner/designercore/model/componenttextmodifier.cpp
@@ -55,7 +55,29 @@ void ComponentTextModifier::move(const MoveInfo &moveInfo)
void ComponentTextModifier::indent(int offset, int length)
{
- m_originalModifier->indent(offset, length);
+ int componentStartLine = getLineInDocument(m_originalModifier->textDocument(), m_componentStartOffset);
+ int componentEndLine = getLineInDocument(m_originalModifier->textDocument(), m_componentEndOffset);
+
+ /* Do not indent lines that contain code of the component and the surrounding QML.
+ * example:
+ * delegate: Item { //startLine
+ * ...
+ * } // endLine
+ * Indenting such lines will change the offsets of the component.
+ */
+
+ --componentStartLine;
+ --componentEndLine;
+
+ int startLine = getLineInDocument(m_originalModifier->textDocument(), offset);
+ int endLine = getLineInDocument(m_originalModifier->textDocument(), offset + length);
+
+ if (startLine < componentStartLine)
+ startLine = componentStartLine;
+ if (endLine > componentEndLine)
+ endLine = componentEndLine;
+
+ indentLines(startLine, endLine);
}
void ComponentTextModifier::indentLines(int startLine, int endLine)
@@ -78,7 +100,7 @@ void ComponentTextModifier::flushGroup()
{
m_originalModifier->flushGroup();
- uint textLength = m_originalModifier->text().length();
+ int textLength = m_originalModifier->text().length();
m_componentEndOffset += (textLength - m_startLength);
m_startLength = textLength;
@@ -88,7 +110,7 @@ void ComponentTextModifier::commitGroup()
{
m_originalModifier->commitGroup();
- uint textLength = m_originalModifier->text().length();
+ int textLength = m_originalModifier->text().length();
m_componentEndOffset += (textLength - m_startLength);
m_startLength = textLength;
}
diff --git a/src/plugins/qmldesigner/qtquickplugin/source/pathviewv2.qml b/src/plugins/qmldesigner/qtquickplugin/source/pathviewv2.qml
index 8122bf2d26..693f703596 100644
--- a/src/plugins/qmldesigner/qtquickplugin/source/pathviewv2.qml
+++ b/src/plugins/qmldesigner/qtquickplugin/source/pathviewv2.qml
@@ -53,21 +53,19 @@ PathView {
colorCode: "green"
}
}
- delegate: Component {
- Column {
- spacing: 5
- Rectangle {
- width: 40
- height: 40
- color: colorCode
- anchors.horizontalCenter: parent.horizontalCenter
- }
- Text {
- x: 5
- text: name
- anchors.horizontalCenter: parent.horizontalCenter
- font.bold: true
- }
+ delegate: Column {
+ spacing: 5
+ Rectangle {
+ width: 40
+ height: 40
+ color: colorCode
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+ Text {
+ x: 5
+ text: name
+ anchors.horizontalCenter: parent.horizontalCenter
+ font.bold: true
}
}
}