Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Tobias Hunger
qt-creator
Commits
1b3016c5
Commit
1b3016c5
authored
Nov 30, 2010
by
Marco Bubke
Browse files
QmlDesigner.NodeInstances: Refactor image send commands
parent
66ed5367
Changes
17
Hide whitespace changes
Inline
Side-by-side
src/plugins/qmldesigner/designercore/designercore.pri
View file @
1b3016c5
...
...
@@ -119,7 +119,9 @@ SOURCES += $$PWD/model/abstractview.cpp \
$$PWD/instances/nodeinstanceserverproxy.cpp \
$$PWD/instances/nodeinstanceclientproxy.cpp \
$$PWD/instances/addimportcommand.cpp \
$$PWD/instances/childrenchangedcommand.cpp
$$PWD/instances/childrenchangedcommand.cpp \
$$PWD/instances/statepreviewimagechangedcommand.cpp \
$$PWD/instances/imagecontainer.cpp
HEADERS += $$PWD/include/corelib_global.h \
$$PWD/include/abstractview.h \
$$PWD/include/nodeinstanceview.h \
...
...
@@ -237,8 +239,9 @@ HEADERS += $$PWD/include/corelib_global.h \
$$PWD/instances/nodeinstanceserverproxy.h \
$$PWD/instances/nodeinstanceclientproxy.h \
$$PWD/instances/addimportcommand.h \
$$PWD/instances/childrenchangedcommand.h
$$PWD/instances/childrenchangedcommand.h \
$$PWD/instances/statepreviewimagechangedcommand.h \
$$PWD/instances/imagecontainer.h
contains(CONFIG, plugin) {
# If core.pri has been included in the qmldesigner plugin
SOURCES += $$PWD/model/basetexteditmodifier.cpp
...
...
src/plugins/qmldesigner/designercore/include/nodeinstanceclientinterface.h
View file @
1b3016c5
...
...
@@ -9,6 +9,7 @@ class ValuesChangedCommand;
class
PixmapChangedCommand
;
class
InformationChangedCommand
;
class
ChildrenChangedCommand
;
class
StatePreviewImageChangedCommand
;
class
NodeInstanceClientInterface
{
...
...
@@ -17,6 +18,7 @@ public:
virtual
void
valuesChanged
(
const
ValuesChangedCommand
&
command
)
=
0
;
virtual
void
pixmapChanged
(
const
PixmapChangedCommand
&
command
)
=
0
;
virtual
void
childrenChanged
(
const
ChildrenChangedCommand
&
command
)
=
0
;
virtual
void
statePreviewImagesChanged
(
const
StatePreviewImageChangedCommand
&
command
)
=
0
;
virtual
void
flush
()
{};
virtual
qint64
bytesToWrite
()
const
{
return
0
;}
...
...
src/plugins/qmldesigner/designercore/include/nodeinstanceview.h
View file @
1b3016c5
...
...
@@ -116,6 +116,7 @@ public:
void
pixmapChanged
(
const
PixmapChangedCommand
&
command
);
void
informationChanged
(
const
InformationChangedCommand
&
command
);
void
childrenChanged
(
const
ChildrenChangedCommand
&
command
);
void
statePreviewImagesChanged
(
const
StatePreviewImageChangedCommand
&
command
);
private:
// functions
NodeInstance
rootNodeInstance
()
const
;
...
...
src/plugins/qmldesigner/designercore/instances/imagecontainer.cpp
0 → 100644
View file @
1b3016c5
#include "imagecontainer.h"
namespace
QmlDesigner
{
ImageContainer
::
ImageContainer
()
:
m_instanceId
(
-
1
)
{
}
ImageContainer
::
ImageContainer
(
qint32
instanceId
,
const
QImage
&
image
)
:
m_image
(
image
),
m_instanceId
(
instanceId
)
{
}
qint32
ImageContainer
::
instanceId
()
const
{
return
m_instanceId
;
}
QImage
ImageContainer
::
image
()
const
{
return
m_image
;
}
QDataStream
&
operator
<<
(
QDataStream
&
out
,
const
ImageContainer
&
container
)
{
out
<<
container
.
instanceId
();
const
QImage
image
=
container
.
image
();
const
QByteArray
data
(
reinterpret_cast
<
const
char
*>
(
image
.
constBits
()),
image
.
byteCount
());
out
<<
qint32
(
image
.
bytesPerLine
());
out
<<
image
.
size
();
out
<<
qint32
(
image
.
format
());
out
<<
qint32
(
image
.
byteCount
());
out
.
writeRawData
(
reinterpret_cast
<
const
char
*>
(
image
.
constBits
()),
image
.
byteCount
());
return
out
;
}
QDataStream
&
operator
>>
(
QDataStream
&
in
,
ImageContainer
&
container
)
{
qint32
byteSize
;
qint32
bytesPerLine
;
QSize
imageSize
;
qint32
format
;
in
>>
container
.
m_instanceId
;
in
>>
bytesPerLine
;
in
>>
imageSize
;
in
>>
format
;
in
>>
byteSize
;
container
.
m_image
=
QImage
(
imageSize
,
QImage
::
Format
(
format
));
in
.
readRawData
(
reinterpret_cast
<
char
*>
(
container
.
m_image
.
bits
()),
byteSize
);
return
in
;
}
}
// namespace QmlDesigner
src/plugins/qmldesigner/designercore/instances/imagecontainer.h
0 → 100644
View file @
1b3016c5
#ifndef IMAGECONTAINER_H
#define IMAGECONTAINER_H
#include <QMetaType>
#include <QImage>
namespace
QmlDesigner
{
class
ImageContainer
{
friend
QDataStream
&
operator
>>
(
QDataStream
&
in
,
ImageContainer
&
container
);
public:
ImageContainer
();
ImageContainer
(
qint32
instanceId
,
const
QImage
&
image
);
qint32
instanceId
()
const
;
QImage
image
()
const
;
private:
QImage
m_image
;
qint32
m_instanceId
;
};
QDataStream
&
operator
<<
(
QDataStream
&
out
,
const
ImageContainer
&
container
);
QDataStream
&
operator
>>
(
QDataStream
&
in
,
ImageContainer
&
container
);
}
// namespace QmlDesigner
Q_DECLARE_METATYPE
(
QmlDesigner
::
ImageContainer
);
#endif // IMAGECONTAINER_H
src/plugins/qmldesigner/designercore/instances/instances.pri
View file @
1b3016c5
...
...
@@ -3,6 +3,8 @@ INCLUDEPATH += $$PWD/../include
HEADERS += $$PWD/behaviornodeinstance.h
HEADERS += $$PWDstatepreviewimagechangedcommand.h
HEADERS += $$PWD//imagecontainer.h
HEADERS += $$PWD/childrenchangedcommand.h
HEADERS += $$PWD/addimportcommand.h
HEADERS += $$PWD/changebindingscommand.h
...
...
@@ -43,6 +45,8 @@ HEADERS += $$PWD/../include/nodeinstanceserverinterface.h
SOURCES += $$PWD/behaviornodeinstance.cpp
SOURCES += $$PWD/statepreviewimagechangedcommand.cpp
SOURCES += $$PWD/imagecontainer.cpp
SOURCES += $$PWD/childrenchangedcommand.cpp
SOURCES += $$PWD/addimportcommand.cpp
SOURCES += $$PWD/changebindingscommand.cpp
...
...
src/plugins/qmldesigner/designercore/instances/nodeinstanceclientproxy.cpp
View file @
1b3016c5
...
...
@@ -28,6 +28,8 @@
#include "pixmapchangedcommand.h"
#include "valueschangedcommand.h"
#include "childrenchangedcommand.h"
#include "imagecontainer.h"
#include "statepreviewimagechangedcommand.h"
namespace
QmlDesigner
{
...
...
@@ -76,6 +78,11 @@ void NodeInstanceClientProxy::childrenChanged(const ChildrenChangedCommand &comm
writeCommand
(
QVariant
::
fromValue
(
command
));
}
void
NodeInstanceClientProxy
::
statePreviewImagesChanged
(
const
StatePreviewImageChangedCommand
&
command
)
{
writeCommand
(
QVariant
::
fromValue
(
command
));
}
void
NodeInstanceClientProxy
::
flush
()
{
}
...
...
src/plugins/qmldesigner/designercore/instances/nodeinstanceclientproxy.h
View file @
1b3016c5
...
...
@@ -24,6 +24,7 @@ public:
void
valuesChanged
(
const
ValuesChangedCommand
&
command
);
void
pixmapChanged
(
const
PixmapChangedCommand
&
command
);
void
childrenChanged
(
const
ChildrenChangedCommand
&
command
);
void
statePreviewImagesChanged
(
const
StatePreviewImageChangedCommand
&
command
);
void
flush
();
qint64
bytesToWrite
()
const
;
...
...
src/plugins/qmldesigner/designercore/instances/nodeinstanceserver.cpp
View file @
1b3016c5
...
...
@@ -82,8 +82,7 @@ void NodeInstanceServer::createInstances(const CreateInstancesCommand &command)
nodeInstanceClient
()
->
valuesChanged
(
createValuesChangedCommand
(
instanceList
));
nodeInstanceClient
()
->
informationChanged
(
createAllInformationChangedCommand
(
instanceList
,
true
));
foreach
(
const
ServerNodeInstance
&
instance
,
instanceList
)
nodeInstanceClient
()
->
pixmapChanged
(
createPixmapChangedCommand
(
instance
));
nodeInstanceClient
()
->
pixmapChanged
(
createPixmapChangedCommand
(
instanceList
));
startRenderTimer
();
}
...
...
@@ -682,10 +681,14 @@ void NodeInstanceServer::removeInstanceRelationsip(qint32 instanceId)
}
}
PixmapChangedCommand
NodeInstanceServer
::
createPixmapChangedCommand
(
const
ServerNodeInstance
&
instance
)
const
PixmapChangedCommand
NodeInstanceServer
::
createPixmapChangedCommand
(
const
QList
<
ServerNodeInstance
>
&
instance
List
)
const
{
qDebug
()
<<
__FUNCTION__
<<
instance
.
internalObject
();
return
PixmapChangedCommand
(
instance
.
instanceId
(),
instance
.
renderImage
());
QVector
<
ImageContainer
>
imageVector
;
foreach
(
const
ServerNodeInstance
&
instance
,
instanceList
)
imageVector
.
append
(
ImageContainer
(
instance
.
instanceId
(),
instance
.
renderImage
()));
return
PixmapChangedCommand
(
imageVector
);
}
bool
NodeInstanceServer
::
nonInstanceChildIsDirty
(
QGraphicsObject
*
graphicsObject
)
const
...
...
@@ -783,8 +786,8 @@ void NodeInstanceServer::findItemChangesAndSendChangeCommands()
if
(
!
propertyChangedList
.
isEmpty
())
nodeInstanceClient
()
->
valuesChanged
(
createValuesChangedCommand
(
propertyChangedList
));
foreach
(
const
ServerNodeInstance
&
instance
,
dirtyInstanceSet
)
nodeInstanceClient
()
->
pixmapChanged
(
createPixmapChangedCommand
(
i
nstance
));
if
(
!
dirtyInstanceSet
.
isEmpty
()
)
nodeInstanceClient
()
->
pixmapChanged
(
createPixmapChangedCommand
(
dirtyI
nstance
Set
.
toList
()
));
if
(
adjustSceneRect
)
{
QRectF
boundingRect
=
m_rootNodeInstance
.
boundingRect
();
...
...
src/plugins/qmldesigner/designercore/instances/nodeinstanceserver.h
View file @
1b3016c5
...
...
@@ -101,7 +101,7 @@ protected:
ValuesChangedCommand
createValuesChangedCommand
(
const
QList
<
ServerNodeInstance
>
&
instanceList
)
const
;
ValuesChangedCommand
createValuesChangedCommand
(
const
QVector
<
InstancePropertyPair
>
&
propertyList
)
const
;
PixmapChangedCommand
createPixmapChangedCommand
(
const
ServerNodeInstance
&
instance
)
const
;
PixmapChangedCommand
createPixmapChangedCommand
(
const
QList
<
ServerNodeInstance
>
&
instance
List
)
const
;
InformationChangedCommand
createAllInformationChangedCommand
(
const
QList
<
ServerNodeInstance
>
&
instanceList
,
bool
initial
=
false
)
const
;
ChildrenChangedCommand
createChildrenChangedCommand
(
const
ServerNodeInstance
&
parentInstance
,
const
QList
<
ServerNodeInstance
>
&
instanceList
)
const
;
...
...
src/plugins/qmldesigner/designercore/instances/nodeinstanceserverinterface.cpp
View file @
1b3016c5
...
...
@@ -22,6 +22,9 @@
#include "valueschangedcommand.h"
#include "addimportcommand.h"
#include "childrenchangedcommand.h"
#include "imagecontainer.h"
#include "statepreviewimagechangedcommand.h"
namespace
QmlDesigner
{
...
...
@@ -108,6 +111,12 @@ void NodeInstanceServerInterface::registerCommands()
qRegisterMetaType
<
ChildrenChangedCommand
>
(
"ChildrenChangedCommand"
);
qRegisterMetaTypeStreamOperators
<
ChildrenChangedCommand
>
(
"ChildrenChangedCommand"
);
qRegisterMetaType
<
ImageContainer
>
(
"ImageContainer"
);
qRegisterMetaTypeStreamOperators
<
ImageContainer
>
(
"ImageContainer"
);
qRegisterMetaType
<
StatePreviewImageChangedCommand
>
(
"StatePreviewImageChangedCommand"
);
qRegisterMetaTypeStreamOperators
<
StatePreviewImageChangedCommand
>
(
"StatePreviewImageChangedCommand"
);
}
}
src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.cpp
View file @
1b3016c5
...
...
@@ -27,6 +27,8 @@
#include "pixmapchangedcommand.h"
#include "valueschangedcommand.h"
#include "childrenchangedcommand.h"
#include "imagecontainer.h"
#include "statepreviewimagechangedcommand.h"
#include "nodeinstanceview.h"
#include "nodeinstanceclientproxy.h"
...
...
@@ -75,6 +77,7 @@ void NodeInstanceServerProxy::dispatchCommand(const QVariant &command)
static
const
int
valuesChangedCommandType
=
QMetaType
::
type
(
"ValuesChangedCommand"
);
static
const
int
pixmapChangedCommandType
=
QMetaType
::
type
(
"PixmapChangedCommand"
);
static
const
int
childrenChangedCommandType
=
QMetaType
::
type
(
"ChildrenChangedCommand"
);
static
const
int
statePreviewImageChangedCommandType
=
QMetaType
::
type
(
"StatePreviewImageChangedCommand"
);
if
(
command
.
userType
()
==
informationChangedCommandType
)
nodeInstanceClient
()
->
informationChanged
(
command
.
value
<
InformationChangedCommand
>
());
...
...
@@ -84,6 +87,8 @@ void NodeInstanceServerProxy::dispatchCommand(const QVariant &command)
nodeInstanceClient
()
->
pixmapChanged
(
command
.
value
<
PixmapChangedCommand
>
());
else
if
(
command
.
userType
()
==
childrenChangedCommandType
)
nodeInstanceClient
()
->
childrenChanged
(
command
.
value
<
ChildrenChangedCommand
>
());
else
if
(
command
.
userType
()
==
statePreviewImageChangedCommandType
)
nodeInstanceClient
()
->
statePreviewImagesChanged
(
command
.
value
<
StatePreviewImageChangedCommand
>
());
else
Q_ASSERT
(
false
);
}
...
...
src/plugins/qmldesigner/designercore/instances/nodeinstanceview.cpp
View file @
1b3016c5
...
...
@@ -72,6 +72,8 @@
#include "changestatecommand.h"
#include "addimportcommand.h"
#include "childrenchangedcommand.h"
#include "imagecontainer.h"
#include "statepreviewimagechangedcommand.h"
#include "nodeinstanceserverproxy.h"
...
...
@@ -864,11 +866,13 @@ void NodeInstanceView::pixmapChanged(const PixmapChangedCommand &command)
{
QSet
<
ModelNode
>
renderImageChangeSet
;
if
(
hasInstanceForId
(
command
.
instanceId
()))
{
NodeInstance
instance
=
instanceForId
(
command
.
instanceId
());
if
(
instance
.
isValid
())
{
instance
.
setRenderImage
(
command
.
renderImage
());
renderImageChangeSet
.
insert
(
instance
.
modelNode
());
foreach
(
const
ImageContainer
&
container
,
command
.
images
())
{
if
(
hasInstanceForId
(
container
.
instanceId
()))
{
NodeInstance
instance
=
instanceForId
(
container
.
instanceId
());
if
(
instance
.
isValid
())
{
instance
.
setRenderImage
(
container
.
image
());
renderImageChangeSet
.
insert
(
instance
.
modelNode
());
}
}
}
...
...
@@ -894,6 +898,11 @@ void NodeInstanceView::informationChanged(const InformationChangedCommand &comma
emitCustomNotification
(
"__instance information changed__"
,
informationChangedList
);
}
void
NodeInstanceView
::
statePreviewImagesChanged
(
const
StatePreviewImageChangedCommand
&
/*command*/
)
{
}
void
NodeInstanceView
::
childrenChanged
(
const
ChildrenChangedCommand
&
command
)
{
QList
<
ModelNode
>
childNodeList
;
...
...
src/plugins/qmldesigner/designercore/instances/pixmapchangedcommand.cpp
View file @
1b3016c5
...
...
@@ -7,58 +7,29 @@
namespace
QmlDesigner
{
PixmapChangedCommand
::
PixmapChangedCommand
()
:
m_instanceId
(
-
1
)
{
}
PixmapChangedCommand
::
PixmapChangedCommand
(
qint32
instanceId
,
const
QImage
&
image
)
:
m_image
(
image
),
m_instanceId
(
instanceId
)
PixmapChangedCommand
::
PixmapChangedCommand
(
const
QVector
<
ImageContainer
>
&
image
Vector
)
:
m_image
Vector
(
imageVector
)
{
}
qint32
PixmapChangedCommand
::
i
nstanceId
()
const
QVector
<
ImageContainer
>
PixmapChangedCommand
::
i
mages
()
const
{
return
m_instanceId
;
}
QImage
PixmapChangedCommand
::
renderImage
()
const
{
return
m_image
;
return
m_imageVector
;
}
QDataStream
&
operator
<<
(
QDataStream
&
out
,
const
PixmapChangedCommand
&
command
)
{
out
<<
command
.
instanceId
();
const
QImage
image
=
command
.
renderImage
();
const
QByteArray
data
(
reinterpret_cast
<
const
char
*>
(
image
.
constBits
()),
image
.
byteCount
());
out
<<
qint32
(
image
.
bytesPerLine
());
out
<<
image
.
size
();
out
<<
qint32
(
image
.
format
());
out
<<
qint32
(
image
.
byteCount
());
out
.
writeRawData
(
reinterpret_cast
<
const
char
*>
(
image
.
constBits
()),
image
.
byteCount
());
out
<<
command
.
images
();
return
out
;
}
QDataStream
&
operator
>>
(
QDataStream
&
in
,
PixmapChangedCommand
&
command
)
{
qint32
byteSize
;
qint32
bytesPerLine
;
QSize
imageSize
;
qint32
format
;
in
>>
command
.
m_instanceId
;
in
>>
bytesPerLine
;
in
>>
imageSize
;
in
>>
format
;
in
>>
byteSize
;
command
.
m_image
=
QImage
(
imageSize
,
QImage
::
Format
(
format
));
in
.
readRawData
(
reinterpret_cast
<
char
*>
(
command
.
m_image
.
bits
()),
byteSize
);
in
>>
command
.
m_imageVector
;
return
in
;
}
...
...
src/plugins/qmldesigner/designercore/instances/pixmapchangedcommand.h
View file @
1b3016c5
...
...
@@ -2,7 +2,7 @@
#define PIXMAPCHANGEDCOMMAND_H
#include <QMetaType>
#include
<QI
mage
>
#include
"i
mage
container.h"
namespace
QmlDesigner
{
...
...
@@ -11,14 +11,12 @@ class PixmapChangedCommand
friend
QDataStream
&
operator
>>
(
QDataStream
&
in
,
PixmapChangedCommand
&
command
);
public:
PixmapChangedCommand
();
PixmapChangedCommand
(
qint32
instanceId
,
const
QImage
&
image
);
PixmapChangedCommand
(
const
QVector
<
ImageContainer
>
&
image
Vector
);
qint32
instanceId
()
const
;
QImage
renderImage
()
const
;
QVector
<
ImageContainer
>
images
()
const
;
private:
QImage
m_image
;
qint32
m_instanceId
;
QVector
<
ImageContainer
>
m_imageVector
;
};
QDataStream
&
operator
<<
(
QDataStream
&
out
,
const
PixmapChangedCommand
&
command
);
...
...
src/plugins/qmldesigner/designercore/instances/statepreviewimagechangedcommand.cpp
0 → 100644
View file @
1b3016c5
#include "statepreviewimagechangedcommand.h"
namespace
QmlDesigner
{
StatePreviewImageChangedCommand
::
StatePreviewImageChangedCommand
()
{
}
StatePreviewImageChangedCommand
::
StatePreviewImageChangedCommand
(
const
QVector
<
ImageContainer
>
&
imageVector
)
:
m_previewVector
(
imageVector
)
{
}
QVector
<
ImageContainer
>
StatePreviewImageChangedCommand
::
previews
()
const
{
return
m_previewVector
;
}
QDataStream
&
operator
<<
(
QDataStream
&
out
,
const
StatePreviewImageChangedCommand
&
command
)
{
out
<<
command
.
previews
();
return
out
;
}
QDataStream
&
operator
>>
(
QDataStream
&
in
,
StatePreviewImageChangedCommand
&
command
)
{
in
>>
command
.
m_previewVector
;
return
in
;
}
}
// namespace QmlDesigner
src/plugins/qmldesigner/designercore/instances/statepreviewimagechangedcommand.h
0 → 100644
View file @
1b3016c5
#ifndef STATEPREVIEWIMAGECHANGEDCOMMAND_H
#define STATEPREVIEWIMAGECHANGEDCOMMAND_H
#include <QMetaType>
#include "imagecontainer.h"
namespace
QmlDesigner
{
class
StatePreviewImageChangedCommand
{
friend
QDataStream
&
operator
>>
(
QDataStream
&
in
,
StatePreviewImageChangedCommand
&
command
);
public:
StatePreviewImageChangedCommand
();
StatePreviewImageChangedCommand
(
const
QVector
<
ImageContainer
>
&
imageVector
);
QVector
<
ImageContainer
>
previews
()
const
;
private:
QVector
<
ImageContainer
>
m_previewVector
;
};
QDataStream
&
operator
<<
(
QDataStream
&
out
,
const
StatePreviewImageChangedCommand
&
command
);
QDataStream
&
operator
>>
(
QDataStream
&
in
,
StatePreviewImageChangedCommand
&
command
);
}
// namespace QmlDesigner
Q_DECLARE_METATYPE
(
QmlDesigner
::
StatePreviewImageChangedCommand
);
#endif // STATEPREVIEWIMAGECHANGEDCOMMAND_H
Write
Preview
Supports
Markdown
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