1bb02e0acSNicolas Bonnefon /* 2bb02e0acSNicolas Bonnefon * Copyright (C) 2010, 2013 Nicolas Bonnefon and other contributors 3bb02e0acSNicolas Bonnefon * 4bb02e0acSNicolas Bonnefon * This file is part of glogg. 5bb02e0acSNicolas Bonnefon * 6bb02e0acSNicolas Bonnefon * glogg is free software: you can redistribute it and/or modify 7bb02e0acSNicolas Bonnefon * it under the terms of the GNU General Public License as published by 8bb02e0acSNicolas Bonnefon * the Free Software Foundation, either version 3 of the License, or 9bb02e0acSNicolas Bonnefon * (at your option) any later version. 10bb02e0acSNicolas Bonnefon * 11bb02e0acSNicolas Bonnefon * glogg is distributed in the hope that it will be useful, 12bb02e0acSNicolas Bonnefon * but WITHOUT ANY WARRANTY; without even the implied warranty of 13bb02e0acSNicolas Bonnefon * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14bb02e0acSNicolas Bonnefon * GNU General Public License for more details. 15bb02e0acSNicolas Bonnefon * 16bb02e0acSNicolas Bonnefon * You should have received a copy of the GNU General Public License 17bb02e0acSNicolas Bonnefon * along with glogg. If not, see <http://www.gnu.org/licenses/>. 18bb02e0acSNicolas Bonnefon */ 19bb02e0acSNicolas Bonnefon 20bb02e0acSNicolas Bonnefon // This file implements QuickFind. 21bb02e0acSNicolas Bonnefon // This class implements the Quick Find mechanism using references 22bb02e0acSNicolas Bonnefon // to the logData, the QFP and the selection passed. 23bb02e0acSNicolas Bonnefon // Search is started just after the selection and the selection is updated 24bb02e0acSNicolas Bonnefon // if a match is found. 25bb02e0acSNicolas Bonnefon 26bb02e0acSNicolas Bonnefon #include <QApplication> 27bb02e0acSNicolas Bonnefon 28bb02e0acSNicolas Bonnefon #include "log.h" 29bb02e0acSNicolas Bonnefon #include "quickfindpattern.h" 30bb02e0acSNicolas Bonnefon #include "selection.h" 31bb02e0acSNicolas Bonnefon #include "data/abstractlogdata.h" 32bb02e0acSNicolas Bonnefon 33bb02e0acSNicolas Bonnefon #include "quickfind.h" 34bb02e0acSNicolas Bonnefon 35bb02e0acSNicolas Bonnefon void SearchingNotifier::reset() 36bb02e0acSNicolas Bonnefon { 37bb02e0acSNicolas Bonnefon dotToDisplay_ = 0; 38bb02e0acSNicolas Bonnefon startTime_ = QTime::currentTime(); 39bb02e0acSNicolas Bonnefon } 40bb02e0acSNicolas Bonnefon 41bb02e0acSNicolas Bonnefon void SearchingNotifier::sendNotification( qint64 current_line, qint64 nb_lines ) 42bb02e0acSNicolas Bonnefon { 43bb02e0acSNicolas Bonnefon LOG( logDEBUG ) << "Emitting Searching...."; 44bb02e0acSNicolas Bonnefon qint64 progress; 45bb02e0acSNicolas Bonnefon if ( current_line < 0 ) 46bb02e0acSNicolas Bonnefon progress = ( nb_lines + current_line ) * 100 / nb_lines; 47bb02e0acSNicolas Bonnefon else 48bb02e0acSNicolas Bonnefon progress = current_line * 100 / nb_lines; 49bb02e0acSNicolas Bonnefon emit notify( QFNotificationProgress( progress ) ); 50bb02e0acSNicolas Bonnefon 51bb02e0acSNicolas Bonnefon QApplication::processEvents( QEventLoop::ExcludeUserInputEvents ); 52bb02e0acSNicolas Bonnefon startTime_ = QTime::currentTime().addMSecs( -800 ); 53bb02e0acSNicolas Bonnefon } 54bb02e0acSNicolas Bonnefon 55bb02e0acSNicolas Bonnefon void QuickFind::LastMatchPosition::set( int line, int column ) 56bb02e0acSNicolas Bonnefon { 57bb02e0acSNicolas Bonnefon if ( ( line_ == -1 ) || 58bb02e0acSNicolas Bonnefon ( ( line <= line_ ) && ( column < column_ ) ) ) 59bb02e0acSNicolas Bonnefon { 60bb02e0acSNicolas Bonnefon line_ = line; 61bb02e0acSNicolas Bonnefon column_ = column; 62bb02e0acSNicolas Bonnefon } 63bb02e0acSNicolas Bonnefon } 64bb02e0acSNicolas Bonnefon 65bb02e0acSNicolas Bonnefon void QuickFind::LastMatchPosition::set( const FilePosition &position ) 66bb02e0acSNicolas Bonnefon { 67bb02e0acSNicolas Bonnefon set( position.line(), position.column() ); 68bb02e0acSNicolas Bonnefon } 69bb02e0acSNicolas Bonnefon 70bb02e0acSNicolas Bonnefon bool QuickFind::LastMatchPosition::isLater( int line, int column ) const 71bb02e0acSNicolas Bonnefon { 72bb02e0acSNicolas Bonnefon if ( line_ == -1 ) 73bb02e0acSNicolas Bonnefon return false; 74bb02e0acSNicolas Bonnefon else if ( ( line == line_ ) && ( column >= column_ ) ) 75bb02e0acSNicolas Bonnefon return true; 76bb02e0acSNicolas Bonnefon else if ( line > line_ ) 77bb02e0acSNicolas Bonnefon return true; 78bb02e0acSNicolas Bonnefon else 79bb02e0acSNicolas Bonnefon return false; 80bb02e0acSNicolas Bonnefon } 81bb02e0acSNicolas Bonnefon 82bb02e0acSNicolas Bonnefon bool QuickFind::LastMatchPosition::isLater( const FilePosition &position ) const 83bb02e0acSNicolas Bonnefon { 84bb02e0acSNicolas Bonnefon return isLater( position.line(), position.column() ); 85bb02e0acSNicolas Bonnefon } 86bb02e0acSNicolas Bonnefon 87bb02e0acSNicolas Bonnefon bool QuickFind::LastMatchPosition::isSooner( int line, int column ) const 88bb02e0acSNicolas Bonnefon { 89bb02e0acSNicolas Bonnefon if ( line_ == -1 ) 90bb02e0acSNicolas Bonnefon return false; 91bb02e0acSNicolas Bonnefon else if ( ( line == line_ ) && ( column <= column_ ) ) 92bb02e0acSNicolas Bonnefon return true; 93bb02e0acSNicolas Bonnefon else if ( line < line_ ) 94bb02e0acSNicolas Bonnefon return true; 95bb02e0acSNicolas Bonnefon else 96bb02e0acSNicolas Bonnefon return false; 97bb02e0acSNicolas Bonnefon } 98bb02e0acSNicolas Bonnefon 99bb02e0acSNicolas Bonnefon bool QuickFind::LastMatchPosition::isSooner( const FilePosition &position ) const 100bb02e0acSNicolas Bonnefon { 101bb02e0acSNicolas Bonnefon return isSooner( position.line(), position.column() ); 102bb02e0acSNicolas Bonnefon } 103bb02e0acSNicolas Bonnefon 104bb02e0acSNicolas Bonnefon QuickFind::QuickFind( const AbstractLogData* const logData, 105bb02e0acSNicolas Bonnefon Selection* selection, 106bb02e0acSNicolas Bonnefon const QuickFindPattern* const quickFindPattern ) : 107bb02e0acSNicolas Bonnefon logData_( logData ), selection_( selection ), 108bb02e0acSNicolas Bonnefon quickFindPattern_( quickFindPattern ), 109bb02e0acSNicolas Bonnefon lastMatch_(), firstMatch_(), searchingNotifier_(), 110bb02e0acSNicolas Bonnefon incrementalSearchStatus_() 111bb02e0acSNicolas Bonnefon { 112bb02e0acSNicolas Bonnefon connect( &searchingNotifier_, SIGNAL( notify( const QFNotification& ) ), 113bb02e0acSNicolas Bonnefon this, SIGNAL( notify( const QFNotification& ) ) ); 114bb02e0acSNicolas Bonnefon } 115bb02e0acSNicolas Bonnefon 116bb02e0acSNicolas Bonnefon void QuickFind::incrementalSearchStop() 117bb02e0acSNicolas Bonnefon { 118bb02e0acSNicolas Bonnefon if ( incrementalSearchStatus_.isOngoing() ) { 119bb02e0acSNicolas Bonnefon if ( selection_->isEmpty() ) { 120bb02e0acSNicolas Bonnefon // Nothing found? 121bb02e0acSNicolas Bonnefon // We reset the selection to what it was 122bb02e0acSNicolas Bonnefon *selection_ = incrementalSearchStatus_.initialSelection(); 123bb02e0acSNicolas Bonnefon } 124bb02e0acSNicolas Bonnefon 125bb02e0acSNicolas Bonnefon incrementalSearchStatus_ = IncrementalSearchStatus(); 126bb02e0acSNicolas Bonnefon } 127bb02e0acSNicolas Bonnefon } 128bb02e0acSNicolas Bonnefon 129bb02e0acSNicolas Bonnefon void QuickFind::incrementalSearchAbort() 130bb02e0acSNicolas Bonnefon { 131bb02e0acSNicolas Bonnefon if ( incrementalSearchStatus_.isOngoing() ) { 132bb02e0acSNicolas Bonnefon // We reset the selection to what it was 133bb02e0acSNicolas Bonnefon *selection_ = incrementalSearchStatus_.initialSelection(); 134bb02e0acSNicolas Bonnefon incrementalSearchStatus_ = IncrementalSearchStatus(); 135bb02e0acSNicolas Bonnefon } 136bb02e0acSNicolas Bonnefon } 137bb02e0acSNicolas Bonnefon 138bb02e0acSNicolas Bonnefon qint64 QuickFind::incrementallySearchForward() 139bb02e0acSNicolas Bonnefon { 140bb02e0acSNicolas Bonnefon LOG( logDEBUG ) << "QuickFind::incrementallySearchForward"; 141bb02e0acSNicolas Bonnefon 142bb02e0acSNicolas Bonnefon // Position where we start the search from 143bb02e0acSNicolas Bonnefon FilePosition start_position = selection_->getNextPosition(); 144bb02e0acSNicolas Bonnefon 145bb02e0acSNicolas Bonnefon if ( incrementalSearchStatus_.direction() == Forward ) { 146bb02e0acSNicolas Bonnefon // An incremental search is active, we restart the search 147bb02e0acSNicolas Bonnefon // from the initial point 148bb02e0acSNicolas Bonnefon LOG( logDEBUG ) << "Restart search from initial point"; 149bb02e0acSNicolas Bonnefon start_position = incrementalSearchStatus_.position(); 150bb02e0acSNicolas Bonnefon } 151bb02e0acSNicolas Bonnefon else { 152bb02e0acSNicolas Bonnefon // It's a new search so we search from the selection 153bb02e0acSNicolas Bonnefon incrementalSearchStatus_ = IncrementalSearchStatus( 154bb02e0acSNicolas Bonnefon Forward, 155bb02e0acSNicolas Bonnefon start_position, 156bb02e0acSNicolas Bonnefon *selection_ ); 157bb02e0acSNicolas Bonnefon } 158bb02e0acSNicolas Bonnefon 159bb02e0acSNicolas Bonnefon qint64 line_found = doSearchForward( start_position ); 160bb02e0acSNicolas Bonnefon 161bb02e0acSNicolas Bonnefon if ( line_found >= 0 ) { 162bb02e0acSNicolas Bonnefon // We have found a result... 163bb02e0acSNicolas Bonnefon // ... the caller will jump to this line. 164bb02e0acSNicolas Bonnefon return line_found; 165bb02e0acSNicolas Bonnefon } 166bb02e0acSNicolas Bonnefon else { 167bb02e0acSNicolas Bonnefon // No result... 168bb02e0acSNicolas Bonnefon // ... we want the client to show the initial line. 169bb02e0acSNicolas Bonnefon selection_->clear(); 170bb02e0acSNicolas Bonnefon return incrementalSearchStatus_.position().line(); 171bb02e0acSNicolas Bonnefon } 172bb02e0acSNicolas Bonnefon } 173bb02e0acSNicolas Bonnefon 174bb02e0acSNicolas Bonnefon qint64 QuickFind::incrementallySearchBackward() 175bb02e0acSNicolas Bonnefon { 176bb02e0acSNicolas Bonnefon LOG( logDEBUG ) << "QuickFind::incrementallySearchBackward"; 177bb02e0acSNicolas Bonnefon 178bb02e0acSNicolas Bonnefon // Position where we start the search from 179bb02e0acSNicolas Bonnefon FilePosition start_position = selection_->getPreviousPosition(); 180bb02e0acSNicolas Bonnefon 181bb02e0acSNicolas Bonnefon if ( incrementalSearchStatus_.direction() == Backward ) { 182bb02e0acSNicolas Bonnefon // An incremental search is active, we restart the search 183bb02e0acSNicolas Bonnefon // from the initial point 184bb02e0acSNicolas Bonnefon LOG( logDEBUG ) << "Restart search from initial point"; 185bb02e0acSNicolas Bonnefon start_position = incrementalSearchStatus_.position(); 186bb02e0acSNicolas Bonnefon } 187bb02e0acSNicolas Bonnefon else { 188bb02e0acSNicolas Bonnefon // It's a new search so we search from the selection 189bb02e0acSNicolas Bonnefon incrementalSearchStatus_ = IncrementalSearchStatus( 190bb02e0acSNicolas Bonnefon Backward, 191bb02e0acSNicolas Bonnefon start_position, 192bb02e0acSNicolas Bonnefon *selection_ ); 193bb02e0acSNicolas Bonnefon } 194bb02e0acSNicolas Bonnefon 195bb02e0acSNicolas Bonnefon qint64 line_found = doSearchBackward( start_position ); 196bb02e0acSNicolas Bonnefon 197bb02e0acSNicolas Bonnefon if ( line_found >= 0 ) { 198bb02e0acSNicolas Bonnefon // We have found a result... 199bb02e0acSNicolas Bonnefon // ... the caller will jump to this line. 200bb02e0acSNicolas Bonnefon return line_found; 201bb02e0acSNicolas Bonnefon } 202bb02e0acSNicolas Bonnefon else { 203bb02e0acSNicolas Bonnefon // No result... 204bb02e0acSNicolas Bonnefon // ... we want the client to show the initial line. 205bb02e0acSNicolas Bonnefon selection_->clear(); 206bb02e0acSNicolas Bonnefon return incrementalSearchStatus_.position().line(); 207bb02e0acSNicolas Bonnefon } 208bb02e0acSNicolas Bonnefon } 209bb02e0acSNicolas Bonnefon 210bb02e0acSNicolas Bonnefon qint64 QuickFind::searchForward() 211bb02e0acSNicolas Bonnefon { 212bb02e0acSNicolas Bonnefon incrementalSearchStatus_ = IncrementalSearchStatus(); 213bb02e0acSNicolas Bonnefon 214bb02e0acSNicolas Bonnefon // Position where we start the search from 215bb02e0acSNicolas Bonnefon FilePosition start_position = selection_->getNextPosition(); 216bb02e0acSNicolas Bonnefon 217bb02e0acSNicolas Bonnefon return doSearchForward( start_position ); 218bb02e0acSNicolas Bonnefon } 219bb02e0acSNicolas Bonnefon 220bb02e0acSNicolas Bonnefon 221bb02e0acSNicolas Bonnefon qint64 QuickFind::searchBackward() 222bb02e0acSNicolas Bonnefon { 223bb02e0acSNicolas Bonnefon incrementalSearchStatus_ = IncrementalSearchStatus(); 224bb02e0acSNicolas Bonnefon 225bb02e0acSNicolas Bonnefon // Position where we start the search from 226bb02e0acSNicolas Bonnefon FilePosition start_position = selection_->getPreviousPosition(); 227bb02e0acSNicolas Bonnefon 228bb02e0acSNicolas Bonnefon return doSearchBackward( start_position ); 229bb02e0acSNicolas Bonnefon } 230bb02e0acSNicolas Bonnefon 231bb02e0acSNicolas Bonnefon // Internal implementation of forward search, 232bb02e0acSNicolas Bonnefon // returns the line where the pattern is found or -1 if not found. 233bb02e0acSNicolas Bonnefon // Parameters are the position the search shall start 234bb02e0acSNicolas Bonnefon qint64 QuickFind::doSearchForward( const FilePosition &start_position ) 235bb02e0acSNicolas Bonnefon { 236bb02e0acSNicolas Bonnefon bool found = false; 237bb02e0acSNicolas Bonnefon int found_start_col; 238bb02e0acSNicolas Bonnefon int found_end_col; 239bb02e0acSNicolas Bonnefon 240bb02e0acSNicolas Bonnefon if ( ! quickFindPattern_->isActive() ) 241bb02e0acSNicolas Bonnefon return -1; 242bb02e0acSNicolas Bonnefon 243bb02e0acSNicolas Bonnefon // Optimisation: if we are already after the last match, 244bb02e0acSNicolas Bonnefon // we don't do any search at all. 245bb02e0acSNicolas Bonnefon if ( lastMatch_.isLater( start_position ) ) { 246bb02e0acSNicolas Bonnefon // Send a notification 247bb02e0acSNicolas Bonnefon emit notify( QFNotificationReachedEndOfFile() ); 248bb02e0acSNicolas Bonnefon 249bb02e0acSNicolas Bonnefon return -1; 250bb02e0acSNicolas Bonnefon } 251bb02e0acSNicolas Bonnefon 252bb02e0acSNicolas Bonnefon qint64 line = start_position.line(); 253bb02e0acSNicolas Bonnefon LOG( logDEBUG ) << "Start searching at line " << line; 254bb02e0acSNicolas Bonnefon // We look at the rest of the first line 255bb02e0acSNicolas Bonnefon if ( quickFindPattern_->isLineMatching( 256bb02e0acSNicolas Bonnefon logData_->getExpandedLineString( line ), 257bb02e0acSNicolas Bonnefon start_position.column() ) ) { 258bb02e0acSNicolas Bonnefon quickFindPattern_->getLastMatch( &found_start_col, &found_end_col ); 259bb02e0acSNicolas Bonnefon found = true; 260bb02e0acSNicolas Bonnefon } 261bb02e0acSNicolas Bonnefon else { 262bb02e0acSNicolas Bonnefon searchingNotifier_.reset(); 263bb02e0acSNicolas Bonnefon // And then the rest of the file 264bb02e0acSNicolas Bonnefon qint64 nb_lines = logData_->getNbLine(); 265bb02e0acSNicolas Bonnefon line++; 266bb02e0acSNicolas Bonnefon while ( line < nb_lines ) { 267bb02e0acSNicolas Bonnefon if ( quickFindPattern_->isLineMatching( 268bb02e0acSNicolas Bonnefon logData_->getExpandedLineString( line ) ) ) { 269bb02e0acSNicolas Bonnefon quickFindPattern_->getLastMatch( 270bb02e0acSNicolas Bonnefon &found_start_col, &found_end_col ); 271bb02e0acSNicolas Bonnefon found = true; 272bb02e0acSNicolas Bonnefon break; 273bb02e0acSNicolas Bonnefon } 274bb02e0acSNicolas Bonnefon line++; 275bb02e0acSNicolas Bonnefon 276bb02e0acSNicolas Bonnefon // See if we need to notify of the ongoing search 277bb02e0acSNicolas Bonnefon searchingNotifier_.ping( line, nb_lines ); 278bb02e0acSNicolas Bonnefon } 279bb02e0acSNicolas Bonnefon } 280bb02e0acSNicolas Bonnefon 281bb02e0acSNicolas Bonnefon if ( found ) { 282bb02e0acSNicolas Bonnefon selection_->selectPortion( 283bb02e0acSNicolas Bonnefon line, found_start_col, found_end_col ); 284bb02e0acSNicolas Bonnefon 285bb02e0acSNicolas Bonnefon // Clear any notification 286bb02e0acSNicolas Bonnefon emit clearNotification(); 287bb02e0acSNicolas Bonnefon 288bb02e0acSNicolas Bonnefon return line; 289bb02e0acSNicolas Bonnefon } 290bb02e0acSNicolas Bonnefon else { 291bb02e0acSNicolas Bonnefon // Update the position of the last match 292bb02e0acSNicolas Bonnefon FilePosition last_match_position = selection_->getPreviousPosition(); 293bb02e0acSNicolas Bonnefon lastMatch_.set( last_match_position ); 294bb02e0acSNicolas Bonnefon 295bb02e0acSNicolas Bonnefon // Send a notification 296bb02e0acSNicolas Bonnefon emit notify( QFNotificationReachedEndOfFile() ); 297bb02e0acSNicolas Bonnefon 298bb02e0acSNicolas Bonnefon return -1; 299bb02e0acSNicolas Bonnefon } 300bb02e0acSNicolas Bonnefon } 301bb02e0acSNicolas Bonnefon 302bb02e0acSNicolas Bonnefon // Internal implementation of backward search, 303bb02e0acSNicolas Bonnefon // returns the line where the pattern is found or -1 if not found. 304bb02e0acSNicolas Bonnefon // Parameters are the position the search shall start 305bb02e0acSNicolas Bonnefon qint64 QuickFind::doSearchBackward( const FilePosition &start_position ) 306bb02e0acSNicolas Bonnefon { 307bb02e0acSNicolas Bonnefon bool found = false; 308bb02e0acSNicolas Bonnefon int start_col; 309bb02e0acSNicolas Bonnefon int end_col; 310bb02e0acSNicolas Bonnefon 311bb02e0acSNicolas Bonnefon if ( ! quickFindPattern_->isActive() ) 312bb02e0acSNicolas Bonnefon return -1; 313bb02e0acSNicolas Bonnefon 314bb02e0acSNicolas Bonnefon // Optimisation: if we are already before the first match, 315bb02e0acSNicolas Bonnefon // we don't do any search at all. 316bb02e0acSNicolas Bonnefon if ( firstMatch_.isSooner( start_position ) ) { 317bb02e0acSNicolas Bonnefon // Send a notification 318bb02e0acSNicolas Bonnefon emit notify( QFNotificationReachedBegininningOfFile() ); 319bb02e0acSNicolas Bonnefon 320bb02e0acSNicolas Bonnefon return -1; 321bb02e0acSNicolas Bonnefon } 322bb02e0acSNicolas Bonnefon 323bb02e0acSNicolas Bonnefon qint64 line = start_position.line(); 324bb02e0acSNicolas Bonnefon LOG( logDEBUG ) << "Start searching at line " << line; 325bb02e0acSNicolas Bonnefon // We look at the beginning of the first line 326bb02e0acSNicolas Bonnefon if ( ( start_position.column() > 0 ) 327bb02e0acSNicolas Bonnefon && ( quickFindPattern_->isLineMatchingBackward( 328bb02e0acSNicolas Bonnefon logData_->getExpandedLineString( line ), 329bb02e0acSNicolas Bonnefon start_position.column() ) ) 330bb02e0acSNicolas Bonnefon ) { 331bb02e0acSNicolas Bonnefon quickFindPattern_->getLastMatch( &start_col, &end_col ); 332bb02e0acSNicolas Bonnefon found = true; 333bb02e0acSNicolas Bonnefon } 334bb02e0acSNicolas Bonnefon else { 335bb02e0acSNicolas Bonnefon searchingNotifier_.reset(); 336bb02e0acSNicolas Bonnefon // And then the rest of the file 337bb02e0acSNicolas Bonnefon qint64 nb_lines = logData_->getNbLine(); 338bb02e0acSNicolas Bonnefon line--; 339bb02e0acSNicolas Bonnefon while ( line >= 0 ) { 340bb02e0acSNicolas Bonnefon if ( quickFindPattern_->isLineMatchingBackward( 341bb02e0acSNicolas Bonnefon logData_->getExpandedLineString( line ) ) ) { 342bb02e0acSNicolas Bonnefon quickFindPattern_->getLastMatch( &start_col, &end_col ); 343bb02e0acSNicolas Bonnefon found = true; 344bb02e0acSNicolas Bonnefon break; 345bb02e0acSNicolas Bonnefon } 346bb02e0acSNicolas Bonnefon line--; 347bb02e0acSNicolas Bonnefon 348bb02e0acSNicolas Bonnefon // See if we need to notify of the ongoing search 349bb02e0acSNicolas Bonnefon searchingNotifier_.ping( -line, nb_lines ); 350bb02e0acSNicolas Bonnefon } 351bb02e0acSNicolas Bonnefon } 352bb02e0acSNicolas Bonnefon 353bb02e0acSNicolas Bonnefon if ( found ) 354bb02e0acSNicolas Bonnefon { 355bb02e0acSNicolas Bonnefon selection_->selectPortion( line, start_col, end_col ); 356bb02e0acSNicolas Bonnefon 357bb02e0acSNicolas Bonnefon // Clear any notification 358bb02e0acSNicolas Bonnefon emit clearNotification(); 359bb02e0acSNicolas Bonnefon 360bb02e0acSNicolas Bonnefon return line; 361bb02e0acSNicolas Bonnefon } 362bb02e0acSNicolas Bonnefon else { 363bb02e0acSNicolas Bonnefon // Update the position of the first match 364bb02e0acSNicolas Bonnefon FilePosition first_match_position = selection_->getNextPosition(); 365bb02e0acSNicolas Bonnefon firstMatch_.set( first_match_position ); 366bb02e0acSNicolas Bonnefon 367bb02e0acSNicolas Bonnefon // Send a notification 368*b423cd88SNicolas Bonnefon LOG( logDEBUG ) << "QF: Send BOF notification."; 369bb02e0acSNicolas Bonnefon emit notify( QFNotificationReachedBegininningOfFile() ); 370bb02e0acSNicolas Bonnefon 371bb02e0acSNicolas Bonnefon return -1; 372bb02e0acSNicolas Bonnefon } 373bb02e0acSNicolas Bonnefon } 374bb02e0acSNicolas Bonnefon 375bb02e0acSNicolas Bonnefon void QuickFind::resetLimits() 376bb02e0acSNicolas Bonnefon { 377bb02e0acSNicolas Bonnefon lastMatch_.reset(); 378bb02e0acSNicolas Bonnefon firstMatch_.reset(); 379bb02e0acSNicolas Bonnefon } 380