Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Q
qt-creator
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tobias Hunger
qt-creator
Commits
e3376b6d
Commit
e3376b6d
authored
Feb 10, 2011
by
Marco Bubke
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
QmlDesigner: Change importAdded and importRemoved in importsChanged
parent
1b3f8c57
Changes
30
Hide whitespace changes
Inline
Side-by-side
Showing
30 changed files
with
90 additions
and
136 deletions
+90
-136
src/plugins/qmldesigner/components/formeditor/dragtool.cpp
src/plugins/qmldesigner/components/formeditor/dragtool.cpp
+4
-1
src/plugins/qmldesigner/components/formeditor/formeditorview.cpp
...gins/qmldesigner/components/formeditor/formeditorview.cpp
+1
-6
src/plugins/qmldesigner/components/formeditor/formeditorview.h
...lugins/qmldesigner/components/formeditor/formeditorview.h
+1
-2
src/plugins/qmldesigner/components/integration/componentview.cpp
...gins/qmldesigner/components/integration/componentview.cpp
+1
-1
src/plugins/qmldesigner/components/integration/componentview.h
...lugins/qmldesigner/components/integration/componentview.h
+1
-0
src/plugins/qmldesigner/components/integration/designdocumentcontroller.cpp
...igner/components/integration/designdocumentcontroller.cpp
+3
-4
src/plugins/qmldesigner/components/integration/designdocumentcontrollerview.cpp
...r/components/integration/designdocumentcontrollerview.cpp
+5
-0
src/plugins/qmldesigner/components/integration/designdocumentcontrollerview.h
...ner/components/integration/designdocumentcontrollerview.h
+2
-0
src/plugins/qmldesigner/components/itemlibrary/itemlibraryview.cpp
...ns/qmldesigner/components/itemlibrary/itemlibraryview.cpp
+1
-6
src/plugins/qmldesigner/components/itemlibrary/itemlibraryview.h
...gins/qmldesigner/components/itemlibrary/itemlibraryview.h
+1
-2
src/plugins/qmldesigner/components/itemlibrary/itemlibrarywidget.cpp
.../qmldesigner/components/itemlibrary/itemlibrarywidget.cpp
+6
-4
src/plugins/qmldesigner/components/navigator/navigatorview.cpp
...lugins/qmldesigner/components/navigator/navigatorview.cpp
+1
-7
src/plugins/qmldesigner/components/navigator/navigatorview.h
src/plugins/qmldesigner/components/navigator/navigatorview.h
+1
-2
src/plugins/qmldesigner/components/stateseditor/stateseditorview.cpp
.../qmldesigner/components/stateseditor/stateseditorview.cpp
+1
-1
src/plugins/qmldesigner/designercore/include/abstractview.h
src/plugins/qmldesigner/designercore/include/abstractview.h
+1
-2
src/plugins/qmldesigner/designercore/include/forwardview.h
src/plugins/qmldesigner/designercore/include/forwardview.h
+3
-7
src/plugins/qmldesigner/designercore/include/model.h
src/plugins/qmldesigner/designercore/include/model.h
+1
-2
src/plugins/qmldesigner/designercore/include/nodeinstanceview.h
...ugins/qmldesigner/designercore/include/nodeinstanceview.h
+1
-2
src/plugins/qmldesigner/designercore/include/qmlmodelview.h
src/plugins/qmldesigner/designercore/include/qmlmodelview.h
+1
-0
src/plugins/qmldesigner/designercore/include/rewriterview.h
src/plugins/qmldesigner/designercore/include/rewriterview.h
+1
-0
src/plugins/qmldesigner/designercore/instances/nodeinstanceview.cpp
...s/qmldesigner/designercore/instances/nodeinstanceview.cpp
+1
-7
src/plugins/qmldesigner/designercore/model/abstractview.cpp
src/plugins/qmldesigner/designercore/model/abstractview.cpp
+0
-16
src/plugins/qmldesigner/designercore/model/model.cpp
src/plugins/qmldesigner/designercore/model/model.cpp
+21
-48
src/plugins/qmldesigner/designercore/model/model_p.h
src/plugins/qmldesigner/designercore/model/model_p.h
+2
-2
src/plugins/qmldesigner/designercore/model/modelmerger.cpp
src/plugins/qmldesigner/designercore/model/modelmerger.cpp
+3
-5
src/plugins/qmldesigner/designercore/model/qmlmodelview.cpp
src/plugins/qmldesigner/designercore/model/qmlmodelview.cpp
+6
-2
src/plugins/qmldesigner/designercore/model/rewriterview.cpp
src/plugins/qmldesigner/designercore/model/rewriterview.cpp
+9
-0
src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp
...gins/qmldesigner/designercore/model/texttomodelmerger.cpp
+2
-2
src/plugins/qmldesigner/designercore/model/viewlogger.cpp
src/plugins/qmldesigner/designercore/model/viewlogger.cpp
+8
-4
src/plugins/qmldesigner/designercore/model/viewlogger.h
src/plugins/qmldesigner/designercore/model/viewlogger.h
+1
-1
No files found.
src/plugins/qmldesigner/components/formeditor/dragtool.cpp
View file @
e3376b6d
...
...
@@ -262,6 +262,7 @@ void DragTool::dragEnterEvent(QGraphicsSceneDragDropEvent * event)
{
if
(
event
->
mimeData
()
->
hasFormat
(
"application/vnd.bauhaus.itemlibraryinfo"
)
||
event
->
mimeData
()
->
hasFormat
(
"application/vnd.bauhaus.libraryresource"
))
{
QList
<
Import
>
importToBeAddedList
;
m_blockMove
=
false
;
if
(
event
->
mimeData
()
->
hasFormat
(
"application/vnd.bauhaus.itemlibraryinfo"
))
{
Q_ASSERT
(
!
event
->
mimeData
()
->
data
(
"application/vnd.bauhaus.itemlibraryinfo"
).
isEmpty
());
...
...
@@ -272,12 +273,14 @@ void DragTool::dragEnterEvent(QGraphicsSceneDragDropEvent * event)
Import
newImport
=
Import
::
createLibraryImport
(
newImportUrl
,
newImportVersion
);
if
(
!
view
()
->
model
()
->
imports
().
contains
(
newImport
))
{
view
()
->
model
()
->
addImport
(
newImport
);
importToBeAddedList
.
append
(
newImport
);
}
}
}
view
()
->
model
()
->
changeImports
(
importToBeAddedList
,
QList
<
Import
>
());
if
(
!
m_rewriterTransaction
.
isValid
())
{
view
()
->
clearSelectedModelNodes
();
m_rewriterTransaction
=
view
()
->
beginRewriterTransaction
();
...
...
src/plugins/qmldesigner/components/formeditor/formeditorview.cpp
View file @
e3376b6d
...
...
@@ -148,12 +148,7 @@ void FormEditorView::modelAboutToBeDetached(Model *model)
QmlModelView
::
modelAboutToBeDetached
(
model
);
}
void
FormEditorView
::
importAdded
(
const
Import
&
)
{
reset
();
}
void
FormEditorView
::
importRemoved
(
const
Import
&
)
void
FormEditorView
::
importsChanged
(
const
QList
<
Import
>
&
/*addedImports*/
,
const
QList
<
Import
>
&
/*removedImports*/
)
{
reset
();
}
...
...
src/plugins/qmldesigner/components/formeditor/formeditorview.h
View file @
e3376b6d
...
...
@@ -70,8 +70,7 @@ public:
void
modelAttached
(
Model
*
model
);
void
modelAboutToBeDetached
(
Model
*
model
);
void
importAdded
(
const
Import
&
import
);
void
importRemoved
(
const
Import
&
import
);
void
importsChanged
(
const
QList
<
Import
>
&
addedImports
,
const
QList
<
Import
>
&
removedImports
);
void
nodeCreated
(
const
ModelNode
&
createdNode
);
void
nodeAboutToBeRemoved
(
const
ModelNode
&
removedNode
);
...
...
src/plugins/qmldesigner/components/integration/componentview.cpp
View file @
e3376b6d
...
...
@@ -185,6 +185,6 @@ void ComponentView::nodeOrderChanged(const NodeListProperty &/*listProperty*/, c
void
ComponentView
::
auxiliaryDataChanged
(
const
ModelNode
&
/*node*/
,
const
QString
&
/*name*/
,
const
QVariant
&
/*data*/
)
{}
void
ComponentView
::
customNotification
(
const
AbstractView
*
/*view*/
,
const
QString
&
/*identifier*/
,
const
QList
<
ModelNode
>
&
/*nodeList*/
,
const
QList
<
QVariant
>
&
/*data*/
)
{}
void
ComponentView
::
importsChanged
(
const
QList
<
Import
>
&
/*addedImports*/
,
const
QList
<
Import
>
&
/*removedImports*/
)
{}
}
// namespace QmlDesigner
src/plugins/qmldesigner/components/integration/componentview.h
View file @
e3376b6d
...
...
@@ -95,6 +95,7 @@ public:
void
customNotification
(
const
AbstractView
*
view
,
const
QString
&
identifier
,
const
QList
<
ModelNode
>
&
nodeList
,
const
QList
<
QVariant
>
&
data
);
void
importsChanged
(
const
QList
<
Import
>
&
addedImports
,
const
QList
<
Import
>
&
removedImports
);
QStandardItemModel
*
standardItemModel
()
const
;
...
...
src/plugins/qmldesigner/components/integration/designdocumentcontroller.cpp
View file @
e3376b6d
...
...
@@ -481,8 +481,7 @@ void DesignDocumentController::copySelected()
QScopedPointer
<
Model
>
model
(
Model
::
create
(
"Qt/Rectangle"
));
model
->
setMetaInfo
(
m_d
->
model
->
metaInfo
());
model
->
setFileUrl
(
m_d
->
model
->
fileUrl
());
foreach
(
const
Import
&
import
,
m_d
->
model
->
imports
())
model
->
addImport
(
import
);
model
->
changeImports
(
m_d
->
model
->
imports
(),
QList
<
Import
>
());
Q_ASSERT
(
model
);
...
...
@@ -578,8 +577,8 @@ void DesignDocumentController::paste()
QScopedPointer
<
Model
>
model
(
Model
::
create
(
"empty"
));
model
->
setMetaInfo
(
m_d
->
model
->
metaInfo
());
model
->
setFileUrl
(
m_d
->
model
->
fileUrl
());
foreach
(
const
Import
&
import
,
m_d
->
model
->
imports
())
model
->
addImport
(
import
);
model
->
changeImports
(
m_d
->
model
->
imports
(),
QList
<
Import
>
());
Q_ASSERT
(
model
);
if
(
!
m_d
->
model
)
...
...
src/plugins/qmldesigner/components/integration/designdocumentcontrollerview.cpp
View file @
e3376b6d
...
...
@@ -107,6 +107,11 @@ void DesignDocumentControllerView::actualStateChanged(const ModelNode &/*node*/)
{
}
void
DesignDocumentControllerView
::
importsChanged
(
const
QList
<
Import
>
&
/*addedImports*/
,
const
QList
<
Import
>
&
/*removedImports*/
)
{
}
static
QStringList
arrayToStringList
(
const
QByteArray
&
byteArray
)
{
QString
str
(
QString
::
fromLatin1
(
byteArray
));
...
...
src/plugins/qmldesigner/components/integration/designdocumentcontrollerview.h
View file @
e3376b6d
...
...
@@ -75,6 +75,8 @@ public:
void
actualStateChanged
(
const
ModelNode
&
node
);
void
importsChanged
(
const
QList
<
Import
>
&
addedImports
,
const
QList
<
Import
>
&
removedImports
);
ModelNode
insertModel
(
const
ModelNode
&
modelNode
)
{
return
m_modelMerger
.
insertModel
(
modelNode
);
}
void
replaceModel
(
const
ModelNode
&
modelNode
)
...
...
src/plugins/qmldesigner/components/itemlibrary/itemlibraryview.cpp
View file @
e3376b6d
...
...
@@ -32,12 +32,7 @@ void ItemLibraryView::modelAboutToBeDetached(Model *model)
m_widget
->
setModel
(
0
);
}
void
ItemLibraryView
::
importAdded
(
const
Import
&
)
{
updateImports
();
}
void
ItemLibraryView
::
importRemoved
(
const
Import
&
)
void
ItemLibraryView
::
importsChanged
(
const
QList
<
Import
>
&
/*addedImports*/
,
const
QList
<
Import
>
&
/*removedImports*/
)
{
updateImports
();
}
...
...
src/plugins/qmldesigner/components/itemlibrary/itemlibraryview.h
View file @
e3376b6d
...
...
@@ -58,8 +58,7 @@ public:
void
modelAttached
(
Model
*
model
);
void
modelAboutToBeDetached
(
Model
*
model
);
void
importAdded
(
const
Import
&
import
);
void
importRemoved
(
const
Import
&
import
);
void
importsChanged
(
const
QList
<
Import
>
&
addedImports
,
const
QList
<
Import
>
&
removedImports
);
void
nodeCreated
(
const
ModelNode
&
createdNode
);
void
nodeRemoved
(
const
ModelNode
&
removedNode
,
const
NodeAbstractProperty
&
parentProperty
,
PropertyChangeFlags
propertyChange
);
...
...
src/plugins/qmldesigner/components/itemlibrary/itemlibrarywidget.cpp
View file @
e3376b6d
...
...
@@ -500,18 +500,20 @@ void ItemLibraryWidget::wheelEvent(QWheelEvent *event)
{
if
(
!
m_d
->
model
)
return
;
QList
<
Import
>
toBeRemovedImportList
;
foreach
(
const
Import
&
import
,
m_d
->
model
->
imports
())
if
(
import
.
isLibraryImport
()
&&
import
.
url
().
compare
(
name
,
Qt
::
CaseInsensitive
)
==
0
)
m_d
->
model
->
removeImport
(
import
);
toBeRemovedImportList
.
append
(
import
);
m_d
->
model
->
changeImports
(
QList
<
Import
>
(),
toBeRemovedImportList
);
}
void
ItemLibraryWidget
::
addImport
(
const
QString
&
name
,
const
QString
&
version
)
{
if
(
!
m_d
->
model
)
return
;
m_d
->
model
->
addImport
(
Import
::
createLibraryImport
(
name
,
version
));
m_d
->
model
->
changeImports
(
QList
<
Import
>
()
<<
Import
::
createLibraryImport
(
name
,
version
),
QList
<
Import
>
());
}
}
src/plugins/qmldesigner/components/navigator/navigatorview.cpp
View file @
e3376b6d
...
...
@@ -111,17 +111,11 @@ void NavigatorView::modelAboutToBeDetached(Model *model)
AbstractView
::
modelAboutToBeDetached
(
model
);
}
void
NavigatorView
::
import
Added
(
const
Import
&
)
void
NavigatorView
::
import
sChanged
(
const
QList
<
Import
>
&
/*addedImports*/
,
const
QList
<
Import
>
&
/*removedImports*/
)
{
treeWidget
()
->
update
();
}
void
NavigatorView
::
importRemoved
(
const
Import
&
)
{
treeWidget
()
->
update
();
}
void
NavigatorView
::
nodeCreated
(
const
ModelNode
&
/*createdNode*/
)
{
}
...
...
src/plugins/qmldesigner/components/navigator/navigatorview.h
View file @
e3376b6d
...
...
@@ -66,8 +66,7 @@ public:
void
modelAttached
(
Model
*
model
);
void
modelAboutToBeDetached
(
Model
*
model
);
void
importAdded
(
const
Import
&
import
);
void
importRemoved
(
const
Import
&
import
);
void
importsChanged
(
const
QList
<
Import
>
&
addedImports
,
const
QList
<
Import
>
&
removedImports
);
void
nodeCreated
(
const
ModelNode
&
createdNode
);
void
nodeRemoved
(
const
ModelNode
&
removedNode
,
const
NodeAbstractProperty
&
parentProperty
,
PropertyChangeFlags
propertyChange
);
...
...
src/plugins/qmldesigner/components/stateseditor/stateseditorview.cpp
View file @
e3376b6d
...
...
@@ -141,7 +141,7 @@ void StatesEditorView::addState()
try
{
if
(
rootStateGroup
().
allStates
().
count
()
<
1
)
model
()
->
addImport
(
Import
::
createLibraryImport
(
"QtQuick"
,
"1.0"
));
model
()
->
changeImports
(
QList
<
Import
>
()
<<
Import
::
createLibraryImport
(
"QtQuick"
,
"1.0"
),
QList
<
Import
>
(
));
ModelNode
newState
=
rootStateGroup
().
addState
(
newStateName
);
setCurrentState
(
newState
);
}
catch
(
RewritingException
&
e
)
{
...
...
src/plugins/qmldesigner/designercore/include/abstractview.h
View file @
e3376b6d
...
...
@@ -154,8 +154,7 @@ public:
virtual
void
nodeOrderChanged
(
const
NodeListProperty
&
listProperty
,
const
ModelNode
&
movedNode
,
int
oldIndex
)
=
0
;
virtual
void
importAdded
(
const
Import
&
import
);
virtual
void
importRemoved
(
const
Import
&
import
);
virtual
void
importsChanged
(
const
QList
<
Import
>
&
addedImports
,
const
QList
<
Import
>
&
removedImports
)
=
0
;
virtual
void
auxiliaryDataChanged
(
const
ModelNode
&
node
,
const
QString
&
name
,
const
QVariant
&
data
);
...
...
src/plugins/qmldesigner/designercore/include/forwardview.h
View file @
e3376b6d
...
...
@@ -74,9 +74,7 @@ public:
void
fileUrlChanged
(
const
QUrl
&
oldUrl
,
const
QUrl
&
newUrl
);
void
nodeOrderChanged
(
const
NodeListProperty
&
listProperty
,
const
ModelNode
&
movedNode
,
int
oldIndex
);
void
importAdded
(
const
Import
&
import
);
void
importRemoved
(
const
Import
&
import
);
void
importsChanged
(
const
QList
<
Import
>
&
addedImports
,
const
QList
<
Import
>
&
removedImports
);
void
auxiliaryDataChanged
(
const
ModelNode
&
node
,
const
QString
&
name
,
const
QVariant
&
data
);
...
...
@@ -224,12 +222,10 @@ void ForwardView<ViewType>::nodeOrderChanged(const NodeListProperty &listPropert
}
template
<
class
ViewType
>
void
ForwardView
<
ViewType
>::
import
Added
(
const
Import
&
import
)
void
ForwardView
<
ViewType
>::
import
Changed
(
const
QList
<
Import
>
&
addedImports
,
const
QList
<
Import
>
&
removedImports
)
{
AbstractView
::
importAdded
(
import
);
foreach
(
const
ViewTypePointer
&
view
,
m_targetViewList
)
view
->
import
Added
(
i
mport
);
view
->
import
Changed
(
addedImport
,
removedI
mport
);
}
template
<
class
ViewType
>
...
...
src/plugins/qmldesigner/designercore/include/model.h
View file @
e3376b6d
...
...
@@ -105,8 +105,7 @@ public:
// Imports:
QList
<
Import
>
imports
()
const
;
void
addImport
(
const
Import
&
import
);
void
removeImport
(
const
Import
&
import
);
void
changeImports
(
const
QList
<
Import
>
&
importsToBeAdded
,
const
QList
<
Import
>
&
importsToBeRemoved
);
RewriterView
*
rewriterView
()
const
;
...
...
src/plugins/qmldesigner/designercore/include/nodeinstanceview.h
View file @
e3376b6d
...
...
@@ -103,8 +103,7 @@ public:
void
scriptFunctionsChanged
(
const
ModelNode
&
node
,
const
QStringList
&
scriptFunctionList
);
void
instancePropertyChange
(
const
QList
<
QPair
<
ModelNode
,
QString
>
>
&
propertyList
);
void
instancesCompleted
(
const
QVector
<
ModelNode
>
&
completedNodeList
);
void
importAdded
(
const
Import
&
import
);
void
importRemoved
(
const
Import
&
import
);
void
importsChanged
(
const
QList
<
Import
>
&
addedImports
,
const
QList
<
Import
>
&
removedImports
);
void
instanceInformationsChange
(
const
QVector
<
ModelNode
>
&
nodeList
);
void
instancesRenderImageChanged
(
const
QVector
<
ModelNode
>
&
nodeList
);
void
instancesPreviewImageChanged
(
const
QVector
<
ModelNode
>
&
nodeList
);
...
...
src/plugins/qmldesigner/designercore/include/qmlmodelview.h
View file @
e3376b6d
...
...
@@ -119,6 +119,7 @@ public:
void
scriptFunctionsChanged
(
const
ModelNode
&
node
,
const
QStringList
&
scriptFunctionList
);
void
selectedNodesChanged
(
const
QList
<
ModelNode
>
&
selectedNodeList
,
const
QList
<
ModelNode
>
&
lastSelectedNodeList
);
void
importsChanged
(
const
QList
<
Import
>
&
addedImports
,
const
QList
<
Import
>
&
removedImports
);
protected:
NodeInstance
instanceForModelNode
(
const
ModelNode
&
modelNode
);
...
...
src/plugins/qmldesigner/designercore/include/rewriterview.h
View file @
e3376b6d
...
...
@@ -152,6 +152,7 @@ public:
void
importAdded
(
const
Import
&
import
);
void
importRemoved
(
const
Import
&
import
);
void
importsChanged
(
const
QList
<
Import
>
&
addedImports
,
const
QList
<
Import
>
&
removedImports
);
void
fileUrlChanged
(
const
QUrl
&
oldUrl
,
const
QUrl
&
newUrl
);
...
...
src/plugins/qmldesigner/designercore/instances/nodeinstanceview.cpp
View file @
e3376b6d
...
...
@@ -443,13 +443,7 @@ void NodeInstanceView::instancesCompleted(const QVector<ModelNode> &/*completedN
{
}
void
NodeInstanceView
::
importAdded
(
const
Import
&
/*import*/
)
{
restartProcess
();
}
void
NodeInstanceView
::
importRemoved
(
const
Import
&
/*import*/
)
void
NodeInstanceView
::
importsChanged
(
const
QList
<
Import
>
&
/*addedImports*/
,
const
QList
<
Import
>
&
/*removedImports*/
)
{
restartProcess
();
}
...
...
src/plugins/qmldesigner/designercore/model/abstractview.cpp
View file @
e3376b6d
...
...
@@ -206,22 +206,6 @@ void AbstractView::fileUrlChanged(const QUrl &/*oldUrl*/, const QUrl &/*newUrl*/
{
}
/*!
\fn AbstractView::importAdded(const Import &import)
\brief Called when an import has been added to the model
*/
void
AbstractView
::
importAdded
(
const
Import
&
/*import*/
)
{
}
/*!
\fn AbstractView::importRemoved(const Import &import)
\brief Called when an import has been removed from the model
*/
void
AbstractView
::
importRemoved
(
const
Import
&
/*import*/
)
{
}
/*!
\fn void AbstractView::nodeAboutToBeRemoved(const ModelNode &)
\brief this is called if a node will be removed
...
...
src/plugins/qmldesigner/designercore/model/model.cpp
View file @
e3376b6d
...
...
@@ -132,58 +132,36 @@ Model *ModelPrivate::create(QString type, int major, int minor)
return
model
;
}
void
ModelPrivate
::
addImport
(
const
Import
&
impor
t
)
void
ModelPrivate
::
changeImports
(
const
QList
<
Import
>
&
toBeAddedImportList
,
const
QList
<
Import
>
&
toBeRemovedImportLis
t
)
{
if
(
m_imports
.
contains
(
import
))
return
;
m_imports
.
append
(
import
);
notifyImportAdded
(
import
);
}
void
ModelPrivate
::
removeImport
(
const
Import
&
import
)
{
if
(
!
m_imports
.
removeOne
(
import
))
return
;
notifyImportRemoved
(
import
);
}
void
ModelPrivate
::
notifyImportAdded
(
const
Import
&
import
)
{
bool
resetModel
=
false
;
QString
description
;
try
{
if
(
rewriterView
())
{
rewriterView
()
->
importAdded
(
import
);
QList
<
Import
>
removedImportList
;
foreach
(
const
Import
&
import
,
toBeRemovedImportList
)
{
if
(
m_imports
.
contains
(
import
))
{
removedImportList
.
append
(
import
);
m_imports
.
removeOne
(
import
);
}
}
catch
(
RewritingException
&
e
)
{
description
=
e
.
description
();
resetModel
=
true
;
}
NodeMetaInfo
::
clearCache
();
if
(
nodeInstanceView
())
nodeInstanceView
()
->
importAdded
(
import
);
foreach
(
const
QWeakPointer
<
AbstractView
>
&
view
,
m_viewList
)
view
->
importAdded
(
import
);
if
(
resetModel
)
{
resetModelByRewriter
(
description
);
QList
<
Import
>
addedImportList
;
foreach
(
const
Import
&
import
,
toBeAddedImportList
)
{
if
(
!
m_imports
.
contains
(
import
))
{
addedImportList
.
append
(
import
);
m_imports
.
append
(
import
);
}
}
if
(
!
removedImportList
.
isEmpty
()
||
!
addedImportList
.
isEmpty
())
notifyImportsChanged
(
addedImportList
,
removedImportList
);
}
void
ModelPrivate
::
notifyImport
Removed
(
const
Import
&
import
)
void
ModelPrivate
::
notifyImport
sChanged
(
const
QList
<
Import
>
&
addedImports
,
const
QList
<
Import
>
&
removedImports
)
{
bool
resetModel
=
false
;
QString
description
;
try
{
if
(
rewriterView
())
{
rewriterView
()
->
import
Removed
(
import
);
rewriterView
()
->
import
sChanged
(
addedImports
,
removedImports
);
}
}
catch
(
RewritingException
&
e
)
{
description
=
e
.
description
();
...
...
@@ -193,10 +171,10 @@ void ModelPrivate::notifyImportRemoved(const Import &import)
NodeMetaInfo
::
clearCache
();
if
(
nodeInstanceView
())
nodeInstanceView
()
->
import
Removed
(
import
);
nodeInstanceView
()
->
import
sChanged
(
addedImports
,
removedImports
);
foreach
(
const
QWeakPointer
<
AbstractView
>
&
view
,
m_viewList
)
view
->
import
Removed
(
import
);
view
->
import
sChanged
(
addedImports
,
removedImports
);
if
(
resetModel
)
{
resetModelByRewriter
(
description
);
...
...
@@ -1698,14 +1676,9 @@ QList<Import> Model::imports() const
return
m_d
->
imports
();
}
void
Model
::
addImport
(
const
Import
&
import
)
{
m_d
->
addImport
(
import
);
}
void
Model
::
removeImport
(
const
Import
&
import
)
void
Model
::
changeImports
(
const
QList
<
Import
>
&
importsToBeAdded
,
const
QList
<
Import
>
&
importsToBeRemoved
)
{
m_d
->
removeImport
(
import
);
m_d
->
changeImports
(
importsToBeAdded
,
importsToBeRemoved
);
}
RewriterView
*
Model
::
rewriterView
()
const
...
...
src/plugins/qmldesigner/designercore/model/model_p.h
View file @
e3376b6d
...
...
@@ -175,8 +175,8 @@ public:
QList
<
Import
>
imports
()
const
{
return
m_imports
;
}
void
addImport
(
const
Import
&
import
);
void
removeImport
(
const
Import
&
import
);
void
notifyImportAdded
(
const
Import
&
import
);
void
notifyImport
Removed
(
const
Import
&
import
);
void
changeImports
(
const
QList
<
Import
>
&
importsToBeAdded
,
const
QList
<
Import
>
&
importToBeRemoved
);
void
notifyImport
sChanged
(
const
QList
<
Import
>
&
addedImports
,
const
QList
<
Import
>
&
removedImports
);
//node state property manipulation
...
...
src/plugins/qmldesigner/designercore/model/modelmerger.cpp
View file @
e3376b6d
...
...
@@ -158,10 +158,9 @@ static ModelNode createNodeFromNode(const ModelNode &modelNode,const QHash<QStri
ModelNode
ModelMerger
::
insertModel
(
const
ModelNode
&
modelNode
)
{
RewriterTransaction
transaction
(
view
()
->
beginRewriterTransaction
());
RewriterTransaction
transaction
(
view
()
->
beginRewriterTransaction
());
foreach
(
const
Import
&
import
,
modelNode
.
model
()
->
imports
())
view
()
->
model
()
->
addImport
(
import
);
view
()
->
model
()
->
changeImports
(
modelNode
.
model
()
->
imports
(),
QList
<
Import
>
());
QHash
<
QString
,
QString
>
idRenamingHash
;
setupIdRenamingHash
(
modelNode
,
idRenamingHash
,
view
());
...
...
@@ -176,8 +175,7 @@ void ModelMerger::replaceModel(const ModelNode &modelNode)
try
{
RewriterTransaction
transaction
(
view
()
->
beginRewriterTransaction
());
foreach
(
const
Import
&
import
,
modelNode
.
model
()
->
imports
())
view
()
->
model
()
->
addImport
(
import
);
view
()
->
model
()
->
changeImports
(
modelNode
.
model
()
->
imports
(),
QList
<
Import
>
());
view
()
->
model
()
->
setFileUrl
(
modelNode
.
model
()
->
fileUrl
());
ModelNode
rootNode
(
view
()
->
rootModelNode
());
...
...
src/plugins/qmldesigner/designercore/model/qmlmodelview.cpp
View file @
e3376b6d
...
...
@@ -117,7 +117,7 @@ QmlItemNode QmlModelView::createQmlItemNodeFromImage(const QString &imageName, c
}
if
(
!
model
()
->
imports
().
contains
(
newImport
))
{
model
()
->
addImport
(
newImport
);
model
()
->
changeImports
(
QList
<
Import
>
()
<<
newImport
,
QList
<
Import
>
()
);
}
QList
<
QPair
<
QString
,
QVariant
>
>
propertyPairList
;
...
...
@@ -187,7 +187,7 @@ QmlItemNode QmlModelView::createQmlItemNode(const ItemLibraryEntry &itemLibraryE
}
if
(
!
model
()
->
imports
().
contains
(
newImport
))
{
model
()
->
addImport
(
newImport
);
model
()
->
changeImports
(
QList
<
Import
>
()
<<
newImport
,
QList
<
Import
>
()
);
}
}
...
...
@@ -372,6 +372,10 @@ void QmlModelView::instancesChildrenChanged(const QVector<ModelNode> &/*nodeList
}
void
QmlModelView
::
importsChanged
(
const
QList
<
Import
>
&
/*addedImports*/
,
const
QList
<
Import
>
&
/*removedImports*/
)
{
}
void
QmlModelView
::
rewriterBeginTransaction
()
{
...
...
src/plugins/qmldesigner/designercore/model/rewriterview.cpp
View file @
e3376b6d
...
...
@@ -283,6 +283,15 @@ void RewriterView::nodeAboutToBeReparented(const ModelNode &/*node*/, const Node
{
}
void
RewriterView
::
importsChanged
(
const
QList
<
Import
>
&
addedImports
,
const
QList
<
Import
>
&
removedImports
)
{
foreach
(
const
Import
&
import
,
addedImports
)
importAdded
(
import
);
foreach
(
const
Import
&
import
,
removedImports
)
importRemoved
(
import
);
}
void
RewriterView
::
importAdded
(
const
Import
&
import
)
{
...
...
src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp
View file @
e3376b6d
...
...
@@ -1152,12 +1152,12 @@ void ModelValidator::idsDiffer(ModelNode &modelNode, const QString &qmlId)
void
ModelAmender
::
modelMissesImport
(
const
Import
&
import
)
{
m_merger
->
view
()
->
model
()
->
addImport
(
import
);
m_merger
->
view
()
->
model
()
->
changeImports
(
QList
<
Import
>
()
<<
import
,
QList
<
Import
>
()
);
}
void
ModelAmender
::
importAbsentInQMl
(
const
Import
&
import
)
{
m_merger
->
view
()
->
model
()
->
removeImport
(
import
);
m_merger
->
view
()
->
model
()
->
changeImports
(
QList
<
Import
>
(),
QList
<
Import
>
()
<<
import
);
}
void
ModelAmender
::
bindingExpressionsDiffer
(
BindingProperty
&
modelProperty
,
...
...
src/plugins/qmldesigner/designercore/model/viewlogger.cpp
View file @
e3376b6d
...
...
@@ -183,14 +183,18 @@ void ViewLogger::nodeOrderChanged(const NodeListProperty &listProperty, const Mo
m_output
<<
time
()
<<
indent
(
"nodeOrderChanged:"
)
<<
listProperty
<<
movedNode
<<
oldIndex
<<
endl
;
}
void
ViewLogger
::
importsChanged
(
)
void
ViewLogger
::
auxiliaryDataChanged
(
const
ModelNode
&
node
,
const
QString
&
name
,
const
QVariant
&
data
)
{
m_output
<<
time
()
<<
indent
(
"
importsChanged:"
)
<<
endl
;
m_output
<<
time
()
<<
indent
(
"
auxiliaryDataChanged:"
)
<<
node
<<
"
\t
"
<<
name
<<
"
\t
"
<<
data
.
toString
(
)
<<
endl
;
}
void
ViewLogger
::
auxiliaryDataChanged
(
const
ModelNode
&
node
,
const
QString
&
name
,
const
QVariant
&
data
)
void
ViewLogger
::
importsChanged
(
const
QList
<
Import
>
&
addedImports
,
const
QList
<
Import
>
&
removedImports
)
{
m_output
<<
time
()
<<
indent
(
"auxiliaryDataChanged:"
)
<<
node
<<
"
\t
"
<<
name
<<
"
\t
"
<<
data
.
toString
()
<<
endl
;
m_output
<<
time
()
<<
indent
(
"importsChanged:"
)
<<
endl
;
foreach
(
const
Import
&
import
,
addedImports
)
m_output
<<
time
()
<<
indent
(
"import added: "
)
<<
import
.
toString
()
<<
endl
;
foreach
(
const
Import
&
import
,
removedImports
)
m_output
<<
time
()
<<
indent
(
"import removed: "
)
<<
import
.
toString
()
<<
endl
;
}
void
ViewLogger
::
customNotification
(
const
AbstractView
*
view
,
const
QString
&
identifier
,
const
QList
<
ModelNode
>
&
nodeList
,
const
QList
<
QVariant
>
&
data
)
...
...
src/plugins/qmldesigner/designercore/model/viewlogger.h
View file @
e3376b6d
...
...
@@ -70,7 +70,7 @@ public:
void
nodeOrderChanged
(
const
NodeListProperty
&
listProperty
,
const
ModelNode
&
movedNode
,
int
oldIndex
);
void
importsChanged
();
void
importsChanged
(
const
QList
<
Import
>
&
addedImports
,
const
QList
<
Import
>
&
removedImports
);
void
auxiliaryDataChanged
(
const
ModelNode
&
node
,
const
QString
&
name
,
const
QVariant
&
data
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment