From 0ecdc5b3c63e6f99ad27e735c7d5d12ac681f6d2 Mon Sep 17 00:00:00 2001 From: Pino Toscano Date: Thu, 23 Aug 2007 22:16:37 +0000 Subject: [PATCH] add the searchId to the searchFinished() signal of the Document, so each search line edit can ignore any search not started by itself svn path=/trunk/KDE/kdegraphics/okular/; revision=704015 --- core/document.cpp | 24 ++++++++++++------------ core/document.h | 2 +- ui/searchlineedit.cpp | 8 ++++++-- ui/searchlineedit.h | 2 +- 4 files changed, 20 insertions(+), 16 deletions(-) diff --git a/core/document.cpp b/core/document.cpp index 6337c3d55..42f6dc47c 100644 --- a/core/document.cpp +++ b/core/document.cpp @@ -818,7 +818,7 @@ void DocumentPrivate::doContinueNextMatchSearch(void *pagesToNotifySet, void * t { // if the user cancelled but he just got a match, give him the match! QApplication::restoreOverrideCursor(); - emit m_parent->searchFinished(Document::SearchCancelled); + emit m_parent->searchFinished( searchID, Document::SearchCancelled ); delete pagesToNotify; return; } @@ -894,8 +894,8 @@ void DocumentPrivate::doContinueNextMatchSearch(void *pagesToNotifySet, void * t foreach(DocumentObserver *observer, m_observers) observer->notifyPageChanged( pageNumber, DocumentObserver::Highlights ); - if (foundAMatch) emit m_parent->searchFinished(Document::MatchFound); - else emit m_parent->searchFinished(Document::NoMatchFound); + if (foundAMatch) emit m_parent->searchFinished( searchID, Document::MatchFound ); + else emit m_parent->searchFinished( searchID, Document::NoMatchFound ); delete pagesToNotify; } @@ -911,7 +911,7 @@ void DocumentPrivate::doContinueAllDocumentSearch(void *pagesToNotifySet, void * typedef QVector MatchesVector; QApplication::restoreOverrideCursor(); - emit m_parent->searchFinished(Document::SearchCancelled); + emit m_parent->searchFinished( searchID, Document::SearchCancelled ); foreach(const MatchesVector &mv, *pageMatches) qDeleteAll(mv); delete pageMatches; delete pagesToNotify; @@ -976,8 +976,8 @@ void DocumentPrivate::doContinueAllDocumentSearch(void *pagesToNotifySet, void * foreach(DocumentObserver *observer, m_observers) observer->notifyPageChanged( pageNumber, DocumentObserver::Highlights ); - if (foundAMatch) emit m_parent->searchFinished(Document::MatchFound); - else emit m_parent->searchFinished(Document::NoMatchFound); + if (foundAMatch) emit m_parent->searchFinished(searchID, Document::MatchFound ); + else emit m_parent->searchFinished( searchID, Document::NoMatchFound ); delete pageMatches; delete pagesToNotify; @@ -996,7 +996,7 @@ void DocumentPrivate::doContinueGooglesDocumentSearch(void *pagesToNotifySet, vo typedef QVector MatchesVector; QApplication::restoreOverrideCursor(); - emit m_parent->searchFinished(Document::SearchCancelled); + emit m_parent->searchFinished( searchID, Document::SearchCancelled ); foreach(const MatchesVector &mv, *pageMatches) { @@ -1094,8 +1094,8 @@ void DocumentPrivate::doContinueGooglesDocumentSearch(void *pagesToNotifySet, vo foreach(DocumentObserver *observer, m_observers) observer->notifyPageChanged( pageNumber, DocumentObserver::Highlights ); - if (foundAMatch) emit m_parent->searchFinished(Document::MatchFound); - else emit m_parent->searchFinished(Document::NoMatchFound); + if (foundAMatch) emit m_parent->searchFinished( searchID, Document::MatchFound ); + else emit m_parent->searchFinished( searchID, Document::NoMatchFound ); delete pageMatches; delete pagesToNotify; @@ -2110,7 +2110,7 @@ void Document::searchText( int searchID, const QString & text, bool fromStart, Q // safety checks: don't perform searches on empty or unsearchable docs if ( !d->m_generator || !d->m_generator->hasFeature( Generator::TextExtraction ) || d->m_pagesVector.isEmpty() ) { - emit searchFinished(NoMatchFound); + emit searchFinished( searchID, NoMatchFound ); return; } @@ -2123,7 +2123,7 @@ void Document::searchText( int searchID, const QString & text, bool fromStart, Q searchDialog->setMainWidget( searchLabel ); QTimer::singleShot(500, searchDialog, SLOT(show())); - connect(this, SIGNAL( searchFinished(Okular::Document::SearchStatus) ), searchDialog, SLOT(deleteLater())); + connect(this, SIGNAL( searchFinished(int, Okular::Document::SearchStatus) ), searchDialog, SLOT(deleteLater())); connect(searchDialog, SIGNAL( finished() ), this, SLOT(cancelSearch())); } @@ -2215,7 +2215,7 @@ void Document::continueSearch( int searchID ) QMap< int, RunningSearch * >::const_iterator it = d->m_searches.constFind( searchID ); if ( it == d->m_searches.constEnd() ) { - emit searchFinished(NoMatchFound); + emit searchFinished( searchID, NoMatchFound ); return; } diff --git a/core/document.h b/core/document.h index 4670db3b3..ca4953ebd 100644 --- a/core/document.h +++ b/core/document.h @@ -611,7 +611,7 @@ class OKULAR_EXPORT Document : public QObject /** * Reports that the current search finished */ - void searchFinished(Okular::Document::SearchStatus endStatus); + void searchFinished( int id, Okular::Document::SearchStatus endStatus ); private: friend class DocumentPrivate; diff --git a/ui/searchlineedit.cpp b/ui/searchlineedit.cpp index dad1b338a..8fb404320 100644 --- a/ui/searchlineedit.cpp +++ b/ui/searchlineedit.cpp @@ -32,7 +32,7 @@ SearchLineEdit::SearchLineEdit( QWidget * parent, Okular::Document * document ) this, SLOT( startSearch() ) ); connect(this, SIGNAL( textChanged(const QString &) ), this, SLOT( slotTextChanged(const QString &) )); - connect(document, SIGNAL( searchFinished(Okular::Document::SearchStatus) ), this, SLOT( searchFinished(Okular::Document::SearchStatus) )); + connect(document, SIGNAL( searchFinished(int, Okular::Document::SearchStatus) ), this, SLOT( searchFinished(int, Okular::Document::SearchStatus) )); } void SearchLineEdit::clearText() @@ -126,8 +126,12 @@ void SearchLineEdit::startSearch() m_document->resetSearch( m_id ); } -void SearchLineEdit::searchFinished(Okular::Document::SearchStatus endStatus) +void SearchLineEdit::searchFinished( int id, Okular::Document::SearchStatus endStatus ) { + // ignore the searches not started by this search edit + if ( id != m_id ) + return; + // if not found, use warning colors if ( endStatus == Okular::Document::NoMatchFound ) { diff --git a/ui/searchlineedit.h b/ui/searchlineedit.h index 6e03819f4..e2ff6375f 100644 --- a/ui/searchlineedit.h +++ b/ui/searchlineedit.h @@ -53,7 +53,7 @@ class SearchLineEdit : public KLineEdit private slots: void slotTextChanged( const QString & text ); void startSearch(); - void searchFinished(Okular::Document::SearchStatus endStatus); + void searchFinished( int id, Okular::Document::SearchStatus endStatus ); }; #endif