diff --git a/bigtext.py b/bigtext.py index 8b69c5e..f552c64 100644 --- a/bigtext.py +++ b/bigtext.py @@ -140,12 +140,16 @@ class InnerBigText(QWidget): painter.setPen(QColor(0, 0, 0)) self.update_font_metrics(painter) - lines_to_show = self.height() / (self.fontMetrics().height()) + lines_to_show = self.height() / float(self.char_height) + #print("%s / %s = %s" %(self.height(), float(self.char_height), lines_to_show)) + self.lines = self.model.data(self._byte_offset, self.scroll_lines, lines_to_show) + #print("lines_to_show: %d returned: %d" % (lines_to_show, len(self.lines))) self.scroll_lines=0 self._byte_offset = self.lines[0].byte_offset() - self.parent.v_scroll_bar.setMaximum( - self.model.byte_count() - 1 - 10) # document length == maximum + pageStep + aFewBytesSoThatTheLastLineIsShown + # document length == maximum + pageStep + aFewBytesSoThatTheLastLineIsShown + self.parent.v_scroll_bar.setMaximum(self.model.byte_count() - 1 - 10) + for l in self.lines: self.update_longest_line(len(l.line())) @@ -198,8 +202,7 @@ class InnerBigText(QWidget): def update_font_metrics(self, painter: QPainter): fm: QFontMetrics = painter.fontMetrics() self.char_height = fm.height() - self.char_width = fm.averageCharWidth() # all chars have same with for monospace font + self.char_width = fm.averageCharWidth() # all chars have same width for monospace font text = "012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789" self.char_width = fm.horizontalAdvance(text) / float(len(text)) - # print("bounding rect: %s"%(boundingRect)) - # print("font width=%s height=%s" % (self.char_width, self.char_height)) + #print("font width=%s height=%s" % (self.char_width, self.char_height)) diff --git a/example.log b/example.log index 398aefa..cf58761 100644 --- a/example.log +++ b/example.log @@ -122,4 +122,24 @@ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| 2018-09-06T00:00:31.309Z,2,vapfacbk01,ApplicationLockService.getLocks,AXC_5.14_526,,successful 2018-09-06T00:00:31.311Z,2,vapfacbk01,ApplicationStateService.getState,AXC_5.14_526,,successful ---------1---------2---------3---------4---------5---------6---------7---------8---------9--------10---------1---------2---------3---------4---------5---------6---------7---------8---------9--------10---------1---------2---------3---------4---------5---------6---------7---------8---------9--------10 ----------1---------2---------3---------4---------5---------6---------7---------8---------9--------10---------1---------2---------3---------4---------5---------6---------7---------8---------9--------10---------1---------2---------3---------4---------5---------6---------7---------8---------9--------10---------1---------2---------3---------4---------5---------6---------7---------8---------9--------10 \ No newline at end of file +---------1---------2---------3---------4---------5---------6---------7---------8---------9--------10---------1---------2---------3---------4---------5---------6---------7---------8---------9--------10---------1---------2---------3---------4---------5---------6---------7---------8---------9--------10---------1---------2---------3---------4---------5---------6---------7---------8---------9--------10 + +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 \ No newline at end of file