# eric7.UI.Browser

Module implementing a browser with class browsing capabilities.

### Global Attributes

None

### Classes

Browser | Class used to display a file system tree.

### Functions

None

## Browser

Class used to display a file system tree.

Via the context menu that is displayed by a right click the user can select various actions on the selected file.

### Signals

binaryFile(filename)
  emitted to open a file as binary (str)
designerFile(filename)
  emitted to open a Qt-Designer file (str)
linguistFile(filename)
  emitted to open a Qt-Linguist (*.ts) file (str)
multiProjectFile(filename)
  emitted to open an eric multi project file (str)
pixmapEditFile(filename)
  emitted to edit a pixmap file (str)
pixmapFile(filename)
  emitted to open a pixmap file (str)
projectFile(filename)
  emitted to open an eric project file (str)
sourceFile(filename)
  emitted to open a Python file at a line (str)
sourceFile(filename, lineno)
  emitted to open a Python file at a line (str, int)
sourceFile(filename, lineno, type)
  emitted to open a Python file at a line giving an explicit file type (str, int, str)
sourceFile(filename, linenos)
  emitted to open a Python file giving a list of lines(str, list)
svgFile(filename)
  emitted to open a SVG file (str)
trpreview(filenames)
  emitted to preview Qt-Linguist (*.qm) files (list of str)
trpreview(filenames, ignore)
  emitted to preview Qt-Linguist (*.qm) files indicating whether non-existent files shall be ignored (list of str, bool)
umlFile(filename)
  emitted to open an eric UML file (str)
unittestOpen(filename)
  emitted to open a Python file for a unit test (str)

### Derived from

QTreeView

### Class Attributes

None

### Class Methods

None

### Methods

Browser | Constructor
__addAsToplevelDir | Private slot to handle the Add as toplevel directory popup menu entry.
__createPopupMenus | Private method to generate the various popup menus.
__deleteDirectory | Private method to delete a directory.
__deleteFile | Private method to delete a file.
__deleteMultiple | Private slot to delete multiple directories and files.
__findInDirectory | Private slot to handle the Find in directory popup menu entry.
__newToplevelDir | Private slot to handle the New toplevel directory popup menu entry.
__refreshDirectory | Private slot to refresh a directory entry.
__refreshSource | Private slot to refresh the structure of a source file.
__removeToplevel | Private slot to handle the Remove from toplevel popup menu entry.
__replaceInDirectory | Private slot to handle the Find&Replace in directory popup menu entry.
__showMimeType | Private slot to show the mime type of the selected entry.
_contextMenuRequested | Protected slot to show the context menu of the listview.
_copyToClipboard | Protected method to copy the text shown for an entry to the clipboard.
_deleteFileOrDirectory | Protected slot to delete a directory or file.
_editPixmap | Protected slot to handle the open in icon editor popup menu entry.
_gotoAttribute | Protected slot to handle the selection of the goto menu.
_init | Protected method to perform initialization tasks common to this base class and all derived classes.
_keyboardSearchType | Protected method to check, if the item is of the correct type.
_newDirectory | Protected slot to create a new directory.
_newFile | Protected slot to create a new file.
_openFileInEditor | Protected slot to handle the Open in Editor menu action.
_openHexEditor | Protected slot to handle the open in hex editor popup menu entry.
_openItem | Protected slot to handle the open popup menu entry.
_resizeColumns | Protected slot to resize the view when items get expanded or collapsed.
_resort | Protected slot to resort the tree.
_showGotoMenu | Protected slot to prepare the goto submenu of the attribute menu.
_showHidden | Protected slot to show or hide hidden files.
getSelectedItems | Public method to get the selected items.
getSelectedItemsCount | Public method to get the count of items selected.
getSelectedItemsCountCategorized | Public method to get a categorized count of selected items.
handleInterpreterChanged | Public slot to handle a change of the debug client's interpreter.
handlePreferencesChanged | Public slot used to handle the preferencesChanged signal.
handleProgramChange | Public slot to handle the programChange signal.
handleUnittest | Public slot to handle the unittest popup menu entry.
keyboardSearch | Public function to search the tree via the keyboard.
layoutDisplay | Public slot to perform a layout operation.
mouseDoubleClickEvent | Protected method of QAbstractItemView.
saveToplevelDirs | Public slot to save the toplevel directories.
wantedItem | Public method to check type of an item.

### Static Methods

None

#### Browser (Constructor)

Browser(parent=None)

Constructor

parent
  parent widget (QWidget)

#### Browser.__addAsToplevelDir

__addAsToplevelDir()

Private slot to handle the Add as toplevel directory popup menu entry.

#### Browser.__createPopupMenus

__createPopupMenus()

Private method to generate the various popup menus.

#### Browser.__deleteDirectory

__deleteDirectory(dn)

Private method to delete a directory.

dn (str)
  directory name to be removed from the project

#### Browser.__deleteFile

__deleteFile(fn)

Private method to delete a file.

fn (str)
  filename to be deleted

#### Browser.__deleteMultiple

__deleteMultiple()

