changeset 141:cdddae282d1a

Removed hexviewer
author Windel Bouwman
date Sun, 27 Jan 2013 12:17:19 +0100
parents 104037b292cc
children 982ddb5f786d
files python/hexedit.py python/hexviewer.py
diffstat 1 files changed, 0 insertions(+), 97 deletions(-) [+]
line wrap: on
line diff
--- a/python/hexviewer.py	Sun Jan 27 12:16:09 2013 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,97 +0,0 @@
-#!/usr/bin/python
-
-from PyQt4.QtCore import *
-from PyQt4.QtGui import *
-from qtpropertyviewer import QtPropertyViewer
-import sys
-import hexfile
-
-
-class HexFileModel(QAbstractTableModel):
-   def __init__(self):
-      super().__init__()
-      self.hexFile = None
-   def setHexFile(self, hf):
-      self.hexFile = hf
-      self.modelReset.emit()
-   def getHexFile(self):
-      return self.hexFile
-   HexFile = property(getHexFile, setHexFile)
-   def rowCount(self, parent):
-      if self.hexFile:
-         region = self.hexFile.regions[-1]
-         r = len(region.data)
-         s = r >> 4
-         if r % 16 != 0:
-            s += 1
-         return s
-      return 0
-   def columnCount(self, parent):
-      return 16 + 1
-   def headerData(self, section, orientation, role):
-      if role == Qt.DisplayRole:
-         if orientation == Qt.Horizontal:
-            if section in range(16):
-               return '{0:X}'.format(section)
-            elif section == 16:
-               return 'Ascii'
-         elif orientation == Qt.Vertical:
-            region = self.hexFile.regions[-1]
-            addr = region.address + 16 * section
-            return '0x{0:X}'.format(addr)
-   def data(self, index, role):
-      if index.isValid():
-         row = index.row()
-         col = index.column()
-         region = self.hexFile.regions[-1]
-         chunk = region.data[row * 16: row * 16 + 16]
-
-         if role == Qt.DisplayRole:
-            if col in range(16):
-               return '{0:02X}'.format(chunk[col])
-            else:
-               s = chunk.decode(encoding='ascii', errors='replace')
-               return s
-
-class BinViewMain(QMainWindow):
-   def __init__(self):
-      super().__init__()
-      self.bv = BinViewer()
-      #self.setCentralWidget(self.bv)
-      tableView = QTableView()
-      self.setCentralWidget(tableView)
-      self.hfm = HexFileModel()
-      self.hfm.modelReset.connect(tableView.resizeColumnsToContents)
-      tableView.setModel(self.hfm)
-      mb = self.menuBar()
-      fileMenu = mb.addMenu("File")
-      
-      def addMenuEntry(name, menu, callback, shortcut=None):
-         a = QAction(name, self)
-         menu.addAction(a)
-         a.triggered.connect(callback)
-         if shortcut: a.setShortcut(shortcut)
-      addMenuEntry("Open", fileMenu, self.openFile, QKeySequence(QKeySequence.Open))
-   def openFile(self):
-      filename = QFileDialog.getOpenFileName(self, "Open hex file...", "*.hex", "Intel hexfiles (*.hex)")
-      if filename:
-         h = hexfile.HexFile(filename)
-   @pyqtProperty(str)
-   def leetValue(self):
-      return '1337'
-
-if __name__ == '__main__':
-   app = QApplication(sys.argv)
-   bv = BinViewMain()
-   #bv.show()
-   hf = hexfile.HexFile('audio.hex')
-   #bv.bv.setHexFile(
-   bv.hfm.HexFile = hf
-   qpv = QtPropertyViewer()
-   qpv.propertyModel.InspectedWidget = bv
-   #qpv.show()
-   bv = BinViewer()
-   bv.show()
-   bv.setHexFile(hf)
-   app.exec_()
-