From 94186b36d9b3b74b87ed892e573c747a24f63b51 Mon Sep 17 00:00:00 2001 From: Lionel Chauvin Date: Sat, 22 Aug 2009 17:43:17 +0200 Subject: Remove url stack --- src/CMakeLists.txt | 1 - src/application.cpp | 6 +-- src/mainview.cpp | 101 +++++++++++++++++--------------------------------- src/mainview.h | 19 ++-------- src/mainwindow.cpp | 11 +++--- src/stackedurlbar.cpp | 16 -------- src/stackedurlbar.h | 70 ---------------------------------- src/urlbar.cpp | 61 +++++++++++++++++++++++++++--- src/urlbar.h | 11 +++++- src/webview.cpp | 18 +++++++++ src/webview.h | 7 +++- 11 files changed, 135 insertions(+), 186 deletions(-) delete mode 100644 src/stackedurlbar.h (limited to 'src') 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(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 -* Copyright (C) 2009 by Paweł Prażak -* -* -* 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 . -* -* ============================================================ */ - - -#ifndef STACKEDURLBAR_H -#define STACKEDURLBAR_H - -// Qt Includes -#include - -// 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 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; }; -- cgit v1.2.1 From a3100049ab5929533da42556a8e6eafaca6dc86c Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sat, 22 Aug 2009 20:38:17 +0200 Subject: Removed unuseful stackedurlbar.cpp file --- src/stackedurlbar.cpp | 143 -------------------------------------------------- 1 file changed, 143 deletions(-) delete mode 100644 src/stackedurlbar.cpp (limited to 'src') diff --git a/src/stackedurlbar.cpp b/src/stackedurlbar.cpp deleted file mode 100644 index 24dafae4..00000000 --- a/src/stackedurlbar.cpp +++ /dev/null @@ -1,143 +0,0 @@ -/* ============================================================ -* -* This file is a part of the rekonq project -* -* Copyright (C) 2009 by Andrea Diamantini -* Copyright (C) 2009 by Paweł Prażak -* -* -* 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 . -* -* ============================================================ */ - - -// Self Includes -#include "stackedurlbar.h" -#include "stackedurlbar.moc" - -// Local Includes -#include "application.h" -#include "history.h" -#include "urlbar.h" - -// KDE Includes -#include - - -StackedUrlBar::StackedUrlBar(QWidget *parent) - : QStackedWidget(parent) - , m_completion(0) - , m_completionModel(0) -{ -} - - -StackedUrlBar::~StackedUrlBar() -{ - delete m_completion; - delete m_completionModel; -} - - - - -void StackedUrlBar::addUrlBar(UrlBar* urlBar) -{ - QStackedWidget::addWidget(urlBar); - - // setup completion objects - urlBar->setCompletionObject(completion()); -} - - -void StackedUrlBar::setCurrentUrlBar(UrlBar* urlBar) -{ - QStackedWidget::setCurrentWidget(urlBar); -} - - -void StackedUrlBar::removeUrlBar(UrlBar* urlBar) -{ - QStackedWidget::removeWidget(urlBar); -} - - -void StackedUrlBar::clear() -{ - currentUrlBar()->clearHistory(); - - for (int i = 0; i < count(); ++i) - { - urlBar(i)->clear(); - } -} - - -QList StackedUrlBar::urlBars() -{ - QList list; - for (int i = 0; i < count(); ++i) - { - const UrlBar* u = urlBar(i); - list.append(u); - } - return list; -} - - -KCompletion *StackedUrlBar::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 *StackedUrlBar::completionModel() -{ - if (!m_completionModel) - { - m_completionModel = new HistoryCompletionModel(this); - m_completionModel->setSourceModel(Application::historyManager()->historyFilterModel()); - } - return m_completionModel; -} -- cgit v1.2.1 From bb0be61558032932ca1775a5068a3e331f5be292 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sat, 22 Aug 2009 21:22:46 +0200 Subject: Some stupid fixes on style, spaces and some comments added --- src/application.h | 5 +---- src/mainview.cpp | 1 + src/mainview.h | 1 - src/mainwindow.h | 1 + src/urlbar.cpp | 14 ++++++++------ src/webpage.cpp | 2 +- src/webpage.h | 3 +-- src/webview.cpp | 5 +++-- src/webview.h | 1 + 9 files changed, 17 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/application.h b/src/application.h index cd617b7a..44173373 100644 --- a/src/application.h +++ b/src/application.h @@ -26,11 +26,10 @@ * ============================================================ */ - - #ifndef APPLICATION_H #define APPLICATION_H + // KDE Includes #include #include @@ -120,7 +119,6 @@ public slots: const Rekonq::OpenType& type = Rekonq::CurrentTab ); - private slots: /** @@ -128,7 +126,6 @@ private slots: */ void postLaunch(); - private: KUrl guessUrlFromString(const QString &url); diff --git a/src/mainview.cpp b/src/mainview.cpp index ef4d869b..2b6d294c 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -295,6 +295,7 @@ void MainView::slotReloadTab(int index) } +// TODO need some extra comments to better understand what happens here.. void MainView::slotCurrentChanged(int index) { WebView *webView = this->webView(index); diff --git a/src/mainview.h b/src/mainview.h index 6343bcf1..82655475 100644 --- a/src/mainview.h +++ b/src/mainview.h @@ -69,7 +69,6 @@ public: WebView *webView(int index) const; QToolButton *addTabButton() const; - // inlines TabBar *tabBar() const; WebView *currentWebView() const; int webViewIndex(WebView *webView) const; diff --git a/src/mainwindow.h b/src/mainwindow.h index 14c59cce..b7f9bae1 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -29,6 +29,7 @@ #ifndef MAINWINDOW_H #define MAINWINDOW_H + // Local Includes #include "bookmarks.h" #include "mainview.h" diff --git a/src/urlbar.cpp b/src/urlbar.cpp index 6ece4783..4b253773 100644 --- a/src/urlbar.cpp +++ b/src/urlbar.cpp @@ -51,6 +51,7 @@ QColor UrlBar::s_defaultBaseColor; + UrlBar::UrlBar(QWidget *parent) : KHistoryComboBox(true, parent) , m_lineEdit(new LineEdit) @@ -149,6 +150,7 @@ void UrlBar::setProgress(int progress) repaint(); } + void UrlBar::slotUpdateUrl() { if (count()) @@ -172,7 +174,7 @@ void UrlBar::slotUpdateUrl() } -inline void UrlBar::slotActivated(const QString& url) +void UrlBar::slotActivated(const QString& url) { if (url.isEmpty()) return; @@ -185,7 +187,7 @@ inline void UrlBar::slotActivated(const QString& url) } -inline void UrlBar::slotCleared() +void UrlBar::slotCleared() { // clear the history on user's request from context menu clear(); @@ -193,7 +195,7 @@ inline void UrlBar::slotCleared() } -inline void UrlBar::slotLoadFinished(bool) +void UrlBar::slotLoadFinished(bool) { // reset progress bar after small delay m_progress = 0; @@ -201,7 +203,7 @@ inline void UrlBar::slotLoadFinished(bool) } -inline void UrlBar::slotUpdateProgress(int progress) +void UrlBar::slotUpdateProgress(int progress) { m_progress = progress; repaint(); @@ -290,7 +292,6 @@ bool UrlBar::isLoading() } - KCompletion *UrlBar::completion() { // make sure completion was created @@ -321,6 +322,7 @@ KCompletion *UrlBar::completion() return m_completion; } + HistoryCompletionModel *UrlBar::completionModel() { if (!m_completionModel) @@ -329,4 +331,4 @@ HistoryCompletionModel *UrlBar::completionModel() m_completionModel->setSourceModel(Application::historyManager()->historyFilterModel()); } return m_completionModel; -} \ No newline at end of file +} diff --git a/src/webpage.cpp b/src/webpage.cpp index c81d93da..1968c751 100644 --- a/src/webpage.cpp +++ b/src/webpage.cpp @@ -65,7 +65,7 @@ #include #include -#include +#include WebPage::WebPage(QObject *parent) diff --git a/src/webpage.h b/src/webpage.h index d1642966..7137da3d 100644 --- a/src/webpage.h +++ b/src/webpage.h @@ -32,8 +32,6 @@ #define WEBPAGE_H -// KDE Includes - // Qt Includes #include #include @@ -43,6 +41,7 @@ class QWebFrame; class QNetworkReply; class QUrl; + class WebPage : public QWebPage { Q_OBJECT diff --git a/src/webview.cpp b/src/webview.cpp index 96c3cef5..1c9440f4 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -55,8 +55,6 @@ #include - - WebView::WebView(QWidget* parent) : QWebView(parent) , m_page(new WebPage(this)) @@ -86,11 +84,13 @@ KUrl WebView::url() const return KUrl(QWebView::url()); } + int WebView::progress() { return m_progress; } + QString WebView::lastStatusBarText() const { return m_statusBarText; @@ -338,6 +338,7 @@ 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 85619fd8..4f283aae 100644 --- a/src/webview.h +++ b/src/webview.h @@ -28,6 +28,7 @@ #ifndef WEBVIEW_H #define WEBVIEW_H + // KDE Includes #include -- cgit v1.2.1