[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdelibs/kparts
From:       David Faure <faure () kde ! org>
Date:       2010-08-24 6:39:51
Message-ID: 20100824063952.021BEAC857 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1167252 by dfaure:

Extract a makeErrorUrl method from redirectToError, so that konqueror can use inline \
errors for more things.


 M  +25 -10    browserrun.cpp  
 M  +11 -0     browserrun.h  


--- trunk/KDE/kdelibs/kparts/browserrun.cpp #1167251:1167252
@@ -487,13 +487,10 @@
     KRun::slotStatResult( job );
 }
 
-void BrowserRun::redirectToError( int error, const QString& errorText )
+// static
+KUrl BrowserRun::makeErrorUrl(int error, const QString& errorText, const QString& \
initialUrl)  {
-    /**
-     * To display this error in KHTMLPart instead of inside a dialog box,
-     * we tell konq that the mimetype is text/html, and we redirect to
-     * an error:/ URL that sends the info to khtml.
-     *
+    /*
      * The format of the error:/ URL is error:/?query#url,
      * where two variables are passed in the query:
      * error = int kio error code, errText = QString error text from kio
@@ -502,13 +499,31 @@
     KUrl newURL(QString("error:/?error=%1&errText=%2")
                 .arg( error )
                 .arg( QString::fromUtf8( QUrl::toPercentEncoding( errorText ) ) ) );
-    KUrl runURL = KRun::url();
+
+    QString cleanedOrigUrl = initialUrl;
+    KUrl runURL = cleanedOrigUrl;
+    if (runURL.isValid()) {
     runURL.setPass( QString() ); // don't put the password in the error URL
+        cleanedOrigUrl = runURL.url();
+    }
 
-    KUrl::List lst;
-    lst << newURL << runURL;
-    KRun::setUrl( KUrl::join( lst ) );
+    newURL.setFragment(cleanedOrigUrl);
+    return newURL;
 
+    // The kde3 approach broke with invalid urls, now that they become empty in qt4.
+    //KUrl::List lst;
+    //lst << newURL << runURL;
+    //return KUrl::join(lst);
+}
+
+void BrowserRun::redirectToError( int error, const QString& errorText )
+{
+    /**
+     * To display this error in KHTMLPart instead of inside a dialog box,
+     * we tell konq that the mimetype is text/html, and we redirect to
+     * an error:/ URL that sends the info to khtml.
+     */
+    KRun::setUrl(makeErrorUrl(error, errorText, url().url()));
     setJob( 0 );
     mimeTypeDetermined( "text/html" );
 }
--- trunk/KDE/kdelibs/kparts/browserrun.h #1167251:1167252
@@ -136,6 +136,17 @@
 
         static bool isTextExecutable( const QString &mimeType );
 
+        /**
+         * KDE webbrowsing kparts support error urls to display errors in-line in \
the browser component. +         * This helper method creates the error URL from its \
parameters. +         * @param error the KIO error code (or KIO::ERR_SLAVE_DEFINED if \
not from KIO) +         * @param errorText the text of the error message
+         * @param initialUrl the URL that we were trying to open (as a string, so \
that this can +         *                   support invalid URLs as well)
+         * @since 4.6
+         */
+        static KUrl makeErrorUrl(int error, const QString& errorText, const QString& \
initialUrl); +
     protected:
         /**
          * Reimplemented from KRun


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic