MCPcopy Create free account
hub / github.com/KDE/labplot / paintSection

Method paintSection

src/frontend/spreadsheet/SpreadsheetHeaderView.cpp:132–179  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

130}
131
132void SpreadsheetHeaderView::paintSection(QPainter* painter, const QRect& rect, int logicalIndex) const {
133 QRect master_rect = rect;
134 auto* model = m_sparklineSlave->getModel();
135 QPixmap pixmap = model->headerData(logicalIndex, Qt::Horizontal, static_cast<int>(SpreadsheetModel::CustomDataRole::SparkLineRole)).value<QPixmap>();
136
137 // Handle header painting for different sections
138 if (m_showComments && m_showSparklines) {
139 int totalHeight = m_commentSlave->sizeHint().height() + m_sparklineSlave->sizeHint().height();
140 master_rect = rect.adjusted(0, 0, 0, -totalHeight);
141 } else if (m_showComments || m_showSparklines) {
142 if (m_showComments)
143 master_rect = rect.adjusted(0, 0, 0, -m_commentSlave->sizeHint().height());
144 else
145 master_rect = rect.adjusted(0, 0, 0, -m_sparklineSlave->sizeHint().height());
146 }
147
148 painter->save();
149 QHeaderView::paintSection(painter, master_rect, logicalIndex);
150 painter->restore();
151
152 if (m_showComments && m_showSparklines && rect.height() > QHeaderView::sizeHint().height()) {
153 if (m_showSparklines) {
154 QRect slave2_rect = rect.adjusted(0, QHeaderView::sizeHint().height(), 0, -m_commentSlave->sizeHint().height());
155 painter->setClipping(false);
156 if (!pixmap.isNull())
157 painter->drawPixmap(slave2_rect, pixmap.scaled(slave2_rect.size(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
158 }
159
160 if (m_showComments) {
161 QRect slave_rect = rect.adjusted(0, m_sparklineSlave->sizeHint().height() + QHeaderView::sizeHint().height(), 0, 0);
162 m_commentSlave->paintSection(painter, slave_rect, logicalIndex);
163 }
164 return;
165 }
166
167 // If only one of the headers (sparkline or comment) is shown
168 if (m_showComments || m_showSparklines) {
169 if (m_showComments) {
170 QRect slave_rect = rect.adjusted(0, QHeaderView::sizeHint().height(), 0, 0);
171 m_commentSlave->paintSection(painter, slave_rect, logicalIndex);
172 } else if (m_showSparklines) {
173 QRect slave_rect = rect.adjusted(0, m_sparklineSlave->sizeHint().height(), 0, 0);
174 painter->setClipping(false);
175 if (!pixmap.isNull())
176 painter->drawPixmap(slave_rect, pixmap.scaled(slave_rect.size(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
177 }
178 }
179}
180
181/*!
182 Show or hide (if \c on = \c false) the column comments.

Callers

nothing calls this directly

Calls 7

getModelMethod · 0.80
heightMethod · 0.80
isNullMethod · 0.80
headerDataMethod · 0.45
sizeHintMethod · 0.45
saveMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected