def _choose_merge(data, others): w = load_ui('merge.ui', None, directory=os.path.dirname(__file__)) w.show() w.raise_() label = others[0].label if len(others) > 0 else data.label w.merged_label.setText(label) entries = [QtGui.QListWidgetItem(other.label) for other in others] for e in entries: e.setCheckState(Qt.Checked) for d, item in zip(others, entries): w.choices.addItem(item) if not w.exec_(): return None result = [ layer for layer, entry in zip(others, entries) if entry.checkState() == Qt.Checked ] if result: result[0].label = str(w.merged_label.text()) return result + [data]
def _set_components(self): """ Set list of component widgets to match current data set """ index = self._ui.data_selector.currentIndex() if index < 0: return data = self._data[index] cids = data.components c_list = self._ui.component_selector c_list.clear() for c in cids: item = QtGui.QListWidgetItem(c.label) c_list.addItem(item) c_list.set_data(item, c)
def _choose_merge(data, others): w = load_ui('merge.ui', None, directory=os.path.dirname(__file__)) w.button_yes.clicked.connect(w.accept) w.button_no.clicked.connect(w.reject) w.show() w.raise_() # Add the main dataset to the list. Some of the 'others' may also be # new ones, so it doesn't really make sense to distinguish between # the two here. The main point is that some datasets, including at # least one new one, have a common shape. others.append(data) others.sort(key=lambda x: x.label) label = others[0].label w.merged_label.setText(label) entries = [QtGui.QListWidgetItem(other.label) for other in others] for e in entries: e.setCheckState(Qt.Checked) for d, item in zip(others, entries): w.choices.addItem(item) if not w.exec_(): return None, None result = [ layer for layer, entry in zip(others, entries) if entry.checkState() == Qt.Checked ] if result: return result, str(w.merged_label.text()) return None, None
def _add_link(self, link): current = self._ui.current_links item = QtGui.QListWidgetItem(str(link)) current.addItem(item) item.setHidden(link.hidden) current.set_data(item, link)