| 868 | } |
| 869 | |
| 870 | void DiffTextWindow::timerEvent(QTimerEvent*) |
| 871 | { |
| 872 | killTimer(d->m_delayedDrawTimer); |
| 873 | d->m_delayedDrawTimer = 0; |
| 874 | |
| 875 | if(d->m_bMyUpdate) |
| 876 | { |
| 877 | qint32 fontHeight = fontMetrics().lineSpacing(); |
| 878 | |
| 879 | if(d->m_selection.getOldLastLine().isValid()) |
| 880 | { |
| 881 | LineRef lastLine; |
| 882 | LineRef firstLine; |
| 883 | if(d->m_selection.getOldFirstLine().isValid()) |
| 884 | { |
| 885 | firstLine = std::min({d->m_selection.getOldFirstLine(), d->m_selection.getLastLine(), d->m_selection.getOldLastLine()}); |
| 886 | lastLine = std::max({d->m_selection.getOldFirstLine(), d->m_selection.getLastLine(), d->m_selection.getOldLastLine()}); |
| 887 | } |
| 888 | else |
| 889 | { |
| 890 | firstLine = std::min(d->m_selection.getLastLine(), d->m_selection.getOldLastLine()); |
| 891 | lastLine = std::max(d->m_selection.getLastLine(), d->m_selection.getOldLastLine()); |
| 892 | } |
| 893 | qint32 y1 = (firstLine - d->m_firstLine) * fontHeight; |
| 894 | qint32 y2 = std::min(height(), (lastLine - d->m_firstLine + 1) * fontHeight); |
| 895 | |
| 896 | if(y1 < height() && y2 > 0) |
| 897 | { |
| 898 | QRect invalidRect = QRect(0, y1 - 1, width(), y2 - y1 + fontHeight); // Some characters in exotic exceed the regular bottom. |
| 899 | update(invalidRect); |
| 900 | } |
| 901 | } |
| 902 | |
| 903 | d->m_bMyUpdate = false; |
| 904 | } |
| 905 | |
| 906 | if(d->m_scrollDeltaX != 0 || d->m_scrollDeltaY != 0) |
| 907 | { |
| 908 | qsizetype newPos = d->m_selection.getLastPos() + d->m_scrollDeltaX; |
| 909 | try |
| 910 | { |
| 911 | LineRef newLine = d->m_selection.getLastLine() + d->m_scrollDeltaY; |
| 912 | |
| 913 | d->m_selection.end(newLine, newPos > 0 ? newPos : 0); |
| 914 | } |
| 915 | catch(const std::system_error&) |
| 916 | { |
| 917 | d->m_selection.end(LineRef::invalid, newPos > 0 ? newPos : 0); |
| 918 | } |
| 919 | Q_EMIT scrollDiffTextWindow(d->m_scrollDeltaX, d->m_scrollDeltaY); |
| 920 | killTimer(d->m_delayedDrawTimer); |
| 921 | d->m_delayedDrawTimer = startTimer(50); |
| 922 | } |
| 923 | } |
| 924 | |
| 925 | void DiffTextWindow::resetSelection() |
| 926 | { |
nothing calls this directly
no test coverage detected