Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion NodeGraphQt/base/commands.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/python
from .utils import minimize_node_ref_count
from .. import QtWidgets
from ..constants import IN_PORT, OUT_PORT
from .utils import minimize_node_ref_count


class PropertyChangedCmd(QtWidgets.QUndoCommand):
Expand Down
26 changes: 22 additions & 4 deletions NodeGraphQt/base/graph.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
import gc
import json
import os
import re

import copy
import gc
from .. import QtCore, QtWidgets, QtGui

from .commands import (NodeAddedCmd,
NodeRemovedCmd,
NodeMovedCmd,
Expand All @@ -15,14 +16,15 @@
from .model import NodeGraphModel
from .node import NodeObject, BaseNode
from .port import Port
from .. import QtCore, QtWidgets, QtGui
from ..constants import (DRAG_DROP_ID,
PIPE_LAYOUT_CURVED,
PIPE_LAYOUT_STRAIGHT,
PIPE_LAYOUT_ANGLE,
IN_PORT, OUT_PORT,
VIEWER_GRID_LINES)
from ..widgets.viewer import NodeViewer
from ..widgets.node_space_bar import node_space_bar
from ..widgets.viewer import NodeViewer


class QWidgetDrops(QtWidgets.QWidget):
Expand Down Expand Up @@ -179,9 +181,10 @@ def _wire_signals(self):
self._viewer.connection_changed.connect(self._on_connection_changed)
self._viewer.moved_nodes.connect(self._on_nodes_moved)
self._viewer.node_double_clicked.connect(self._on_node_double_clicked)
self._viewer.node_name_changed.connect(self._on_node_name_changed)
self._viewer.insert_node.connect(self._insert_node)

# pass through signals.
# pass through translated signals.
self._viewer.node_selected.connect(self._on_node_selected)
self._viewer.node_selection_changed.connect(
self._on_node_selection_changed)
Expand Down Expand Up @@ -254,6 +257,21 @@ def _on_property_bin_changed(self, node_id, prop_name, prop_value):
value = copy.deepcopy(prop_value)
node.set_property(prop_name, value)

def _on_node_name_changed(self, node_id, name):
"""
called when a node text qgraphics item in the viewer is edited.
(sets the name through the node object so undo commands are registered.)

Args:
node_id (str): node id emitted by the viewer.
name (str): new node name.
"""
node = self.get_node_by_id(node_id)
node.set_name(name)

# TODO: not sure about redrawing the node here.
node.view.draw_node()

def _on_node_double_clicked(self, node_id):
"""
called when a node in the viewer is double click.
Expand Down
3 changes: 1 addition & 2 deletions NodeGraphQt/base/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from .commands import PropertyChangedCmd
from .model import NodeModel
from .port import Port
from .utils import update_node_down_stream
from ..constants import (NODE_PROP,
NODE_PROP_QLINEEDIT,
NODE_PROP_QTEXTEDIT,
Expand All @@ -23,7 +24,6 @@
NodeIntEdit,
NodeCheckBox,
NodeFilePath)
from .utils import update_node_down_stream


class classproperty(object):
Expand Down Expand Up @@ -528,7 +528,6 @@ def __init__(self):
self._inputs = []
self._outputs = []
self._has_draw = False
self._view.text_item.editingFinished.connect(self.set_name)

def draw(self, force=True):
"""
Expand Down
2 changes: 1 addition & 1 deletion NodeGraphQt/pkg_info.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
__version__ = '0.1.2'
__version__ = '0.1.1'
__status__ = 'Work in Progress'
__license__ = 'MIT'

Expand Down
9 changes: 6 additions & 3 deletions NodeGraphQt/qgraphics/node_abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ def visible(self, visible=False):
def xy_pos(self):
"""
return the item scene postion.
("node.pos" conflicted with "QGraphicsItem.pos()" so it was refactored to "xy_pos".)
("node.pos" conflicted with "QGraphicsItem.pos()"
so it was refactored to "xy_pos".)

Returns:
list[float]: x, y scene position.
Expand All @@ -173,7 +174,8 @@ def xy_pos(self):
def xy_pos(self, pos=None):
"""
set the item scene postion.
("node.pos" conflicted with "QGraphicsItem.pos()" so it was refactored to "xy_pos".)
("node.pos" conflicted with "QGraphicsItem.pos()"
so it was refactored to "xy_pos".)

Args:
pos (list[float]): x, y scene position.
Expand Down Expand Up @@ -231,7 +233,8 @@ def from_dict(self, node_dict):
node_attrs = list(self._properties.keys()) + ['width', 'height', 'pos']
for name, value in node_dict.items():
if name in node_attrs:
# "node.pos" conflicted with "QGraphicsItem.pos()" so it's refactored to "xy_pos".
# "node.pos" conflicted with "QGraphicsItem.pos()"
# so it's refactored to "xy_pos".
if name == 'pos':
name = 'xy_pos'
setattr(self, name, value)
Loading