| 1089 | } |
| 1090 | |
| 1091 | void QHexEdit::adjust() |
| 1092 | { |
| 1093 | // recalc Graphics |
| 1094 | if (_addressArea) |
| 1095 | { |
| 1096 | _addrDigits = addressWidth(); |
| 1097 | _pxPosHexX = _pxAreaMargin + _addrDigits*_pxCharWidth + 2 * _pxAreaMargin; |
| 1098 | } |
| 1099 | else |
| 1100 | _pxPosHexX = _pxAreaMargin; |
| 1101 | _pxPosAdrX = _pxAreaMargin; |
| 1102 | _pxPosAsciiX = _pxPosHexX + _hexCharsInLine * _pxCharWidth + 2 * _pxAreaMargin; |
| 1103 | |
| 1104 | // set horizontalScrollBar() |
| 1105 | int pxWidth = _pxPosAsciiX; |
| 1106 | if (_asciiArea) |
| 1107 | pxWidth += _bytesPerLine*_pxCharWidth; |
| 1108 | horizontalScrollBar()->setRange(0, pxWidth - viewport()->width()); |
| 1109 | horizontalScrollBar()->setPageStep(viewport()->width()); |
| 1110 | |
| 1111 | // set verticalScrollbar() |
| 1112 | _rowsShown = ((viewport()->height()-4)/_pxCharHeight); |
| 1113 | int lineCount = (int)(_chunks->size() / (qint64)_bytesPerLine) + 1; |
| 1114 | verticalScrollBar()->setRange(0, lineCount - _rowsShown); |
| 1115 | verticalScrollBar()->setPageStep(_rowsShown); |
| 1116 | |
| 1117 | int value = verticalScrollBar()->value(); |
| 1118 | _bPosFirst = (qint64)value * _bytesPerLine; |
| 1119 | _bPosLast = _bPosFirst + (qint64)(_rowsShown * _bytesPerLine) - 1; |
| 1120 | if (_bPosLast >= _chunks->size()) |
| 1121 | _bPosLast = _chunks->size() - 1; |
| 1122 | readBuffers(); |
| 1123 | setCursorPosition(_cursorPosition); |
| 1124 | } |
| 1125 | |
| 1126 | void QHexEdit::dataChangedPrivate(int) |
| 1127 | { |