Beispiel #1
0
  def data(self, index, role = Qt.DisplayRole):
    if not index.isValid():
      return QVariant()

    if role == Qt.TextAlignmentRole:
      return QVariant(Qt.AlignHCenter | Qt.AlignVCenter)

    elif role == Qt.DisplayRole:
      if self.is_readable(index.row()):
        return QVariant(  word2str(     self.memory[index.row()]  ))
      else:
        return QVariant(self.tr("LOCKED"))
    elif role == Qt.ToolTipRole:
      if self.is_readable(index.row()):
        return QVariant(  word2toolTip( self.memory[index.row()]  ))
      else:
        return QVariant(self.tr("This memory cell is locked for reading"))

    else:
      return QVariant()
Beispiel #2
0
    def data(self, index, role=Qt.DisplayRole):
        if not index.isValid():
            return QVariant()

        if role == Qt.TextAlignmentRole:
            return QVariant(Qt.AlignHCenter | Qt.AlignVCenter)

        elif role == Qt.DisplayRole:
            if self.is_readable(index.row()):
                return QVariant(word2str(self.memory[index.row()]))
            else:
                return QVariant(self.tr("LOCKED"))
        elif role == Qt.ToolTipRole:
            if self.is_readable(index.row()):
                return QVariant(word2toolTip(self.memory[index.row()]))
            else:
                return QVariant(
                    self.tr("This memory cell is locked for reading"))

        else:
            return QVariant()
Beispiel #3
0
    def data(self, index, role=Qt.DisplayRole):
        if not index.isValid():
            return QVariant()

        if role == Qt.TextAlignmentRole:
            if index.column() in (0, 1):
                # address, mix word
                return QVariant(Qt.AlignHCenter | Qt.AlignVCenter)
            else:
                # source line
                return QVariant(Qt.AlignLeft | Qt.AlignVCenter)

        elif role == Qt.BackgroundRole:
            changed_row = self.lines[index.row()].modified
            ca_row = index.row() == self.current_line
            locked_row = self.is_locked(self.lines[index.row()].addr)
            if changed_row and ca_row and locked_row:
                return QVariant(QColor(200, 150, 0))

            elif changed_row and ca_row:
                return QVariant(QColor(220, 220, 0))
            elif changed_row and locked_row:
                return QVariant(QColor(200, 25, 0))
            elif locked_row and ca_row:
                return QVariant(QColor(255, 175, 0))

            elif changed_row:
                return QVariant(QColor(Qt.gray))
            elif ca_row:
                return QVariant(QColor(255, 255, 0))
            elif locked_row:
                return QVariant(QColor(255, 50, 0))
            else:
                return QVariant()

        elif role == Qt.DisplayRole:
            listing_line = self.lines[index.row()]
            column = index.column()

            if column == 0:
                if listing_line.addr is not None:
                    return QVariant(listing_line.addr2str())
                else:
                    return QVariant(u"")

            elif column == 1:
                if listing_line.addr is not None:
                    if self.is_readable(listing_line.addr):
                        return QVariant(self.words[listing_line.addr].addr_str(
                        ))  # print first two bytes as one address
                    else:
                        return QVariant(self.tr("LOCKED"))
                else:
                    return QVariant(u"")

            else:
                return QVariant(listing_line.line)

        elif role == Qt.ToolTipRole:
            if self.lines[
                    index.row()].addr is not None and index.column() == 1:
                if self.is_readable(self.lines[index.row()].addr):
                    return QVariant(
                        word2toolTip(self.words[self.lines[index.row()].addr]))
                else:
                    return QVariant(
                        self.tr("This memory cell is locked for reading"))
            else:
                return QVariant(u"")

        else:
            return QVariant()
