(self, ranges)
Fills Rangelist with Data
Fills Rangelist with Data
Fills Rangelist with Data
def _on_setranges(self, ranges):
        """ Fills Rangelist with Data
        """
        if self._ranges_model.rowCount():
            return

        self.ranges.header().setSectionResizeMode(0, QHeaderView.Fixed)
        if isinstance(ranges, list):
            self._ranges_model.removeRows(0, self._ranges_model.rowCount())
            for range_entry in ranges:
                if 'protection' in range_entry and isinstance(
                        range_entry['protection'], str):
                    if 'r' not in range_entry['protection']:
                        # skip not readable range
                        continue

                else:
                    continue
                # create items to add
                str_frmt = ''
                if self.ranges._uppercase_hex:
                    str_frmt = '0x{0:X}'
                else:
                    str_frmt = '0x{0:x}'

                addr = QStandardItem()
                addr.setTextAlignment(Qt.AlignCenter)
                addr.setText(str_frmt.format(int(range_entry['base'], 16)))

                size = QStandardItem()
                size.setTextAlignment(Qt.AlignRight)
                size.setText("{0:,d}".format(int(range_entry['size'])))

                protection = QStandardItem()
                protection.setTextAlignment(Qt.AlignCenter)
                protection.setText(range_entry['protection'])

                file_path = None
                file_addr = None
                file_size = None

                if len(range_entry) > 3:
                    if range_entry['file']['path']:
                        file_path = QStandardItem()
                        file_path.setText(range_entry['file']['path'])

                    if range_entry['file']['offset']:
                        file_addr = QStandardItem()
                        file_addr.setTextAlignment(Qt.AlignCenter)
                        file_addr.setText(
                            str_frmt.format(range_entry['file']['offset']))

                    if range_entry['file']['size']:
                        file_size = QStandardItem()
                        file_size.setTextAlignment(Qt.AlignRight)
                        file_size.setText("{0:,d}".format(
                            int(range_entry['file']['size'])))

                checkbox = QStandardItem()
                checkbox.setCheckable(True)

                self._ranges_model.appendRow([
                    checkbox, addr, size, protection, file_addr, file_size,
                    file_path
                ])
def _on_setranges ( self , ranges ) : if self . _ranges_model . rowCount ( ) : return self . ranges . header ( ) . setSectionResizeMode ( 0 , QHeaderView . Fixed ) if isinstance ( ranges , list ) : self . _ranges_model . removeRows ( 0 , self . _ranges_model . rowCount ( ) ) for range_entry in ranges : if 'protection' in range_entry and isinstance ( range_entry [ 'protection' ] , str ) : if 'r' not in range_entry [ 'protection' ] : # skip not readable range continue else : continue # create items to add str_frmt = '' if self . ranges . _uppercase_hex : str_frmt = '0x{0:X}' else : str_frmt = '0x{0:x}' addr = QStandardItem ( ) addr . setTextAlignment ( Qt . AlignCenter ) addr . setText ( str_frmt . format ( int ( range_entry [ 'base' ] , 16 ) ) ) size = QStandardItem ( ) size . setTextAlignment ( Qt . AlignRight ) size . setText ( "{0:,d}" . format ( int ( range_entry [ 'size' ] ) ) ) protection = QStandardItem ( ) protection . setTextAlignment ( Qt . AlignCenter ) protection . setText ( range_entry [ 'protection' ] ) file_path = None file_addr = None file_size = None if len ( range_entry ) > 3 : if range_entry [ 'file' ] [ 'path' ] : file_path = QStandardItem ( ) file_path . setText ( range_entry [ 'file' ] [ 'path' ] ) if range_entry [ 'file' ] [ 'offset' ] : file_addr = QStandardItem ( ) file_addr . setTextAlignment ( Qt . AlignCenter ) file_addr . setText ( str_frmt . format ( range_entry [ 'file' ] [ 'offset' ] ) ) if range_entry [ 'file' ] [ 'size' ] : file_size = QStandardItem ( ) file_size . setTextAlignment ( Qt . AlignRight ) file_size . setText ( "{0:,d}" . format ( int ( range_entry [ 'file' ] [ 'size' ] ) ) ) checkbox = QStandardItem ( ) checkbox . setCheckable ( True ) self . _ranges_model . appendRow ( [ checkbox , addr , size , protection , file_addr , file_size , file_path ] )