| 193 | } |
| 194 | |
| 195 | qint64 QHexEdit::cursorPosition(QPoint pos) |
| 196 | { |
| 197 | // Calc cursor position depending on a graphical position |
| 198 | qint64 result = -1; |
| 199 | int posX = pos.x() + horizontalScrollBar()->value(); |
| 200 | int posY = pos.y() - 3; |
| 201 | if ((posX >= _pxPosHexX) && (posX < (_pxPosHexX + (1 + _hexCharsInLine) * _pxCharWidth))) |
| 202 | { |
| 203 | _editAreaIsAscii = false; |
| 204 | int x = (posX - _pxPosHexX) / _pxCharWidth; |
| 205 | x = (x / 3) * 2 + x % 3; |
| 206 | int y = (posY / _pxCharHeight) * 2 * _bytesPerLine; |
| 207 | result = _bPosFirst * 2 + x + y; |
| 208 | } |
| 209 | else |
| 210 | if (_asciiArea && (posX >= _pxPosAsciiX) && (posX < (_pxPosAsciiX + (1 + _bytesPerLine) * _pxCharWidth))) |
| 211 | { |
| 212 | _editAreaIsAscii = true; |
| 213 | int x = 2 * (posX - _pxPosAsciiX) / _pxCharWidth; |
| 214 | int y = (posY / _pxCharHeight) * 2 * _bytesPerLine; |
| 215 | result = _bPosFirst * 2 + x + y; |
| 216 | } |
| 217 | return result; |
| 218 | } |
| 219 | |
| 220 | qint64 QHexEdit::cursorPosition() |
| 221 | { |