diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/mainview.cpp | 58 | ||||
| -rw-r--r-- | src/mainview.h | 2 | ||||
| -rw-r--r-- | src/mainwindow.cpp | 1 | ||||
| -rw-r--r-- | src/webpage.cpp | 36 | ||||
| -rw-r--r-- | src/webpage.h | 5 | 
5 files changed, 55 insertions, 47 deletions
| diff --git a/src/mainview.cpp b/src/mainview.cpp index 75154528..f3ccbce2 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -46,6 +46,7 @@  #include <KActionCollection>  #include <KDebug>  #include <KStandardDirs> +#include <KToolInvocation>  // Qt Includes  #include <QtCore/QTimer> @@ -629,24 +630,71 @@ void MainView::webViewUrlChanged(const QUrl &url)  } +// WARNING this method is ready to be refactored with real KServices implementation +// and moved to a RekonqRun class (0.3 target)  void MainView::loadUrl(const KUrl &url)  {      if (url.isEmpty())          return; -    currentUrlBar()->setUrl(url.prettyUrl()); +    QString scheme = url.scheme(); -    WebView *webView = currentWebView(); +    if (scheme == QLatin1String("mailto")) +    { +        KToolInvocation::invokeMailer(url); +        return; +    }      KUrl loadingUrl(url); +    // create convenience fake api:// protocol for KDE apidox search and Qt docs +    if (scheme == QLatin1String("api")) +    { +        QString path; +        QString className = url.host().toLower(); +        if (className[0] == 'k') +        { +            path = QString("http://api.kde.org/new.classmapper.php?class=%1").arg(className); +        } +        else if (className[0] == 'q') +        { +            path = QString("http://doc.trolltech.com/4.5/%1.html").arg(className); +        } +        loadingUrl.setUrl(path); +    } +      if (loadingUrl.isRelative())      { -        QString fn = loadingUrl.url(KUrl::RemoveTrailingSlash); -        loadingUrl.setUrl("//" + fn); -        loadingUrl.setScheme("http"); +        if(loadingUrl.path().contains('.')) +        { +            QString fn = loadingUrl.url(KUrl::RemoveTrailingSlash); +            loadingUrl.setUrl("//" + fn); +            loadingUrl.setScheme("http"); +        } +        else +        { +            scheme = QLatin1String("gg"); +        } +    } + +    // create convenience fake gg:// protocol, waiting for KServices learning +    if(scheme == QLatin1String("gg")) +    { +        QString str = loadingUrl.path(); +        loadingUrl.setUrl( QString("http://google.com/complete/search?output=toolbar&q=%1").arg(str) );      } +    // create convenience fake wk:// protocol, waiting for KServices learning +    if(scheme == QLatin1String("wk")) +    { +        QString str = loadingUrl.path(); +        loadingUrl.setUrl( QString("http://en.wikipedia.org/wiki/%1").arg(str) ); +    } + +    currentUrlBar()->setUrl(loadingUrl.prettyUrl()); + +    WebView *webView = currentWebView(); +      if (webView)      {          webView->load(loadingUrl); diff --git a/src/mainview.h b/src/mainview.h index 7cb4e035..d338402a 100644 --- a/src/mainview.h +++ b/src/mainview.h @@ -2,7 +2,7 @@  *  * This file is a part of the rekonq project  * -* Copyright (C) 2008 by Andrea Diamantini <adjam7 at gmail dot com> +* Copyright (C) 2008-2009 by Andrea Diamantini <adjam7 at gmail dot com>  * Copyright (C) 2009 by Paweł Prażak <pawelprazak at gmail dot com>  *  * diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 519081d6..79a6db4b 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -891,7 +891,6 @@ void MainWindow::notifyMessage(const QString &msg, Rekonq::Notify status)      m_popup->setView(msg);      int h = KGlobalSettings::generalFont().pointSize(); -    kWarning() << "h: " << h;      // setting popus in bottom-left position      int x = geometry().x(); diff --git a/src/webpage.cpp b/src/webpage.cpp index 8c6c0d2a..133a263c 100644 --- a/src/webpage.cpp +++ b/src/webpage.cpp @@ -40,7 +40,7 @@  #include <KUrl>  #include <KActionCollection>  #include <KDebug> -#include <KToolInvocation> +  #include <KDE/KParts/BrowserRun>  #include <KDE/KMimeTypeTrader> @@ -76,40 +76,6 @@ WebPage::WebPage(QObject *parent)  } -bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, NavigationType type) -{ - -    // TODO: implement ioslaves protocols -    QString scheme = request.url().scheme(); -    if (scheme == QLatin1String("mailto")) -    { -        KToolInvocation::invokeMailer(request.url()); -        return false; -    } - -    // create convenience fake api:// protocol for KDE apidox search and Qt docs -    if (scheme == QLatin1String("api")) -    { -        QString path; -        QString className = request.url().host().toLower(); -        if (className[0] == 'k') -        { -            path = QString("http://api.kde.org/new.classmapper.php?class=%1").arg(className); -        } -        else if (className[0] == 'q') -        { -            path = QString("http://doc.trolltech.com/4.5/%1.html").arg(className); -        } -        KUrl url(path); - -        Application::instance()->mainWindow()->loadUrl(url); -        return false; -    } - -    return QWebPage::acceptNavigationRequest(frame, request, type); -} - -  KWebPage *WebPage::createWindow(QWebPage::WebWindowType type)  {      kDebug() << "creating window as new tab.. "; diff --git a/src/webpage.h b/src/webpage.h index 8fe9517d..c43212b6 100644 --- a/src/webpage.h +++ b/src/webpage.h @@ -48,13 +48,8 @@ public slots:      void manageNetworkErrors(QNetworkReply* reply);  protected: -    bool acceptNavigationRequest(QWebFrame *frame, -                                 const QNetworkRequest &request, -                                 NavigationType type); -      KWebPage *createWindow(QWebPage::WebWindowType type); -  protected Q_SLOTS:      virtual void slotHandleUnsupportedContent(QNetworkReply *reply); | 
