source/riffle/browser.py
def _setLocation(self, path):
        '''Set current location to *path*.

        *path* must be the same as root or under the root.

        .. note::

            Comparisons are case-sensitive. If you set the root as 'D:/' then
            location can be set as 'D:/folder' *not* 'd:/folder'.

        '''
        model = self._filesystemWidget.model()

        if not path.startswith(model.root.path):
            raise ValueError('Location must be root or under root.')

        # Ensure children for each segment in path are loaded.
        segments = self._segmentPath(path)
        for segment in reversed(segments):
            pathIndex = model.pathIndex(segment)
            model.fetchMore(pathIndex)

        self._filesystemWidget.setRootIndex(model.pathIndex(path))
        self._locationWidget.clear()

        # Add history entry for each segment.
        for segment in segments:
            index = model.pathIndex(segment)
            if not index.isValid():
                # Root item.
                icon = model.iconFactory.icon(
                    riffle.icon_factory.IconType.Computer
                )
                self._locationWidget.addItem(
                    icon, model.root.path or model.root.name, model.root.path
                )
            else:
                icon = model.icon(index)
                self._locationWidget.addItem(icon, segment, segment)

        if self._locationWidget.count() > 1:
            self._upButton.setEnabled(True)
            self._upShortcut.setEnabled(True)
        else:
            self._upButton.setEnabled(False)
            self._upShortcut.setEnabled(False)
def _setLocation(self, path):
        '''Set current location to *path*.

        *path* must be the same as root or under the root.

        .. note::

            Comparisons are case-sensitive. If you set the root as 'D:/' then
            location can be set as 'D:/folder' *not* 'd:/folder'.

        '''
        model = self._filesystemWidget.model()

        if not path.startswith(model.root.path):
            raise ValueError('Location must be root or under root.')

        # Ensure children for each segment in path are loaded.
        segments = self._segmentPath(path)
        for segment in reversed(segments):
            pathIndex = model.pathIndex(segment)
            model.fetchMore(pathIndex)

        self._filesystemWidget.setRootIndex(model.pathIndex(path))
        self._locationWidget.clear()

        # Add history entry for each segment.
        for segment in segments:
            index = model.pathIndex(segment)
            if not index.isValid():
                # Root item.
                icon = model.iconFactory.icon(
                    riffle.icon_factory.IconType.Computer
                )
                self._locationWidget.addItem(
                    icon, model.root.path or model.root.name, model.root.path
                )
            else:
                icon = model.icon(index)
                self._locationWidget.addItem(icon, segment, segment)

        if self._locationWidget.count() > 1:
            self._upButton.setEnabled(True)
            self._upShortcut.setEnabled(True)
        else:
            self._upButton.setEnabled(False)
            self._upShortcut.setEnabled(False)
Set current location to *path*.

        *path* must be the same as root or under the root.

        .. note::

            Comparisons are case-sensitive. If you set the root as 'D:/' then
            location can be set as 'D:/folder' *not* 'd:/folder'.