# eric4.Project.ProjectBrowserModel

Module implementing the browser model.

### Global Attributes

ProjectBrowserFormType
ProjectBrowserInterfaceType
ProjectBrowserItemDirectory
ProjectBrowserItemFile
ProjectBrowserItemSimpleDirectory
ProjectBrowserNoType
ProjectBrowserOthersType
ProjectBrowserResourceType
ProjectBrowserSourceType
ProjectBrowserTranslationType

### Classes

ProjectBrowserDirectoryItem | Class implementing the data structure for project browser directory items.
ProjectBrowserFileItem | Class implementing the data structure for project browser file items.
ProjectBrowserItemMixin | Class implementing common methods of project browser items.
ProjectBrowserModel | Class implementing the project browser model.
ProjectBrowserSimpleDirectoryItem | Class implementing the data structure for project browser simple directory items.

### Functions

None

## ProjectBrowserDirectoryItem

Class implementing the data structure for project browser directory items.

### Derived from

BrowserDirectoryItem, ProjectBrowserItemMixin

### Class Attributes

None

### Class Methods

None

### Methods

ProjectBrowserDirectoryItem | Constructor

### Static Methods

None

#### ProjectBrowserDirectoryItem (Constructor)

ProjectBrowserDirectoryItem(parent, dinfo, projectType, full = True, bold = False)

Constructor

parent
  parent item
dinfo
  dinfo is the string for the directory (string or QString)
projectType
  type of file/directory in the project
full
  flag indicating full pathname should be displayed (boolean)
bold
  flag indicating a highlighted font (boolean)

Up

## ProjectBrowserFileItem

Class implementing the data structure for project browser file items.

### Derived from

BrowserFileItem, ProjectBrowserItemMixin

### Class Attributes

None

### Class Methods

None

### Methods

ProjectBrowserFileItem | Constructor

### Static Methods

None

#### ProjectBrowserFileItem (Constructor)

ProjectBrowserFileItem(parent, finfo, projectType, full = True, bold = False, sourceLanguage = "")

Constructor

parent
  parent item
finfo
  the string for the file (string)
projectType
  type of file/directory in the project
full
  flag indicating full pathname should be displayed (boolean)
bold
  flag indicating a highlighted font (boolean)
sourceLanguage
  source code language of the project (string)

Up

## ProjectBrowserItemMixin

Class implementing common methods of project browser items.

It is meant to be used as a mixin class.

### Derived from

object

### Class Attributes

None

### Class Methods

None

### Methods

ProjectBrowserItemMixin | Constructor
addProjectType | Public method to add a type to the list.
addVcsStatus | Public method to add the VCS status.
getProjectTypes | Public method to get the project type.
getTextColor | Public method to get the items text color.
setVcsState | Public method to set the items VCS state.
setVcsStatus | Public method to set the VCS status.

### Static Methods

None

#### ProjectBrowserItemMixin (Constructor)

ProjectBrowserItemMixin(type_, bold = False)

Constructor

type_
  type of file/directory in the project
bold
  flag indicating a highlighted font

#### ProjectBrowserItemMixin.addProjectType

addProjectType(type_)

Public method to add a type to the list.

type_
  type to add to the list

#### ProjectBrowserItemMixin.addVcsStatus

addVcsStatus(vcsStatus)

Public method to add the VCS status.

vcsStatus
  VCS status text (string or QString)

#### ProjectBrowserItemMixin.getProjectTypes

getProjectTypes()

Public method to get the project type.

Returns:
  project type

#### ProjectBrowserItemMixin.getTextColor

getTextColor()

Public method to get the items text color.

Returns:
  text color (QVariant(QColor))

#### ProjectBrowserItemMixin.setVcsState

setVcsState(state)

Public method to set the items VCS state.

state
  VCS state (one of A, C, M, U or " ") (string)

#### ProjectBrowserItemMixin.setVcsStatus

setVcsStatus(vcsStatus)

Public method to set the VCS status.

vcsStatus
  VCS status text (string or QString)

Up

## ProjectBrowserModel

Class implementing the project browser model.

### Signals

vcsStateChanged(string)
  emitted after the VCS state has changed

### Derived from

BrowserModel

### Class Attributes

None

### Class Methods

None

### Methods

ProjectBrowserModel | Constructor
__addVCSStatus | Private method used to set the vcs status of a node.
__changeParentsVCSState | Private method to recursively change the parents VCS state.
__updateVCSStatus | Private method used to update the vcs status of a node.
addNewItem | Public method to add a new item to the model.
changeVCSStates | Public slot to record the (non normal) VCS states.
data | Public method to get data of an item.
findChildItem | Public method to find a child item given some text.
findItem | Public method to find an item given it's name.
findParentItemByName | Public method to find an item given it's name.
itemIndexByName | Public method to find an item's index given it's name.
populateItem | Public method to populate an item's subtree.
populateProjectDirectoryItem | Public method to populate a directory item's subtree.
preferencesChanged | Public method used to handle a change in preferences.
projectClosed | Public method called after a project has been closed.
projectOpened | Public method used to populate the model after a project has been opened.
projectPropertiesChanged | Public method to react on a change of the project properties.
removeItem | Public method to remove a named item.
renameItem | Public method to rename an item.
repopulateItem | Public method to repopulate an item.
updateVCSStatus | Public method used to update the vcs status of a node.

### Static Methods

None

#### ProjectBrowserModel (Constructor)

ProjectBrowserModel(parent)

Constructor

parent
  reference to parent object (Project.Project)

#### ProjectBrowserModel.__addVCSStatus

__addVCSStatus(item, name)

Private method used to set the vcs status of a node.

