'Add a directory entry to the model.'

def add_directory(self, parent, path):

    row_items = self.create_row(path, True)
    try:
        parent_path = parent.path
    except AttributeError:
        parent_path = u''
    try:
        row = self.dir_rows[parent_path]
    except KeyError:
        row = self.dir_rows[parent_path] = 0
    parent.insertRow(row, row_items)
    self.dir_rows[parent_path] += 1
    self.dir_entries[path] = row_items[0]
    return row_items[0]
