| 283 | } |
| 284 | |
| 285 | void RDHeaderView::resizeSections(QHeaderView::ResizeMode mode) |
| 286 | { |
| 287 | if(!m_sectionStretchHints.isEmpty()) |
| 288 | { |
| 289 | resizeSectionsWithHints(); |
| 290 | return; |
| 291 | } |
| 292 | |
| 293 | if(!m_customSizing) |
| 294 | return QHeaderView::resizeSections(mode); |
| 295 | |
| 296 | if(mode != ResizeToContents) |
| 297 | return; |
| 298 | |
| 299 | QAbstractItemModel *m = this->model(); |
| 300 | |
| 301 | int rowCount = m->rowCount(); |
| 302 | |
| 303 | for(int col = 0; col < m_sections.count(); col++) |
| 304 | { |
| 305 | QSize sz; |
| 306 | |
| 307 | for(int row = 0; row < rowCount; row++) |
| 308 | { |
| 309 | QVariant v = m->data(m->index(row, col), Qt::SizeHintRole); |
| 310 | if(v.isValid() && v.canConvert<QSize>()) |
| 311 | sz = sz.expandedTo(v.value<QSize>()); |
| 312 | } |
| 313 | |
| 314 | int oldSize = m_sections[col].size; |
| 315 | |
| 316 | m_sections[col].size = sz.width(); |
| 317 | |
| 318 | emit sectionResized(col, oldSize, sz.width()); |
| 319 | } |
| 320 | } |
| 321 | |
| 322 | void RDHeaderView::resizeSections(const QList<int> &sizes) |
| 323 | { |
no test coverage detected