summaryrefslogtreecommitdiff
path: root/src/urlbar
diff options
context:
space:
mode:
Diffstat (limited to 'src/urlbar')
-rw-r--r--src/urlbar/completionwidget.cpp21
-rw-r--r--src/urlbar/completionwidget.h2
-rw-r--r--src/urlbar/listitem.cpp1
-rw-r--r--src/urlbar/stackedurlbar.cpp74
-rw-r--r--src/urlbar/stackedurlbar.h56
-rw-r--r--src/urlbar/urlbar.cpp26
-rw-r--r--src/urlbar/urlbar.h4
-rw-r--r--src/urlbar/urlresolver.cpp64
8 files changed, 196 insertions, 52 deletions
diff --git a/src/urlbar/completionwidget.cpp b/src/urlbar/completionwidget.cpp
index 1bb01785..b19b163e 100644
--- a/src/urlbar/completionwidget.cpp
+++ b/src/urlbar/completionwidget.cpp
@@ -35,6 +35,7 @@
#include "application.h"
#include "urlresolver.h"
#include "searchengine.h"
+#include "urlbar.h"
// KDE Includes
#include <KGlobalSettings>
@@ -180,7 +181,8 @@ bool CompletionWidget::eventFilter(QObject *o, QEvent *e)
if (wid && wid->isAncestorOf(_parent) && isVisible())
{
ListItem *child;
-
+ UrlBar *w;
+
if (type == QEvent::KeyPress)
{
QKeyEvent *ev = static_cast<QKeyEvent *>(e);
@@ -214,12 +216,21 @@ bool CompletionWidget::eventFilter(QObject *o, QEvent *e)
case Qt::Key_Enter:
case Qt::Key_Return:
- child = findChild<ListItem *>(QString::number(_currentIndex));
- emit chosenUrl(child->url(), Rekonq::CurrentTab);
+ w = qobject_cast<UrlBar *>(parent());
+ if(w->text() == _typedString)
+ {
+ child = findChild<ListItem *>(QString::number(_currentIndex));
+ emit chosenUrl(child->url(), Rekonq::CurrentTab);
+ }
+ else
+ {
+ // this will be used just on fast typing..
+ emit chosenUrl(KUrl(w->text()), Rekonq::CurrentTab);
+ }
ev->accept();
hide();
return true;
-
+
case Qt::Key_Escape:
hide();
return true;
@@ -259,6 +270,8 @@ void CompletionWidget::itemChosen(ListItem *item, Qt::MouseButton button)
void CompletionWidget::suggestUrls(const QString &text)
{
+ _typedString = text;
+
QWidget *w = qobject_cast<QWidget *>(parent());
if (!w->hasFocus())
return;
diff --git a/src/urlbar/completionwidget.h b/src/urlbar/completionwidget.h
index 4ce8248d..2d33b59f 100644
--- a/src/urlbar/completionwidget.h
+++ b/src/urlbar/completionwidget.h
@@ -85,6 +85,8 @@ private:
int _currentIndex;
KService::Ptr _searchEngine;
+
+ QString _typedString;
};
#endif // COMPLETION_WIDGET_H
diff --git a/src/urlbar/listitem.cpp b/src/urlbar/listitem.cpp
index c6f75348..f91840d2 100644
--- a/src/urlbar/listitem.cpp
+++ b/src/urlbar/listitem.cpp
@@ -296,6 +296,7 @@ QString SearchListItem::searchItemTitle(QString engine, QString text)
return QString(i18nc("%1=search engine, e.g. Google, Wikipedia %2=text to search for", "Search %1 for <b>%2</b>", engine, text));
}
+
void SearchListItem::changeSearchEngine(KService::Ptr engine)
{
m_titleLabel->setText(searchItemTitle(engine->name(), m_text));
diff --git a/src/urlbar/stackedurlbar.cpp b/src/urlbar/stackedurlbar.cpp
new file mode 100644
index 00000000..1882d98c
--- /dev/null
+++ b/src/urlbar/stackedurlbar.cpp
@@ -0,0 +1,74 @@
+/* ============================================================
+*
+* This file is a part of the rekonq project
+*
+* Copyright (C) 2010 by Andrea Diamantini <adjam7 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 "urlbar.h"
+
+
+StackedUrlBar::StackedUrlBar(QWidget *parent)
+ : QStackedWidget(parent)
+{
+ // cosmetic
+ setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
+ setMinimumWidth(200);
+ setMinimumHeight(26); // FIXME in Qt 4.7 we can probably move using MinimumWidth 20
+}
+
+
+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::moveBar(int from, int to)
+{
+ QWidget *fromBar = widget(from);
+ removeWidget(fromBar);
+ insertWidget(to, fromBar);
+}
diff --git a/src/urlbar/stackedurlbar.h b/src/urlbar/stackedurlbar.h
new file mode 100644
index 00000000..d2c76c8a
--- /dev/null
+++ b/src/urlbar/stackedurlbar.h
@@ -0,0 +1,56 @@
+/* ============================================================
+*
+* This file is a part of the rekonq project
+*
+* Copyright (C) 2010 by Andrea Diamantini <adjam7 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 STACKED_URLBAR_H
+#define STACKED_URLBAR_H
+
+
+// Rekonq Includes
+#include "rekonq_defines.h"
+
+// Qt Includes
+#include <QStackedWidget>
+
+// Forward Declarations
+class UrlBar;
+
+
+class REKONQ_TESTS_EXPORT StackedUrlBar : public QStackedWidget
+{
+ Q_OBJECT
+
+public:
+ StackedUrlBar(QWidget *parent = 0);
+ ~StackedUrlBar();
+
+ UrlBar *currentUrlBar();
+ UrlBar *urlBar(int index);
+
+private slots:
+ void moveBar(int, int);
+};
+
+#endif // STACKED_URLBAR_H
diff --git a/src/urlbar/urlbar.cpp b/src/urlbar/urlbar.cpp
index e1e542b7..d2992c4d 100644
--- a/src/urlbar/urlbar.cpp
+++ b/src/urlbar/urlbar.cpp
@@ -61,6 +61,7 @@ IconButton::IconButton(QWidget *parent)
setCursor(Qt::ArrowCursor);
}
+
void IconButton::mouseReleaseEvent(QMouseEvent* event)
{
emit clicked(event->globalPos());
@@ -80,11 +81,6 @@ UrlBar::UrlBar(QWidget *parent)
// initial style
setStyleSheet(QString("UrlBar { padding: 0 0 0 %1px;} ").arg(_icon->sizeHint().width()));
- // cosmetic
- setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
- setMinimumWidth(200);
- setMinimumHeight(26);
-
// doesn't show the clear button
setClearButtonShown(false);
@@ -190,7 +186,7 @@ void UrlBar::paintEvent(QPaintEvent *event)
// you need this before our code to draw inside the line edit..
KLineEdit::paintEvent(event);
- if (text().isEmpty())
+ if( text().isEmpty() && progr == 0 )
{
QStyleOptionFrame option;
initStyleOption(&option);
@@ -305,7 +301,7 @@ void UrlBar::loadFinished()
void UrlBar::loadTyped(const QString &text)
{
- activated(KUrl(text));
+ activated( KUrl(text) );
}
@@ -363,7 +359,8 @@ IconButton *UrlBar::addRightIcon(UrlBar::icon ic)
_rightIconsList << rightIcon;
int iconsCount = _rightIconsList.count();
- rightIcon->move(width() - 23*iconsCount, 6);
+ int iconHeight = (height() - 18) / 2;
+ rightIcon->move(width() - 23*iconsCount, iconHeight);
rightIcon->show();
return rightIcon;
@@ -379,7 +376,7 @@ void UrlBar::clearRightIcons()
void UrlBar::resizeEvent(QResizeEvent *event)
{
- int newHeight = (height() - 19) / 2;
+ int newHeight = (height() - 18) / 2;
_icon->move(4, newHeight);
int iconsCount = _rightIconsList.count();
@@ -392,17 +389,20 @@ void UrlBar::resizeEvent(QResizeEvent *event)
}
KLineEdit::resizeEvent(event);
-
}
void UrlBar::detectTypedString(const QString &typed)
{
- Q_UNUSED(typed);
+ if(typed.count() == 1)
+ {
+ QTimer::singleShot(0, this, SLOT(suggest()));
+ return;
+ }
if(_suggestionTimer->isActive())
_suggestionTimer->stop();
- _suggestionTimer->start(200);
+ _suggestionTimer->start(150);
}
@@ -410,4 +410,4 @@ void UrlBar::suggest()
{
if(!_box.isNull())
_box.data()->suggestUrls( text() );
-} \ No newline at end of file
+}
diff --git a/src/urlbar/urlbar.h b/src/urlbar/urlbar.h
index cda8a2e1..7fbe8bb4 100644
--- a/src/urlbar/urlbar.h
+++ b/src/urlbar/urlbar.h
@@ -90,9 +90,11 @@ public:
void setPrivateMode(bool on);
+public slots:
+ void setQUrl(const QUrl &url);
+
private slots:
void activated(const KUrl& url, Rekonq::OpenType = Rekonq::CurrentTab);
- void setQUrl(const QUrl &url);
void loadFinished();
void loadTyped(const QString &);
diff --git a/src/urlbar/urlresolver.cpp b/src/urlbar/urlresolver.cpp
index e86adc62..840fd78f 100644
--- a/src/urlbar/urlresolver.cpp
+++ b/src/urlbar/urlresolver.cpp
@@ -88,50 +88,47 @@ UrlSearchList UrlResolver::orderedSearchItems()
}
- if (_typedString.length() >= 2)
- {
- int firstResults = list.count();
- int checkPoint = 9 - firstResults;
+ int firstResults = list.count();
+ int checkPoint = 9 - firstResults;
- UrlSearchList historyList = historyResolution();
- int historyResults = historyList.count();
+ UrlSearchList historyList = historyResolution();
+ int historyResults = historyList.count();
- UrlSearchList bookmarksList = bookmarksResolution();
- int bookmarkResults = bookmarksList.count();
+ UrlSearchList bookmarksList = bookmarksResolution();
+ int bookmarkResults = bookmarksList.count();
- if (historyResults + bookmarkResults > checkPoint)
- {
- historyList = historyList.mid(0, 3);
- bookmarksList = bookmarksList.mid(0, 3);
- }
+ if (historyResults + bookmarkResults > checkPoint)
+ {
+ historyList = historyList.mid(0, 3);
+ bookmarksList = bookmarksList.mid(0, 3);
+ }
- QList<UrlSearchItem> common;
+ QList<UrlSearchItem> common;
- foreach(UrlSearchItem i, historyList)
- {
- if (!bookmarksList.contains(i))
- {
- list << i;
- }
- else
- {
- i.type |= UrlSearchItem::Bookmark;
- common << i;
- }
- }
-
- foreach(const UrlSearchItem &i, common)
+ foreach(UrlSearchItem i, historyList)
+ {
+ if (!bookmarksList.contains(i))
{
list << i;
}
-
- foreach(const UrlSearchItem &i, bookmarksList)
+ else
{
- if (!common.contains(i))
- list << i;
+ i.type |= UrlSearchItem::Bookmark;
+ common << i;
}
}
+ foreach(const UrlSearchItem &i, common)
+ {
+ list << i;
+ }
+
+ foreach(const UrlSearchItem &i, bookmarksList)
+ {
+ if (!common.contains(i))
+ list << i;
+ }
+
list = placeTypedDomaineNameOnTop(list);
return list;
@@ -225,7 +222,7 @@ UrlSearchList UrlResolver::bookmarksResolution()
UrlSearchList UrlResolver::placeTypedDomaineNameOnTop(UrlSearchList list)
{
- int i=0;
+ int i = 0;
bool found = false;
while(i<list.count() && !found)
@@ -242,4 +239,3 @@ UrlSearchList UrlResolver::placeTypedDomaineNameOnTop(UrlSearchList list)
return list;
}
-