[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdeaddons/konq-plugins/searchbar
From:       Stephan Binner <binner () kde ! org>
Date:       2005-07-05 21:28:25
Message-ID: 1120598905.453671.25075.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 432021 by binner:

Ctrl-Up/Down shortcuts for changing search mode/provider


 M  +84 -1     searchbar.cpp  
 M  +6 -0      searchbar.h  


--- trunk/KDE/kdeaddons/konq-plugins/searchbar/searchbar.cpp #432020:432021
@@ -62,6 +62,7 @@
 	m_searchCombo->setDuplicatesEnabled(false);
 	m_searchCombo->setMaxCount(5);
 	m_searchCombo->setFixedWidth(180);
+	m_searchCombo->lineEdit()->installEventFilter(this);
 
 	m_popupMenu = 0;
 
@@ -105,6 +106,88 @@
 	m_searchCombo = 0L;
 }
 
+bool SearchBarPlugin::eventFilter(QObject *o, QEvent *e)
+{
+	if( o==m_searchCombo->lineEdit() && e->type() == QEvent::KeyPress ) 
+	{
+		QKeyEvent *k = (QKeyEvent *)e;
+		if(k->state() & ControlButton)
+		{
+			if(k->key()==Key_Down)
+			{
+				nextSearchEntry();
+				return true;
+			}
+			if(k->key()==Key_Up)
+			{
+				previousSearchEntry();
+				return true;
+			}
+		}
+	}
+	return false;
+}
+
+void SearchBarPlugin::nextSearchEntry()
+{
+	if(m_searchMode == FindInThisPage)
+	{
+		m_searchMode = UseSearchProvider;
+		if(m_searchEngines.count())
+		{
+			m_currentEngine = *m_searchEngines.at(0);
+		}
+		else
+		{
+			m_currentEngine = "google";
+		}
+	}
+	else
+	{
+		QStringList::ConstIterator it = m_searchEngines.find(m_currentEngine);
+		it++;
+		if(it==m_searchEngines.end())
+		{
+			m_searchMode = FindInThisPage;
+		}
+		else
+		{
+			m_currentEngine = *it;
+		}
+	}
+	setIcon();
+}
+
+void SearchBarPlugin::previousSearchEntry()
+{
+	if(m_searchMode == FindInThisPage)
+	{
+		m_searchMode = UseSearchProvider;
+		if(m_searchEngines.count())
+		{
+			m_currentEngine = *m_searchEngines.fromLast();
+		}
+		else
+		{
+			m_currentEngine = "google";
+		}
+	}
+	else
+	{
+		QStringList::ConstIterator it = m_searchEngines.find(m_currentEngine);
+		it--;
+		if(it==m_searchEngines.begin())
+		{
+			m_searchMode = FindInThisPage;
+		}
+		else
+		{
+			m_currentEngine = *it;
+		}
+	}
+	setIcon();
+}
+
 void SearchBarPlugin::startSearch(const QString &search)
 {
 	if(m_urlEnterLock || search.isEmpty() || !m_part)
@@ -264,7 +347,7 @@
 
 void SearchBarPlugin::useFindInThisPage()
 {
-		m_searchMode = FindInThisPage;
+	m_searchMode = FindInThisPage;
 	setIcon();
 }
 
--- trunk/KDE/kdeaddons/konq-plugins/searchbar/searchbar.h #432020:432021
@@ -112,6 +112,9 @@
 		                const QStringList &);
 		virtual ~SearchBarPlugin();
 
+	protected:
+		bool eventFilter(QObject *o, QEvent *e);
+
 	private slots:
 		/**
 		 * Starts a search by putting the query URL from the selected
@@ -147,6 +150,9 @@
 
 		void focusSearchbar();
 	private:
+		void nextSearchEntry();
+		void previousSearchEntry();
+
 		QGuardedPtr<KHTMLPart> m_part;
 		SearchBarCombo        *m_searchCombo;
                 KWidgetAction         *m_searchComboAction;
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic