diff options
author | Andrea Diamantini <adjam7@gmail.com> | 2009-07-24 02:20:44 +0200 |
---|---|---|
committer | Andrea Diamantini <adjam7@gmail.com> | 2009-07-24 02:20:44 +0200 |
commit | c3ff1138d5d62e7092abb9d66f7f26097014f6e8 (patch) | |
tree | 096c858597df0470d8914f14c322f8037f57b48d /src | |
parent | Removed rekonqrun class and provided slots in Application one. (diff) | |
download | rekonq-c3ff1138d5d62e7092abb9d66f7f26097014f6e8.tar.xz |
Big Big Big Commit!
Refactored loadUrl code to divide UI classes from WEB classes.
We now have two loadUrl methods in the Application class to load
(hopefully) every kind of (k)url..
Diffstat (limited to 'src')
-rw-r--r-- | src/bookmarks.cpp | 4 | ||||
-rw-r--r-- | src/mainview.cpp | 92 | ||||
-rw-r--r-- | src/mainview.h | 7 | ||||
-rw-r--r-- | src/mainwindow.cpp | 14 | ||||
-rw-r--r-- | src/mainwindow.h | 1 |
5 files changed, 6 insertions, 112 deletions
diff --git a/src/bookmarks.cpp b/src/bookmarks.cpp index 70626b13..c3787ff0 100644 --- a/src/bookmarks.cpp +++ b/src/bookmarks.cpp @@ -89,11 +89,9 @@ void BookmarkOwner::openFolderinTabs(const KBookmarkGroup &bm) { QList<KUrl> urlList = bm.groupUrlList(); QList<KUrl>::iterator url; - Application* app = Application::instance(); for (url = urlList.begin(); url != urlList.end(); ++url) { - app->newWebView(); - app->mainWindow()->loadUrl(*url); + Application::instance()->loadUrl(*url, Rekonq::New); } } diff --git a/src/mainview.cpp b/src/mainview.cpp index 05e461ee..74fff11b 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -356,7 +356,7 @@ WebView *MainView::newTab() { // line edit UrlBar *urlBar = new UrlBar; // Ownership of widget is passed on to the QStackedWidget (addWidget method). - connect(urlBar, SIGNAL(activated(const KUrl&)), this, SLOT(loadUrl(const KUrl&))); + connect(urlBar, SIGNAL(activated(const KUrl&)), Application::instance(), SLOT(loadUrl(const KUrl&))); m_urlBars->addUrlBar(urlBar); WebView *webView = new WebView; // should be deleted on tab close @@ -386,23 +386,6 @@ WebView *MainView::newTab() setCurrentWidget(webView); // this method does NOT take ownership of webView urlBar->setFocus(); -// switch(type) -// { -// case Rekonq::Default: -// if (!m_makeBackTab) -// { -// setCurrentWidget(webView); // this method does NOT take ownership of webView -// urlBar->setFocus(); -// } -// break; -// case Rekonq::New: -// setCurrentWidget(webView); // this method does NOT take ownership of webView -// urlBar->setFocus(); -// break; -// case Rekonq::Background: -// break; -// }; - emit tabsChanged(); showTabBar(); @@ -629,79 +612,6 @@ 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; - - QString scheme = url.scheme(); - - 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()) - { - 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/search?&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->setFocus(); - webView->load(loadingUrl); - } -} - - void MainView::nextTab() { int next = currentIndex() + 1; diff --git a/src/mainview.h b/src/mainview.h index 05a7d96f..0324d4ed 100644 --- a/src/mainview.h +++ b/src/mainview.h @@ -104,13 +104,6 @@ public slots: */ WebView *newTab(); - /** - * Core browser slot. Load an url in a webview - * - * @param url The url to load - */ - void loadUrl(const KUrl &url); - void slotCloneTab(int index = -1); void slotCloseTab(int index = -1); void slotCloseOtherTabs(int index); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index ef51e1e0..09c36263 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -177,7 +177,7 @@ void MainWindow::postLaunch() connect(m_findBar, SIGNAL(searchString(const QString &)), this, SLOT(slotFind(const QString &))); // bookmarks loading - connect(Application::bookmarkProvider(), SIGNAL(openUrl(const KUrl&)), this, SLOT(loadUrl(const KUrl&))); + connect(Application::bookmarkProvider(), SIGNAL(openUrl(const KUrl&)), Application::instance(), SLOT(loadUrl(const KUrl&))); // setting up toolbars to NOT have context menu enabled setContextMenuPolicy(Qt::DefaultContextMenu); @@ -350,7 +350,7 @@ void MainWindow::setupSidePanel() { // Setup history side panel m_sidePanel = new SidePanel(i18n("History"), this); - connect(m_sidePanel, SIGNAL(openUrl(const KUrl&)), this, SLOT(loadUrl(const KUrl&))); + connect(m_sidePanel, SIGNAL(openUrl(const KUrl&)), Application::instance(), SLOT(loadUrl(const KUrl&))); connect(m_sidePanel, SIGNAL(destroyed()), Application::instance(), SLOT(slotSaveConfiguration())); addDockWidget(Qt::LeftDockWidgetArea, m_sidePanel); @@ -367,7 +367,7 @@ void MainWindow::setupSidePanel() void MainWindow::setupHistoryMenu() { HistoryMenu *historyMenu = new HistoryMenu(this); - connect(historyMenu, SIGNAL(openUrl(const KUrl&)), this, SLOT(loadUrl(const KUrl&))); + connect(historyMenu, SIGNAL(openUrl(const KUrl&)), Application::instance(), SLOT(loadUrl(const KUrl&))); historyMenu->setTitle(i18n("&History")); // setting history menu position @@ -445,12 +445,6 @@ void MainWindow::slotUpdateBrowser() } -void MainWindow::loadUrl(const KUrl &url) -{ - m_view->loadUrl(url); -} - - void MainWindow::slotOpenLocation() { m_view->currentUrlBar()->selectAll(); @@ -725,7 +719,7 @@ void MainWindow::slotViewPageSource() void MainWindow::slotHome() { - loadUrl(KUrl(m_homePage)); + Application::instance()->loadUrl(KUrl(m_homePage)); } diff --git a/src/mainwindow.h b/src/mainwindow.h index 0ca13429..aa00e274 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -75,7 +75,6 @@ private: public slots: void slotHome(); - void loadUrl(const KUrl &url); void slotUpdateBrowser(); /** |