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
F
flatpak-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
Marco Bubke
flatpak-qt-creator
Commits
a82d88df
Commit
a82d88df
authored
Mar 24, 2010
by
Marco Bubke
Committed by
Kai Koehne
Mar 30, 2010
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update the node instance if a file has changed on the local drive
parent
24cc2acd
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
122 additions
and
10 deletions
+122
-10
src/plugins/qmldesigner/core/include/nodeinstance.h
src/plugins/qmldesigner/core/include/nodeinstance.h
+1
-0
src/plugins/qmldesigner/core/include/nodeinstanceview.h
src/plugins/qmldesigner/core/include/nodeinstanceview.h
+14
-0
src/plugins/qmldesigner/core/instances/nodeinstance.cpp
src/plugins/qmldesigner/core/instances/nodeinstance.cpp
+5
-0
src/plugins/qmldesigner/core/instances/nodeinstanceview.cpp
src/plugins/qmldesigner/core/instances/nodeinstanceview.cpp
+40
-0
src/plugins/qmldesigner/core/instances/objectnodeinstance.cpp
...plugins/qmldesigner/core/instances/objectnodeinstance.cpp
+61
-10
src/plugins/qmldesigner/core/instances/objectnodeinstance.h
src/plugins/qmldesigner/core/instances/objectnodeinstance.h
+1
-0
No files found.
src/plugins/qmldesigner/core/include/nodeinstance.h
View file @
a82d88df
...
...
@@ -148,6 +148,7 @@ private: // functions
void
setPropertyDynamicBinding
(
const
QString
&
name
,
const
QString
&
typeName
,
const
QString
&
expression
);
void
resetProperty
(
const
QString
&
name
);
void
refreshProperty
(
const
QString
&
name
);
void
activateState
();
void
deactivateState
();
...
...
src/plugins/qmldesigner/core/include/nodeinstanceview.h
View file @
a82d88df
...
...
@@ -41,6 +41,8 @@
class
QDeclarativeEngine
;
class
QGraphicsView
;
class
QFileSystemWatcher
;
namespace
QmlDesigner
{
...
...
@@ -59,6 +61,7 @@ class CORESHARED_EXPORT NodeInstanceView : public AbstractView
public:
typedef
QWeakPointer
<
NodeInstanceView
>
Pointer
;
typedef
QPair
<
QWeakPointer
<
QObject
>
,
QString
>
ObjectPropertyPair
;
NodeInstanceView
(
QObject
*
parent
=
0
);
~
NodeInstanceView
();
...
...
@@ -105,6 +108,7 @@ public:
private
slots
:
void
emitParentChanged
(
QObject
*
child
);
void
refreshLocalFileProperty
(
const
QString
&
path
);
private:
// functions
NodeInstance
rootNodeInstance
()
const
;
...
...
@@ -131,6 +135,11 @@ private: // functions
void
setStateInstance
(
const
NodeInstance
&
stateInstance
);
void
clearStateInstance
();
QFileSystemWatcher
*
fileSystemWatcher
();
void
addFilePropertyToFileSystemWatcher
(
QObject
*
object
,
const
QString
&
propertyName
,
const
QString
&
path
);
void
removeFilePropertyFromFileSystemWatcher
(
QObject
*
object
,
const
QString
&
propertyName
,
const
QString
&
path
);
private:
//variables
NodeInstance
m_rootNodeInstance
;
NodeInstance
m_activeStateInstance
;
...
...
@@ -138,12 +147,17 @@ private: //variables
QHash
<
ModelNode
,
NodeInstance
>
m_nodeInstanceHash
;
QHash
<
QObject
*
,
NodeInstance
>
m_objectInstanceHash
;
// This is purely internal. Might contain dangling pointers!
QMultiHash
<
QString
,
ObjectPropertyPair
>
m_fileSystemWatcherHash
;
QWeakPointer
<
QDeclarativeEngine
>
m_engine
;
QWeakPointer
<
Internal
::
ChildrenChangeEventFilter
>
m_childrenChangeEventFilter
;
QWeakPointer
<
QmlModelView
>
m_qmlModelView
;
QWeakPointer
<
QFileSystemWatcher
>
m_fileSystemWatcher
;
bool
m_blockStatePropertyChanges
;
};
}
// namespace NodeInstanceView
...
...
src/plugins/qmldesigner/core/instances/nodeinstance.cpp
View file @
a82d88df
...
...
@@ -394,6 +394,11 @@ void NodeInstance::resetProperty(const QString &name)
m_nodeInstance
->
resetProperty
(
name
);
}
void
NodeInstance
::
refreshProperty
(
const
QString
&
name
)
{
m_nodeInstance
->
refreshProperty
(
name
);
}
void
NodeInstance
::
setId
(
const
QString
&
id
)
{
m_nodeInstance
->
setId
(
id
);
...
...
src/plugins/qmldesigner/core/instances/nodeinstanceview.cpp
View file @
a82d88df
...
...
@@ -38,6 +38,7 @@
#include <QGraphicsView>
#include <QGraphicsScene>
#include <QGraphicsObject>
#include <QFileSystemWatcher>
#include <model.h>
#include <modelnode.h>
...
...
@@ -653,6 +654,7 @@ void NodeInstanceView::render(QPainter * painter, const QRectF &target, const QR
}
}
QRectF
NodeInstanceView
::
sceneRect
()
const
{
if
(
m_graphicsView
)
...
...
@@ -662,3 +664,41 @@ QRectF NodeInstanceView::sceneRect() const
}
}
QFileSystemWatcher
*
NodeInstanceView
::
fileSystemWatcher
()
{
if
(
m_fileSystemWatcher
.
isNull
())
{
m_fileSystemWatcher
=
new
QFileSystemWatcher
(
this
);
connect
(
m_fileSystemWatcher
.
data
(),
SIGNAL
(
fileChanged
(
QString
)),
this
,
SLOT
(
refreshLocalFileProperty
(
QString
)));
}
return
m_fileSystemWatcher
.
data
();
}
void
NodeInstanceView
::
addFilePropertyToFileSystemWatcher
(
QObject
*
object
,
const
QString
&
propertyName
,
const
QString
&
path
)
{
m_fileSystemWatcherHash
.
insert
(
path
,
ObjectPropertyPair
(
object
,
propertyName
));
fileSystemWatcher
()
->
addPath
(
path
);
}
void
NodeInstanceView
::
removeFilePropertyFromFileSystemWatcher
(
QObject
*
object
,
const
QString
&
propertyName
,
const
QString
&
path
)
{
fileSystemWatcher
()
->
removePath
(
path
);
m_fileSystemWatcherHash
.
remove
(
path
,
ObjectPropertyPair
(
object
,
propertyName
));
}
void
NodeInstanceView
::
refreshLocalFileProperty
(
const
QString
&
path
)
{
if
(
m_fileSystemWatcherHash
.
contains
(
path
))
{
QList
<
ObjectPropertyPair
>
objectPropertyPairList
=
m_fileSystemWatcherHash
.
values
();
foreach
(
const
ObjectPropertyPair
&
objectPropertyPair
,
objectPropertyPairList
)
{
QObject
*
object
=
objectPropertyPair
.
first
.
data
();
QString
propertyName
=
objectPropertyPair
.
second
;
if
(
hasInstanceForObject
(
object
))
{
instanceForObject
(
object
).
refreshProperty
(
propertyName
);
}
}
}
}
src/plugins/qmldesigner/core/instances/objectnodeinstance.cpp
View file @
a82d88df
...
...
@@ -55,6 +55,9 @@
#include <QDeclarativeEngine>
#include <QDeclarativeProperty>
#include <QSharedPointer>
#include <QFileInfo>
#include <QFileSystemWatcher>
#include <QPixmapCache>
#include <private/qdeclarativebinding_p.h>
#include <private/qdeclarativemetatype_p.h>
...
...
@@ -404,7 +407,27 @@ void ObjectNodeInstance::reparent(const NodeInstance &oldParentInstance, const Q
void
ObjectNodeInstance
::
setPropertyVariant
(
const
QString
&
name
,
const
QVariant
&
value
)
{
QDeclarativeProperty
property
(
object
(),
name
,
context
());
QVariant
oldValue
=
property
.
read
();
if
(
oldValue
.
type
()
==
QVariant
::
Url
)
{
QUrl
url
=
oldValue
.
toUrl
();
QString
path
=
url
.
toLocalFile
();
if
(
QFileInfo
(
path
).
exists
()
&&
nodeInstanceView
()
&&
!
path
.
isEmpty
())
nodeInstanceView
()
->
removeFilePropertyFromFileSystemWatcher
(
object
(),
name
,
path
);
}
property
.
write
(
value
);
QVariant
newValue
=
property
.
read
();
if
(
newValue
.
type
()
==
QVariant
::
Url
)
{
QUrl
url
=
newValue
.
toUrl
();
QString
path
=
url
.
toLocalFile
();
if
(
QFileInfo
(
path
).
exists
()
&&
nodeInstanceView
()
&&
!
path
.
isEmpty
())
nodeInstanceView
()
->
addFilePropertyToFileSystemWatcher
(
object
(),
name
,
path
);
}
}
void
ObjectNodeInstance
::
setPropertyBinding
(
const
QString
&
name
,
const
QString
&
expression
)
...
...
@@ -460,27 +483,55 @@ NodeInstance ObjectNodeInstance::instanceForNode(const ModelNode &node, const QS
}
}
void
ObjectNodeInstance
::
refreshProperty
(
const
QString
&
name
)
{
QDeclarativeProperty
property
(
object
(),
name
,
context
());
QVariant
oldValue
(
property
.
read
());
if
(
property
.
isResettable
())
property
.
reset
();
else
property
.
write
(
resetValue
(
name
));
if
(
oldValue
.
type
()
==
QVariant
::
Url
)
{
QByteArray
key
=
oldValue
.
toUrl
().
toEncoded
(
QUrl
::
FormattingOption
(
0x100
));
QString
pixmapKey
=
QString
::
fromLatin1
(
key
.
constData
(),
key
.
count
());
QPixmapCache
::
remove
(
pixmapKey
);
}
property
.
write
(
oldValue
);
}
void
ObjectNodeInstance
::
resetProperty
(
QObject
*
object
,
const
QString
&
propertyName
)
{
m_modelAbstractPropertyHash
.
remove
(
propertyName
);
QDeclarativeProperty
qmlProperty
(
object
,
propertyName
,
context
());
QMetaProperty
metaProperty
=
qmlProperty
.
property
();
QDeclarativeProperty
property
(
object
,
propertyName
,
context
());
QVariant
oldValue
=
property
.
read
();
if
(
oldValue
.
type
()
==
QVariant
::
Url
)
{
QUrl
url
=
oldValue
.
toUrl
();
QString
path
=
url
.
toLocalFile
();
if
(
QFileInfo
(
path
).
exists
()
&&
nodeInstanceView
())
nodeInstanceView
()
->
removeFilePropertyFromFileSystemWatcher
(
object
,
propertyName
,
path
);
}
QDeclarativeAbstractBinding
*
binding
=
QDeclarativePropertyPrivate
::
binding
(
qmlP
roperty
);
QDeclarativeAbstractBinding
*
binding
=
QDeclarativePropertyPrivate
::
binding
(
p
roperty
);
if
(
binding
)
{
binding
->
setEnabled
(
false
,
0
);
binding
->
destroy
();
}
if
(
metaP
roperty
.
isResettable
())
{
metaProperty
.
reset
(
object
);
}
else
if
(
qmlP
roperty
.
isWritable
())
{
if
(
qmlP
roperty
.
read
()
==
resetValue
(
propertyName
))
if
(
p
roperty
.
isResettable
())
{
property
.
reset
(
);
}
else
if
(
p
roperty
.
isWritable
())
{
if
(
p
roperty
.
read
()
==
resetValue
(
propertyName
))
return
;
qmlP
roperty
.
write
(
resetValue
(
propertyName
));
}
else
if
(
qmlP
roperty
.
propertyTypeCategory
()
==
QDeclarativeProperty
::
List
)
{
qvariant_cast
<
QDeclarativeListReference
>
(
qmlP
roperty
.
read
()).
clear
();
p
roperty
.
write
(
resetValue
(
propertyName
));
}
else
if
(
p
roperty
.
propertyTypeCategory
()
==
QDeclarativeProperty
::
List
)
{
qvariant_cast
<
QDeclarativeListReference
>
(
p
roperty
.
read
()).
clear
();
}
}
...
...
src/plugins/qmldesigner/core/instances/objectnodeinstance.h
View file @
a82d88df
...
...
@@ -143,6 +143,7 @@ public:
virtual
void
setPropertyBinding
(
const
QString
&
name
,
const
QString
&
expression
);
virtual
QVariant
property
(
const
QString
&
name
)
const
;
virtual
void
resetProperty
(
const
QString
&
name
);
virtual
void
refreshProperty
(
const
QString
&
name
);
virtual
bool
isVisible
()
const
;
virtual
void
setVisible
(
bool
isVisible
);
...
...
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