Пример #1
0
def load_filesystem_view(startpath, tree):
    """
    Load Project structure tree
    @param startpath
    @param tree
    @return
    """

    if not startpath:
        return

    if isinstance(tree, QTreeWidget):
        tree.clear()
    curr_dir = pathlib.Path(startpath)
    for element in curr_dir.glob('**/*'):
        path_info = curr_dir.joinpath(element)
        parent_itm = QTreeWidgetItem(tree, [os.path.basename(element)])
        parent_itm.filepath = path_info
        if path_info.is_dir():
            parent_itm.setIcon(0, QIcon(DIR_CLOSED_ICON_PATH))
            parent_itm.item_type = "dir"
            parent_itm.was_expanded = False
            parent_itm.setChildIndicatorPolicy(QTreeWidgetItem.ShowIndicator)
        else:
            parent_itm.setIcon(0, QIcon(get_icon_for_extension(path_info.suffix)))
            parent_itm.item_type = "file"