src/eric7/Debugger/VariablesViewer.py

branch
eric7
changeset 11000
f8371a2dd08f
parent 10928
46651e194fbe
child 11006
a671918232f3
equal deleted inserted replaced
10999:c3cf24fe9113 11000:f8371a2dd08f
443 if end > parent.absolutCount: 443 if end > parent.absolutCount:
444 self.beginRemoveRows(parentIdx, parent.absolutCount, end) 444 self.beginRemoveRows(parentIdx, parent.absolutCount, end)
445 del parent.children[parent.absolutCount :] 445 del parent.children[parent.absolutCount :]
446 self.endRemoveRows() 446 self.endRemoveRows()
447 447
448 def resetModifiedMarker(self, parentIdx=QModelIndex(), pathlist=()): 448 def resetModifiedMarker(self, parentIdx=None, pathlist=None):
449 """ 449 """
450 Public method to remove the modified marker from changed items. 450 Public method to remove the modified marker from changed items.
451 451
452 @param parentIdx item to reset marker 452 @param parentIdx item to reset marker (defaults to None)
453 @type QModelIndex 453 @type QModelIndex (optional)
454 @param pathlist full path to the variable 454 @param pathlist full path to the variable (defaults to None)
455 @type list of str 455 @type list of str (optional)
456 """ 456 """
457 if parentIdx is None:
458 parentIdx = QModelIndex()
459 if pathlist is None:
460 pathlist = []
461
457 parent = parentIdx.internalPointer() if parentIdx.isValid() else self.rootNode 462 parent = parentIdx.internalPointer() if parentIdx.isValid() else self.rootNode
458 463
459 parent.newItems.clear() 464 parent.newItems.clear()
460 parent.changedItems.clear() 465 parent.changedItems.clear()
461 466
488 self.rootNode.populated = False 493 self.rootNode.populated = False
489 idxStart = self.index(0, 0, QModelIndex()) 494 idxStart = self.index(0, 0, QModelIndex())
490 idxEnd = self.index(0, 2, QModelIndex()) 495 idxEnd = self.index(0, 2, QModelIndex())
491 self.dataChanged.emit(idxStart, idxEnd) 496 self.dataChanged.emit(idxStart, idxEnd)
492 497
493 def columnCount(self, parent=QModelIndex()): # noqa: U100 498 def columnCount(self, parent=None): # noqa: U100
494 """ 499 """
495 Public method to get the column count. 500 Public method to get the column count.
496 501
497 @param parent the model parent (unused) 502 @param parent the model parent (defaults to None) (unused)
498 @type QModelIndex 503 @type QModelIndex (optional)
499 @return number of columns 504 @return number of columns
500 @rtype int 505 @rtype int
501 """ 506 """
502 return 3 507 return 3
503 508
504 def rowCount(self, parent=QModelIndex()): 509 def rowCount(self, parent=None):
505 """ 510 """
506 Public method to get the row count. 511 Public method to get the row count.
507 512
508 @param parent the model parent 513 @param parent the model parent (defaults to None)
509 @type QModelIndex 514 @type QModelIndex (optional)
510 @return number of rows 515 @return number of rows
511 @rtype int 516 @rtype int
512 """ 517 """
513 node = parent.internalPointer() if parent.isValid() else self.rootNode 518 node = (
519 parent.internalPointer()
520 if parent is not None and parent.isValid()
521 else self.rootNode
522 )
514 523
515 return len(node.children) 524 return len(node.children)
516 525
517 def flags(self, index): 526 def flags(self, index):
518 """ 527 """
526 if not index.isValid(): 535 if not index.isValid():
527 return Qt.ItemFlag.NoItemFlags 536 return Qt.ItemFlag.NoItemFlags
528 537
529 return Qt.ItemFlag.ItemIsEnabled | Qt.ItemFlag.ItemIsSelectable 538 return Qt.ItemFlag.ItemIsEnabled | Qt.ItemFlag.ItemIsSelectable
530 539
531 def hasChildren(self, parent=QModelIndex()): 540 def hasChildren(self, parent=None):
532 """ 541 """
533 Public method to get a flag if parent has children. 542 Public method to get a flag if parent has children.
534 543
535 @param parent the model parent 544 @param parent the model parent (defaults to None)
536 @type QModelIndex 545 @type QModelIndex (optional)
537 @return flag indicating parent has children 546 @return flag indicating parent has children
538 @rtype bool 547 @rtype bool
539 """ 548 """
540 if not parent.isValid(): 549 if parent is None or not parent.isValid():
541 return self.rootNode.children != [] 550 return self.rootNode.children != []
542 551
543 return parent.internalPointer().hasChildren 552 return parent.internalPointer().hasChildren
544 553
545 def index(self, row, column, parent=QModelIndex()): 554 def index(self, row, column, parent=None):
546 """ 555 """
547 Public method to get the index of item at row:column of parent. 556 Public method to get the index of item at row:column of parent.
548 557
549 @param row number of rows 558 @param row number of rows
550 @type int 559 @type int
551 @param column number of columns 560 @param column number of columns
552 @type int 561 @type int
553 @param parent the model parent 562 @param parent the model parent (defaults to None)
554 @type QModelIndex 563 @type QModelIndex (optional)
555 @return new model index for child 564 @return new model index for child
556 @rtype QModelIndex 565 @rtype QModelIndex
557 """ 566 """
567 if parent is None:
568 parent = QModelIndex()
569
558 if not self.hasIndex(row, column, parent): 570 if not self.hasIndex(row, column, parent):
559 return QModelIndex() 571 return QModelIndex()
560 572
561 node = parent.internalPointer() if parent.isValid() else self.rootNode 573 node = parent.internalPointer() if parent.isValid() else self.rootNode
562 574

eric ide

mercurial