MCPcopy Create free account
hub / github.com/clementgallet/libTAS / drawHeader

Method drawHeader

src/external/qhexview/src/qhexview.cpp:554–675  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

552}
553
554void QHexView::drawHeader(QTextCursor& c) const {
555 if(m_options.hasFlag(QHexFlags::NoHeader))
556 return;
557
558 static const auto RESET_FORMAT = [](const QHexOptions& options,
559 QTextCharFormat& cf) {
560 cf = {};
561 cf.setForeground(options.headercolor);
562 };
563
564 QString addresslabel;
565 if(m_hexdelegate)
566 addresslabel = m_hexdelegate->addressHeader(this);
567 if(addresslabel.isEmpty() && !m_options.addresslabel.isEmpty())
568 addresslabel = m_options.addresslabel;
569
570 QTextCharFormat cf;
571 RESET_FORMAT(m_options, cf);
572 if(m_hexdelegate)
573 m_hexdelegate->renderHeaderPart(addresslabel, QHexArea::Address, cf,
574 this);
575 c.insertText(
576 " " + QHexView::reduced(addresslabel, this->addressWidth()) + " ", cf);
577
578 if(m_hexdelegate)
579 RESET_FORMAT(m_options, cf);
580
581 QString hexlabel;
582 if(m_hexdelegate)
583 hexlabel = m_hexdelegate->hexHeader(this);
584 if(hexlabel.isEmpty())
585 hexlabel = m_options.hexlabel;
586
587 if(hexlabel.isNull()) {
588 c.insertText(" ", {});
589
590 for(auto i = 0u; i < m_options.linelength; i += m_options.grouplength) {
591 QString h = QString::number(i, 16)
592 .rightJustified(m_options.grouplength * 2, '0')
593 .toUpper();
594
595 if(m_hexdelegate) {
596 RESET_FORMAT(m_options, cf);
597 m_hexdelegate->renderHeaderPart(h, QHexArea::Hex, cf, this);
598 }
599
600 if(m_hexcursor->column() == static_cast<qint64>(i) &&
601 m_options.hasFlag(QHexFlags::HighlightColumn)) {
602 cf.setBackground(this->palette().color(QPalette::Highlight));
603 cf.setForeground(
604 this->palette().color(QPalette::HighlightedText));
605 }
606
607 c.insertText(h, cf);
608 c.insertText(" ", {});
609 RESET_FORMAT(m_options, cf);
610 }
611 }

Callers 1

paintMethod · 0.95

Calls 15

addressWidthMethod · 0.95
hexColumnWidthMethod · 0.95
cellWidthMethod · 0.95
endColumnXMethod · 0.95
asciiColumnXMethod · 0.95
hasFlagMethod · 0.80
addressHeaderMethod · 0.80
renderHeaderPartMethod · 0.80
hexHeaderMethod · 0.80
columnMethod · 0.80
asciiHeaderMethod · 0.80
renderHeaderMethod · 0.80

Tested by

no test coverage detected