summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorkh <qtc-committer@nokia.com>2009-04-01 11:34:48 (GMT)
committerkh <qtc-committer@nokia.com>2009-04-01 11:34:48 (GMT)
commit363636a3aa8abce0344388c0357a237e0d23baa3 (patch)
treeb604642774d1da5070d6483ab979383a462b9913 /tools
parent8006e8bcb427a3949b6b4eec80b65bb58b5fdb8a (diff)
downloadQt-363636a3aa8abce0344388c0357a237e0d23baa3.zip
Qt-363636a3aa8abce0344388c0357a237e0d23baa3.tar.gz
Qt-363636a3aa8abce0344388c0357a237e0d23baa3.tar.bz2
strip fragment and other parts from url in case of pdf
Task-number: part of 238496 Reviewed-by: hjk
Diffstat (limited to 'tools')
-rw-r--r--tools/assistant/tools/assistant/helpviewer.cpp24
1 files changed, 16 insertions, 8 deletions
diff --git a/tools/assistant/tools/assistant/helpviewer.cpp b/tools/assistant/tools/assistant/helpviewer.cpp
index 9817f23..6b049e8 100644
--- a/tools/assistant/tools/assistant/helpviewer.cpp
+++ b/tools/assistant/tools/assistant/helpviewer.cpp
@@ -201,10 +201,14 @@ bool HelpPage::acceptNavigationRequest(QWebFrame *,
{
const QUrl &url = request.url();
if (isLocalUrl(url)) {
- if (url.path().endsWith(QLatin1String("pdf"))) {
- QString fileName = url.toString();
- fileName = QDir::tempPath() + QDir::separator() + fileName.right
- (fileName.length() - fileName.lastIndexOf(QChar('/')));
+ const QString& path = url.path();
+ if (path.endsWith(QLatin1String(".pdf"))) {
+ const int lastDash = path.lastIndexOf(QChar('/'));
+ QString fileName = QDir::tempPath() + QDir::separator();
+ if (lastDash < 0)
+ fileName += path;
+ else
+ fileName += path.mid(lastDash + 1, path.length());
QFile tmpFile(QDir::cleanPath(fileName));
if (tmpFile.open(QIODevice::ReadWrite)) {
@@ -396,15 +400,19 @@ void HelpViewer::zoomOut(int range)
bool HelpViewer::launchedWithExternalApp(const QUrl &url)
{
- bool isPdf = url.path().endsWith(QLatin1String("pdf"));
+ bool isPdf = url.path().endsWith(QLatin1String(".pdf"));
if (url.scheme() == QLatin1String("http")
|| url.scheme() == QLatin1String("ftp")
|| url.scheme() == QLatin1String("mailto") || isPdf) {
bool launched = false;
if (isPdf && url.scheme() == QLatin1String("qthelp")) {
- QString fileName = url.toString();
- fileName = QDir::tempPath() + QDir::separator() + fileName.right
- (fileName.length() - fileName.lastIndexOf(QLatin1Char('/')));
+ const QString& path = url.path();
+ const int lastDash = path.lastIndexOf(QChar('/'));
+ QString fileName = QDir::tempPath() + QDir::separator();
+ if (lastDash < 0)
+ fileName += path;
+ else
+ fileName += path.mid(lastDash + 1, path.length());
QFile tmpFile(QDir::cleanPath(fileName));
if (tmpFile.open(QIODevice::ReadWrite)) {