MCPcopy Index your code
hub / github.com/SLiCAP/SLiCAP_python / _copy_selection

Method _copy_selection

SLiCAP/schematic/canvas.py:253–316  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

251 # ── copy / paste ──────────────────────────────────────────────────────────
252
253 def _copy_selection(self) -> None:
254 from .component_item import ComponentItem
255 sel = self.selectedItems()
256 if not sel:
257 return
258 self._clipboard.clear()
259 self._paste_count = 0
260 for item in sel:
261 if isinstance(item, ComponentItem):
262 item._save_label_offsets()
263 self._clipboard.append({
264 'kind': 'component',
265 'symbol_name': item.symbol_name,
266 'svg_bytes': item._svg_bytes,
267 'x': item.pos().x(),
268 'y': item.pos().y(),
269 'rotation': item.rotation(),
270 'h_flip': item.h_flip,
271 'v_flip': item.v_flip,
272 'params': dict(item.params),
273 'model': item.model,
274 'refs': list(item.refs),
275 'prop_display': {k: tuple(v) for k, v in item.prop_display.items()},
276 'prop_offsets': {k: list(v) for k, v in item.prop_offsets.items()},
277 })
278 elif isinstance(item, WireItem):
279 self._clipboard.append({
280 'kind': 'wire',
281 'points': [(p.x(), p.y()) for p in item.points],
282 'net_name': item.net_name,
283 'display_name': item.display_name,
284 'label_offset': (item.label_offset.x(), item.label_offset.y()),
285 })
286 elif isinstance(item, CommandItem):
287 self._clipboard.append({
288 'kind': 'command',
289 'x': item.pos().x(),
290 'y': item.pos().y(),
291 'text': item.toPlainText(),
292 })
293 elif isinstance(item, FreeTextItem):
294 self._clipboard.append({
295 'kind': 'free_text',
296 'x': item.pos().x(),
297 'y': item.pos().y(),
298 'text': item.toPlainText(),
299 })
300 elif isinstance(item, AnalysisItem):
301 self._clipboard.append({
302 'kind': 'analysis',
303 'x': item.pos().x(),
304 'y': item.pos().y(),
305 'source': list(item.source),
306 'detector': [list(d) for d in item.detector],
307 'lgref': list(item.lgref),
308 })
309 elif isinstance(item, HyperlinkItem):
310 self._clipboard.append({

Callers 1

keyPressEventMethod · 0.80

Calls 2

clearMethod · 0.80
_save_label_offsetsMethod · 0.80

Tested by

no test coverage detected