summaryrefslogtreecommitdiff
path: root/src/urlbar/listitem.cpp
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2010-04-16 03:14:48 +0200
committerAndrea Diamantini <adjam7@gmail.com>2010-04-16 03:14:48 +0200
commit72e0446fbc7017e7703102f733568a4f2e3c5195 (patch)
tree597f9ae450fc7e751688d1b060cd558b59aa2884 /src/urlbar/listitem.cpp
parentMerge commit 'refs/merge-requests/77' of git://gitorious.org/rekonq/mainline ... (diff)
downloadrekonq-72e0446fbc7017e7703102f733568a4f2e3c5195.tar.xz
Fixing Lionel's merge request:
- clean/fix APIs - removed no more used methods/signals from CompletionWidget - use item->url() (as it has been defined) - Change the "pointing out text" from underline to bold (better, IMO) - QString --> Q/K url, as needed - Restore UrlFromUserInput engine: why it has been deleted? - Comment out the isHttp() check. That way I cannot in any way connect to localhost or to my home server. Apart from typing their IPs.. - Partially fixed the switch search engine implementation. Btw, I have to say I really don't like rekonq switch my default engine just because one time I decided to give a try to another... Not sure about. - Something more coming.. But tomorrow! Now it's 3:20 am here. Good night!
Diffstat (limited to 'src/urlbar/listitem.cpp')
-rw-r--r--src/urlbar/listitem.cpp86
1 files changed, 52 insertions, 34 deletions
diff --git a/src/urlbar/listitem.cpp b/src/urlbar/listitem.cpp
index ef09d4f3..7d1d39b2 100644
--- a/src/urlbar/listitem.cpp
+++ b/src/urlbar/listitem.cpp
@@ -40,7 +40,6 @@
#include <KConfigGroup>
#include <KIcon>
-
// Qt Includes
#include <QHBoxLayout>
#include <QVBoxLayout>
@@ -147,8 +146,11 @@ void ListItem::nextItemSubChoice()
}
+// ---------------------------------------------------------------
+
+
TypeIcon::TypeIcon(int type, QWidget *parent)
-:QLabel(parent)
+ : QLabel(parent)
{
setMinimumWidth(40);
QHBoxLayout *hLayout = new QHBoxLayout;
@@ -173,9 +175,11 @@ QLabel *TypeIcon::getIcon(QString icon)
}
+// ---------------------------------------------------------------
+
-ItemIcon::ItemIcon(QString icon, QWidget *parent)
-:QLabel(parent)
+ItemIcon::ItemIcon(const QString &icon, QWidget *parent)
+ : QLabel(parent)
{
QPixmap pixmapIcon = KIcon(QWebSettings::iconForUrl(icon)).pixmap(16);
if (pixmapIcon.isNull())
@@ -188,18 +192,16 @@ ItemIcon::ItemIcon(QString icon, QWidget *parent)
}
-ItemText::ItemText(QString text, QString underlined, QWidget *parent)
-:QLabel(underlineText(text,underlined), parent)
-{
- setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);
-}
+// ---------------------------------------------------------------
-QString ItemText::underlineText(QString text, QString textToUnderline)
+ItemText::ItemText(const QString &text, const QString &textToPointOut, QWidget *parent)
+ : QLabel(parent)
{
QString t = text;
- t = t.replace(QRegExp("("+textToUnderline+")", Qt::CaseInsensitive), "<u>\\1</u>");
- return t;
+ t = t.replace(QRegExp("(" + textToPointOut + ")", Qt::CaseInsensitive), "<b>\\1</b>");
+ setText(t);
+ setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);
}
@@ -207,7 +209,7 @@ QString ItemText::underlineText(QString text, QString textToUnderline)
PreviewListItem::PreviewListItem(const UrlSearchItem &item, const QString &text, QWidget *parent)
-:ListItem(item, parent)
+ : ListItem(item, parent)
{
QLabel *previewLabelIcon = new QLabel;
previewLabelIcon->setFixedSize(45,33);
@@ -225,13 +227,16 @@ PreviewListItem::PreviewListItem(const UrlSearchItem &item, const QString &text,
}
-ItemPreview::ItemPreview(QString url, int width, int height, QWidget *parent)
-:QLabel(parent)
+// ---------------------------------------------------------------
+
+
+ItemPreview::ItemPreview(const QString &url, int width, int height, QWidget *parent)
+ : QLabel(parent)
{
setFixedSize(width, height);
setFrameStyle(QFrame::StyledPanel | QFrame::Raised);
- QString path = KStandardDirs::locateLocal("cache", QString("thumbs/") + guessNameFromUrl(url) + ".png", true);
+ QString path = KStandardDirs::locateLocal("cache", QString("thumbs/") + guessNameFromUrl( QUrl(url) ) + ".png", true);
if(QFile::exists(path))
{
QPixmap preview;
@@ -260,12 +265,16 @@ QString ItemPreview::guessNameFromUrl(QUrl url)
return name;
}
-//--------------------------------------------------------------------------------------------
+
+// ---------------------------------------------------------------
+
+
QString SearchListItem::m_currentEngine = "";
+
SearchListItem::SearchListItem(const UrlSearchItem &item, const QString &text, QWidget *parent)
- :ListItem(item, parent)
- ,m_text(text)
+ : ListItem(item, parent)
+ , m_text(text)
{
if (m_currentEngine == "") m_currentEngine = EngineBar::defaultEngine();
@@ -273,6 +282,9 @@ SearchListItem::SearchListItem(const UrlSearchItem &item, const QString &text, Q
m_titleLabel = new ItemText(searchItemTitle(m_currentEngine, text), text);
m_engineBar = new EngineBar(text, m_currentEngine, this);
+ // without this it will not work :)
+ m_url = m_engineBar->url();
+
layout()->addWidget(m_iconLabel);
layout()->addWidget(m_titleLabel);
layout()->addWidget(new QLabel("Engines: "));
@@ -292,8 +304,9 @@ QString SearchListItem::searchItemTitle(QString engine, QString text)
void SearchListItem::changeSearchEngine(QString url, QString engine)
{
m_titleLabel->setText(searchItemTitle(engine,m_text));
- m_iconLabel->setPixmap(Application::icon(url).pixmap(16));
- m_url = KUrl(url);
+ m_iconLabel->setPixmap(Application::icon( KUrl(url) ).pixmap(16));
+ QString url2 = url.replace("\\{@}",m_text);
+ m_url = KUrl(url2);
m_currentEngine = engine;
}
@@ -304,9 +317,9 @@ void SearchListItem::nextItemSubChoice()
}
-EngineBar::EngineBar(QString text, QString selectedEngine, QWidget *parent)
-:KToolBar(parent)
-{
+EngineBar::EngineBar(const QString &text, const QString &selectedEngine, QWidget *parent)
+ : KToolBar(parent)
+{
setIconSize(QSize(16,16));
setToolButtonStyle(Qt::ToolButtonIconOnly);
@@ -322,7 +335,12 @@ EngineBar::EngineBar(QString text, QString selectedEngine, QWidget *parent)
KService::Ptr service;
service = KService::serviceByDesktopPath(QString("searchproviders/%1.desktop").arg(defaultEngine));
- m_engineGroup->addAction(newEngineAction(service, selectedEngine, text));
+ m_engineGroup->addAction(newEngineAction(service, selectedEngine));
+
+ // set url;
+ QString url = service->property("Query").toString();
+ url = url.replace("\\{@}",text);
+ m_url = KUrl(url);
Q_FOREACH(const QString &engine, favoriteEngines)
{
@@ -331,7 +349,7 @@ EngineBar::EngineBar(QString text, QString selectedEngine, QWidget *parent)
service = KService::serviceByDesktopPath(QString("searchproviders/%1.desktop").arg(engine));
if(service && service->desktopEntryName()!=defaultEngine)
{
- m_engineGroup->addAction(newEngineAction(service, selectedEngine, text));
+ m_engineGroup->addAction(newEngineAction(service, selectedEngine));
}
}
}
@@ -350,13 +368,14 @@ QString EngineBar::defaultEngine()
}
-KAction *EngineBar::newEngineAction(KService::Ptr service, QString selectedEngine, QString text)
+KAction *EngineBar::newEngineAction(KService::Ptr service, QString selectedEngine)
{
- QString url = service->property("Query").toString();
- url = url.replace("\\{@}",text);
- KAction *a = new KAction(Application::icon(url), service->name(), this);
+ KAction *a = new KAction(Application::icon(m_url), service->name(), this);
a->setCheckable(true);
if (service->name()==selectedEngine) a->setChecked(true);
+
+ QString url = service->property("Query").toString();
+
a->setData(QStringList() << url << service->name());
connect(a, SIGNAL(triggered(bool)), this, SLOT(changeSearchEngine()));
@@ -394,11 +413,11 @@ void EngineBar::selectNextEngine()
}
-//--------------------------------------------------------------------------------------------
+// ---------------------------------------------------------------
BrowseListItem::BrowseListItem(const UrlSearchItem &item, const QString &text, QWidget *parent)
-:ListItem(item, parent)
+ : ListItem(item, parent)
{
QString url = text;
layout()->addWidget(new ItemIcon(item.url.url()));
@@ -407,7 +426,7 @@ BrowseListItem::BrowseListItem(const UrlSearchItem &item, const QString &text, Q
}
-//--------------------------------------------------------------------------------------------
+// ---------------------------------------------------------------
ListItem *ListItemFactory::create(const UrlSearchItem &item, const QString &text, QWidget *parent)
@@ -429,4 +448,3 @@ ListItem *ListItemFactory::create(const UrlSearchItem &item, const QString &text
return newItem;
}
-