summaryrefslogtreecommitdiff
path: root/src/urlbar
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2013-11-19 16:39:13 +0100
committerAndrea Diamantini <adjam7@gmail.com>2013-11-19 17:41:31 +0100
commit4ff1ef46d5a03e1fe19619ce41070c70a517d41d (patch)
tree5bd3532aad1d958e6737b620b73ff4f53ceafc7b /src/urlbar
parentAdopt a new loading icon. It seems fixing some problems :) (diff)
downloadrekonq-4ff1ef46d5a03e1fe19619ce41070c70a517d41d.tar.xz
improvement on urlbar suggestions
STEP 1: clean up! - remember deleting ASAP the UrlSuggester - remove preview label icon to let loading being faster - remove unused opensearch inventories - let ESC key on suggestions behave like major browser (restoring original string)
Diffstat (limited to 'src/urlbar')
-rw-r--r--src/urlbar/completionwidget.cpp6
-rw-r--r--src/urlbar/listitem.cpp122
-rw-r--r--src/urlbar/listitem.h56
-rw-r--r--src/urlbar/urlsuggester.h19
4 files changed, 14 insertions, 189 deletions
diff --git a/src/urlbar/completionwidget.cpp b/src/urlbar/completionwidget.cpp
index f745afae..b7a7bfdb 100644
--- a/src/urlbar/completionwidget.cpp
+++ b/src/urlbar/completionwidget.cpp
@@ -334,6 +334,10 @@ bool CompletionWidget::eventFilter(QObject *obj, QEvent *ev)
}
case Qt::Key_Escape:
hide();
+
+ w = qobject_cast<UrlBar *>(parent());
+ w->setText(_typedString);
+
return true;
}
}
@@ -400,6 +404,8 @@ void CompletionWidget::suggestUrls(const QString &text)
// NOTE: It's important to call this AFTER orderedSearchItems() to let everything work
res->computeSuggestions();
+
+ delete res;
}
diff --git a/src/urlbar/listitem.cpp b/src/urlbar/listitem.cpp
index 02605167..b8b980c6 100644
--- a/src/urlbar/listitem.cpp
+++ b/src/urlbar/listitem.cpp
@@ -344,14 +344,6 @@ PreviewListItem::PreviewListItem(const UrlSuggestionItem &item, const QString &t
vLayout->addWidget(new TextLabel("<i>" + item.url + "</i>", text, this));
hLayout->addLayout(vLayout);
- // preview label icon
- QLabel *previewLabelIcon = new QLabel(this);
- previewLabelIcon->setFixedSize(45, 33);
- new PreviewLabel(item.url, 38, 29, previewLabelIcon);
- IconLabel* icon = new IconLabel(item.url, previewLabelIcon);
- icon->move(27, 16);
- hLayout->addWidget(previewLabelIcon);
-
setLayout(hLayout);
}
@@ -359,67 +351,6 @@ PreviewListItem::PreviewListItem(const UrlSuggestionItem &item, const QString &t
// ---------------------------------------------------------------
-PreviewLabel::PreviewLabel(const QString &url, int width, int height, QWidget *parent)
- : QLabel(parent)
-{
- setFixedSize(width, height);
- setFrameStyle(QFrame::StyledPanel | QFrame::Raised);
-
- KUrl u = KUrl(url);
- if (WebSnap::existsImage(KUrl(u)))
- {
- QPixmap preview;
- preview.load(WebSnap::imagePathFromUrl(u));
- setPixmap(preview.scaled(width, height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
- }
-}
-
-
-// ---------------------------------------------------------------
-
-
-ImageLabel::ImageLabel(const QString &url, int width, int height, QWidget *parent)
- : QLabel(parent),
- m_url(url)
-{
- setFixedSize(width, height);
- if (WebSnap::existsImage(KUrl(url)))
- {
- QPixmap pix;
- pix.load(WebSnap::imagePathFromUrl(url));
- setPixmap(pix);
- }
- else
- {
- KIO::TransferJob *job = KIO::get(KUrl(url), KIO::NoReload, KIO::HideProgressInfo);
- connect(job, SIGNAL(data(KIO::Job*,QByteArray)),
- this, SLOT(slotData(KJob*,QByteArray)));
- connect(job, SIGNAL(result(KJob*)),
- this, SLOT(slotResult(KJob*)));
- }
-}
-
-
-void ImageLabel::slotData(KJob *job, const QByteArray &data)
-{
- Q_UNUSED(job);
- m_data.append(data);
-}
-
-
-void ImageLabel::slotResult(KJob *)
-{
- QPixmap pix;
- if (!pix.loadFromData(m_data))
- kDebug() << "error while loading image: ";
- setPixmap(pix);
- pix.save(WebSnap::imagePathFromUrl(m_url), "PNG");
-}
-
-
-// ---------------------------------------------------------------
-
-
SearchListItem::SearchListItem(const UrlSuggestionItem &item, const QString &text, QWidget *parent)
: ListItem(item, parent)
, m_text(text)
@@ -590,52 +521,6 @@ QString SuggestionListItem::text()
// ---------------------------------------------------------------
-VisualSuggestionListItem::VisualSuggestionListItem(const UrlSuggestionItem &item, const QString &text, QWidget *parent)
- : ListItem(item, parent)
- , m_text(item.title)
-{
-
- QHBoxLayout *hLayout = new QHBoxLayout;
- hLayout->setSpacing(4);
- QLabel *previewLabelIcon = new QLabel(this);
-
- if (!item.image.isEmpty())
- {
- previewLabelIcon->setFixedSize(item.image_width + 10, item.image_height + 10);
- new ImageLabel(item.image, item.image_width, item.image_height, previewLabelIcon);
- IconLabel* icon = new IconLabel(item.url, previewLabelIcon);
- icon->move(item.image_width - 10, item.image_height - 10);
- }
- else
- {
- previewLabelIcon->setFixedSize(18, 18);
- new IconLabel(item.url, previewLabelIcon);
- }
-
- hLayout->addWidget(previewLabelIcon);
- QVBoxLayout *vLayout = new QVBoxLayout;
- vLayout->setMargin(0);
- vLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::MinimumExpanding));
- vLayout->addWidget(new TextLabel(item.title, text, this));
- DescriptionLabel *d = new DescriptionLabel("", this);
- vLayout->addWidget(d);
- vLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::MinimumExpanding));
- hLayout->addLayout(vLayout);
- hLayout->addWidget(new TypeIconLabel(item.type, this));
- setLayout(hLayout);
- d->setText("<i>" + item.description + "</i>");
-}
-
-
-QString VisualSuggestionListItem::text()
-{
- return m_text;
-}
-
-
-// ---------------------------------------------------------------
-
-
BrowseListItem::BrowseListItem(const UrlSuggestionItem &item, const QString &text, QWidget *parent)
: ListItem(item, parent)
{
@@ -676,12 +561,7 @@ ListItem *ListItemFactory::create(const UrlSuggestionItem &item, const QString &
if (item.type & UrlSuggestionItem::Suggestion)
{
- if (item.description.isEmpty())
- {
- return new SuggestionListItem(item, text, parent);
- }
-
- return new VisualSuggestionListItem(item, text, parent);
+ return new SuggestionListItem(item, text, parent);
}
return new PreviewListItem(item, text, parent);
diff --git a/src/urlbar/listitem.h b/src/urlbar/listitem.h
index 54bff109..f34da334 100644
--- a/src/urlbar/listitem.h
+++ b/src/urlbar/listitem.h
@@ -97,7 +97,7 @@ class REKONQ_TESTS_EXPORT TypeIconLabel : public QLabel
public:
explicit TypeIconLabel(int type, QWidget *parent = 0);
-
+
private:
QLabel *getIcon(QString icon);
};
@@ -126,10 +126,11 @@ class REKONQ_TESTS_EXPORT TextLabel : public QLabel
public:
explicit TextLabel(const QString &text, const QString &textToPointOut = QString(), QWidget *parent = 0);
explicit TextLabel(QWidget *parent = 0);
-
+
void setEngineText(const QString &engine, const QString &text);
};
+
// -------------------------------------------------------------------------
@@ -151,6 +152,7 @@ class REKONQ_TESTS_EXPORT EngineBar : public KToolBar
public:
explicit EngineBar(KService::Ptr selectedEngine, QWidget *parent = 0);
+
void selectNextEngine();
Q_SIGNALS:
@@ -175,6 +177,7 @@ class REKONQ_TESTS_EXPORT SearchListItem : public ListItem
public:
explicit SearchListItem(const UrlSuggestionItem &item, const QString &text, QWidget *parent = 0);
+
QString text();
public Q_SLOTS:
@@ -201,22 +204,7 @@ class REKONQ_TESTS_EXPORT SuggestionListItem : public ListItem
public:
SuggestionListItem(const UrlSuggestionItem &item, const QString &text, QWidget *parent = 0);
- QString text();
-
-private:
- QString m_text;
-};
-
-
-// -------------------------------------------------------------------------
-
-
-class REKONQ_TESTS_EXPORT VisualSuggestionListItem : public ListItem
-{
- Q_OBJECT
-
-public:
- VisualSuggestionListItem(const UrlSuggestionItem &item, const QString &text, QWidget *parent = 0);
+
QString text();
private:
@@ -239,38 +227,6 @@ public:
// -------------------------------------------------------------------------
-class REKONQ_TESTS_EXPORT PreviewLabel : public QLabel
-{
- Q_OBJECT
-
-public:
- PreviewLabel(const QString &url, int width, int height, QWidget *parent = 0);
-};
-
-
-// -------------------------------------------------------------------------
-
-
-class REKONQ_TESTS_EXPORT ImageLabel : public QLabel
-{
- Q_OBJECT
-
-public:
- ImageLabel(const QString &url, int width, int height, QWidget *parent);
-
-private:
- QString m_url;
- QByteArray m_data;
-
-private Q_SLOTS:
- void slotData(KJob* job, const QByteArray& data);
- void slotResult(KJob* job);
-};
-
-
-// -------------------------------------------------------------------------
-
-
class REKONQ_TESTS_EXPORT BrowseListItem : public ListItem
{
Q_OBJECT
diff --git a/src/urlbar/urlsuggester.h b/src/urlbar/urlsuggester.h
index a5914504..14df59fc 100644
--- a/src/urlbar/urlsuggester.h
+++ b/src/urlbar/urlsuggester.h
@@ -58,9 +58,6 @@ public:
QString url;
QString title;
QString description;
- QString image;
- int image_width;
- int image_height;
QString bookmarkPath;
UrlSuggestionItem(const UrlSuggestionItem &item)
@@ -68,9 +65,6 @@ public:
, url(item.url)
, title(item.title)
, description(item.description)
- , image(item.image)
- , image_width(item.image_width)
- , image_height(item.image_height)
{};
UrlSuggestionItem()
@@ -78,26 +72,17 @@ public:
, url(QString())
, title(QString())
, description(QString())
- , image(QString())
- , image_width(0)
- , image_height(0)
{};
UrlSuggestionItem(const int &_type,
const QString &_url,
const QString &_title = QString(),
- const QString &_description = QString(),
- const QString &_image = QString(),
- const int &_image_width = 0,
- const int &_image_height = 0
+ const QString &_description = QString()
)
: type(_type)
, url(_url)
, title(_title)
, description(_description)
- , image(_image)
- , image_width(_image_width)
- , image_height(_image_height)
{};
inline bool operator==(const UrlSuggestionItem &i) const
@@ -113,8 +98,6 @@ typedef QList <UrlSuggestionItem> UrlSuggestionList;
// ----------------------------------------------------------------------
-
-
class UrlSuggester : public QObject
{
Q_OBJECT