Beispiel #4
0
  def data(self, index, role = Qt.DisplayRole):
    if not index.isValid():
      return QVariant()

    if role == Qt.TextAlignmentRole:
      if index.column() in (0,1):
        # address, mix word
        return QVariant(Qt.AlignHCenter | Qt.AlignVCenter)
      else:
        # source line
        return QVariant(Qt.AlignLeft | Qt.AlignVCenter)

    elif role == Qt.BackgroundRole:
      changed_row = self.lines[index.row()].modified
      ca_row = index.row() == self.current_line
      locked_row = self.is_locked(self.lines[index.row()].addr)
      if changed_row and ca_row and locked_row:
        return QVariant(QColor(200, 150, 0))

      elif changed_row and ca_row:
        return QVariant(QColor(220, 220, 0))
      elif changed_row and locked_row:
        return QVariant(QColor(200, 25, 0))
      elif locked_row and ca_row:
        return QVariant(QColor(255, 175, 0))

      elif changed_row:
        return QVariant(QColor(Qt.gray))
      elif ca_row:
        return QVariant(QColor(255, 255, 0))
      elif locked_row:
        return QVariant(QColor(255, 50, 0))
      else:
        return QVariant()

    elif role == Qt.DisplayRole:
      listing_line = self.lines[index.row()]
      column = index.column()

      if column == 0:
        if listing_line.addr is not None:
          return QVariant(listing_line.addr2str())
        else:
          return QVariant(u"")

      elif column == 1:
        if listing_line.addr is not None:
          if self.is_readable(listing_line.addr):
            return QVariant(self.words[listing_line.addr].addr_str()) # print first two bytes as one address
          else:
            return QVariant(self.tr("LOCKED"))
        else:
          return QVariant(u"")

      else:
        return QVariant(listing_line.line)

    elif role == Qt.ToolTipRole:
        if self.lines[index.row()].addr is not None and index.column() == 1:
          if self.is_readable(self.lines[index.row()].addr):
            return QVariant(word2toolTip( self.words[self.lines[index.row()].addr] ))
          else:
            return QVariant(self.tr("This memory cell is locked for reading"))
        else:
          return QVariant(u"")

    else:
      return QVariant()
Beispiel #5
0
  def data(self, index, role = Qt.DisplayRole):
    if not index.isValid():
      return QVariant()

    i = index.row()

    if role == Qt.TextAlignmentRole:
      if index.column() in (0,1):
        # address, mix word
        return QVariant(Qt.AlignHCenter | Qt.AlignVCenter)
      else:
        # disasm line
        return QVariant(Qt.AlignLeft | Qt.AlignVCenter)

    elif role == Qt.BackgroundRole:
      changed_row = self.modified[i]
      ca_row =  i == self.ca
      locked_row = self.is_locked(i)
      if changed_row and ca_row and locked_row:
        return QVariant(QColor(200, 150, 0))

      elif changed_row and ca_row:
        return QVariant(QColor(220, 220, 0))
      elif changed_row and locked_row:
        return QVariant(QColor(200, 25, 0))
      elif locked_row and ca_row:
        return QVariant(QColor(255, 175, 0))

      elif changed_row:
        return QVariant(QColor(Qt.lightGray))
      elif ca_row:
        return QVariant(QColor(255, 255, 0))
      elif locked_row:
        return QVariant(QColor(255, 50, 0))
      else:
        return QVariant()

    elif role == Qt.DisplayRole:
      if index.column() == 0:
        return QVariant(str(i))

      elif index.column() == 1:
        if self.is_readable(i):
          return QVariant(self.words[i].addr_str()) # print first two bytes as one address
        else:
          return QVariant(self.tr("LOCKED"))

      else:
        if self.is_readable(i):
          return QVariant(self.disasm.disasm2str(self.words[i], i, self.symtable, self.end_addr, "\t"))
        else:
          return QVariant(self.tr("LOCKED"))

    elif role == Qt.ToolTipRole:
        if index.column() == 1:
          if self.is_readable(i):
            return QVariant(word2toolTip( self.words[i] ))
          else:
            return QVariant(self.tr("This memory cell is locked for reading"))
        else:
          return QVariant()

    else:
      return QVariant()