summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/application.cpp6
-rw-r--r--src/mainview.cpp101
-rw-r--r--src/mainview.h19
-rw-r--r--src/mainwindow.cpp11
-rw-r--r--src/stackedurlbar.cpp16
-rw-r--r--src/stackedurlbar.h70
-rw-r--r--src/urlbar.cpp61
-rw-r--r--src/urlbar.h11
-rw-r--r--src/webview.cpp18
-rw-r--r--src/webview.h7
11 files changed, 135 insertions, 186 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 45a2afb2..d4e513fd 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -20,7 +20,6 @@ SET( rekonq_SRCS
sidepanel.cpp
panelhistory.cpp
lineedit.cpp
- stackedurlbar.cpp
webpage.cpp
)
diff --git a/src/application.cpp b/src/application.cpp
index 711e3fb8..44d50a88 100644
--- a/src/application.cpp
+++ b/src/application.cpp
@@ -301,19 +301,19 @@ void Application::loadUrl(const KUrl& url, const Rekonq::OpenType& type)
webView = m_mainWindow->mainView()->newTab(!ReKonfig::openTabsBack());
if (!ReKonfig::openTabsBack())
{
- m_mainWindow->mainView()->currentUrlBar()->setUrl(loadingUrl.prettyUrl());
+ m_mainWindow->mainView()->urlBar()->setUrl(loadingUrl.prettyUrl());
}
break;
case Rekonq::NewCurrentTab:
webView = m_mainWindow->mainView()->newTab(true);
- m_mainWindow->mainView()->currentUrlBar()->setUrl(loadingUrl.prettyUrl());
+ m_mainWindow->mainView()->urlBar()->setUrl(loadingUrl.prettyUrl());
break;
case Rekonq::NewBackTab:
webView = m_mainWindow->mainView()->newTab(false);
break;
case Rekonq::CurrentTab:
webView = m_mainWindow->mainView()->currentWebView();
- m_mainWindow->mainView()->currentUrlBar()->setUrl(loadingUrl.prettyUrl());
+ m_mainWindow->mainView()->urlBar()->setUrl(loadingUrl.prettyUrl());
break;
};
diff --git a/src/mainview.cpp b/src/mainview.cpp
index efabf0f1..ef4d869b 100644
--- a/src/mainview.cpp
+++ b/src/mainview.cpp
@@ -38,7 +38,6 @@
#include "application.h"
#include "mainwindow.h"
#include "history.h"
-#include "stackedurlbar.h"
#include "urlbar.h"
#include "webview.h"
@@ -65,9 +64,10 @@
MainView::MainView(QWidget *parent)
: KTabWidget(parent)
- , m_urlBars(new StackedUrlBar(this))
+ , m_urlBar(new UrlBar(this))
, m_tabBar(new TabBar(this))
, m_addTabButton(new QToolButton(this))
+ , m_currentTabIndex(0)
{
// setting tabbar
setTabBar(m_tabBar);
@@ -83,9 +83,12 @@ MainView::MainView(QWidget *parent)
connect(m_tabBar, SIGNAL(reloadAllTabs()), this, SLOT(slotReloadAllTabs()));
connect(m_tabBar, SIGNAL(tabMoved(int, int)), this, SLOT(moveTab(int, int)));
+ // connecting urlbar signals
+ connect(urlBar(), SIGNAL(activated(const KUrl&)), Application::instance(), SLOT(loadUrl(const KUrl&)));
+
// current page index changing
connect(this, SIGNAL(currentChanged(int)), this, SLOT(slotCurrentChanged(int)));
-
+
setTabsClosable(true);
connect(m_tabBar, SIGNAL(tabCloseRequested(int)), this, SLOT(slotCloseTab(int)));
@@ -140,25 +143,21 @@ void MainView::addTabButtonPosition()
}
-UrlBar *MainView::currentUrlBar() const
-{
- return urlBar(-1);
-}
-
-
TabBar *MainView::tabBar() const
{
return m_tabBar;
}
+
QToolButton *MainView::addTabButton() const
{
return m_addTabButton;
}
-StackedUrlBar *MainView::urlBarStack() const
+
+UrlBar *MainView::urlBar() const
{
- return m_urlBars;
+ return m_urlBar;
}
@@ -276,13 +275,9 @@ void MainView::slotWebPaste()
void MainView::clear()
{
- // clear the line edit history
- for (int i = 0; i < m_urlBars->count(); ++i)
- {
- /// TODO What exactly do we need to clear here?
- urlBar(i)->clearHistory();
- urlBar(i)->clear();
- }
+ /// TODO What exactly do we need to clear here?
+ m_urlBar->clearHistory();
+ m_urlBar->clear();
}
@@ -306,29 +301,41 @@ void MainView::slotCurrentChanged(int index)
if (!webView)
return;
- Q_ASSERT(m_urlBars->count() == count());
+ WebView *oldWebView = this->webView(m_currentTabIndex);
+ m_currentTabIndex=index;
- WebView *oldWebView = this->webView(m_urlBars->currentIndex());
if (oldWebView)
- {
+ {
+ // disconnecting webview with urlbar
+ disconnect(oldWebView, SIGNAL(loadProgress(int)), urlBar(), SLOT(slotUpdateProgress(int)));
+ disconnect(oldWebView, SIGNAL(loadFinished(bool)), urlBar(), SLOT(slotLoadFinished(bool)));
+ disconnect(oldWebView, SIGNAL(urlChanged(const QUrl &)), urlBar(), SLOT(setUrl(const QUrl &)));
+ disconnect(oldWebView, SIGNAL(iconChanged()), urlBar(), SLOT(slotUpdateUrl()));
+
disconnect(oldWebView->page(), SIGNAL(statusBarMessage(const QString&)),
this, SIGNAL(showStatusBarMessage(const QString&)));
disconnect(oldWebView->page(), SIGNAL(linkHovered(const QString&, const QString&, const QString&)),
this, SIGNAL(linkHovered(const QString&)));
}
+ // connecting webview with urlbar
+ connect(webView, SIGNAL(loadProgress(int)), urlBar(), SLOT(slotUpdateProgress(int)));
+ connect(webView, SIGNAL(loadFinished(bool)), urlBar(), SLOT(slotLoadFinished(bool)));
+ connect(webView, SIGNAL(urlChanged(const QUrl &)), urlBar(), SLOT(setUrl(const QUrl &)));
+ connect(webView, SIGNAL(iconChanged()), urlBar(), SLOT(slotUpdateUrl()));
+
connect(webView->page(), SIGNAL(statusBarMessage(const QString&)),
this, SIGNAL(showStatusBarMessage(const QString&)));
connect(webView->page(), SIGNAL(linkHovered(const QString&, const QString&, const QString&)),
this, SIGNAL(linkHovered(const QString&)));
emit setCurrentTitle(webView->title());
- m_urlBars->setCurrentIndex(index);
- currentUrlBar()->setUrl(webView->url());
+ urlBar()->setUrl(webView->url());
+ urlBar()->setProgress(webView->progress());
emit showStatusBarMessage(webView->lastStatusBarText());
// notify UI to eventually switch stop/reload button
- if(currentUrlBar()->isLoading())
+ if(urlBar()->isLoading())
emit browserTabLoading(true);
else
emit browserTabLoading(false);
@@ -338,22 +345,6 @@ void MainView::slotCurrentChanged(int index)
}
-UrlBar *MainView::urlBar(int index) const
-{
- if (index == -1)
- {
- index = m_urlBars->currentIndex();
- }
- UrlBar *urlBar = m_urlBars->urlBar(index);
- if (urlBar)
- {
- return urlBar;
- }
- kWarning() << "URL bar with index" << index << "not found. Returning NULL. (line:" << __LINE__ << ")";
- return NULL;
-}
-
-
WebView *MainView::webView(int index) const
{
QWidget *widget = this->widget(index);
@@ -373,19 +364,8 @@ WebView *MainView::webView(int index) const
// without working with the focus and loading an url
WebView *MainView::newTab(bool focused)
{
- // line edit
- UrlBar *urlBar = new UrlBar; // Ownership of widget is passed on to the QStackedWidget (addWidget method).
- 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?
- // connecting webview with urlbar
- connect(webView, SIGNAL(loadProgress(int)), urlBar, SLOT(slotUpdateProgress(int)));
- connect(webView, SIGNAL(loadFinished(bool)), urlBar, SLOT(slotLoadFinished(bool)));
- connect(webView, SIGNAL(urlChanged(const QUrl &)), urlBar, SLOT(setUrl(const QUrl &)));
- connect(webView, SIGNAL(iconChanged()), urlBar, SLOT(slotUpdateUrl()));
-
// connecting webview with mainview
connect(webView, SIGNAL(loadStarted()), this, SLOT(webViewLoadStarted()));
connect(webView, SIGNAL(loadFinished(bool)), this, SLOT(webViewLoadFinished(bool)));
@@ -401,14 +381,15 @@ WebView *MainView::newTab(bool focused)
connect(webView->page(), SIGNAL(printRequested(QWebFrame *)), this, SIGNAL(printRequested(QWebFrame *)));
addTab(webView, i18n("(Untitled)"));
+
+ urlBar()->setUrl(KUrl(""));
if (focused)
{
setCurrentWidget(webView);
+ urlBar()->setFocus();
}
-
- urlBar->setFocus();
-
+
emit tabsChanged();
showTabBar();
@@ -518,10 +499,6 @@ void MainView::slotCloseTab(int index)
hasFocus = tab->hasFocus();
}
- QWidget *urlBar = m_urlBars->urlBar(index);
- m_urlBars->removeWidget(urlBar);
- urlBar->deleteLater(); // urlBar is scheduled for deletion.
-
QWidget *webView = widget(index);
removeTab(index);
webView->deleteLater(); // webView is scheduled for deletion.
@@ -656,14 +633,6 @@ void MainView::previousTab()
}
-void MainView::moveTab(int fromIndex, int toIndex)
-{
- QWidget *lineEdit = m_urlBars->widget(fromIndex);
- m_urlBars->removeWidget(lineEdit);
- m_urlBars->insertWidget(toIndex, lineEdit);
-}
-
-
QLabel *MainView::animatedLoading(int index, bool addMovie)
{
if (index == -1)
diff --git a/src/mainview.h b/src/mainview.h
index 3e6b9efb..6343bcf1 100644
--- a/src/mainview.h
+++ b/src/mainview.h
@@ -45,8 +45,6 @@ class QUrl;
class QWebFrame;
class QLabel;
-
-class StackedUrlBar;
class TabBar;
class UrlBar;
@@ -67,14 +65,12 @@ public:
public:
- UrlBar *urlBar(int index) const;
- UrlBar *currentUrlBar() const;
+ UrlBar *urlBar() const;
WebView *webView(int index) const;
QToolButton *addTabButton() const;
// inlines
TabBar *tabBar() const;
- StackedUrlBar *urlBarStack() const;
WebView *currentWebView() const;
int webViewIndex(WebView *webView) const;
@@ -139,15 +135,6 @@ private slots:
void windowCloseRequested();
- /**
- * This functions move tab info "from index to index"
- *
- * @param fromIndex the index from which we move
- *
- * @param toIndex the index to which we move
- */
- void moveTab(int fromIndex, int toIndex);
-
void postLaunch();
protected:
@@ -171,12 +158,14 @@ private:
*/
QLabel *animatedLoading(int index, bool addMovie);
- StackedUrlBar *m_urlBars;
+ UrlBar *m_urlBar;
TabBar *m_tabBar;
QString m_loadingGitPath;
QToolButton *m_addTabButton;
+
+ int m_currentTabIndex;
};
#endif // MAINVIEW_H
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 3ac46a1b..8a84b844 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -45,7 +45,6 @@
#include "findbar.h"
#include "sidepanel.h"
#include "urlbar.h"
-#include "stackedurlbar.h"
// Ui Includes
#include "ui_cleardata.h"
@@ -206,7 +205,7 @@ void MainWindow::setupBars()
// location bar
a = new KAction(i18n("Location Bar"), this);
a->setShortcut(KShortcut(Qt::Key_F6));
- a->setDefaultWidget(m_view->urlBarStack());
+ a->setDefaultWidget(m_view->urlBar());
actionCollection()->addAction(QLatin1String("url_bar"), a);
// bookmarks bar
@@ -468,8 +467,8 @@ void MainWindow::slotUpdateBrowser()
void MainWindow::slotOpenLocation()
{
- m_view->currentUrlBar()->selectAll();
- m_view->currentUrlBar()->setFocus();
+ m_view->urlBar()->selectAll();
+ m_view->urlBar()->setFocus();
}
@@ -591,7 +590,7 @@ void MainWindow::slotPrivateBrowsing(bool enable)
if (button == KMessageBox::Yes)
{
settings->setAttribute(QWebSettings::PrivateBrowsingEnabled, true);
- m_view->currentUrlBar()->setBackgroundColor(Qt::lightGray); // palette().color(QPalette::Active, QPalette::Background));
+ m_view->urlBar()->setBackgroundColor(Qt::lightGray); // palette().color(QPalette::Active, QPalette::Background));
}
else
{
@@ -601,7 +600,7 @@ void MainWindow::slotPrivateBrowsing(bool enable)
else
{
settings->setAttribute(QWebSettings::PrivateBrowsingEnabled, false);
- m_view->currentUrlBar()->setBackgroundColor(palette().color(QPalette::Active, QPalette::Base));
+ m_view->urlBar()->setBackgroundColor(palette().color(QPalette::Active, QPalette::Base));
m_lastSearch.clear();
m_view->clear();
diff --git a/src/stackedurlbar.cpp b/src/stackedurlbar.cpp
index 18912ccd..24dafae4 100644
--- a/src/stackedurlbar.cpp
+++ b/src/stackedurlbar.cpp
@@ -53,22 +53,6 @@ StackedUrlBar::~StackedUrlBar()
}
-UrlBar *StackedUrlBar::currentUrlBar()
-{
- return urlBar(currentIndex());
-}
-
-
-UrlBar *StackedUrlBar::urlBar(int index)
-{
- UrlBar *urlBar = qobject_cast<UrlBar*>(QStackedWidget::widget(index));
- if (!urlBar)
- {
- kWarning() << "URL bar with index" << index << "not found. Returning NULL. line:" << __LINE__;
- }
-
- return urlBar;
-}
void StackedUrlBar::addUrlBar(UrlBar* urlBar)
diff --git a/src/stackedurlbar.h b/src/stackedurlbar.h
deleted file mode 100644
index bda4b8fc..00000000
--- a/src/stackedurlbar.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/* ============================================================
-*
-* This file is a part of the rekonq project
-*
-* Copyright (C) 2009 by Andrea Diamantini <adjam7 at gmail dot com>
-* Copyright (C) 2009 by Paweł Prażak <pawelprazak at gmail dot com>
-*
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License as
-* published by the Free Software Foundation; either version 2 of
-* the License or (at your option) version 3 or any later version
-* accepted by the membership of KDE e.V. (or its successor approved
-* by the membership of KDE e.V.), which shall act as a proxy
-* defined in Section 14 of version 3 of the license.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see <http://www.gnu.org/licenses/>.
-*
-* ============================================================ */
-
-
-#ifndef STACKEDURLBAR_H
-#define STACKEDURLBAR_H
-
-// Qt Includes
-#include <QStackedWidget>
-
-// Forward Declarations
-class KCompletion;
-class HistoryCompletionModel;
-class UrlBar;
-
-
-class StackedUrlBar : public QStackedWidget
-{
- Q_OBJECT
-
-public:
- StackedUrlBar(QWidget *parent = 0);
- ~StackedUrlBar();
-
-public:
- UrlBar *currentUrlBar();
- UrlBar *urlBar(int index);
- void addUrlBar(UrlBar *urlBar);
- void setCurrentUrlBar(UrlBar *urlBar);
- void removeUrlBar(UrlBar *urlBar);
-
- QList<const UrlBar *> urlBars();
-
- KCompletion *completion();
- HistoryCompletionModel *completionModel();
-
-public slots:
- void clear();
-
-private:
- Q_DISABLE_COPY(StackedUrlBar)
-
- KCompletion *m_completion;
- HistoryCompletionModel *m_completionModel;
-};
-
-#endif // STACKEDURLBAR_H
diff --git a/src/urlbar.cpp b/src/urlbar.cpp
index 94f248e3..6ece4783 100644
--- a/src/urlbar.cpp
+++ b/src/urlbar.cpp
@@ -55,11 +55,16 @@ UrlBar::UrlBar(QWidget *parent)
: KHistoryComboBox(true, parent)
, m_lineEdit(new LineEdit)
, m_progress(0)
+ , m_completion(0)
+ , m_completionModel(0)
{
setUrlDropsEnabled(true);
setAutoDeleteCompletionObject(true);
- setMinimumWidth(180);
+ //cosmetic
+ setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
+ setMinimumWidth(180);
+
setTrapReturnKey(true);
setupLineEdit();
@@ -72,7 +77,8 @@ UrlBar::UrlBar(QWidget *parent)
// setup completion box
completionBox()->setTabHandling(true); // Konqueror bug #167135
-
+ setCompletionObject(completion());
+
// set dropdown list background
QPalette p = view()->palette();
p.setColor(QPalette::Base, palette().color(QPalette::Base));
@@ -132,14 +138,17 @@ void UrlBar::setupLineEdit()
void UrlBar::setUrl(const QUrl& url)
{
- if (url.isEmpty())
- return;
-
m_currentUrl = url;
slotUpdateUrl();
}
+void UrlBar::setProgress(int progress)
+{
+ m_progress = progress;
+ repaint();
+}
+
void UrlBar::slotUpdateUrl()
{
if (count())
@@ -279,3 +288,45 @@ bool UrlBar::isLoading()
}
return true;
}
+
+
+
+KCompletion *UrlBar::completion()
+{
+ // make sure completion was created
+ if (!m_completion)
+ {
+ m_completion = new KCompletion();
+ m_completion->setCompletionMode(KGlobalSettings::CompletionPopupAuto);
+ m_completion->setOrder(KCompletion::Weighted);
+ m_completion->setIgnoreCase(true);
+
+ kDebug() << "Initialize completion list...";
+ HistoryCompletionModel *model = completionModel();
+ int count = model->rowCount();
+ kDebug() << "...initialize history items" << count;
+
+ // change order to insertion to avoid confusion of the addItem method
+ // in weighted it expects format string:number and it thinks http it the whole string
+ m_completion->setOrder(KCompletion::Insertion);
+ for (int i = 0; i < count; ++i)
+ {
+ QString item = model->data(model->index(i, 0)).toString();
+ item.remove(QRegExp("^http://|/$"));
+ m_completion->addItem(item);
+ }
+
+ m_completion->setOrder(KCompletion::Weighted);
+ }
+ return m_completion;
+}
+
+HistoryCompletionModel *UrlBar::completionModel()
+{
+ if (!m_completionModel)
+ {
+ m_completionModel = new HistoryCompletionModel(this);
+ m_completionModel->setSourceModel(Application::historyManager()->historyFilterModel());
+ }
+ return m_completionModel;
+} \ No newline at end of file
diff --git a/src/urlbar.h b/src/urlbar.h
index 50ba40f7..41d7945e 100644
--- a/src/urlbar.h
+++ b/src/urlbar.h
@@ -44,7 +44,8 @@
// Forward Declarations
class QLinearGradient;
class QWidget;
-
+class KCompletion;
+class HistoryCompletionModel;
class UrlBar : public KHistoryComboBox
{
@@ -59,7 +60,10 @@ public:
QSize sizeHint() const;
void setBackgroundColor(QColor);
bool isLoading();
-
+ KCompletion *completion();
+ HistoryCompletionModel *completionModel();
+ void setProgress(int progress);
+
signals:
void activated(const KUrl&);
@@ -90,6 +94,9 @@ private:
KUrl m_currentUrl;
int m_progress;
+
+ KCompletion *m_completion;
+ HistoryCompletionModel *m_completionModel;
};
#endif
diff --git a/src/webview.cpp b/src/webview.cpp
index 75dc0979..96c3cef5 100644
--- a/src/webview.cpp
+++ b/src/webview.cpp
@@ -60,10 +60,13 @@
WebView::WebView(QWidget* parent)
: QWebView(parent)
, m_page(new WebPage(this))
+ , m_progress(0)
{
setPage(m_page);
connect(page(), SIGNAL(statusBarMessage(const QString&)), this, SLOT(setStatusBarText(const QString&)));
+ connect(this, SIGNAL(loadProgress(int)), this, SLOT(slotUpdateProgress(int)));
+ connect(this, SIGNAL(loadFinished(bool)), this, SLOT(slotLoadFinished(bool)));
}
@@ -83,6 +86,10 @@ KUrl WebView::url() const
return KUrl(QWebView::url());
}
+int WebView::progress()
+{
+ return m_progress;
+}
QString WebView::lastStatusBarText() const
{
@@ -324,3 +331,14 @@ void WebView::slotSearch()
KUrl urlSearch = KUrl::fromEncoded(search.toUtf8());
Application::instance()->loadUrl(urlSearch, Rekonq::NewCurrentTab);
}
+
+
+void WebView::slotUpdateProgress(int p)
+{
+ m_progress=p;
+}
+
+void WebView::slotLoadFinished(bool)
+{
+ m_progress=0;
+}
diff --git a/src/webview.h b/src/webview.h
index 5a2638b8..85619fd8 100644
--- a/src/webview.h
+++ b/src/webview.h
@@ -48,6 +48,7 @@ public:
WebPage *page();
KUrl url() const;
QString lastStatusBarText() const;
+ int progress();
signals:
// switching tabs
@@ -67,10 +68,12 @@ protected:
private slots:
void setStatusBarText(const QString &string);
void slotSearch();
-
+ void slotUpdateProgress(int progress);
+ void slotLoadFinished(bool);
+
private:
WebPage *m_page;
-
+ int m_progress;
QString m_statusBarText;
};