Document Viewer "Open in New Window" and absolute links

Stuart Haslam lists at bozon.net
Tue Feb 24 17:19:02 UTC 2004


Hello,

The context menu item "Open in New Window" within the Document Viewer
doesn't work correctly for absolute links, as it assumes all links are
relative.

I've fixed this and the diff output is below. I'm new to KDevelop (and
KDE/Qt in general) so I welcome any criticism.. specifically, is there a
better way to determine if a link is relative or absolute?

Stuart.

kdevelop/src/documentationpart.cpp

@@ -97,8 +97,16 @@

   if (r == idNewWindow)
   {
-    KURL kurl (DocumentationPart::url().upURL());
-    kurl.addPath(url);
+    KURL kurl(url);
+    // link has no hostname and does not refer to a local file
+    // so must be relative
+    if (!kurl.hasHost() && (kurl.protocol() != "file"))
+    {
+      kurl = DocumentationPart::url().upURL();
+      kurl.addPath(url);
+    }
+
     if (kurl.isValid())
         PartController::getInstance()->showDocument(kurl, url);
   }






More information about the KDevelop-devel mailing list