| 35 | } |
| 36 | |
| 37 | QUrl 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 | |
| 56 | QString serializeOptions(const QCommandLineParser &args) |
| 57 | { |