def removeRows(self, position, rows=1, index=QModelIndex()): """ Remove N (default=1) rows from the model at a desired position. """ if 0 <= position < len(self.row_data) and 0 <= position + rows < len( self.row_data): self.beginRemoveRows(QModelIndex(), position, position + rows - 1) del self.row_data[position:position + rows] self.endRemoveRows() return True return False
def insertRows(self, position, rows=1, index=QModelIndex()): """ Insert N (default=1) rows into the model at a desired position. """ self.beginInsertRows(QModelIndex(), position, position + rows - 1) for row in range(rows): self.row_data.insert(position + row, [None, "LOADING", "USER", datetime.now()]) self.checks.insert(position + row, False) self.endInsertRows() return True
def update_table(self): for address, function in self.controller.functions().items(): self.insertRows(0) row_data = [address, function.name, "", -1] for i in range(len(self.HEADER)): idx = self.index(0, i, QModelIndex()) self.setData(idx, row_data[i], role=Qt.EditRole)
def push(self): self.proxymodel.setFilterFixedString("") for i in range(self.proxymodel.rowCount()): proxyIndex = self.proxymodel.index(i, 0, QModelIndex()) mappedIndex = self.proxymodel.mapToSource(proxyIndex) if self.model.checkState(mappedIndex): func_addr = int(self.model.data(mappedIndex), 16) self.controller.force_push_function(func_addr)
def handle_filteredit_change(self, text): """ Handle text changes in the filter box, filters the table by the arg. """ self.proxymodel.setFilterFixedString(text) self.select_all.setChecked(False) for i in range(self.proxymodel.rowCount()): proxyIndex = self.proxymodel.index(i, 0, QModelIndex()) mappedIndex = self.proxymodel.mapToSource(proxyIndex) if not self.model.data(mappedIndex, Qt.CheckStateRole): break else: self.select_all.setChecked(True)
def push(self): self.proxymodel.setFilterFixedString("") for i in range(self.proxymodel.rowCount()): proxyIndex = self.proxymodel.index(i, 0, QModelIndex()) mappedIndex = self.proxymodel.mapToSource(proxyIndex) if self.model.checkState(mappedIndex): type_ = self.model.data(mappedIndex) name = self.model.data(mappedIndex.sibling(mappedIndex.row(), 1)) lookup_item = self._lookup_addr_for_gvar(name) if type_ == "Variable" else name print(f"\npushing {lookup_item}\n") self.controller.force_push_global_artifact(lookup_item)
def update_table(self): decompiler_structs = self.controller.structs() decompiler_gvars = self.controller.global_vars() decompiler_enums = self.controller.enums() self.gvar_name_to_addr_map = {gvar.name: addr for addr, gvar in decompiler_gvars.items()} all_artifacts = [(decompiler_structs, "Struct"), (decompiler_gvars, "Variable"), (decompiler_enums, "Enum")] for type_artifacts, type_ in all_artifacts: for _, artifact in type_artifacts.items(): row = [type_, artifact.name or artifact.addr, "", -1] tab_idx = 0 self.insertRows(0) for i in range(self.columnCount()): idx = self.index(tab_idx, i, QModelIndex()) self.setData(idx, row[i], role=Qt.EditRole)
def columnCount(self, index=QModelIndex()): """ Returns number of columns the model holds. """ return len(self.HEADER)
def rowCount(self, index=QModelIndex()): """ Returns number of rows the model holds. """ return len(self.row_data)
def uncheck_all(self): for i in range(self.proxymodel.rowCount()): proxyIndex = self.proxymodel.index(i, 0, QModelIndex()) mappedIndex = self.proxymodel.mapToSource(proxyIndex) self.model.setData(mappedIndex, False, Qt.CheckStateRole)