From fd9b924083594cc7fb5d42d6ae2f624f52b5e8ba Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 22 Jan 2010 17:28:19 +0100 Subject: STEP 1: Subdivide loadUrl stuffs --- src/application.cpp | 90 ++++++++++++++++++++++++++++++++--------------------- src/application.h | 6 ++++ 2 files changed, 60 insertions(+), 36 deletions(-) diff --git a/src/application.cpp b/src/application.cpp index 98579cf0..6684439c 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -42,6 +42,7 @@ #include "urlbar.h" #include "sessionmanager.h" #include "adblockmanager.h" +#include "webview.h" // KDE Includes #include @@ -283,36 +284,9 @@ void Application::loadUrl(const KUrl& url, const Rekonq::OpenType& type) return; } - // first, create the webview(s) to not let hangs UI.. - WebTab *tab = 0; - MainWindow *w = 0; - w = (type == Rekonq::NewWindow) - ? newMainWindow() - : mainWindow(); - - switch(type) - { - case Rekonq::SettingOpenTab: - tab = w->mainView()->newWebTab(!ReKonfig::openTabsBack(), - ReKonfig::openTabsNearCurrent()); - break; - case Rekonq::NewCurrentTab: - tab = w->mainView()->newWebTab(true); - break; - case Rekonq::NewBackTab: - tab = w->mainView()->newWebTab(false, ReKonfig::openTabsNearCurrent()); - break; - case Rekonq::NewWindow: - case Rekonq::CurrentTab: - tab = w->mainView()->currentWebTab(); - break; - }; + WebView *view = createView(type); - // this should let rekonq filtering URI info and supporting - // the beautiful KDE web browsing shortcuts - KUriFilterData data(loadingUrl.pathOrUrl()); - data.setCheckForExecutables(false); // if true, queries like "rekonq" or "dolphin" are considered as executables - loadingUrl = KUriFilter::self()->filterUri(data) ? data.uri().pathOrUrl() : QUrl::fromUserInput(loadingUrl.pathOrUrl()); + loadingUrl = resolvUrl( loadingUrl.pathOrUrl() ); // we are sure of the url now, let's add it to history // anyway we store here just http sites because local and ftp ones are @@ -320,15 +294,15 @@ void Application::loadUrl(const KUrl& url, const Rekonq::OpenType& type) if( url.protocol() == QLatin1String("http") || url.protocol() == QLatin1String("https") ) historyManager()->addHistoryEntry( loadingUrl.prettyUrl() ); - if (!ReKonfig::openTabsBack()) - { - w->mainView()->urlBar()->setUrl(loadingUrl.prettyUrl()); - } +// if (!ReKonfig::openTabsBack()) +// { +// w->mainView()->urlBar()->setUrl(loadingUrl.prettyUrl()); +// } - if (tab) + if (view) { - tab->setFocus(); - tab->view()->load(loadingUrl); + view->setFocus(); + view->load(loadingUrl); } } @@ -372,3 +346,47 @@ AdBlockManager *Application::adblockManager() } return s_adblockManager; } + + +WebView *Application::createView(const Rekonq::OpenType &type) +{ + // first, create the webview(s) to not let hangs UI.. + WebTab *tab = 0; + MainWindow *w = 0; + w = (type == Rekonq::NewWindow) + ? newMainWindow() + : mainWindow(); + + switch(type) + { + case Rekonq::SettingOpenTab: + tab = w->mainView()->newWebTab(!ReKonfig::openTabsBack(), ReKonfig::openTabsNearCurrent()); + break; + case Rekonq::NewCurrentTab: + tab = w->mainView()->newWebTab(true); + break; + case Rekonq::NewBackTab: + tab = w->mainView()->newWebTab(false, ReKonfig::openTabsNearCurrent()); + break; + case Rekonq::NewWindow: + case Rekonq::CurrentTab: + tab = w->mainView()->currentWebTab(); + break; + }; + + return tab->view(); +} + + +KUrl Application::resolvUrl(const QString &urlString) +{ + // this should let rekonq filtering URI info and supporting + // the beautiful KDE web browsing shortcuts + KUriFilterData data(urlString); + data.setCheckForExecutables(false); // if true, queries like "rekonq" or "dolphin" are considered as executables + KUrl url = KUriFilter::self()->filterUri(data) + ? data.uri().pathOrUrl() + : QUrl::fromUserInput( urlString ); + + return url; +} diff --git a/src/application.h b/src/application.h index a0cd6745..c9fb079d 100644 --- a/src/application.h +++ b/src/application.h @@ -48,6 +48,7 @@ class HistoryManager; class MainWindow; class SessionManager; class AdBlockManager; +class WebView; typedef QList< QPointer > MainWindowList; @@ -135,6 +136,11 @@ private slots: void postLaunch(); private: + + // loadUrl Utilities + WebView *createView(const Rekonq::OpenType &); + KUrl resolvUrl(const QString &); + static QPointer s_historyManager; static QPointer s_bookmarkProvider; static QPointer s_sessionManager; -- cgit v1.2.1