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
This commit is contained in:
Pino Toscano 2007-08-23 22:16:37 +00:00
parent 78d7cb27a3
commit 0ecdc5b3c6
4 changed files with 20 additions and 16 deletions

View file

@ -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<RegularAreaRect *> 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<MatchColor> 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;
}

View file

@ -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;

View file

@ -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 )
{

View file

@ -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