| 714 | } |
| 715 | |
| 716 | void DiffTextWindow::mouseDoubleClickEvent(QMouseEvent* e) |
| 717 | { |
| 718 | qCInfo(kdiffDiffTextWindow) << "Mouse Double Clicked"; |
| 719 | qCDebug(kdiffDiffTextWindow) << "d->m_lastKnownMousePos = " << d->m_lastKnownMousePos << ", e->pos() = " << e->pos(); |
| 720 | qCDebug(kdiffDiffTextWindow) << "d->m_bSelectionInProgress = " << d->m_bSelectionInProgress; |
| 721 | |
| 722 | d->m_bSelectionInProgress = false; |
| 723 | d->m_lastKnownMousePos = e->pos(); |
| 724 | if(e->button() == Qt::LeftButton) |
| 725 | { |
| 726 | LineRef line; |
| 727 | qint32 pos; |
| 728 | convertToLinePos(e->pos().x(), e->pos().y(), line, pos); |
| 729 | qCInfo(kdiffDiffTextWindow) << "Left Button detected,"; |
| 730 | qCDebug(kdiffDiffTextWindow) << "line = " << line << ", pos = " << pos; |
| 731 | |
| 732 | // Get the string data of the current line |
| 733 | QString s; |
| 734 | if(d->m_bWordWrap) |
| 735 | { |
| 736 | if(!line.isValid() || (size_t)line >= d->m_diff3WrapLineVector.size()) |
| 737 | return; |
| 738 | const Diff3WrapLine& d3wl = d->m_diff3WrapLineVector[line]; |
| 739 | s = d->getString(d3wl.diff3LineIndex).mid(d3wl.wrapLineOffset, d3wl.wrapLineLength); |
| 740 | } |
| 741 | else |
| 742 | { |
| 743 | if(!line.isValid() || (size_t)line >= d->getDiff3LineVector()->size()) |
| 744 | return; |
| 745 | s = d->getString(line); |
| 746 | } |
| 747 | |
| 748 | if(!s.isEmpty()) |
| 749 | { |
| 750 | const bool selectionWasEmpty = d->m_selection.isEmpty(); |
| 751 | qsizetype pos1, pos2; |
| 752 | Utils::calcTokenPos(s, pos, pos1, pos2); |
| 753 | |
| 754 | resetSelection(); |
| 755 | d->m_selection.start(line, pos1); |
| 756 | d->m_selection.end(line, pos2); |
| 757 | if(!d->m_selection.isEmpty() && selectionWasEmpty) |
| 758 | Q_EMIT newSelection(); |
| 759 | |
| 760 | update(); |
| 761 | // Q_EMIT d->m_selectionEnd() happens in the mouseReleaseEvent. |
| 762 | showStatusLine(line); |
| 763 | } |
| 764 | } |
| 765 | } |
| 766 | |
| 767 | void DiffTextWindow::mouseReleaseEvent(QMouseEvent* e) |
| 768 | { |