Hello community,
here is the log from the commit of package kdeaddons3
checked in at Fri Jun 9 02:21:39 CEST 2006.
--------
--- KDE/kdeaddons3/kdeaddons3.changes 2006-05-29 23:28:31.000000000 +0200
+++ kdeaddons3/kdeaddons3.changes 2006-06-08 18:26:43.000000000 +0200
@@ -1,0 +2,5 @@
+Thu Jun 8 18:25:21 CEST 2006 - stbinner@suse.de
+
+- use Google Suggest in web search bar (only used for Google)
+
+-------------------------------------------------------------------
New:
----
google-suggest.diff
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ kdeaddons3.spec ++++++
--- /var/tmp/diff_new_pack.iSG8kx/_old 2006-06-09 02:16:54.000000000 +0200
+++ /var/tmp/diff_new_pack.iSG8kx/_new 2006-06-09 02:16:54.000000000 +0200
@@ -20,13 +20,14 @@
Summary: Additional Modules for Kate, Kicker, Konqueror, and Noatun
BuildRoot: %{_tmppath}/%{name}-%{version}-build
Version: 3.5.3
-Release: 3
+Release: 4
Url: http://www.kde.org
Requires: kdelibs3 >= %(rpm -q --queryformat '%{VERSION}' kdelibs3)
Source: kdeaddons-%{version}.tar.bz2
#Patch0: 3_5_BRANCH.diff
Patch1: disable-lnk.diff
Patch2: fix-kimgalleryplugin-output.diff
+Patch3: google-suggest.diff
Patch4: searchbar-fallback-icon.diff
Provides: kdeaddons
@@ -50,7 +51,7 @@
%package games
# usesubdirs atlantikdesigner
Version: 3.5.3
-Release: 3
+Release: 4
Provides: kdeaddons3 = %{version}-%{release}
Summary: Additional Modules for Atlantik
Group: System/GUI/KDE
@@ -72,7 +73,7 @@
Provides: kdeaddons3:/opt/kde3/share/apps/khtml/kpartplugins/plugin_babelfish.rc
Provides: kdeaddons3 = %{version}-%{release}
Version: 3.5.3
-Release: 3
+Release: 4
Summary: Konqueror Related Add-Ons
Group: Productivity/Networking/Web/Utilities
@@ -91,7 +92,7 @@
%package kontact
# usesubdirs kontact ksig
Version: 3.5.3
-Release: 3
+Release: 4
Requires: kdenetwork3-news
Provides: kdeaddons
Provides: kdeaddons3 = %{version}-%{release}
@@ -114,7 +115,7 @@
%package sound
# usesubdirs noatun-plugins
Version: 3.5.3
-Release: 3
+Release: 4
Provides: kdeaddons
Provides: kdeaddons3:/opt/kde3/bin/noatunsynaescope.bin
Provides: kdeaddons3 = %{version}-%{release}
@@ -134,7 +135,7 @@
%package kate
# usesubdirs kate
Version: 3.5.3
-Release: 3
+Release: 4
Provides: kdeaddons
Provides: kdeaddons3:/opt/kde3/bin/dcop_kate
Provides: kdeaddons3 = %{version}-%{release}
@@ -155,7 +156,7 @@
%package kicker
# usesubdirs kicker-applets
Version: 3.5.3
-Release: 3
+Release: 4
Provides: kdeaddons
Provides: kdeaddons3:/opt/kde3/share/apps/kicker/applets/ktimemon.desktop
Provides: kdeaddons3 = %{version}-%{release}
@@ -178,6 +179,7 @@
#%patch
%patch1
%patch2
+%patch3
%patch4
. /etc/opt/kde3/common_options
update_admin
@@ -358,6 +360,8 @@
/opt/kde3/share/icons/*/*/*/ksig.*
%changelog -n kdeaddons3
+* Thu Jun 08 2006 - stbinner@suse.de
+- use Google Suggest in web search bar (only used for Google)
* Mon May 29 2006 - stbinner@suse.de
- fix build for openSUSE build service
* Wed May 24 2006 - stbinner@suse.de
++++++ google-suggest.diff ++++++
Index: konq-plugins/searchbar/searchbar.h
===================================================================
--- konq-plugins/searchbar/searchbar.h (revision 549393)
+++ konq-plugins/searchbar/searchbar.h (working copy)
@@ -1,4 +1,6 @@
/* This file is part of the KDE project
+ Copyright (C) 2005 by Tobi Vollebregt
+ Copyright (C) 2004 by Vinay Khaitan
Copyright (C) 2004 Arend van Beelen jr.
This program is free software; you can redistribute it and/or
@@ -32,6 +34,7 @@
class KHTMLPart;
class KProcess;
class QPopupMenu;
+class QTimer;
/**
* Combo box which catches mouse clicks on the pixmap.
@@ -149,6 +152,22 @@
void updateComboVisibility();
void focusSearchbar();
+
+ // Google Suggest private slots
+
+ void gsStartDelay();
+ void gsMakeCompletionList();
+ void gsDataArrived(KIO::Job*, const QByteArray& data);
+ void gsJobFinished(KIO::Job* job);
+ void gsSetCompletedText(const QString& text);
+ void gsPutTextInBox(const QString& text);
+
+ signals:
+
+ // Google Suggest signals
+
+ void gsCompleteDelayed();
+
private:
void nextSearchEntry();
void previousSearchEntry();
@@ -163,6 +182,11 @@
bool m_urlEnterLock;
QString m_currentEngine;
QStringList m_searchEngines;
+
+ // Google Suggest private members
+
+ QTimer m_gsTimer;
+ QString m_gsData;
};
#endif // SEARCHBAR_PLUGIN
Index: konq-plugins/searchbar/searchbar.cpp
===================================================================
--- konq-plugins/searchbar/searchbar.cpp (revision 549393)
+++ konq-plugins/searchbar/searchbar.cpp (working copy)
@@ -1,4 +1,6 @@
/* This file is part of the KDE project
+ Copyright (C) 2005 by Tobi Vollebregt
+ Copyright (C) 2004 by Vinay Khaitan
Copyright (C) 2004 Arend van Beelen jr.
This program is free software; you can redistribute it and/or
@@ -32,10 +34,13 @@
#include
#include
#include
+#include
#include
#include
#include
+#include
+
#include
#include
@@ -50,19 +55,20 @@
K_EXPORT_COMPONENT_FACTORY(libsearchbarplugin,
SearchBarPluginFactory("searchbarplugin"))
-
SearchBarPlugin::SearchBarPlugin(QObject *parent, const char *name,
const QStringList &) :
KParts::Plugin(parent, name),
m_searchCombo(0),
m_searchMode(UseSearchProvider),
- m_urlEnterLock(false)
+ m_urlEnterLock(false),
+ m_gsTimer(this)
{
m_searchCombo = new SearchBarCombo(0L, "search combo");
m_searchCombo->setDuplicatesEnabled(false);
m_searchCombo->setMaxCount(5);
m_searchCombo->setFixedWidth(180);
m_searchCombo->lineEdit()->installEventFilter(this);
+ m_searchCombo->listBox()->setFocusProxy(m_searchCombo);
m_popupMenu = 0;
@@ -93,6 +99,11 @@
SLOT (partChanged (KParts::Part*)));
partChanged(partMan->activePart());
}
+
+ connect(this, SIGNAL(gsCompleteDelayed()), SLOT(gsStartDelay()));
+ connect(&m_gsTimer, SIGNAL(timeout()), SLOT(gsMakeCompletionList()));
+ connect(m_searchCombo->listBox(), SIGNAL(highlighted(const QString&)), SLOT(gsSetCompletedText(const QString&)));
+ connect(m_searchCombo, SIGNAL(activated(const QString&)), SLOT(gsPutTextInBox(const QString&)));
}
SearchBarPlugin::~SearchBarPlugin()
@@ -118,6 +129,14 @@
if( o==m_searchCombo->lineEdit() && e->type() == QEvent::KeyPress )
{
QKeyEvent *k = (QKeyEvent *)e;
+ QString text = k->text();
+ if(!text.isEmpty())
+ {
+ if(k->key() != Qt::Key_Return && k->key() != Key_Enter && k->key() != Key_Escape)
+ {
+ emit gsCompleteDelayed();
+ }
+ }
if(k->state() & ControlButton)
{
if(k->key()==Key_Down)
@@ -131,6 +150,36 @@
return true;
}
}
+ else
+ {
+ if (k->key() == Key_Up || k->key() == Key_Down)
+ {
+ if(m_searchCombo->listBox()->isVisible())
+ {
+ qApp->sendEvent(m_searchCombo->listBox(), e);
+ return true;
+ }
+ }
+ }
+ if (k->key() == Key_Enter || k->key() == Key_Return)
+ {
+ /*- Fix a bug which caused the searchbar to search for the completed
+ input instead of the literal input when enter was pressed and
+ the listbox was visible.
+ if(m_searchCombo->listBox()->isVisible())
+ {
+ qApp->sendEvent(m_searchCombo->listBox(),e);
+ }*/
+ }
+ if (k->key() == Key_Escape)
+ {
+ m_searchCombo->listBox()->hide();
+ if (m_searchCombo->lineEdit()->hasSelectedText())
+ {
+ m_searchCombo->lineEdit()->setText(m_searchCombo->currentText().left(m_searchCombo->lineEdit()->selectionStart()));
+ }
+ m_gsTimer.stop();
+ }
}
return false;
}
@@ -195,11 +244,16 @@
setIcon();
}
-void SearchBarPlugin::startSearch(const QString &search)
+void SearchBarPlugin::startSearch(const QString &_search)
{
- if(m_urlEnterLock || search.isEmpty() || !m_part)
+ if(m_urlEnterLock || _search.isEmpty() || !m_part)
return;
+ m_gsTimer.stop();
+ m_searchCombo->listBox()->hide();
+
+ QString search = _search.section('(', 0, 0).stripWhiteSpace();
+
if(m_searchMode == FindInThisPage)
{
m_part->findText(search, 0);
@@ -544,4 +598,104 @@
}
}
+// Google Suggest code
+
+// adapted and modified by Tobi Vollebregt
+// original code from Googlebar by Vinay Khaitan
+
+void SearchBarPlugin::gsStartDelay()
+{
+ m_gsTimer.stop();
+ m_searchCombo->listBox()->hide();
+ // FIXME: make configurable
+ m_gsTimer.start(500, true);
+}
+
+void SearchBarPlugin::gsMakeCompletionList()
+{
+ if (m_currentEngine != "google")
+ return;
+
+ if (!m_searchCombo->currentText().isEmpty())
+ {
+ KIO::TransferJob* tj =
+ KIO::get(KURL("http://www.google.com/complete/search?hl=en&js=true&qu=" + m_searchCombo->currentText()), false, false);
+ connect(tj, SIGNAL(data(KIO::Job*, const QByteArray&)), this, SLOT(gsDataArrived(KIO::Job*, const QByteArray&)));
+ connect(tj, SIGNAL(result(KIO::Job*)), this, SLOT(gsJobFinished(KIO::Job*)));
+ }
+}
+
+void SearchBarPlugin::gsDataArrived(KIO::Job*, const QByteArray& data)
+{
+ m_gsData += QString::fromUtf8(data.data());
+}
+
+static QString reformatNumber(const QString& number)
+{
+ static const char suffix[] = { 'k', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y' };
+ QString s = number.stripWhiteSpace();
+ uint c = 0;
+ for (int i = s.length() - 1; i > 0 && s[i] == '0'; --i) ++c;
+ c /= 3;
+ if (c >= sizeof(suffix)/sizeof(suffix[0]))
+ c = sizeof(suffix)/sizeof(suffix[0]) - 1;
+ s = s.left(s.length() - c * 3) + suffix[c];
+ return s;
+}
+
+void SearchBarPlugin::gsJobFinished(KIO::Job* job)
+{
+ if (((KIO::TransferJob*)job)->error() == 0)
+ {
+ QString temp;
+ temp = m_gsData.mid(m_gsData.find('(') + 1, m_gsData.findRev(')') - m_gsData.find('(') - 1);
+ temp = temp.mid(temp.find('(') + 1, temp.find(')') - temp.find('(') - 1);
+ temp.remove('"');
+ QStringList compList1 = QStringList::split(',', temp);
+ temp = m_gsData.mid(m_gsData.find(')') + 1, m_gsData.findRev(')') - m_gsData.find('(') - 1);
+ temp = temp.mid(temp.find('(') + 1, temp.find(')') - temp.find('(') - 1);
+ temp.remove('"');
+ temp.remove(',');
+ temp.remove('s');
+ QStringList compList2 = QStringList::split("reult", temp);
+ QStringList finalList;
+ for(uint j = 0; j < compList1.count(); j++)
+ {
+ finalList.append(compList1[j].stripWhiteSpace() + " (" + reformatNumber(compList2[j]) + ")");
+ }
+ //store text so that we can restore it if it gets erased after GS returns no results
+ temp = m_searchCombo->currentText();
+ m_searchCombo->listBox()->clear();
+ m_searchCombo->listBox()->insertStringList(finalList);
+ m_searchCombo->setIcon(m_searchIcon);
+ //restore text
+ m_searchCombo->lineEdit()->setText(temp);
+ if (finalList.count() != 0 && !m_gsTimer.isActive())
+ {
+ m_searchCombo->popup();
+ }
+ }
+ m_gsData = "";
+}
+
+void SearchBarPlugin::gsSetCompletedText(const QString& text)
+{
+ QString currentText;
+ if (m_searchCombo->lineEdit()->hasSelectedText())
+ currentText = m_searchCombo->currentText().left(m_searchCombo->lineEdit()->selectionStart());
+ else
+ currentText = m_searchCombo->currentText();
+ if (currentText == text.left(currentText.length()))
+ {
+ m_searchCombo->lineEdit()->setText(text.left(text.find('(') - 1));
+ m_searchCombo->lineEdit()->setCursorPosition(currentText.length());
+ m_searchCombo->lineEdit()->setSelection(currentText.length(), m_searchCombo->currentText().length() - currentText.length());
+ }
+}
+
+void SearchBarPlugin::gsPutTextInBox(const QString& text)
+{
+ m_searchCombo->lineEdit()->setText(text.section('(', 0, 0).stripWhiteSpace());
+}
+
#include "searchbar.moc"
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Remember to have fun...
---------------------------------------------------------------------
To unsubscribe, e-mail: opensuse-commit-unsubscribe@opensuse.org
For additional commands, e-mail: opensuse-commit-help@opensuse.org