item
  item to work on
name
  filename belonging to this item (string)

#### ProjectBrowserModel.__changeParentsVCSState

__changeParentsVCSState(path, itemCache)

Private method to recursively change the parents VCS state.

path
  pathname of parent item (string)
itemCache
  reference to the item cache used to store references to named items

#### ProjectBrowserModel.__updateVCSStatus

__updateVCSStatus(item, name, recursive = True)

Private method used to update the vcs status of a node.

item
  item to work on
name
  filename belonging to this item (string)
recursive
  flag indicating a recursive update (boolean)

#### ProjectBrowserModel.addNewItem

addNewItem(typeString, name, additionalTypeStrings = [])

Public method to add a new item to the model.

typeString
  string denoting the type of the new item (string)
name
  name of the new item (string)
additionalTypeStrings
  names of additional types (list of string)

#### ProjectBrowserModel.changeVCSStates

changeVCSStates(statesList)

Public slot to record the (non normal) VCS states.

statesList
  list of VCS state entries (QStringList) giving the states in the first column and the path relative to the project directory starting with the third column. The allowed status flags are:
  - "A" path was added but not yet comitted
  - "M" path has local changes
  - "R" path was deleted and then re-added
  - "U" path needs an update
  - "Z" path contains a conflict
  - " " path is back at normal

#### ProjectBrowserModel.data

data(index, role)

Public method to get data of an item.

index
  index of the data to retrieve (QModelIndex)
role
  role of data (Qt.ItemDataRole)

Returns:
  requested data (QVariant)

#### ProjectBrowserModel.findChildItem

findChildItem(text, column, parentItem = None)

Public method to find a child item given some text.

text
  text to search for (string or QString)
column
  column to search in (integer)
parentItem
  reference to parent item

Returns:
  reference to the item found

#### ProjectBrowserModel.findItem

findItem(name)

Public method to find an item given it's name.

name
  name of the item (string or QString)

Returns:
  reference to the item found

#### ProjectBrowserModel.findParentItemByName

findParentItemByName(type_, name, dontSplit = False)

Public method to find an item given it's name.

Note: This method creates all necessary parent items, if they don't exist.

type_
  type of the item
name
  name of the item (string or QString)
dontSplit
  flag indicating the name should not be split (boolean)

Returns:
  reference to the item found and the new display name (QString)

#### ProjectBrowserModel.itemIndexByName

itemIndexByName(name)

Public method to find an item's index given it's name.

name
  name of the item (string or QString)

Returns:
  index of the item found (QModelIndex)

#### ProjectBrowserModel.populateItem

populateItem(parentItem, repopulate = False)

Public method to populate an item's subtree.

parentItem
  reference to the item to be populated
repopulate
  flag indicating a repopulation (boolean)

#### ProjectBrowserModel.populateProjectDirectoryItem

populateProjectDirectoryItem(parentItem, repopulate = False)

Public method to populate a directory item's subtree.

parentItem
  reference to the directory item to be populated
repopulate
  flag indicating a repopulation (boolean)

#### ProjectBrowserModel.preferencesChanged

preferencesChanged()

Public method used to handle a change in preferences.

#### ProjectBrowserModel.projectClosed

projectClosed()

Public method called after a project has been closed.

#### ProjectBrowserModel.projectOpened

projectOpened()

Public method used to populate the model after a project has been opened.

#### ProjectBrowserModel.projectPropertiesChanged

projectPropertiesChanged()

Public method to react on a change of the project properties.

#### ProjectBrowserModel.removeItem

removeItem(name)

Public method to remove a named item.

name
  file or directory name of the item (string or QString).

#### ProjectBrowserModel.renameItem

renameItem(name, newFilename)

Public method to rename an item.

name
  the old display name (string or QString)
newFilename
  new filename of the item (string)

#### ProjectBrowserModel.repopulateItem

repopulateItem(name)

Public method to repopulate an item.

name
  name of the file relative to the project root (string)

#### ProjectBrowserModel.updateVCSStatus

updateVCSStatus(name, recursive = True)

Public method used to update the vcs status of a node.

name
  filename belonging to this item (string)
recursive
  flag indicating a recursive update (boolean)

Up

## ProjectBrowserSimpleDirectoryItem

Class implementing the data structure for project browser simple directory items.

### Derived from

BrowserItem, ProjectBrowserItemMixin

### Class Attributes

None

### Class Methods

None

### Methods

ProjectBrowserSimpleDirectoryItem | Constructor
dirName | Public method returning the directory name.
lessThan | Public method to check, if the item is less than the other one.
setName | Public method to set the directory name.

### Static Methods

None

#### ProjectBrowserSimpleDirectoryItem (Constructor)

ProjectBrowserSimpleDirectoryItem(parent, projectType, text, path = "")

Constructor

parent
  parent item
projectType
  type of file/directory in the project
text
  text to be displayed (string or QString)
path
  path of the directory (string or QString)

#### ProjectBrowserSimpleDirectoryItem.dirName

dirName()

Public method returning the directory name.

Returns:
  directory name (string)

#### ProjectBrowserSimpleDirectoryItem.lessThan

lessThan(other, column, order)

Public method to check, if the item is less than the other one.

other
  reference to item to compare against (BrowserItem)
column
  column number to use for the comparison (integer)
order
  sort order (Qt.SortOrder) (for special sorting)

Returns:
  true, if this item is less than other (boolean)

#### ProjectBrowserSimpleDirectoryItem.setName

setName(dinfo, full = True)

Public method to set the directory name.

dinfo
  dinfo is the string for the directory (string or QString)
full
  flag indicating full pathname should be displayed (boolean)

Up