1417 if (d->minimumSectionSize == -1) { |
1417 if (d->minimumSectionSize == -1) { |
1418 QSize strut = QApplication::globalStrut(); |
1418 QSize strut = QApplication::globalStrut(); |
1419 int margin = style()->pixelMetric(QStyle::PM_HeaderMargin, 0, this); |
1419 int margin = style()->pixelMetric(QStyle::PM_HeaderMargin, 0, this); |
1420 if (d->orientation == Qt::Horizontal) |
1420 if (d->orientation == Qt::Horizontal) |
1421 return qMax(strut.width(), (fontMetrics().maxWidth() + margin)); |
1421 return qMax(strut.width(), (fontMetrics().maxWidth() + margin)); |
1422 return qMax(strut.height(), (fontMetrics().lineSpacing() + margin)); |
1422 return qMax(strut.height(), (fontMetrics().height() + margin)); |
1423 } |
1423 } |
1424 return d->minimumSectionSize; |
1424 return d->minimumSectionSize; |
1425 } |
1425 } |
1426 |
1426 |
1427 void QHeaderView::setMinimumSectionSize(int size) |
1427 void QHeaderView::setMinimumSectionSize(int size) |
1911 Q_D(QHeaderView); |
1911 Q_D(QHeaderView); |
1912 |
1912 |
1913 Q_ASSERT(start >= 0); |
1913 Q_ASSERT(start >= 0); |
1914 Q_ASSERT(end >= 0); |
1914 Q_ASSERT(end >= 0); |
1915 |
1915 |
1916 d->executePostedLayout(); |
|
1917 d->invalidateCachedSizeHint(); |
1916 d->invalidateCachedSizeHint(); |
1918 |
1917 |
1919 if (end + 1 < d->sectionCount) { |
1918 if (end + 1 < d->sectionCount) { |
1920 int newCount = end + 1; |
1919 int newCount = end + 1; |
1921 d->removeSectionsFromSpans(newCount, d->sectionCount); |
1920 d->removeSectionsFromSpans(newCount, d->sectionCount); |
1937 |
1936 |
1938 int oldCount = d->sectionCount; |
1937 int oldCount = d->sectionCount; |
1939 d->sectionCount = end + 1; |
1938 d->sectionCount = end + 1; |
1940 |
1939 |
1941 if (!d->logicalIndices.isEmpty()) { |
1940 if (!d->logicalIndices.isEmpty()) { |
1942 d->logicalIndices.resize(d->sectionCount); |
1941 if (oldCount <= d->sectionCount) { |
1943 d->visualIndices.resize(d->sectionCount); |
1942 d->logicalIndices.resize(d->sectionCount); |
1944 for (int i = start; i < d->sectionCount; ++i){ |
1943 d->visualIndices.resize(d->sectionCount); |
1945 d->logicalIndices[i] = i; |
1944 for (int i = oldCount; i < d->sectionCount; ++i) { |
1946 d->visualIndices[i] = i; |
1945 d->logicalIndices[i] = i; |
|
1946 d->visualIndices[i] = i; |
|
1947 } |
|
1948 } else { |
|
1949 int j = 0; |
|
1950 for (int i = 0; i < oldCount; ++i) { |
|
1951 int v = d->logicalIndices.at(i); |
|
1952 if (v < d->sectionCount) { |
|
1953 d->logicalIndices[j] = v; |
|
1954 d->visualIndices[v] = j; |
|
1955 j++; |
|
1956 } |
|
1957 } |
|
1958 d->logicalIndices.resize(d->sectionCount); |
|
1959 d->visualIndices.resize(d->sectionCount); |
1947 } |
1960 } |
1948 } |
1961 } |
1949 |
1962 |
1950 if (d->globalResizeMode == Stretch) |
1963 if (d->globalResizeMode == Stretch) |
1951 d->stretchSections = d->sectionCount; |
1964 d->stretchSections = d->sectionCount; |
2394 break; |
2407 break; |
2395 case QEvent::ContextMenu: { |
2408 case QEvent::ContextMenu: { |
2396 d->state = QHeaderViewPrivate::NoState; |
2409 d->state = QHeaderViewPrivate::NoState; |
2397 d->pressed = d->section = d->target = -1; |
2410 d->pressed = d->section = d->target = -1; |
2398 d->updateSectionIndicator(d->section, -1); |
2411 d->updateSectionIndicator(d->section, -1); |
2399 } |
2412 break; } |
|
2413 case QEvent::Wheel: { |
|
2414 QAbstractScrollArea *asa = qobject_cast<QAbstractScrollArea *>(parentWidget()); |
|
2415 if (asa) |
|
2416 return QApplication::sendEvent(asa->viewport(), e); |
|
2417 break; } |
2400 default: |
2418 default: |
2401 break; |
2419 break; |
2402 } |
2420 } |
2403 return QAbstractItemView::viewportEvent(e); |
2421 return QAbstractItemView::viewportEvent(e); |
2404 } |
2422 } |
2513 |
2531 |
2514 QSize QHeaderView::sectionSizeFromContents(int logicalIndex) const |
2532 QSize QHeaderView::sectionSizeFromContents(int logicalIndex) const |
2515 { |
2533 { |
2516 Q_D(const QHeaderView); |
2534 Q_D(const QHeaderView); |
2517 Q_ASSERT(logicalIndex >= 0); |
2535 Q_ASSERT(logicalIndex >= 0); |
|
2536 |
|
2537 ensurePolished(); |
2518 |
2538 |
2519 // use SizeHintRole |
2539 // use SizeHintRole |
2520 QVariant variant = d->model->headerData(logicalIndex, d->orientation, Qt::SizeHintRole); |
2540 QVariant variant = d->model->headerData(logicalIndex, d->orientation, Qt::SizeHintRole); |
2521 if (variant.isValid()) |
2541 if (variant.isValid()) |
2522 return qvariant_cast<QSize>(variant); |
2542 return qvariant_cast<QSize>(variant); |