# eric7.HexEdit.HexEditMainWindow

Module implementing the hex editor main window.

### Global Attributes

None

### Classes

HexEditMainWindow | Class implementing the web browser main window.

### Functions

None

## HexEditMainWindow

Class implementing the web browser main window.

### Signals

editorClosed()
  emitted after the window was requested to close down

### Derived from

EricMainWindow

### Class Attributes

maxMenuFilePathLen
windows

### Class Methods

None

### Methods

HexEditMainWindow | Constructor
__about | Private slot to show a little About message.
__aboutQt | Private slot to handle the About Qt dialog.
__addToRecentList | Private method to add a file name to the list of recently opened files.
__checkActions | Private slot to check some actions for their enable/disable status.
__clearRecent | Private method to clear the list of recently opened files.
__closeAll | Private slot to close all windows.
__closeOthers | Private slot to close all other windows.
__createStatusBar | Private method to initialize the status bar.
__goto | Private method to handle the goto action.
__initActions | Private method to define the user interface actions.
__initConfigActions | Private method to create the Settings actions.
__initEditActions | Private method to create the Edit actions.
__initFileActions | Private method to define the file related user interface actions.
__initHelpActions | Private method to create the Help actions.
__initMenus | Private method to create the menus.
__initToolbars | Private method to create the toolbars.
__loadHexFile | Private method to load a binary file.
__loadRecent | Private method to load the list of recently opened files.
__maybeSave | Private method to ask the user to save the file, if it was modified.
__modificationChanged | Private slot to handle the dataChanged signal.
__openHexFile | Private slot to open a binary file.
__openHexFileNewWindow | Private slot called to open a binary file in new hex editor window.
__openHexFileReadOnly | Private slot to open a binary file in read only mode.
__openRecentHexFile | Private method to open a file from the list of recently opened files.
__preferencesChangedByLocalPreferencesDialog | Private slot to handle preferences changes by our local dialog.
__replace | Private method to handle the replace action.
__saveHexDataFile | Private method to save the binary data to a file.
__saveHexFile | Private method to save a binary file.
__saveHexFileAs | Private method to save the data to a new file.
__saveHexFileReadable | Private method to save the binary data in readable format.
__saveRecent | Private method to save the list of recently opened files.
__saveSelectionReadable | Private method to save the data of the current selection in readable format.
__search | Private method to handle the search action.
__setCurrentFile | Private method to register the file name of the current file.
__setReadOnlyActionTexts | Private method to switch the 'Open Read Only' action between 'read only' and 'read write'.
__showAddress | Private slot to show the address of the cursor position.
__showEditMode | Private slot to show the edit mode.
__showFileMenu | Private slot to modify the file menu before being shown.
__showPreferences | Private slot to set the preferences.
__showReadOnlyMode | Private slot to show the read only mode.
__showRecentMenu | Private slot to set up the recent files menu.
__showSelectionInfo | Private slot to show selection information.
__showSize | Private slot to show the binary data size.
__strippedName | Private method to return the filename part of the given path.
__toggleEditMode | Private slot to toggle the edit mode upon a click on the status bar label.
__toggleReadOnlyMode | Private slot to toggle the read only mode upon a click on the status bar label.
__whatsThis | Private slot called in to enter Whats This mode.
closeEvent | Protected event handler for the close event.
getSRHistory | Public method to get the search or replace history list.
preferencesChanged | Public method to (re-)read the various settings.
setRecentPaths | Public method to set the last open and save paths.

### Static Methods

None

#### HexEditMainWindow (Constructor)

HexEditMainWindow(fileName="", parent=None, fromEric=False, project=None)

Constructor

fileName
  name of a file to load on startup (string)
parent
  parent widget of this window (QWidget)
fromEric
  flag indicating whether it was called from within eric (boolean)
project
  reference to the project object (Project)

#### HexEditMainWindow.__about

__about()

Private slot to show a little About message.

#### HexEditMainWindow.__aboutQt

__aboutQt()

Private slot to handle the About Qt dialog.

#### HexEditMainWindow.__addToRecentList

__addToRecentList(fileName)

Private method to add a file name to the list of recently opened files.

fileName
  name of the file to be added

#### HexEditMainWindow.__checkActions

__checkActions()

Private slot to check some actions for their enable/disable status.

#### HexEditMainWindow.__clearRecent

__clearRecent()

Private method to clear the list of recently opened files.

#### HexEditMainWindow.__closeAll

__closeAll()

Private slot to close all windows.

#### HexEditMainWindow.__closeOthers

__closeOthers()

Private slot to close all other windows.

#### HexEditMainWindow.__createStatusBar

__createStatusBar()

Private method to initialize the status bar.

#### HexEditMainWindow.__goto

__goto()

Private method to handle the goto action.

#### HexEditMainWindow.__initActions

__initActions()

Private method to define the user interface actions.

#### HexEditMainWindow.__initConfigActions

__initConfigActions()

Private method to create the Settings actions.

#### HexEditMainWindow.__initEditActions

__initEditActions()

Private method to create the Edit actions.

#### HexEditMainWindow.__initFileActions

__initFileActions()

Private method to define the file related user interface actions.

#### HexEditMainWindow.__initHelpActions

__initHelpActions()

Private method to create the Help actions.

#### HexEditMainWindow.__initMenus

__initMenus()

Private method to create the menus.

#### HexEditMainWindow.__initToolbars

__initToolbars()

Private method to create the toolbars.

#### HexEditMainWindow.__loadHexFile

__loadHexFile(fileName)

Private method to load a binary file.

fileName (str)
  name of the binary file to load

#### HexEditMainWindow.__loadRecent

__loadRecent()

Private method to load the list of recently opened files.

#### HexEditMainWindow.__maybeSave

__maybeSave()

Private method to ask the user to save the file, if it was modified.

Return:
  flag indicating, if it is ok to continue

Return Type:
  bool

#### HexEditMainWindow.__modificationChanged

__modificationChanged(m)

Private slot to handle the dataChanged signal.

m (bool)
  modification status

#### HexEditMainWindow.__openHexFile

__openHexFile()

Private slot to open a binary file.

#### HexEditMainWindow.__openHexFileNewWindow

__openHexFileNewWindow()

Private slot called to open a binary file in new hex editor window.

#### HexEditMainWindow.__openHexFileReadOnly

__openHexFileReadOnly()

Private slot to open a binary file in read only mode.

#### HexEditMainWindow.__openRecentHexFile

__openRecentHexFile(act)

Private method to open a file from the list of recently opened files.

act
  reference to the action that triggered (QAction)

#### HexEditMainWindow.__preferencesChangedByLocalPreferencesDialog

__preferencesChangedByLocalPreferencesDialog()

Private slot to handle preferences changes by our local dialog.

#### HexEditMainWindow.__replace

__replace()

Private method to handle the replace action.

#### HexEditMainWindow.__saveHexDataFile

__saveHexDataFile(fileName)

Private method to save the binary data to a file.

fileName (str)
  name of the file to write to

Return:
  flag indicating success

Return Type:
  bool

#### HexEditMainWindow.__saveHexFile

__saveHexFile()

Private method to save a binary file.

Return:
  flag indicating success

Return Type:
  bool

#### HexEditMainWindow.__saveHexFileAs

__saveHexFileAs()

Private method to save the data to a new file.

Return:
  flag indicating success

Return Type:
  bool

#### HexEditMainWindow.__saveHexFileReadable

__saveHexFileReadable(selectionOnly=False)

Private method to save the binary data in readable format.

selectionOnly (bool)
  flag indicating to save the selection only

#### HexEditMainWindow.__saveRecent

__saveRecent()

Private method to save the list of recently opened files.

#### HexEditMainWindow.__saveSelectionReadable

__saveSelectionReadable()

Private method to save the data of the current selection in readable format.

#### HexEditMainWindow.__search

__search()

Private method to handle the search action.

#### HexEditMainWindow.__setCurrentFile

__setCurrentFile(fileName)

Private method to register the file name of the current file.

fileName (str)
  name of the file to register

#### HexEditMainWindow.__setReadOnlyActionTexts

__setReadOnlyActionTexts()

Private method to switch the 'Open Read Only' action between 'read only' and 'read write'.

#### HexEditMainWindow.__showAddress

__showAddress(address)

Private slot to show the address of the cursor position.

address (int)
  address of the cursor

#### HexEditMainWindow.__showEditMode

__showEditMode(overwrite)

Private slot to show the edit mode.

overwrite (bool)
  flag indicating overwrite mode

#### HexEditMainWindow.__showFileMenu

__showFileMenu()

Private slot to modify the file menu before being shown.

#### HexEditMainWindow.__showPreferences

__showPreferences()

Private slot to set the preferences.

#### HexEditMainWindow.__showReadOnlyMode

__showReadOnlyMode(on)

Private slot to show the read only mode.

on (bool)
  flag indicating the read only state

#### HexEditMainWindow.__showRecentMenu

__showRecentMenu()

Private slot to set up the recent files menu.

#### HexEditMainWindow.__showSelectionInfo

__showSelectionInfo(avail)

Private slot to show selection information.

avail (bool)
  flag indicating the availability of a selection.

#### HexEditMainWindow.__showSize

__showSize(size)

Private slot to show the binary data size.

size (int)
  size of the binary data

#### HexEditMainWindow.__strippedName

__strippedName(fullFileName)

Private method to return the filename part of the given path.

fullFileName (str)
  full pathname of the given file

Return:
  filename part

Return Type:
  str

#### HexEditMainWindow.__toggleEditMode

__toggleEditMode()

Private slot to toggle the edit mode upon a click on the status bar label.

#### HexEditMainWindow.__toggleReadOnlyMode

__toggleReadOnlyMode()

Private slot to toggle the read only mode upon a click on the status bar label.

#### HexEditMainWindow.__whatsThis

__whatsThis()

Private slot called in to enter Whats This mode.

#### HexEditMainWindow.closeEvent

closeEvent(evt)

Protected event handler for the close event.

evt (QCloseEvent)
  reference to the close event
  This event is simply accepted after the history has been saved and all window references have been deleted.

#### HexEditMainWindow.getSRHistory

getSRHistory(key)

Public method to get the search or replace history list.

key (str (must be 'search' or 'replace'))
  name of list to return

Return:
  the requested history list

Return Type:
  list of tuples of (int, str)

#### HexEditMainWindow.preferencesChanged

preferencesChanged()

Public method to (re-)read the various settings.

#### HexEditMainWindow.setRecentPaths

setRecentPaths(openPath, savePath)

Public method to set the last open and save paths.

openPath (str)
  least recently used open path
savePath (str)
  least recently used save path

Up