diff options
| -rw-r--r-- | src/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | src/application.cpp | 6 | ||||
| -rw-r--r-- | src/application.h | 5 | ||||
| -rw-r--r-- | src/mainview.cpp | 102 | ||||
| -rw-r--r-- | src/mainview.h | 20 | ||||
| -rw-r--r-- | src/mainwindow.cpp | 11 | ||||
| -rw-r--r-- | src/mainwindow.h | 1 | ||||
| -rw-r--r-- | src/stackedurlbar.cpp | 159 | ||||
| -rw-r--r-- | src/stackedurlbar.h | 70 | ||||
| -rw-r--r-- | src/urlbar.cpp | 71 | ||||
| -rw-r--r-- | src/urlbar.h | 11 | ||||
| -rw-r--r-- | src/webpage.cpp | 2 | ||||
| -rw-r--r-- | src/webpage.h | 3 | ||||
| -rw-r--r-- | src/webview.cpp | 23 | ||||
| -rw-r--r-- | src/webview.h | 8 | 
15 files changed, 150 insertions, 343 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 812081de..9263113e 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/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 <KUniqueApplication>  #include <KIcon> @@ -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 efabf0f1..2b6d294c 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();  } @@ -300,35 +295,48 @@ 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);      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 +346,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 +365,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 +382,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 +500,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 +634,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..82655475 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,11 @@ 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 +134,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 +157,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/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/stackedurlbar.cpp b/src/stackedurlbar.cpp deleted file mode 100644 index 18912ccd..00000000 --- a/src/stackedurlbar.cpp +++ /dev/null @@ -1,159 +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/>. -* -* ============================================================ */ - - -// Self Includes -#include "stackedurlbar.h" -#include "stackedurlbar.moc" - -// Local Includes -#include "application.h" -#include "history.h" -#include "urlbar.h" - -// KDE Includes -#include <KDebug> - - -StackedUrlBar::StackedUrlBar(QWidget *parent) -        : QStackedWidget(parent) -        , m_completion(0) -        , m_completionModel(0) -{ -} - - -StackedUrlBar::~StackedUrlBar() -{ -    delete m_completion; -    delete m_completionModel; -} - - -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) -{ -    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<const UrlBar* > StackedUrlBar::urlBars() -{ -    QList<const UrlBar *> 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; -} 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..4b253773 100644 --- a/src/urlbar.cpp +++ b/src/urlbar.cpp @@ -51,15 +51,21 @@  QColor UrlBar::s_defaultBaseColor; +  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 +78,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 +139,18 @@ 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()) @@ -163,7 +174,7 @@ void UrlBar::slotUpdateUrl()  } -inline void UrlBar::slotActivated(const QString& url) +void UrlBar::slotActivated(const QString& url)  {      if (url.isEmpty())          return; @@ -176,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(); @@ -184,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; @@ -192,7 +203,7 @@ inline void UrlBar::slotLoadFinished(bool)  } -inline void UrlBar::slotUpdateProgress(int progress) +void UrlBar::slotUpdateProgress(int progress)  {      m_progress = progress;      repaint(); @@ -279,3 +290,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; +} 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/webpage.cpp b/src/webpage.cpp index c81d93da..1968c751 100644 --- a/src/webpage.cpp +++ b/src/webpage.cpp @@ -65,7 +65,7 @@  #include <QtGui/QClipboard>  #include <QtGui/QKeyEvent> -#include <QUiLoader> +#include <QtUiTools/QUiLoader>  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 <QWebPage>  #include <QUrl> @@ -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 75dc0979..1c9440f4 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -55,15 +55,16 @@  #include <QtGui/QAction> - -  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)));  } @@ -84,6 +85,12 @@ KUrl WebView::url() const  } +int WebView::progress() +{ +    return m_progress; +} + +  QString WebView::lastStatusBarText() const  {       return m_statusBarText;  @@ -324,3 +331,15 @@ 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..4f283aae 100644 --- a/src/webview.h +++ b/src/webview.h @@ -28,6 +28,7 @@  #ifndef WEBVIEW_H  #define WEBVIEW_H +  // KDE Includes  #include <KUrl> @@ -48,6 +49,7 @@ public:      WebPage *page();      KUrl url() const;      QString lastStatusBarText() const; +    int progress();  signals:      // switching tabs @@ -67,10 +69,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;  }; | 
