Example #1
0
void csPdfSearchResultsModel::insertResults(const csPdfSearchResults& incoming)
{
  if( incoming.isEmpty() ) {
    return;
  }

  beginResetModel();
  _results += incoming;
  qSort(_results);
  endResetModel();
}
Example #2
0
void csPdfSearch::processSearch()
{
  if( !_running ) {
    return;
  }

  if( _cancel ) {
    _running = false;
    emit canceled();
    return;
  }

  int blockSize = 0;
  if(        !isBlocksFinished() ) {
    // Do CSPDF_SEARCH_BLOCKSIZE's Work...
    blockSize = CSPDF_SEARCH_BLOCKSIZE;
    _cntBlocks++;
  } else if(  isBlocksFinished()  &&  !isRemainFinished() ) {
    // Do _numRemain's Work...
    blockSize = _numRemain;
    _cntRemain += _numRemain;
  }

  if( blockSize != 0 ) {
    const csPdfSearchResults results =
        searchPages(_doc.textPages(_cntIndex, blockSize),
                    _needles, _cs, _context);
    if( !results.isEmpty() ) {
      emit found(results);
    }
    _cntIndex += blockSize;
    _cntDone  += blockSize;
    progressUpdate();
  }

  if( isFinished()  &&  _startIndex != 0  &&  _wrap ) {
    initialize(0, _startIndex);
    _startIndex = 0;
  }

  if( !isFinished() ) {
    QMetaObject::invokeMethod(this, "processSearch", Qt::QueuedConnection);
  } else {
    _running = false;
    emit finished();
  }
}