@@ -325,10 +325,17 @@ void QHexView::keyPressEvent(QKeyEvent *e) {
325325QPoint QHexView::absolutePosition (const QPoint &pos) const {
326326 auto margins = viewport ()->contentsMargins ();
327327 QPoint shift (horizontalScrollBar ()->value () - margins.left (),
328- -margins.top () * m_renderer-> lineHeight () );
328+ -margins.top ());
329329 return pos + shift;
330330}
331331
332+ bool QHexView::disableInternalPaint () const { return m_disableInternalPaint; }
333+
334+ void QHexView::setDisableInternalPaint (bool newDisableInternalPaint) {
335+ m_disableInternalPaint = newDisableInternalPaint;
336+ update ();
337+ }
338+
332339QHexCursor *QHexView::cursor () const { return m_cursor; }
333340
334341qsizetype QHexView::copyLimit () const { return m_copylimit; }
@@ -786,22 +793,25 @@ void QHexView::paintEvent(QPaintEvent *e) {
786793
787794 // these are lines from the point of view of the visible rect
788795 // where the first "headerCount" are taken by the header
789- const int first = (r.top () / lineHeight) ; // included
796+ const int first = (r.top () - m. top ()) / lineHeight; // included
790797 const int lastPlusOne =
791- (r.bottom () / lineHeight) + 1 - m.top () - m.bottom (); // excluded
798+ (( r.bottom () - m.top () - m.bottom ()) / lineHeight) + 1 ; // excluded
792799
793800 // compute document lines, adding firstVisible and removing the header
794801 // the max is necessary if the rect covers the header
795802 const qsizetype begin = firstVisible + std::max (first - headerCount, 0 );
796803 const qsizetype end = firstVisible + std::max (lastPlusOne - headerCount, 0 );
797804
798805 Q_EMIT onPaintCustomEventBegin ();
799- painter.save ();
800806 auto xOff = this ->horizontalScrollBar ()->value ();
801- painter.translate (-xOff + m.left (), m.top () * m_renderer->lineHeight ());
802- m_renderer->render (&painter, begin, end, firstVisible);
803- m_renderer->renderFrame (&painter);
804- painter.restore ();
807+ if (Q_LIKELY (!m_disableInternalPaint)) {
808+ painter.save ();
809+ painter.translate (-xOff + m.left (), m.top ());
810+ m_renderer->render (&painter, begin, end, firstVisible);
811+ m_renderer->renderFrame (&painter);
812+ m_renderer->renderAdditonalFrame (&painter, m.top () > 0 , m.left () > 0 );
813+ painter.restore ();
814+ }
805815 Q_EMIT onPaintCustomEvent (xOff, firstVisible, begin, end);
806816}
807817
@@ -1184,7 +1194,6 @@ void QHexView::adjustScrollBars() {
11841194
11851195 auto docLines = m_renderer->documentLines ();
11861196 auto visLines = this ->visibleLines ();
1187- auto margins = viewport ()->contentsMargins ();
11881197
11891198 // modified by wingsummer,fix the scrollbar bug
11901199 if (docLines > visLines && !m_document->isEmpty ()) {
@@ -1200,6 +1209,7 @@ void QHexView::adjustScrollBars() {
12001209 QScrollBar *hscrollbar = this ->horizontalScrollBar ();
12011210 int documentWidth = m_renderer->documentWidth ();
12021211 int viewportWidth = viewport ()->width ();
1212+ auto margins = viewport ()->contentsMargins ();
12031213
12041214 if (documentWidth > viewportWidth) {
12051215 this ->setHorizontalScrollBarPolicy (Qt::ScrollBarAlwaysOn);
@@ -1231,9 +1241,10 @@ qsizetype QHexView::lastVisibleLine() const {
12311241
12321242qsizetype QHexView::visibleLines () const {
12331243 auto margins = viewport ()->contentsMargins ();
1234- auto visLines = qsizetype (std::ceil (
1235- this ->height () / m_renderer->lineHeight () -
1236- m_renderer->headerLineCount () - margins.top () - margins.bottom ()));
1244+ auto visLines = qsizetype (
1245+ std::ceil ((this ->height () - margins.top () - margins.bottom ()) /
1246+ m_renderer->lineHeight () -
1247+ m_renderer->headerLineCount ()));
12371248 return std::min (visLines, m_renderer->documentLines ());
12381249}
12391250
0 commit comments