Skip to content

Commit

Permalink
Added buttons to toggle visibility of type and port visibility icon
Browse files Browse the repository at this point in the history
gui/module_info.py:
  Added portVisibility and typeVisibility buttons
gui/ports_pane.py:
  Use portVisibility and typeVisibility options
  • Loading branch information
rexissimus committed Oct 1, 2014
1 parent 4113f7a commit c48a9c3
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 7 deletions.
51 changes: 50 additions & 1 deletion vistrails/gui/module_info.py
Expand Up @@ -34,23 +34,69 @@
###############################################################################
from PyQt4 import QtCore, QtGui

from vistrails.core.system import systemType
from vistrails.core.system import systemType, vistrails_root_directory
from vistrails.core.utils import versions_increasing
from vistrails.gui.common_widgets import QDockPushButton
from vistrails.gui.module_annotation import QModuleAnnotationTable
from vistrails.gui.ports_pane import PortsList
from vistrails.gui.version_prop import QVersionProp
from vistrails.gui.vistrails_palette import QVistrailsPaletteInterface

import os

class QModuleInfo(QtGui.QWidget, QVistrailsPaletteInterface):
def __init__(self, parent=None, flags=QtCore.Qt.Widget):
QtGui.QWidget.__init__(self, parent, flags)
self.portsVisible = True
self.typesVisible = True
self.build_widget()
self.controller = None
self.module = None
self.pipeline_view = None # pipeline_view
self.read_only = False
self.is_updating = False
self.addButtonsToToolbar()

def addButtonsToToolbar(self):
# button for toggling executions
eye_open_icon = \
QtGui.QIcon(os.path.join(vistrails_root_directory(),
'gui/resources/images/eye.png'))

self.portVisibilityAction = QtGui.QAction(eye_open_icon,
"Show/hide port visibility toggle buttons",
None,
triggered=self.showPortVisibility)
self.portVisibilityAction.setCheckable(True)
self.portVisibilityAction.setChecked(True)
self.toolWindow().toolbar.insertAction(self.toolWindow().pinAction,
self.portVisibilityAction)
# build a 'T' icon
pixmap = QtGui.QPixmap(48,48)
pixmap.fill(QtCore.Qt.transparent)
painter = QtGui.QPainter(pixmap)
painter.setPen(QtGui.QColor(0, 0, 0, 255))
font = painter.font()
font.setPointSize(40)
painter.setFont(font)
painter.drawText(0, 0, 48, 48, QtCore.Qt.AlignCenter, 'T')
painter.end()
self.showTypesAction = QtGui.QAction(QtGui.QIcon(pixmap),
"Show/hide type information",
None,
triggered=self.showTypes)
self.showTypesAction.setCheckable(True)
self.showTypesAction.setChecked(True)
self.toolWindow().toolbar.insertAction(self.toolWindow().pinAction,
self.showTypesAction)

def showPortVisibility(self, checked):
self.portsVisible = checked
self.update_module(self.module)

def showTypes(self, checked):
self.typesVisible = checked
self.update_module(self.module)

def build_widget(self):
name_label = QtGui.QLabel("Name:")
Expand Down Expand Up @@ -149,6 +195,9 @@ def set_controller(self, controller):
self.update_module()

def update_module(self, module=None):
for plist in self.ports_lists:
plist.typesVisible = self.typesVisible
plist.portsVisible = self.portsVisible
self.module = module
for ports_list in self.ports_lists:
ports_list.update_module(module)
Expand Down
19 changes: 13 additions & 6 deletions vistrails/gui/ports_pane.py
Expand Up @@ -142,11 +142,12 @@ class ParameterEntry(QtGui.QTreeWidgetItem):
'gui/resources/images/plus.png'))
minus_icon = QtGui.QIcon(os.path.join(vistrails_root_directory(),
'gui/resources/images/minus.png'))
def __init__(self, port_spec, function=None, parent=None):
def __init__(self, port_spec, function=None, types_visible=True, parent=None):
QtGui.QTreeWidgetItem.__init__(self, parent)
self.setFirstColumnSpanned(True)
self.port_spec = port_spec
self.function = function
self.types_visible = types_visible

def build_widget(self, widget_accessor, with_alias=True):
reg = get_module_registry()
Expand Down Expand Up @@ -224,7 +225,9 @@ def add_method():
else:
obj = Parameter(psi.descriptor)
obj.port_spec_item = psi
if with_alias:
if not self.types_visible:
label = QtGui.QLabel('')
elif with_alias:
label = AliasLabel(obj.alias, obj.type, psi.label)
self.my_labels.append(label)
else:
Expand Down Expand Up @@ -368,6 +371,8 @@ def __init__(self, port_type, parent=None):
self.module = None
self.port_spec_items = {}
self.entry_klass = ParameterEntry
self.portsVisible = True
self.typesVisible = True

def setReadOnly(self, read_only):
self.setEnabled(not read_only)
Expand All @@ -384,6 +389,7 @@ def update_module(self, module):
# this is strange but if you try to clear the widget when the focus is
# in one of the items (after setting a parameter for example),
# VisTrails crashes on a Mac (Emanuele) This is probably a Qt bug
self.setColumnHidden(0, not self.portsVisible)
w = QtGui.QApplication.focusWidget()
if self.isAncestorOf(w):
w.clearFocus()
Expand Down Expand Up @@ -420,11 +426,12 @@ def update_module(self, module):
if not function.is_valid:
continue
port_spec, item = self.port_spec_items[function.name]
subitem = self.entry_klass(port_spec, function)
subitem = self.entry_klass(port_spec, function,
self.typesVisible)
self.function_map[function.real_id] = subitem
item.addChild(subitem)
subitem.setFirstColumnSpanned(True)
self.setItemWidget(subitem, 0, subitem.get_widget())
self.setItemWidget(subitem, 1, subitem.get_widget())
item.setExpanded(True)

# self.setItemWidget(item, 0, item.get_visible())
Expand Down Expand Up @@ -502,7 +509,7 @@ def update_module(self, module):
self.function_map[function.real_id] = subitem
item.addChild(subitem)
subitem.setFirstColumnSpanned(True)
self.setItemWidget(subitem, 0, subitem.get_widget())
self.setItemWidget(subitem, 1, subitem.get_widget())
item.setExpanded(True)

def item_clicked(self, item, col):
Expand Down Expand Up @@ -600,7 +607,7 @@ def do_add_method(self, port_spec, item):
subitem = self.entry_klass(port_spec)
item.addChild(subitem)
subitem.setFirstColumnSpanned(True)
self.setItemWidget(subitem, 0, subitem.get_widget())
self.setItemWidget(subitem, 1, subitem.get_widget())
item.setExpanded(True)
if len(port_spec.descriptors()) == 0:
self.update_method(subitem, port_spec.name, [], [])
Expand Down

0 comments on commit c48a9c3

Please sign in to comment.