Commit 3a311694 authored by Pino Toscano's avatar Pino Toscano

search line edit:

- save and get wether a search is running
- add a method to cancel a running one

svn path=/trunk/KDE/kdegraphics/okular/; revision=965457
parent 23f93e3a
......@@ -24,7 +24,8 @@ SearchLineEdit::SearchLineEdit( QWidget * parent, Okular::Document * document )
: KLineEdit( parent ), m_document( document ), m_minLength( 0 ),
m_caseSensitivity( Qt::CaseInsensitive ),
m_searchType( Okular::Document::AllDocument ), m_id( -1 ),
m_moveViewport( false ), m_changed( false ), m_fromStart( true )
m_moveViewport( false ), m_changed( false ), m_fromStart( true ),
m_searchRunning( false )
{
setObjectName( "SearchLineEdit" );
setClearButtonShown( true );
......@@ -87,6 +88,11 @@ void SearchLineEdit::setSearchFromStart( bool fromStart )
m_fromStart = fromStart;
}
bool SearchLineEdit::isSearchRunning() const
{
return m_searchRunning;
}
void SearchLineEdit::restartSearch()
{
m_inputDelayTimer->stop();
......@@ -94,6 +100,18 @@ void SearchLineEdit::restartSearch()
m_changed = true;
}
void SearchLineEdit::stopSearch()
{
if ( m_id == -1 || !m_searchRunning )
return;
m_inputDelayTimer->stop();
// ### this should just cancel the search with id m_id, not all of them
m_document->cancelSearch();
// flagging as "changed" so the search will be reset at the next one
m_changed = true;
}
void SearchLineEdit::findNext()
{
if ( m_id == -1 || m_searchType != Okular::Document::NextMatch )
......@@ -102,6 +120,7 @@ void SearchLineEdit::findNext()
if ( !m_changed )
{
emit searchStarted();
m_searchRunning = true;
m_document->continueSearch( m_id, m_searchType );
}
else
......@@ -116,6 +135,7 @@ void SearchLineEdit::findPrev()
if ( !m_changed )
{
emit searchStarted();
m_searchRunning = true;
m_document->continueSearch( m_id, m_searchType );
}
else
......@@ -157,6 +177,7 @@ void SearchLineEdit::startSearch()
if ( thistext.length() >= qMax( m_minLength, 1 ) )
{
emit searchStarted();
m_searchRunning = true;
m_document->searchText( m_id, thistext, m_fromStart, m_caseSensitivity,
m_searchType, m_moveViewport, m_color );
}
......@@ -188,6 +209,7 @@ void SearchLineEdit::searchFinished( int id, Okular::Document::SearchStatus endS
setPalette( pal );
}
m_searchRunning = false;
emit searchStopped();
}
......
......@@ -37,12 +37,15 @@ class SearchLineEdit : public KLineEdit
void setSearchMoveViewport( bool move );
void setSearchFromStart( bool fromStart );
bool isSearchRunning() const;
signals:
void searchStarted();
void searchStopped();
public slots:
void restartSearch();
void stopSearch();
void findNext();
void findPrev();
......@@ -57,6 +60,7 @@ class SearchLineEdit : public KLineEdit
bool m_moveViewport;
bool m_changed;
bool m_fromStart;
bool m_searchRunning;
private slots:
void slotTextChanged( const QString & text );
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment