In flex how should I copy and paste connector connecting two object - flex4.6

I have dragged objects from Diagram Palette on to the Group container.After that I clicked on connector button and then connect dragged objects by mouse move.Now i want to perform copy and paste.On copying only objects are copying not connector.How can I copy connector with dragged objects.

Related

Custom TreeCell with cell factory, and background threads

How do I make it so the TreeView is populated with ProgressIndicators while stuff is happening, but without blocking the thread, using a cell factory?
How does TreeItem.setGraphic() differ from TreeCell.setGraphic()?
When I instantiate the TreeItem, I need to set the graphic to a ProgressIndicator, but I'm not sure whether this ought to happen while creating the TreeItem or from the TreeCell.updateItem dumped out by the factory.
I think when using cell factories, all graphical stuff needs to happen there, thus TreeItem.setGraphic is merely a convenience, and I should figure out my problem from within updateItem.
I'm doing the file explorer example. Each item in the TreeView has the value set to a sun.nio.fs.WindowsPath, and is implemented by inheriting from TreeItem. I override isLeaf() and getChildren(). The problem is isLeaf() can take a long time on network drives when I'm not plugged into the network.
So this is what I'm doing to create a new tree item with a path value (not using cell factory yet):
Start new thread (using Clojure futures) to check if the path value is a path or file using isRegularFile(). The result from this is available later when dereferencing the future.
Instantiate instance of anonymous TreeItem derivative (using Clojure proxy).
Call setGraphic() on the new TreeItem instance with a ProgressIndicator().
Start another thread which checks the result of the first thread. When the first thread is finished, then based on the value of the leaf function, the first thread sets the appropriate file or folder icon, and calls addEventHandler() with local anonymous functions that change the graphic based on expanded or collapsed.
Return the new instance of TreeItem (from step 2) before either of the new threads is finished.
This works and has the effect of putting a swirly graphic at each network drive while isLeaf is running. But I'm not sure how to do all this when both TreeItem and TreeCell seem to have a setGraphic() function; I'm not sure who "owns" what. I think the TreeView owns the both the items and the cells, and calling setGraphic() on a TreeItem somehow references the default cell's graphic, when not using a custom cell factory.
I need to figure out how to access the isLeaf value from the cell factory updateItem(), etc. etc.

Smoothly Updating QGraphicsscene

Hi I have managed to add a number of qgraphicsitems to a qgraphicsscene using the code below
def generate_graph_and_update_scene(self):
try:
local_params=locals() #for error log get local paramters
this_function_name=sys._getframe().f_code.co_name #for error log get function name
self.vertex_dict.clear()
self.clear() #clear graphicsscene
self.graph_pos.clear() #clear graph position holder object
#function that generates the node data
root_nodes=my_database_query.get_nodes_information()
for node in root_nodes:
# add nodes to nx.graph object
self.nx_graph.add_node(node['column1'])
# create networkx graph
self.graph_pos = nx.spring_layout(self.nx_graph, iterations=25,scale=10)
for node in self.nx_graph.nodes(): # Add nodes to qgraphicsscene
v=default_nodeobject.my_ellipse(node,self.graph_pos)
self.addItem(v) # Add ellipse to qgraphics scene
for edge in self.nx_graph.edges():
self.addItem(defaultedgeview.edgeview(edge[0], edge[1],self.graph_pos))#add edges to qgraphicscene
except:
#Exception handler
message=str(sys.exc_info())
message=message + str(local_params)+" "+ str(this_function_name)
print message
This allows me to add say 600 'nodes' to my qgraphics scene, however when I clear the scene and add another say 1500 nodes, adding the items blocks the UI and my whole application freezes for a few seconds.
Also whenever I am doing things like looping through the graphicsitems say looking for the nodes that have a certain property, again the main thread freezes while I am looping,
Could anyone suggest a good method of keeping the UI responsive while things are being done to the grpahicsscene/items in the scene.
Ideally would like to have smooth, non-blocking updates to the scene, even when I have a few thousand items showing.
The problem here is the management of each node as a graphics item. Adding and removing to a scene, as well as rendering each item is going to take time. With this many items, I suggest designing it differently.
Consider the node graph as a single, custom graphics item which stores a group of nodes and manages them as a single unit, rather than 600+ separate items.
Designed this way, you only add one item to the scene (the node graph) which allows rapid addition and removal of nodes and you will also see a performance improvement in rendering the scene, as all nodes are drawn in one call to paint().
Of-course, if you need to move nodes around by clicking and dragging them, you'll have to add additional code to handle detecting which node is being selected in the item and move it yourself.
However, this is the optimal way to handle such a large number of items in a scene.

qt malloc(): smallbin double linked list corrupted

In my Qt widget I sometimes get this error:
malloc(): smallbin double linked list corrupted
It does not happen all the time but I think I have narrowed it down to when it starts.
I have a QGraphicsView and QGraphicsScene and there I'm drawing lines whos points are stored in a vector. Reason for this is I need to pass this points to another library. Once I draw the points I have an option if I click on a line I'm prompted to another window where I can change the coordinates of a line.
ResizeDialog *dialog = new ResizeDialog(this);
dialog->exec();
delete dialog;
The above code is the code I use to open a new QDialog. I know if I use this->close() the
qt malloc(): smallbin double linked list corrupted does not appear but then I lose the instance of QGraphicsView. Reason I need to keep the QGraphicsView window open if I need to chose to add further lines.
Any advice on how I can eliminate this issue wold be helpful.
Rather than using delete dialog;, use dialog->deleteLater();. I assume the small code portion is inside a slot of the object referenced by "this", and direct deletion is source of trouble as ResizeDialog *dialog = new ResizeDialog(this); affect the parent object this.

Trigger action on completion of drag action

I'm trying to allow items from a QListWidget to be dragged to a "Trash" (A subclassed widget which accepts drops and does nothing with them).
I know that if I setDropAction(Qt.MoveAction), the items I am removing from the source will be automatically deleted. This works correctly.
My problem is that I also need to trigger an action that updates other widgets who depend upon the contents of the source.
It seems to me that the dropEvent happens before any items are actually removed from the source. I'm having a terrible time trying to figure out this problem. I've thought of two possible solutions:
Find a way to embed the references to the actual QListWidgetItems that are being dragged in the event's QMimeData. This would allow me to do the deletions by hand, before I trigger updates.
Figure out how to wait until the source has been automatically cleared, but I can't find any signals that fire when items are removed from a list automatically.
Aha!
The key I was missing was the mimeData method. This method is called when a drag is started, and in it I am passed a list of all files being dragged.
I first built the meta object to be returned, then I deleted the files being dragged from the list, and called the refresh action that I needed.
Here's an example:
def mimeData(self, items):
m = QMimeData()
m.setUrls([QUrl(i.url) for i in items])
# Clean up the list:
[self.files.takeItem(self.files.indexFromItem(i).row()) for i in items]
self._update_meta()
return m

Flex Drawing Edge using path, Show Preview

Hi am trying to connect two flex graphic objects using drag and drop (drag from source shape and drop on target, then a line is created that connect the two, using path object).
Is there any way that i can see a preview of the line while i am dragging between the shapes?
Update a data object whenever the object moves, and bind the endpoints of the line to that data object.

Resources