MCPcopy Create free account
hub / github.com/KDE/okular / urlFromArg

Function urlFromArg

shell/shellutils.cpp:37–54  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35}
36
37QUrl urlFromArg(const QString &_arg, FileExistFunc exist_func, const QString &pageArg)
38{
39 QUrl url = QUrl::fromUserInput(_arg, QDir::currentPath(), QUrl::AssumeLocalFile);
40 if (url.isLocalFile()) {
41 // make sure something like /tmp/foo#bar.pdf is treated as a path name (default)
42 // but something like /tmp/foo.pdf#bar is foo.pdf plus an anchor "bar"
43 const QString path = url.path();
44 int hashIndex = path.lastIndexOf(QLatin1Char('#'));
45 if (hashIndex != -1 && !exist_func(url.toLocalFile())) {
46 url.setPath(path.left(hashIndex));
47 url.setFragment(path.mid(hashIndex + 1));
48 }
49 }
50 if (!pageArg.isEmpty()) {
51 url.setFragment(pageArg);
52 }
53 return url;
54}
55
56QString serializeOptions(const QCommandLineParser &args)
57{

Callers 6

attachUniqueInstanceFunction · 0.85
attachExistingInstanceFunction · 0.85
mainFunction · 0.85
testUrlArgsMethod · 0.85

Calls 2

isEmptyMethod · 0.80
pathMethod · 0.45

Tested by 3

testUrlArgsMethod · 0.68