def url_from_value(self, value): base = value.variable.attributes.get("origin", "") if QDir(base).exists(): base = QUrl.fromLocalFile(base) else: base = QUrl(base) path = base.path() if path.strip() and not path.endswith("/"): base.setPath(path + "/") url = base.resolved(QUrl(str(value))) return url
def urlFromValue(self, value): variable = value.variable origin = variable.attributes.get("origin", "") if origin and QDir(origin).exists(): origin = QUrl.fromLocalFile(origin) elif origin: origin = QUrl(origin) if not origin.scheme(): origin.setScheme("file") else: origin = QUrl("") base = origin.path() if base.strip() and not base.endswith("/"): origin.setPath(base + "/") name = QUrl(str(value)) url = origin.resolved(name) if not url.scheme(): url.setScheme("file") return url
def qurl_from_path(urlpath): if QDir(urlpath).isAbsolute(): # deal with absolute paths including windows drive letters return QUrl.fromLocalFile(urlpath) return QUrl(urlpath, QUrl.TolerantMode)