def remove_footprint(self): directory = self.active_library.directory fn = self.active_footprint.filename QtCore.QDir(directory).remove(fn) # fall back to first_foot in library, if any library = self.rescan_library(self.active_library.name) if library.select_first_foot(): self.active_footprint = library.first_foot_meta self.active_library = library.coffee_lib # else fall back to any first foot... else: root = self.model.invisibleRootItem() for row_index in range(0, root.rowCount()): library = root.child(row_index) if library.select_first_foot(): self.active_footprint_id = library.first_foot.id self.active_library = library directory = self.active_library.directory fn = self.active_footprint.id + '.coffee' ffn = QtCore.QDir(directory).filePath(fn) with open(ffn) as f: self.parent.update_text(f.read())
def disconnect_library(self): dialog = DisconnectLibraryDialog(self) if dialog.exec_() != QtGui.QDialog.Accepted: return lib_name = dialog.get_data() del self.coffee_lib[lib_name] self.save_libraries(self.parent.settings) root = self.model.invisibleRootItem() for row_index in range(0, root.rowCount()): library = root.child(row_index) if library.name == lib_name: break root.removeRow(row_index) if lib_name != self.active_library: return # select first foot of the first library which contains foots for row_index in range(0, root.rowCount()): library = root.child(row_index) if library.select_first_foot(): self.active_footprint = library.first_foot_meta self.active_library = library.coffee_lib fn = self.active_footprint.filename with open(fn) as f: self.parent.update_text(f.read()) return