Private slot to delete multiple directories and files.

Note: The context menu for multi selection is only shown for file items.

#### Browser.__findInDirectory

__findInDirectory()

Private slot to handle the Find in directory popup menu entry.

#### Browser.__newToplevelDir

__newToplevelDir()

Private slot to handle the New toplevel directory popup menu entry.

#### Browser.__refreshDirectory

__refreshDirectory()

Private slot to refresh a directory entry.

#### Browser.__refreshSource

__refreshSource()

Private slot to refresh the structure of a source file.

#### Browser.__removeToplevel

__removeToplevel()

Private slot to handle the Remove from toplevel popup menu entry.

#### Browser.__replaceInDirectory

__replaceInDirectory()

Private slot to handle the Find&Replace in directory popup menu entry.

#### Browser.__showMimeType

__showMimeType()

Private slot to show the mime type of the selected entry.

#### Browser._contextMenuRequested

_contextMenuRequested(coord)

Protected slot to show the context menu of the listview.

coord
  the position of the mouse pointer (QPoint)

#### Browser._copyToClipboard

_copyToClipboard()

Protected method to copy the text shown for an entry to the clipboard.

#### Browser._deleteFileOrDirectory

_deleteFileOrDirectory()

Protected slot to delete a directory or file.

#### Browser._editPixmap

_editPixmap()

Protected slot to handle the open in icon editor popup menu entry.

#### Browser._gotoAttribute

_gotoAttribute(act)

Protected slot to handle the selection of the goto menu.

act
  reference to the action (EricAction)

#### Browser._init

_init()

Protected method to perform initialization tasks common to this base class and all derived classes.

#### Browser._keyboardSearchType

_keyboardSearchType(item)

Protected method to check, if the item is of the correct type.

item (BrowserItem)
  reference to the item

Return:
  flag indicating a correct type

Return Type:
  bool

#### Browser._newDirectory

_newDirectory()

Protected slot to create a new directory.

#### Browser._newFile

_newFile()

Protected slot to create a new file.

#### Browser._openFileInEditor

_openFileInEditor()

Protected slot to handle the Open in Editor menu action.

#### Browser._openHexEditor

_openHexEditor()

Protected slot to handle the open in hex editor popup menu entry.

#### Browser._openItem

_openItem()

Protected slot to handle the open popup menu entry.

#### Browser._resizeColumns

_resizeColumns(index)

Protected slot to resize the view when items get expanded or collapsed.

index
  index of item (QModelIndex)

#### Browser._resort

_resort()

Protected slot to resort the tree.

#### Browser._showGotoMenu

_showGotoMenu()

Protected slot to prepare the goto submenu of the attribute menu.

#### Browser._showHidden

_showHidden(checked)

Protected slot to show or hide hidden files.

checked (bool)
  flag indicating the state of the action

#### Browser.getSelectedItems

getSelectedItems(filterList=None)

Public method to get the selected items.

filterList
  list of classes to check against

Return:
  list of selected items (list of BrowserItem)

#### Browser.getSelectedItemsCount

getSelectedItemsCount(filterList=None)

Public method to get the count of items selected.

filterList
  list of classes to check against

Return:
  count of items selected (integer)

#### Browser.getSelectedItemsCountCategorized

getSelectedItemsCountCategorized(filterList=None)

Public method to get a categorized count of selected items.

filterList
  list of classes to check against

Return:
  a dictionary containing the counts of items belonging to the individual filter classes. The keys of the dictionary are the string representation of the classes given in the filter (i.e. str(filterClass)). The dictionary contains an additional entry with key "sum", that stores the sum of all selected entries fulfilling the filter criteria.

#### Browser.handleInterpreterChanged

handleInterpreterChanged(interpreter)

Public slot to handle a change of the debug client's interpreter.

interpreter
  interpreter of the debug client (string)

#### Browser.handlePreferencesChanged

handlePreferencesChanged()

Public slot used to handle the preferencesChanged signal.

#### Browser.handleProgramChange

handleProgramChange(fn)

Public slot to handle the programChange signal.

fn
  file name (string)

#### Browser.handleUnittest

handleUnittest()

Public slot to handle the unittest popup menu entry.

#### Browser.keyboardSearch

keyboardSearch(search)

Public function to search the tree via the keyboard.

search (str)
  the character entered via the keyboard

#### Browser.layoutDisplay

layoutDisplay()

Public slot to perform a layout operation.

#### Browser.mouseDoubleClickEvent

mouseDoubleClickEvent(mouseEvent)

Protected method of QAbstractItemView.

Reimplemented to disable expanding/collapsing of items when double-clicking. Instead the double-clicked entry is opened.

mouseEvent
  the mouse event (QMouseEvent)

#### Browser.saveToplevelDirs

saveToplevelDirs()

Public slot to save the toplevel directories.

#### Browser.wantedItem

wantedItem(itm, filterList=None)

Public method to check type of an item.

itm
  the item to check (BrowserItem)
filterList
  list of classes to check against

Return:
  flag indicating item is a valid type (boolean)

Up