Skip to content

Commit

Permalink
Merge pull request #1795 from astrofrog/fixes-export
Browse files Browse the repository at this point in the history
Fixes related to Export Data dialog
  • Loading branch information
astrofrog authored Jun 27, 2018
2 parents 5d23985 + 6cf98f1 commit c8c7056
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 12 deletions.
5 changes: 5 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ v0.13.4 (unreleased)
* Improve performance when updating links and changing attributes
on subsets. [#1716]

* Fix errors that happened when clicking on the 'Export Data' and
'Define arithmetic attributes' buttons when no data was present,
and fixed Qt errors that happened if the data collection changed
after the 'Export Data' dialog was opened. [#1795]

* Fixed parsing of AVM meta-data from images. [#1732]

v0.13.3 (unreleased)
Expand Down
5 changes: 4 additions & 1 deletion glue/app/qt/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,6 @@ def _setup_ui(self):
self._button_link_data.setIcon(get_icon('glue_link'))
self._button_link_data.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
self._button_link_data.clicked.connect(self._set_up_links)
self._on_data_collection_change()

self._data_toolbar.addWidget(self._button_link_data)

Expand Down Expand Up @@ -409,6 +408,8 @@ def _setup_ui(self):

self.addToolBar(self._data_toolbar)

self._on_data_collection_change()

# Selection mode toolbar

tbar = EditSubsetModeToolBar(parent=self)
Expand Down Expand Up @@ -452,7 +453,9 @@ def _setup_ui(self):
self._hub.subscribe(self, DataCollectionMessage, handler=self._on_data_collection_change)

def _on_data_collection_change(self, *event):
self._button_save_data.setEnabled(len(self.data_collection) > 0)
self._button_link_data.setEnabled(len(self.data_collection) > 1)
self._button_edit_components.setEnabled(len(self.data_collection) > 0)

def keyPressEvent(self, event):
if self.current_tab.activeSubWindow() and self.current_tab.activeSubWindow().widget():
Expand Down
2 changes: 1 addition & 1 deletion glue/app/qt/save_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def __init__(self, data_collection=None, parent=None):

self.ui = load_ui('save_data.ui', parent=self,
directory=os.path.dirname(__file__))
autoconnect_callbacks_to_qt(self.state, self)
autoconnect_callbacks_to_qt(self.state, self.ui)

self.ui.button_cancel.clicked.connect(self.reject)
self.ui.button_ok.clicked.connect(self.accept)
Expand Down
35 changes: 25 additions & 10 deletions glue/core/data_combo_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,18 +374,18 @@ def refresh(self, *args):
self.choices = choices

def _filter_msg(self, msg):
return msg.data in self._data or msg.sender in self._data_collection
return msg.sender in self._data

def register_to_hub(self, hub):
hub.subscribe(self, DataRenameComponentMessage,
handler=self._on_rename,
filter=lambda msg: msg.sender in self._data)
filter=self._filter_msg)
hub.subscribe(self, DataReorderComponentMessage,
handler=self.refresh,
filter=lambda msg: msg.sender in self._data)
filter=self._filter_msg)
hub.subscribe(self, ComponentsChangedMessage,
handler=self.refresh,
filter=lambda msg: msg.sender in self._data)
filter=self._filter_msg)
if self._data_collection is not None:
hub.subscribe(self, DataCollectionDeleteMessage,
handler=self._remove_data)
Expand Down Expand Up @@ -535,16 +535,25 @@ def remove_data(self, data):
self._datasets.remove(data)
self.refresh()

def _remove_data_msg(self, msg):
self.remove_data(msg.data)

def _filter_msg(self, msg):
return msg.sender in self._datasets

def _filter_msg_dc(self, msg):
return msg.sender is self._data_collection

def register_to_hub(self, hub):

super(ManualDataComboHelper, self).register_to_hub(hub)

hub.subscribe(self, DataUpdateMessage,
handler=self._on_data_update,
filter=lambda msg: msg.sender in self._datasets)
filter=self._filter_msg)
hub.subscribe(self, DataCollectionDeleteMessage,
handler=lambda msg: self.remove_data(msg.data),
filter=lambda msg: msg.sender is self._data_collection)
handler=self._remove_data_msg,
filter=self._filter_msg_dc)


class DataCollectionComboHelper(BaseDataComboHelper):
Expand All @@ -571,14 +580,20 @@ def __init__(self, state, selection_property, data_collection):

self.refresh()

def _filter_msg_in(self, msg):
return msg.sender in self._datasets

def _filter_msg_is(self, msg):
return msg.sender is self._datasets

def register_to_hub(self, hub):
super(DataCollectionComboHelper, self).register_to_hub(hub)
hub.subscribe(self, DataUpdateMessage,
handler=self._on_data_update,
filter=lambda msg: msg.sender in self._datasets)
filter=self._filter_msg_in)
hub.subscribe(self, DataCollectionAddMessage,
handler=self.refresh,
filter=lambda msg: msg.sender is self._datasets)
filter=self._filter_msg_is)
hub.subscribe(self, DataCollectionDeleteMessage,
handler=self.refresh,
filter=lambda msg: msg.sender is self._datasets)
filter=self._filter_msg_is)
18 changes: 18 additions & 0 deletions glue/external/echo/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,16 @@ def remove_callback(self, instance, func):
else:
raise ValueError("Callback function not found: %s" % func)

def clear_callbacks(self, instance):
"""
Remove all callbacks on this property.
"""
for cb in [self._callbacks, self._2arg_callbacks]:
if instance in cb:
cb[instance].clear()
if instance in self._disabled:
self._disabled.pop(instance)


class HasCallbackProperties(object):
"""
Expand Down Expand Up @@ -346,6 +356,14 @@ def iter_callback_properties(self):
def callback_properties(self):
return [name for name in dir(self) if self.is_callback_property(name)]

def clear_callbacks(self):
"""
Remove all global and property-specific callbacks.
"""
self._global_callbacks.clear()
for name, prop in self.iter_callback_properties():
prop.clear_callbacks(self)


def add_callback(instance, prop, callback, echo_old=False, priority=0):
"""
Expand Down

0 comments on commit c8c7056

Please sign in to comment.