summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormegabigbug <megabigbug@arrakis.(none)>2010-03-24 22:58:51 +0100
committermegabigbug <megabigbug@arrakis.(none)>2010-03-24 22:58:51 +0100
commit0475cb6bfca254e51f5e98d018f0b2a0e6535024 (patch)
treeb1d3d5e3b5ee4b346e247d26c58005e8da14bbb8
parentderivation of the lastbar branch: UltimateLastBar :) (diff)
downloadrekonq-0475cb6bfca254e51f5e98d018f0b2a0e6535024.tar.xz
Revert "derivation of the lastbar branch: UltimateLastBar :)"
This reverts commit f45e39322dd7561bc1cd2756b4c9223bc586425b.
-rw-r--r--src/CMakeLists.txt3
-rw-r--r--src/bookmarks/bookmarksmanager.cpp20
-rw-r--r--src/bookmarks/bookmarksmanager.h10
-rw-r--r--src/mainview.cpp1
-rw-r--r--src/urlbar/lineedit.cpp4
-rw-r--r--src/urlbar/lineedit.h12
-rw-r--r--src/urlbar/urlbar.cpp237
-rw-r--r--src/urlbar/urlbar.h26
8 files changed, 132 insertions, 181 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 477eaf40..bc4e91c8 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -48,9 +48,6 @@ SET( rekonq_KDEINIT_SRCS
#----------------------------------------
urlbar/urlbar.cpp
urlbar/lineedit.cpp
- urlbar/completionwidget.cpp
- urlbar/urlresolver.cpp
- urlbar/listitem.cpp
)
diff --git a/src/bookmarks/bookmarksmanager.cpp b/src/bookmarks/bookmarksmanager.cpp
index c97b46af..cfe26a55 100644
--- a/src/bookmarks/bookmarksmanager.cpp
+++ b/src/bookmarks/bookmarksmanager.cpp
@@ -161,12 +161,7 @@ BookmarkProvider::BookmarkProvider(QObject *parent)
, m_actionCollection(new KActionCollection(this))
, m_bookmarkMenu(0)
, m_bookmarkToolBar(0)
- , m_completion(0)
{
- // take care of the completion object
- m_completion = new KCompletion;
- m_completion->setOrder( KCompletion::Weighted );
-
KUrl bookfile = KUrl("~/.kde/share/apps/konqueror/bookmarks.xml"); // share konqueror bookmarks
if (!QFile::exists(bookfile.path()))
@@ -225,7 +220,6 @@ void BookmarkProvider::slotBookmarksChanged(const QString &group, const QString
return;
m_bookmarkToolBar->clear(); // FIXME CRASH
- m_completion->clear();
KBookmark bookmark = toolBarGroup.first();
while (!bookmark.isNull())
@@ -291,8 +285,7 @@ KAction *BookmarkProvider::fillBookmarkBar(const KBookmark &bookmark)
return a;
}
else
- {
- m_completion->addItem(bookmark.url().path());
+ {
return new KBookmarkAction(bookmark, m_owner, this);
}
}
@@ -302,14 +295,3 @@ KBookmarkGroup BookmarkProvider::rootGroup()
{
return m_manager->root();
}
-
-KCompletion *BookmarkProvider::completionObject() const
-{
- return m_completion;
-}
-
-
-KBookmarkManager *BookmarkProvider::bookmarkManager()
-{
- return m_manager;
-}
diff --git a/src/bookmarks/bookmarksmanager.h b/src/bookmarks/bookmarksmanager.h
index d6b8f8e0..d4afb997 100644
--- a/src/bookmarks/bookmarksmanager.h
+++ b/src/bookmarks/bookmarksmanager.h
@@ -39,7 +39,6 @@
// KDE Includes
#include <KBookmarkOwner>
-#include <KCompletion>
// Forward Declarations
class BookmarkProvider;
@@ -211,13 +210,7 @@ public:
*/
KBookmarkGroup rootGroup();
- KBookmarkManager *bookmarkManager();
-
- /**
- * @returns the KCompletion object.
- */
- KCompletion *completionObject() const;
-
+ KBookmarkManager *bookmarkManager() { return m_manager; }
signals:
/**
* @short This signal is emitted when an url has to be loaded
@@ -252,7 +245,6 @@ private:
KActionCollection *m_actionCollection;
BookmarkMenu *m_bookmarkMenu;
KToolBar *m_bookmarkToolBar;
- KCompletion *m_completion;
};
#endif
diff --git a/src/mainview.cpp b/src/mainview.cpp
index ae745046..f2152364 100644
--- a/src/mainview.cpp
+++ b/src/mainview.cpp
@@ -242,6 +242,7 @@ void MainView::clear()
{
// FIXME (the programmer, not the code)
// What exactly do we need to clear here?
+ m_urlBar->clearHistory();
m_urlBar->clear();
m_recentlyClosedTabs.clear();
diff --git a/src/urlbar/lineedit.cpp b/src/urlbar/lineedit.cpp
index f3c93e8e..db36bd0c 100644
--- a/src/urlbar/lineedit.cpp
+++ b/src/urlbar/lineedit.cpp
@@ -2,9 +2,9 @@
*
* This file is a part of the rekonq project
*
-* Copyright (C) 2009 by Andrea Diamantini <adjam7 at gmail dot com>
+* Copyright (C) 2009-2010 by Andrea Diamantini <adjam7 at gmail dot com>
* Copyright (C) 2009 by Paweł Prażak <pawelprazak at gmail dot com>
-* Copyright (C) 2009 by Lionel Chauvin <megabigbug@yahoo.fr>
+* Copyright (C) 2009-2010 by Lionel Chauvin <megabigbug@yahoo.fr>
*
*
* This program is free software; you can redistribute it and/or
diff --git a/src/urlbar/lineedit.h b/src/urlbar/lineedit.h
index d76a5fcb..1ac3af2e 100644
--- a/src/urlbar/lineedit.h
+++ b/src/urlbar/lineedit.h
@@ -2,9 +2,9 @@
*
* This file is a part of the rekonq project
*
-* Copyright (C) 2009 by Andrea Diamantini <adjam7 at gmail dot com>
+* Copyright (C) 2009-2010 by Andrea Diamantini <adjam7 at gmail dot com>
* Copyright (C) 2009 by Paweł Prażak <pawelprazak at gmail dot com>
-* Copyright (C) 2009 by Lionel Chauvin <megabigbug@yahoo.fr>
+* Copyright (C) 2009-2010 by Lionel Chauvin <megabigbug@yahoo.fr>
*
*
* This program is free software; you can redistribute it and/or
@@ -30,6 +30,9 @@
#define LINEEDIT_H
+// Local Includes
+#include "rekonqprivate_export.h"
+
// KDE Includes
#include <KLineEdit>
@@ -39,7 +42,7 @@ class QFocusEvent;
class QKeyEvent;
-class LineEdit : public KLineEdit
+class REKONQ_TESTS_EXPORT LineEdit : public KLineEdit
{
Q_OBJECT
@@ -47,12 +50,9 @@ public:
explicit LineEdit(QWidget *parent = 0);
virtual ~LineEdit();
-
protected:
virtual void keyPressEvent(QKeyEvent*);
virtual void mouseDoubleClickEvent(QMouseEvent *);
-
-
};
#endif // LINEEDIT_H
diff --git a/src/urlbar/urlbar.cpp b/src/urlbar/urlbar.cpp
index 270cdc5e..718d9f67 100644
--- a/src/urlbar/urlbar.cpp
+++ b/src/urlbar/urlbar.cpp
@@ -2,10 +2,10 @@
*
* This file is a part of the rekonq project
*
-* Copyright (C) 2008-2009 by Andrea Diamantini <adjam7 at gmail dot com>
+* Copyright (C) 2008-2010 by Andrea Diamantini <adjam7 at gmail dot com>
* Copyright (C) 2009 by Domrachev Alexandr <alexandr.domrachev@gmail.com>
* Copyright (C) 2009 by Paweł Prażak <pawelprazak at gmail dot com>
-* Copyright (C) 2009 by Lionel Chauvin <megabigbug@yahoo.fr>
+* Copyright (C) 2009-2010 by Lionel Chauvin <megabigbug@yahoo.fr>
*
*
* This program is free software; you can redistribute it and/or
@@ -36,7 +36,8 @@
#include "lineedit.h"
#include "mainwindow.h"
#include "webview.h"
-#include "urlresolver.h"
+#include "historymanager.h"
+#include "webtab.h"
// KDE Includes
#include <KDebug>
@@ -48,41 +49,43 @@
#include <QPaintEvent>
#include <QPalette>
#include <QTimer>
-#include <QVBoxLayout>
+
QColor UrlBar::s_defaultBaseColor;
UrlBar::UrlBar(QWidget *parent)
- : KComboBox(true, parent)
- , m_lineEdit(new LineEdit)
- , m_progress(0)
+ : KHistoryComboBox(true, parent)
+ , m_lineEdit(new LineEdit)
+ , m_progress(0)
{
+ setUrlDropsEnabled(true);
+ setAutoDeleteCompletionObject(true);
+
//cosmetic
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
setMinimumWidth(180);
-
- // signal handlings
- setTrapReturnKey(true);
- setUrlDropsEnabled(true);
- // Make m_lineEdit background transparent
- QPalette p = m_lineEdit->palette();
- p.setColor(QPalette::Base, Qt::transparent);
- m_lineEdit->setPalette(p);
+ setTrapReturnKey(true);
- if (!s_defaultBaseColor.isValid())
- {
- s_defaultBaseColor = palette().color(QPalette::Base);
- }
+ setupLineEdit();
- setLineEdit(m_lineEdit);
+ // add every item to history
+ connect(this, SIGNAL(returnPressed(const QString&)), SLOT(activated(const QString&)));
+ connect(completionBox(), SIGNAL(activated(const QString&)), SLOT(activated(const QString&)));
- // clear the URL bar
- m_lineEdit->clear();
+ connect(this, SIGNAL(cleared()), SLOT(cleared()));
+
+ // setup completion box
+ setCompletionObject( Application::historyManager()->completionObject() );
+ // set dropdown list background
+ QPalette p = view()->palette();
+ p.setColor(QPalette::Base, palette().color(QPalette::Base));
+ view()->setPalette(p);
+
// load urls on activated urlbar signal
- connect(this, SIGNAL(returnPressed(const QString&)), SLOT(activated(const QString&)));
+ connect(this, SIGNAL(activated(const KUrl&)), Application::instance(), SLOT(loadUrl(const KUrl&)));
}
@@ -93,7 +96,7 @@ UrlBar::~UrlBar()
void UrlBar::selectAll() const
{
- m_lineEdit->selectAll();
+ lineEdit()->selectAll();
}
@@ -103,18 +106,49 @@ KUrl UrlBar::url() const
}
+KLineEdit *UrlBar::lineEdit() const
+{
+ return m_lineEdit;
+}
+
+
+void UrlBar::setupLineEdit()
+{
+ // Make m_lineEdit background transparent
+ QPalette p = m_lineEdit->palette();
+ p.setColor(QPalette::Base, Qt::transparent);
+ m_lineEdit->setPalette(p);
+
+ if (!s_defaultBaseColor.isValid())
+ {
+ s_defaultBaseColor = palette().color(QPalette::Base);
+ }
+
+ setLineEdit(m_lineEdit);
+
+ // Make the lineedit consume the Qt::Key_Enter event...
+ lineEdit()->setTrapReturnKey(true);
+
+ lineEdit()->setHandleSignals(true);
+
+ // clear the URL bar
+ lineEdit()->clear();
+}
+
+
void UrlBar::setUrl(const QUrl& url)
{
if(url.scheme() == "about")
{
m_currentUrl = KUrl();
+ updateUrl(); // updateUrl before setFocus
setFocus();
}
else
{
m_currentUrl = KUrl(url);
+ updateUrl();
}
- updateUrl();
}
@@ -161,30 +195,29 @@ void UrlBar::updateUrl()
// Must be AFTER setCurrentIndex
if (!hasFocus())
{
- m_lineEdit->setCursorPosition(0);
+ lineEdit()->setCursorPosition(0);
}
}
void UrlBar::activated(const QString& urlString)
{
- disconnect(this, SIGNAL(editTextChanged(const QString &)), this, SLOT(suggestUrls(const QString &)));
+ if (urlString.isEmpty())
+ return;
-
- if(!m_suggestedUrl.isEmpty())
- {
- kDebug() << "+++++++++++++++++ suggested url NOT empty +++++++++++++++++++++++";
- m_currentUrl = m_suggestedUrl;
- updateUrl();
- m_suggestedUrl = KUrl();
- }
- else
- {
- if (urlString.isEmpty())
- return;
- setUrl(urlString);
- }
- Application::instance()->loadUrl(m_currentUrl);
+ // this fix urlbar behaviour, removing focus from there and enabling
+ // loading animation. Temporary fix??
+ Application::instance()->mainWindow()->currentTab()->setFocus();
+
+ setUrl( KUrl(urlString) );
+ emit activated( KUrl(urlString) );
+}
+
+
+void UrlBar::cleared()
+{
+ // clear the history on user's request from context menu
+ clear();
}
@@ -210,7 +243,7 @@ void UrlBar::paintEvent(QPaintEvent *event)
p.setColor(QPalette::Base, s_defaultBaseColor);
setPalette(p);
- KComboBox::paintEvent(event);
+ KHistoryComboBox::paintEvent(event);
if (!hasFocus())
{
@@ -228,7 +261,7 @@ void UrlBar::paintEvent(QPaintEvent *event)
painter.setBrush(generateGradient(loadingColor, height()));
painter.setPen(Qt::transparent);
- QRect backgroundRect = m_lineEdit->frameGeometry();
+ QRect backgroundRect = lineEdit()->frameGeometry();
int mid = backgroundRect.width() * m_progress / 100;
QRect progressRect(backgroundRect.x(), backgroundRect.y(), mid, backgroundRect.height());
painter.drawRect(progressRect);
@@ -239,7 +272,7 @@ void UrlBar::paintEvent(QPaintEvent *event)
QSize UrlBar::sizeHint() const
{
- return m_lineEdit->sizeHint();
+ return lineEdit()->sizeHint();
}
@@ -275,99 +308,43 @@ bool UrlBar::isLoading()
return true;
}
+
void UrlBar::keyPressEvent(QKeyEvent *event)
{
-
- // this handles the up/down arrow with active suggestions
- if(m_box)
- {
- switch(event->key())
- {
- case Qt::Key_Escape:
- m_box->hide();
- setFocus();
- break;
- case Qt::Key_Up:
- m_suggestedUrl = m_box->activatePrevious();
- kDebug() << "oooooooooooooooooo Up Arrow";
- break;
-
- case Qt::Key_Down:
- m_suggestedUrl = m_box->activateNext();
- kDebug() << "oooooooooooooooooo Down Arrow";
- break;
-
- default:
- break;
- }
- return KComboBox::keyPressEvent(event);
- }
-
- // this handles the Modifiers + Return key combinations
QString currentText = m_lineEdit->text().trimmed();
- if ((event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return)
- && !currentText.startsWith(QLatin1String("http://"), Qt::CaseInsensitive))
+ if (event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return)
{
- QString append;
- if (event->modifiers() == Qt::ControlModifier)
- {
- append = QLatin1String(".com");
- }
- else if (event->modifiers() == (Qt::ControlModifier | Qt::ShiftModifier))
+ if( !currentText.startsWith(QLatin1String("http://"), Qt::CaseInsensitive) )
{
- append = QLatin1String(".org");
+ QString append;
+ if (event->modifiers() == Qt::ControlModifier)
+ {
+ append = QLatin1String(".com");
+ }
+ else if (event->modifiers() == (Qt::ControlModifier | Qt::ShiftModifier))
+ {
+ append = QLatin1String(".org");
+ }
+ else if (event->modifiers() == Qt::ShiftModifier)
+ {
+ append = QLatin1String(".net");
+ }
+
+ QUrl url(QLatin1String("http://www.") + currentText);
+ QString host = url.host();
+ if (!host.endsWith(append, Qt::CaseInsensitive))
+ {
+ host += append;
+ url.setHost(host);
+ m_lineEdit->setText(url.toString());
+ }
}
- else if (event->modifiers() == Qt::ShiftModifier)
- {
- append = QLatin1String(".net");
- }
-
- QUrl url(QLatin1String("http://www.") + currentText);
- QString host = url.host();
- if (!host.endsWith(append, Qt::CaseInsensitive))
+ else
{
- host += append;
- url.setHost(host);
- m_lineEdit->setText(url.toString());
+ // fill lineEdit with its stripped contents to remove trailing spaces
+ m_lineEdit->setText(currentText);
}
}
-
- KComboBox::keyPressEvent(event);
-}
-
-void UrlBar::suggestUrls(const QString &text)
-{
- if(text.isEmpty())
- return;
-
- UrlResolver res(text);
- UrlSearchList list = res.orderedSearchItems();
-
- if(list.count() > 0)
- {
- if (m_box) delete m_box;
- m_box=new CompletionWidget(this);
- m_box->insertSearchList(list);
- m_box->popup();
- }
-}
-
-
-void UrlBar::focusInEvent(QFocusEvent *event)
-{
- // activate suggestions on edit text
- connect(this, SIGNAL(editTextChanged(const QString &)), this, SLOT(suggestUrls(const QString &)));
-
- KComboBox::focusInEvent(event);
-}
-
-
-void UrlBar::changeEvent(QEvent *event)
-{
- if (event->type()==QEvent::EnabledChange
- && !isEnabled()
- && m_box
- && m_box->isVisible()) m_box->hide();
- KComboBox::changeEvent(event);
+ KHistoryComboBox::keyPressEvent(event);
}
diff --git a/src/urlbar/urlbar.h b/src/urlbar/urlbar.h
index 18878e5f..39911bb2 100644
--- a/src/urlbar/urlbar.h
+++ b/src/urlbar/urlbar.h
@@ -2,10 +2,10 @@
*
* This file is a part of the rekonq project
*
-* Copyright (C) 2008-2009 by Andrea Diamantini <adjam7 at gmail dot com>
+* Copyright (C) 2008-2010 by Andrea Diamantini <adjam7 at gmail dot com>
* Copyright (C) 2009 by Domrachev Alexandr <alexandr.domrachev@gmail.com>
* Copyright (C) 2009 by Paweł Prażak <pawelprazak at gmail dot com>
-* Copyright (C) 2009 by Lionel Chauvin <megabigbug@yahoo.fr>
+* Copyright (C) 2009-2010 by Lionel Chauvin <megabigbug@yahoo.fr>
*
*
* This program is free software; you can redistribute it and/or
@@ -32,23 +32,23 @@
// Local Includes
+#include "rekonqprivate_export.h"
#include "lineedit.h"
-#include "completionwidget.h"
// KDE Includes
#include <KUrl>
-#include <KComboBox>
+#include <KHistoryComboBox>
// Qt Includes
#include <QUrl>
-#include <QPointer>
// Forward Declarations
class QLinearGradient;
class QWidget;
+class KCompletion;
-class UrlBar : public KComboBox
+class REKONQ_TESTS_EXPORT UrlBar : public KHistoryComboBox
{
Q_OBJECT
@@ -64,6 +64,9 @@ public:
void setProgress(int progress);
+signals:
+ void activated(const KUrl&);
+
public slots:
void setUrl(const QUrl &url);
void updateProgress(int progress);
@@ -72,15 +75,17 @@ public slots:
private slots:
void activated(const QString& url);
void loadFinished(bool);
- void suggestUrls(const QString &editedText);
+ void cleared();
protected:
virtual void paintEvent(QPaintEvent *event);
virtual void keyPressEvent(QKeyEvent *event);
- virtual void focusInEvent(QFocusEvent *event);
- virtual void changeEvent (QEvent* event);
private:
+ void setupLineEdit();
+
+ KLineEdit *lineEdit() const;
+
static QLinearGradient generateGradient(const QColor &color, int height);
static QColor s_defaultBaseColor;
@@ -89,9 +94,6 @@ private:
KUrl m_currentUrl;
int m_progress;
-
- CompletionWidget *m_box;
- KUrl m_suggestedUrl;
};
#endif