'Restore directory expanded state'

def restore_directory_state(self, fname):

    root = osp.normpath(to_text_string(fname))
    if (not osp.exists(root)):
        return
    for basename in os.listdir(root):
        path = osp.normpath(osp.join(root, basename))
        if (osp.isdir(path) and (path in self.__expanded_state)):
            self.__expanded_state.pop(self.__expanded_state.index(path))
            if (self._to_be_loaded is None):
                self._to_be_loaded = []
            self._to_be_loaded.append(path)
            self.setExpanded(self.get_index(path), True)
    if ((not self.__expanded_state) and (not is_pyqt46)):
        self.fsmodel.directoryLoaded.disconnect(self.restore_directory_state)
