summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2010-02-24 11:39:07 +0100
committerAndrea Diamantini <adjam7@gmail.com>2010-02-24 11:39:07 +0100
commitfde7402105174421318e3556401fe2d5f8cda96b (patch)
treeecde7c2daaba33a0bfed0b4af011a65443d4f3cd
parentMoved away the m_requestedUrl call, using currentFrame()->url(). (diff)
parentClean and optimize the findBar code. (diff)
downloadrekonq-fde7402105174421318e3556401fe2d5f8cda96b.tar.xz
Merge commit 'refs/merge-requests/95' of git://gitorious.org/rekonq/mainline into m95
-rw-r--r--src/findbar.cpp36
-rw-r--r--src/findbar.h8
-rw-r--r--src/mainwindow.cpp19
3 files changed, 12 insertions, 51 deletions
diff --git a/src/findbar.cpp b/src/findbar.cpp
index 6b92f130..43b23035 100644
--- a/src/findbar.cpp
+++ b/src/findbar.cpp
@@ -43,7 +43,6 @@
#include <QtGui/QToolButton>
#include <QtGui/QLabel>
#include <QtGui/QColor>
-#include <QtGui/QKeyEvent>
#include <QtCore/QString>
#include <QtCore/QTimer>
@@ -64,7 +63,6 @@ FindBar::FindBar(KMainWindow *mainwindow)
hideButton->setAutoRaise(true);
hideButton->setIcon(KIcon("dialog-close"));
connect(hideButton, SIGNAL(clicked()), this, SLOT(hide()));
- connect(hideButton, SIGNAL(clicked()), mainwindow, SLOT(findNext()));
layout->addWidget(hideButton);
layout->setAlignment(hideButton, Qt::AlignLeft | Qt::AlignTop);
@@ -122,41 +120,21 @@ bool FindBar::matchCase() const
}
-void FindBar::clear()
-{
- m_lineEdit->setText(QString());
-}
-
-
void FindBar::show()
{
- // set focus to findbar if user select showFindBar shortcut
- m_lineEdit->setFocus();
- m_lineEdit->selectAll();
-
// show findbar if not visible
if (isVisible())
return;
-
+
QWidget::show();
m_hideTimer->start(60000);
// emit a new find signal with the current text
- QString temp = m_lineEdit->text();
- m_lineEdit->setText("");
- m_lineEdit->setText(temp);
-}
-
-
-void FindBar::keyPressEvent(QKeyEvent* event)
-{
- if (event->key() == Qt::Key_Return && !m_lineEdit->text().isEmpty())
- {
- emit searchString(m_lineEdit->text());
- return;
- }
-
- QWidget::keyPressEvent(event);
+ emit(searchString(m_lineEdit->text()));
+
+ // set focus to findbar if user select showFindBar shortcut
+ m_lineEdit->setFocus();
+ m_lineEdit->selectAll();
}
@@ -184,9 +162,9 @@ void FindBar::notifyMatch(bool match)
}
-
void FindBar::hide()
{
m_hideTimer->stop();
QWidget::hide();
+ emit(searchString(m_lineEdit->text()));
}
diff --git a/src/findbar.h b/src/findbar.h
index d56b8d25..8f220c92 100644
--- a/src/findbar.h
+++ b/src/findbar.h
@@ -35,11 +35,9 @@
// Qt Includes
#include <QtGui/QWidget>
#include <QtGui/QCheckBox>
-#include <QtGui/QKeyEvent>
// Forward Declarations
class KMainWindow;
-class QKeyEvent;
class QString;
@@ -52,15 +50,11 @@ public:
~FindBar();
KLineEdit *lineEdit() const;
bool matchCase() const;
+ void notifyMatch(bool match);
public slots:
- void clear();
void show();
void hide();
- void notifyMatch(bool match);
-
-protected Q_SLOTS:
- void keyPressEvent(QKeyEvent* event);
signals:
void searchString(const QString &);
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index ef74adab..39dd9a40 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -777,22 +777,17 @@ void MainWindow::find(const QString & search)
findNext();
}
+
void MainWindow::matchCaseUpdate()
{
if (!currentTab())
return;
- QWebPage::FindFlags options = QWebPage::FindWrapsAroundDocument;
-
- if (m_findBar->matchCase())
- options |= QWebPage::FindCaseSensitively;
-
currentTab()->view()->findText(m_lastSearch, QWebPage::FindBackward | QWebPage::FindWrapsAroundDocument);
- bool found = currentTab()->view()->findText(m_lastSearch, options);
- m_findBar->notifyMatch(found);
- if(!found)
- currentTab()->view()->page()->focusNextPrevChild(true);
+ findNext();
}
+
+
void MainWindow::findNext()
{
if (!currentTab())
@@ -819,12 +814,6 @@ void MainWindow::findPrevious()
{
if (!currentTab())
return;
-
- if(m_findBar->isHidden())
- {
- currentTab()->view()->page()->focusNextPrevChild(true);
- return;
- }
QWebPage::FindFlags options = QWebPage::FindBackward | QWebPage::FindWrapsAroundDocument;
if (m_findBar->matchCase())