| 1507 | } |
| 1508 | |
| 1509 | bool DiffTextWindow::findString(const QString& s, LineRef& d3vLine, qsizetype& posInLine, bool bDirDown, bool bCaseSensitive) |
| 1510 | { |
| 1511 | LineRef it = d3vLine; |
| 1512 | qsizetype endIt = bDirDown ? d->getDiff3LineVector()->size() : -1; |
| 1513 | qint32 step = bDirDown ? 1 : -1; |
| 1514 | qsizetype startPos = posInLine; |
| 1515 | |
| 1516 | for(; it != endIt; it += step) |
| 1517 | { |
| 1518 | QString line = d->getString(it); |
| 1519 | if(!line.isEmpty()) |
| 1520 | { |
| 1521 | qsizetype pos = line.indexOf(s, startPos, bCaseSensitive ? Qt::CaseSensitive : Qt::CaseInsensitive); |
| 1522 | //TODO: Provide error message when failsafe is triggered. |
| 1523 | if(Q_UNLIKELY(pos > limits<qint32>::max())) |
| 1524 | { |
| 1525 | qCWarning(kdiffMain) << "Skip possiable match line offset to large."; |
| 1526 | continue; |
| 1527 | } |
| 1528 | |
| 1529 | if(pos != -1) |
| 1530 | { |
| 1531 | d3vLine = it; |
| 1532 | posInLine = pos; |
| 1533 | |
| 1534 | setSelection(d3vLine, posInLine, d3vLine, posInLine + s.length()); |
| 1535 | mVScrollBar->setValue(d->m_selection.beginLine() - DiffTextWindow::mVScrollBar->pageStep() / 2); |
| 1536 | |
| 1537 | scrollToH(d->m_selection.beginPos()); |
| 1538 | return true; |
| 1539 | } |
| 1540 | |
| 1541 | startPos = 0; |
| 1542 | } |
| 1543 | } |
| 1544 | return false; |
| 1545 | } |
| 1546 | |
| 1547 | void DiffTextWindow::convertD3LCoordsToLineCoords(LineType d3LIdx, qsizetype d3LPos, LineRef& line, qsizetype& pos) const |
| 1548 | { |
no test coverage detected