#include <qheaderview.h>
Inheritance diagram for QHeaderView:


A QHeaderView displays the headers used in item views such as the QTableView and QTreeView classes. It takes the place of the QHeader class previously used for the same purpose, but uses the Qt's model/view architecture for consistency with the item view classes.
The QHeaderView class is one of the {Model/View Classes} and is part of Qt's {Model/View Programming}{model/view framework}.
The header gets the data for each section from the model using the QAbstractItemModel::headerData() function. You can set the data by using QAbstractItemModel::setHeaderData().
Each header has an orientation() and a number of sections, given by the count() function. Sections can be moved and resized using moveSection() and resizeSection(); they can be hidden and shown with hideSection() and showSection().
Each section of a header is described by a section ID, specified by its section(), and can be located at a particular visualIndex() in the header. A section can have a sort indicator set with setSortIndicator(); this indicates whether the items in the associated item view will be sorted in the order given by the section.
A header can be fixed in place, or made movable with setMovable(). It can be made clickable with setClickable(), and has resizing behavior in accordance with setResizeMode().
A header emits sectionMoved() if the user moves a section, sectionResized() if the user resizes a section, and sectionClicked() and sectionHandleDoubleClicked() in response to mouse clicks. A header also emits sectionCountChanged() and sectionAutoResize().
You can identify a section using the logicalIndex() and logicalIndexAt() functions, or by its index position, using the visualIndex() and visualIndexAt() functions. The visual index will change if a section is moved while the logical index wont change.
For a horizontal header the section is equivalent to a column in the model, and for a vertical header the section is equivalent to a row in the model.
Definition at line 37 of file qheaderview.h.
Public Types | |
| enum | ResizeMode |
Public Slots | |
| void | setOffset (int offset) |
| void | setOffsetToSectionPosition (int visualIndex) |
| void | headerDataChanged (Qt::Orientation orientation, int logicalFirst, int logicalLast) |
Signals | |
| void | sectionMoved (int logicalIndex, int oldVisualIndex, int newVisualIndex) |
| void | sectionResized (int logicalIndex, int oldSize, int newSize) |
| void | sectionPressed (int logicalIndex) |
| void | sectionClicked (int logicalIndex) |
| void | sectionDoubleClicked (int logicalIndex) |
| void | sectionCountChanged (int oldCount, int newCount) |
| void | sectionHandleDoubleClicked (int logicalIndex) |
| void | sectionAutoResize (int logicalIndex, QHeaderView::ResizeMode mode) |
| void | geometriesChanged () |
Public Member Functions | |
| QHeaderView (Qt::Orientation orientation, QWidget *parent=0) | |
| virtual | ~QHeaderView () |
| void | setModel (QAbstractItemModel *model) |
| Qt::Orientation | orientation () const |
| int | offset () const |
| int | length () const |
| QSize | sizeHint () const |
| int | sectionSizeHint (int logicalIndex) const |
| int | visualIndexAt (int position) const |
| int | logicalIndexAt (int position) const |
| int | logicalIndexAt (int x, int y) const |
| int | logicalIndexAt (const QPoint &pos) const |
| int | sectionSize (int logicalIndex) const |
| int | sectionPosition (int logicalIndex) const |
| int | sectionViewportPosition (int logicalIndex) const |
| void | moveSection (int from, int to) |
| void | swapSections (int first, int second) |
| void | resizeSection (int logicalIndex, int size) |
| void | resizeSections (QHeaderView::ResizeMode mode) |
| bool | isSectionHidden (int logicalIndex) const |
| void | setSectionHidden (int logicalIndex, bool hide) |
| int | hiddenSectionCount () const |
| void | hideSection (int logicalIndex) |
| void | showSection (int logicalIndex) |
| int | count () const |
| int | visualIndex (int logicalIndex) const |
| int | logicalIndex (int visualIndex) const |
| void | setMovable (bool movable) |
| bool | isMovable () const |
| void | setClickable (bool clickable) |
| bool | isClickable () const |
| void | setHighlightSections (bool highlight) |
| bool | highlightSections () const |
| void | setResizeMode (ResizeMode mode) |
| void | setResizeMode (int logicalIndex, ResizeMode mode) |
| ResizeMode | resizeMode (int logicalIndex) const |
| int | stretchSectionCount () const |
| void | setSortIndicatorShown (bool show) |
| bool | isSortIndicatorShown () const |
| void | setSortIndicator (int logicalIndex, Qt::SortOrder order) |
| int | sortIndicatorSection () const |
| Qt::SortOrder | sortIndicatorOrder () const |
| bool | stretchLastSection () const |
| void | setStretchLastSection (bool stretch) |
| bool | cascadingSectionResizes () const |
| void | setCascadingSectionResizes (bool enable) |
| int | defaultSectionSize () const |
| void | setDefaultSectionSize (int size) |
| int | minimumSectionSize () const |
| void | setMinimumSectionSize (int size) |
| Qt::Alignment | defaultAlignment () const |
| void | setDefaultAlignment (Qt::Alignment alignment) |
| void | doItemsLayout () |
| bool | sectionsMoved () const |
| bool | sectionsHidden () const |
Protected Slots | |
| void | updateSection (int logicalIndex) |
| void | resizeSections () |
| void | sectionsInserted (const QModelIndex &parent, int logicalFirst, int logicalLast) |
| void | sectionsAboutToBeRemoved (const QModelIndex &parent, int logicalFirst, int logicalLast) |
Protected Member Functions | |
| QHeaderView (QHeaderViewPrivate &dd, Qt::Orientation orientation, QWidget *parent=0) | |
| void | initialize () |
| void | initializeSections () |
| void | initializeSections (int start, int end) |
| void | currentChanged (const QModelIndex ¤t, const QModelIndex &old) |
| bool | event (QEvent *e) |
| void | paintEvent (QPaintEvent *e) |
| void | mousePressEvent (QMouseEvent *e) |
| void | mouseMoveEvent (QMouseEvent *e) |
| void | mouseReleaseEvent (QMouseEvent *e) |
| void | mouseDoubleClickEvent (QMouseEvent *e) |
| bool | viewportEvent (QEvent *e) |
| virtual void | paintSection (QPainter *painter, const QRect &rect, int logicalIndex) const |
| virtual QSize | sectionSizeFromContents (int logicalIndex) const |
| int | horizontalOffset () const |
| int | verticalOffset () const |
| void | updateGeometries () |
| void | scrollContentsBy (int dx, int dy) |
| void | dataChanged (const QModelIndex &topLeft, const QModelIndex &bottomRight) |
| void | rowsInserted (const QModelIndex &parent, int start, int end) |
| QRect | visualRect (const QModelIndex &index) const |
| void | scrollTo (const QModelIndex &index, ScrollHint hint) |
| QModelIndex | indexAt (const QPoint &p) const |
| bool | isIndexHidden (const QModelIndex &index) const |
| QModelIndex | moveCursor (CursorAction, Qt::KeyboardModifiers) |
| void | setSelection (const QRect &, QItemSelectionModel::SelectionFlags) |
| QRegion | visualRegionForSelection (const QItemSelection &selection) const |
The resize mode specifies the behavior of the header sections. It can be set on the entire header view or on individual sections using setResizeMode().
Interactive The user can resize the section. The section can also be resized programmatically using resizeSection(). The section size defaults to defaultSectionSize. (See also cascadingSectionResizes.)
Fixed The user cannot resize the section. The section can only be resized programmatically using resizeSection(). The section size defaults to defaultSectionSize.
Stretch QHeaderView will automatically resize the section to fill the available space. The size cannot be changed by the user or programmatically.
ResizeToContents QHeaderView will automatically resize the section to its optimal size based on the contents of the entire column or row. The size cannot be changed by the user or programmatically.
The following values are obsolete: Custom Use Fixed instead.
Definition at line 51 of file qheaderview.h.
00052 { 00053 Interactive, 00054 Stretch, 00055 Fixed, 00056 Custom = Fixed, 00057 ResizeToContents 00058 };
| QHeaderView::QHeaderView | ( | Qt::Orientation | orientation, | |
| QWidget * | parent = 0 | |||
| ) | [explicit] |
Creates a new generic header with the given orientation and parent.
Definition at line 221 of file qheaderview.cpp.
References d, and initialize().
00222 : QAbstractItemView(*new QHeaderViewPrivate, parent) 00223 { 00224 Q_D(QHeaderView); 00225 d->setDefaultValues(orientation); 00226 initialize(); 00227 }
Here is the call graph for this function:

| QHeaderView::~QHeaderView | ( | ) | [virtual] |
| QHeaderView::QHeaderView | ( | QHeaderViewPrivate & | dd, | |
| Qt::Orientation | orientation, | |||
| QWidget * | parent = 0 | |||
| ) | [protected] |
Definition at line 232 of file qheaderview.cpp.
References d, and initialize().
00234 : QAbstractItemView(dd, parent) 00235 { 00236 Q_D(QHeaderView); 00237 d->setDefaultValues(orientation); 00238 initialize(); 00239 }
Here is the call graph for this function:

| void QHeaderView::setModel | ( | QAbstractItemModel * | model | ) | [virtual] |
Reimplemented from QAbstractItemView.
Definition at line 267 of file qheaderview.cpp.
References QObject::connect(), d, QObject::disconnect(), headerDataChanged(), Qt::Horizontal, initializeSections(), QAbstractItemView::model(), QAbstractItemView::rowsAboutToBeRemoved(), rowsInserted(), sectionsAboutToBeRemoved(), sectionsInserted(), QAbstractItemView::setModel(), SIGNAL, and SLOT.
00268 { 00269 // Don't optimize away: 00270 // if (model == this->model()) 00271 // return; 00272 // This is the only way to reset moved sections 00273 Q_D(QHeaderView); 00274 if (d->orientation == Qt::Horizontal) { 00275 QObject::disconnect(d->model, SIGNAL(columnsInserted(QModelIndex,int,int)), 00276 this, SLOT(sectionsInserted(QModelIndex,int,int))); 00277 QObject::disconnect(d->model, SIGNAL(columnsAboutToBeRemoved(QModelIndex,int,int)), 00278 this, SLOT(sectionsAboutToBeRemoved(QModelIndex,int,int))); 00279 QObject::disconnect(d->model, SIGNAL(columnsRemoved(QModelIndex,int,int)), 00280 this, SLOT(_q_sectionsRemoved(QModelIndex,int,int))); 00281 } else { 00282 QObject::disconnect(d->model, SIGNAL(rowsInserted(QModelIndex,int,int)), 00283 this, SLOT(sectionsInserted(QModelIndex,int,int))); 00284 QObject::disconnect(d->model, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)), 00285 this, SLOT(sectionsAboutToBeRemoved(QModelIndex,int,int))); 00286 QObject::disconnect(d->model, SIGNAL(rowsRemoved(QModelIndex,int,int)), 00287 this, SLOT(_q_sectionsRemoved(QModelIndex,int,int))); 00288 } 00289 QObject::disconnect(d->model, SIGNAL(headerDataChanged(Qt::Orientation,int,int)), 00290 this, SLOT(headerDataChanged(Qt::Orientation,int,int))); 00291 00292 if (model) { 00293 if (d->orientation == Qt::Horizontal) { 00294 QObject::connect(model, SIGNAL(columnsInserted(QModelIndex,int,int)), 00295 this, SLOT(sectionsInserted(QModelIndex,int,int))); 00296 QObject::connect(model, SIGNAL(columnsAboutToBeRemoved(QModelIndex,int,int)), 00297 this, SLOT(sectionsAboutToBeRemoved(QModelIndex,int,int))); 00298 QObject::connect(model, SIGNAL(columnsRemoved(QModelIndex,int,int)), 00299 this, SLOT(_q_sectionsRemoved(QModelIndex,int,int))); 00300 } else { 00301 QObject::connect(model, SIGNAL(rowsInserted(QModelIndex,int,int)), 00302 this, SLOT(sectionsInserted(QModelIndex,int,int))); 00303 QObject::connect(model, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)), 00304 this, SLOT(sectionsAboutToBeRemoved(QModelIndex,int,int))); 00305 QObject::connect(model, SIGNAL(rowsRemoved(QModelIndex,int,int)), 00306 this, SLOT(_q_sectionsRemoved(QModelIndex,int,int))); 00307 } 00308 QObject::connect(model, SIGNAL(headerDataChanged(Qt::Orientation,int,int)), 00309 this, SLOT(headerDataChanged(Qt::Orientation,int,int))); 00310 } 00311 d->clear(); 00312 00313 QAbstractItemView::setModel(model); 00314 // Users want to set sizes and modes before the widget is shown. 00315 // Thus, we have to initialize when the model is set, 00316 // and not lazily like we do in the other views. 00317 initializeSections(); 00318 }
Here is the call graph for this function:

| Qt::Orientation QHeaderView::orientation | ( | ) | const |
Returns the orientation of the header.
Definition at line 326 of file qheaderview.cpp.
References d.
Referenced by horizontalOffset(), minimumSectionSize(), mouseDoubleClickEvent(), mouseMoveEvent(), mousePressEvent(), mouseReleaseEvent(), paintEvent(), paintSection(), resizeSection(), sectionSizeFromContents(), updateSection(), verticalOffset(), viewportEvent(), and visualRegionForSelection().
00327 { 00328 Q_D(const QHeaderView); 00329 return d->orientation; 00330 }
| int QHeaderView::offset | ( | ) | const |
Returns the offset of the header: this is the header's left-most (or top-most for vertical headers) visible pixel.
Definition at line 339 of file qheaderview.cpp.
References d.
Referenced by QTreeView::drawRow(), paintEvent(), and QTableView::paintEvent().
00340 { 00341 Q_D(const QHeaderView); 00342 return d->offset; 00343 }
| int QHeaderView::length | ( | ) | const |
Returns the length along the orientation of the header.
Definition at line 396 of file qheaderview.cpp.
References d.
Referenced by QTreeView::drawRow(), QTableView::paintEvent(), and QTreeViewPrivate::updateScrollBars().
00397 { 00398 Q_D(const QHeaderView); 00399 //Q_ASSERT(d->headerLength() == d->length); 00400 return d->length; 00401 }
| QSize QHeaderView::sizeHint | ( | ) | const [virtual] |
Returns a suitable size hint for this header.
Reimplemented from QAbstractScrollArea.
Definition at line 409 of file qheaderview.cpp.
References c, count(), d, QWidget::height(), i, j, qMax(), qMin(), sectionSizeFromContents(), and QWidget::width().
00410 { 00411 Q_D(const QHeaderView); 00412 if (count() < 1) 00413 return QSize(0, 0); 00414 if (d->cachedSizeHint.isValid()) 00415 return d->cachedSizeHint; 00416 int width = 0; 00417 int height = 0; 00418 // get size hint for the first n sections 00419 int c = qMin(count(), 100); 00420 for (int i = 0; i < c; ++i) { 00421 QSize hint = sectionSizeFromContents(i); 00422 width = qMax(hint.width(), width); 00423 height = qMax(hint.height(), height); 00424 } 00425 // get size hint for the last n sections 00426 c = qMax(count() - 100, c); 00427 for (int j = count() - 1; j >= c; --j) { 00428 QSize hint = sectionSizeFromContents(j); 00429 width = qMax(hint.width(), width); 00430 height = qMax(hint.height(), height); 00431 } 00432 d->cachedSizeHint = QSize(width, height); 00433 return d->cachedSizeHint; 00434 }
Here is the call graph for this function:

| int QHeaderView::sectionSizeHint | ( | int | logicalIndex | ) | const |
Returns a suitable size hint for the section specified by logicalIndex.
Definition at line 442 of file qheaderview.cpp.
References count(), d, QSize::height(), Qt::Horizontal, minimumSectionSize(), qMax(), sectionSizeFromContents(), QWidget::size(), and QSize::width().
Referenced by initializeSections().
00443 { 00444 Q_D(const QHeaderView); 00445 if (logicalIndex < 0 || logicalIndex >= count()) 00446 return -1; 00447 QSize size = sectionSizeFromContents(logicalIndex); 00448 int hint = d->orientation == Qt::Horizontal ? size.width() : size.height(); 00449 return qMax(minimumSectionSize(), hint); 00450 }
Here is the call graph for this function:

| int QHeaderView::visualIndexAt | ( | int | position | ) | const |
Returns the visual index of the section that covers the given position in the viewport.
Definition at line 458 of file qheaderview.cpp.
Referenced by logicalIndexAt(), mouseMoveEvent(), paintEvent(), QTableView::paintEvent(), and QTreeViewPrivate::startAndEndColumns().
00459 { 00460 Q_D(const QHeaderView); 00461 uint vposition = position; 00462 d->executePostedLayout(); 00463 const int count = d->sectionCount; 00464 if (count < 1) 00465 return -1; 00466 00467 if (d->reverse()) 00468 vposition = d->viewport->width() - vposition; 00469 vposition += d->offset; 00470 00471 if (vposition > d->length) 00472 return -1; 00473 int visual = d->headerVisualIndexAt(vposition); 00474 if (visual < 0) 00475 return -1; 00476 00477 while (d->isVisualIndexHidden(visual)){ 00478 ++visual; 00479 if (visual >= count) 00480 return -1; 00481 } 00482 return visual; 00483 }
Here is the call graph for this function:

| int QHeaderView::logicalIndexAt | ( | int | position | ) | const |
Returns the section that covers the given position in the viewport.
Definition at line 491 of file qheaderview.cpp.
References logicalIndex(), and visualIndexAt().
Referenced by QTreeViewPrivate::columnAt(), event(), QTreeViewPrivate::itemDecorationAt(), logicalIndexAt(), mouseDoubleClickEvent(), mousePressEvent(), mouseReleaseEvent(), and viewportEvent().
00492 { 00493 const int visual = visualIndexAt(position); 00494 if (visual > -1) 00495 return logicalIndex(visual); 00496 return -1; 00497 }
Here is the call graph for this function:

| int QHeaderView::logicalIndexAt | ( | int | x, | |
| int | y | |||
| ) | const [inline] |
Returns the logical index of the section at the given coordinate. If the header is horizontal x will be used, otherwise y will be used to find the logical index.
Definition at line 202 of file qheaderview.h.
References Qt::Horizontal.
00203 { return orientation() == Qt::Horizontal ? logicalIndexAt(ax) : logicalIndexAt(ay); }
| int QHeaderView::logicalIndexAt | ( | const QPoint & | pos | ) | const [inline] |
Returns the logical index of the section at the position given in pos. If the header is horizontal the x-coordinate will be used to find the logical index; otherwise the y-coordinate will be used.
Definition at line 204 of file qheaderview.h.
References logicalIndexAt(), QPoint::x(), and QPoint::y().
00205 { return logicalIndexAt(apos.x(), apos.y()); }
Here is the call graph for this function:

| int QHeaderView::sectionSize | ( | int | logicalIndex | ) | const |
Returns the width (or height for vertical headers) of the given logicalIndex.
Definition at line 505 of file qheaderview.cpp.
References count(), d, isSectionHidden(), and visualIndex().
Referenced by currentChanged(), QTreeView::drawRow(), headerDataChanged(), QTreeViewPrivate::itemDecorationAt(), mousePressEvent(), paintEvent(), QTableView::paintEvent(), resizeSection(), sectionViewportPosition(), setSectionHidden(), QTreeViewPrivate::updateScrollBars(), updateSection(), and visualRegionForSelection().
00506 { 00507 Q_D(const QHeaderView); 00508 if (logicalIndex < 0 || logicalIndex >= count()) 00509 return 0; 00510 if (isSectionHidden(logicalIndex)) 00511 return 0; 00512 int visual = visualIndex(logicalIndex); 00513 if (visual == -1) 00514 return 0; 00515 return d->headerSectionSize(visual); 00516 }
Here is the call graph for this function:

| int QHeaderView::sectionPosition | ( | int | logicalIndex | ) | const |
Returns the section position of the given logicalIndex, or -1 if the section is hidden.
Definition at line 525 of file qheaderview.cpp.
References d, and visualIndex().
Referenced by sectionViewportPosition().
00526 { 00527 Q_D(const QHeaderView); 00528 int visual = visualIndex(logicalIndex); 00529 // in some cases users may change the selections 00530 // before we have a chance to do the layout 00531 if (visual == -1) 00532 return -1; 00533 return d->headerSectionPosition(visual); 00534 }
Here is the call graph for this function:

| int QHeaderView::sectionViewportPosition | ( | int | logicalIndex | ) | const |
Returns the section viewport position of the given logicalIndex.
If the section is hidden, this function returns an undefined value.
Definition at line 544 of file qheaderview.cpp.
References count(), d, sectionPosition(), and sectionSize().
Referenced by currentChanged(), headerDataChanged(), QTreeViewPrivate::itemDecorationAt(), paintEvent(), resizeSection(), updateSection(), visualRegionForSelection(), and QTableViewPrivate::visualSpanRect().
00545 { 00546 Q_D(const QHeaderView); 00547 if (logicalIndex < 0 || logicalIndex >= count()) 00548 return -1; 00549 int position = sectionPosition(logicalIndex); 00550 if (position < 0) 00551 return position; // the section was hidden 00552 int offsetPosition = position - d->offset; 00553 if (d->reverse()) 00554 return d->viewport->width() - (offsetPosition + sectionSize(logicalIndex)); 00555 return offsetPosition; 00556 }
Here is the call graph for this function:

| void QHeaderView::moveSection | ( | int | from, | |
| int | to | |||
| ) |
Moves the section at visual index from to occupy visual index to.
Definition at line 582 of file qheaderview.cpp.
References d, emit, QBitArray::isEmpty(), logicalIndex(), sectionMoved(), QBitArray::setBit(), QWidget::size(), QBitArray::testBit(), and updateSection().
Referenced by mouseReleaseEvent().
00583 { 00584 Q_D(QHeaderView); 00585 00586 d->executePostedLayout(); 00587 if (from < 0 || from >= d->sectionCount || to < 0 || to >= d->sectionCount) 00588 return; 00589 00590 if (from == to) { 00591 int logical = logicalIndex(from); 00592 Q_ASSERT(logical != -1); 00593 updateSection(logical); 00594 return; 00595 } 00596 00597 //int oldHeaderLength = length(); // ### for debugging; remove later 00598 d->initializeIndexMapping(); 00599 00600 QBitArray sectionHidden = d->sectionHidden; 00601 int *visualIndices = d->visualIndices.data(); 00602 int *logicalIndices = d->logicalIndices.data(); 00603 int logical = logicalIndices[from]; 00604 int visual = from; 00605 00606 int affected_count = qAbs(to - from) + 1; 00607 QVarLengthArray<int> sizes(affected_count); 00608 QVarLengthArray<ResizeMode> modes(affected_count); 00609 00610 // move sections and indices 00611 if (to > from) { 00612 sizes[to - from] = d->headerSectionSize(from); 00613 modes[to - from] = d->headerSectionResizeMode(from); 00614 while (visual < to) { 00615 sizes[visual - from] = d->headerSectionSize(visual + 1); 00616 modes[visual - from] = d->headerSectionResizeMode(visual + 1); 00617 if (!sectionHidden.isEmpty()) 00618 sectionHidden.setBit(visual, sectionHidden.testBit(visual + 1)); 00619 visualIndices[logicalIndices[visual + 1]] = visual; 00620 logicalIndices[visual] = logicalIndices[visual + 1]; 00621 ++visual; 00622 } 00623 } else { 00624 sizes[0] = d->headerSectionSize(from); 00625 modes[0] = d->headerSectionResizeMode(from); 00626 while (visual > to) { 00627 sizes[visual - to] = d->headerSectionSize(visual - 1); 00628 modes[visual - to] = d->headerSectionResizeMode(visual - 1); 00629 if (!sectionHidden.isEmpty()) 00630 sectionHidden.setBit(visual, sectionHidden.testBit(visual - 1)); 00631 visualIndices[logicalIndices[visual - 1]] = visual; 00632 logicalIndices[visual] = logicalIndices[visual - 1]; 00633 --visual; 00634 } 00635 } 00636 if (!sectionHidden.isEmpty()) { 00637 sectionHidden.setBit(to, d->sectionHidden.testBit(from)); 00638 d->sectionHidden = sectionHidden; 00639 } 00640 visualIndices[logical] = to; 00641 logicalIndices[to] = logical; 00642 00643 //Q_ASSERT(oldHeaderLength == length()); 00644 // move sizes 00645 // ### check for spans of section sizes here 00646 if (to > from) { 00647 for (visual = from; visual <= to; ++visual) { 00648 int size = sizes[visual - from]; 00649 ResizeMode mode = modes[visual - from]; 00650 d->createSectionSpan(visual, visual, size, mode); 00651 } 00652 } else { 00653 for (visual = to; visual <= from; ++visual) { 00654 int size = sizes[visual - to]; 00655 ResizeMode mode = modes[visual - to]; 00656 d->createSectionSpan(visual, visual, size, mode); 00657 } 00658 } 00659 //Q_ASSERT(d->headerLength() == length()); 00660 //Q_ASSERT(oldHeaderLength == length()); 00661 00662 d->viewport->update(); 00663 emit sectionMoved(logical, from, to); 00664 }
Here is the call graph for this function:

| void QHeaderView::swapSections | ( | int | first, | |
| int | second | |||
| ) |
Definition at line 672 of file qheaderview.cpp.
References d, emit, and sectionMoved().
00673 { 00674 Q_D(QHeaderView); 00675 00676 if (first == second) 00677 return; 00678 d->executePostedLayout(); 00679 if (first < 0 || first >= d->sectionCount || second < 0 || second >= d->sectionCount) 00680 return; 00681 00682 int firstSize = d->headerSectionSize(first); 00683 ResizeMode firstMode = d->headerSectionResizeMode(first); 00684 int firstLogical = d->logicalIndex(first); 00685 00686 int secondSize = d->headerSectionSize(second); 00687 ResizeMode secondMode = d->headerSectionResizeMode(second); 00688 int secondLogical = d->logicalIndex(second); 00689 00690 d->createSectionSpan(second, second, firstSize, firstMode); 00691 d->createSectionSpan(first, first, secondSize, secondMode); 00692 00693 d->initializeIndexMapping(); 00694 00695 d->visualIndices[firstLogical] = second; 00696 d->logicalIndices[second] = firstLogical; 00697 00698 d->visualIndices[secondLogical] = first; 00699 d->logicalIndices[first] = secondLogical; 00700 00701 if (!d->sectionHidden.isEmpty()) { 00702 bool firstHidden = d->sectionHidden.testBit(first); 00703 bool secondHidden = d->sectionHidden.testBit(second); 00704 d->sectionHidden.setBit(first, secondHidden); 00705 d->sectionHidden.setBit(second, firstHidden); 00706 } 00707 00708 d->viewport->update(); 00709 emit sectionMoved(firstLogical, first, second); 00710 emit sectionMoved(secondLogical, second, first); 00711 }
| void QHeaderView::resizeSection | ( | int | logicalIndex, | |
| int | size | |||
| ) |
Resizes the section specified by logicalIndex to the size measured in pixels.
Definition at line 721 of file qheaderview.cpp.
References count(), d, emit, h, Qt::Horizontal, QWidget::isRightToLeft(), isSectionHidden(), QRect::normalized(), orientation(), QWidget::pos(), resizeSections(), sectionResized(), sectionSize(), sectionViewportPosition(), QRect::setRect(), stretchLastSection(), visualIndex(), and w.
Referenced by MainWindow::createImagesGroupBox(), LocationDialog::LocationDialog(), mouseMoveEvent(), MessagesTreeView::setModel(), setSectionHidden(), setStretchLastSection(), and QFileDialogPrivate::setupTreeView().
00722 { 00723 Q_D(QHeaderView); 00724 if (logical < 0 || logical >= count()) 00725 return; 00726 00727 if (isSectionHidden(logical)) 00728 return; 00729 00730 int oldSize = sectionSize(logical); 00731 if (oldSize == size) 00732 return; 00733 00734 d->executePostedLayout(); 00735 d->invalidateCachedSizeHint(); 00736 00737 int visual = visualIndex(logical); 00738 Q_ASSERT(visual != -1); 00739 00740 if (stretchLastSection() && visual == count() - 1) 00741 d->lastSectionSize = size; 00742 00743 if (size != oldSize) 00744 d->createSectionSpan(visual, visual, size, d->headerSectionResizeMode(visual)); 00745 00746 int w = d->viewport->width(); 00747 int h = d->viewport->height(); 00748 int pos = sectionViewportPosition(logical); 00749 QRect r; 00750 if (orientation() == Qt::Horizontal) 00751 if (isRightToLeft()) 00752 r.setRect(0, 0, pos + size, h); 00753 else 00754 r.setRect(pos, 0, w - pos, h); 00755 else 00756 r.setRect(0, pos, w, h - pos); 00757 00758 if (d->hasAutoResizeSections()) { 00759 resizeSections(); 00760 r = d->viewport->rect(); 00761 } 00762 d->viewport->update(r.normalized()); 00763 emit sectionResized(logical, oldSize, size); 00764 }
Here is the call graph for this function:

| void QHeaderView::resizeSections | ( | QHeaderView::ResizeMode | mode | ) |
Resizes the sections according to the given mode, ignoring the current resize mode.
Definition at line 773 of file qheaderview.cpp.
References d.
00774 { 00775 Q_D(QHeaderView); 00776 d->resizeSections(mode, true); 00777 }
| bool QHeaderView::isSectionHidden | ( | int | logicalIndex | ) | const |
Returns true if the section specified by logicalIndex is explicitly hidden from the user; otherwise returns false.
Definition at line 800 of file qheaderview.cpp.
References d, and visualIndex().
Referenced by QTreeView::drawRow(), QTableViewPrivate::isHidden(), mouseDoubleClickEvent(), mousePressEvent(), QTableView::paintEvent(), resizeSection(), sectionSize(), and QTableViewPrivate::trimHiddenSelections().
00801 { 00802 Q_D(const QHeaderView); 00803 if (logicalIndex >= d->sectionHidden.count() || logicalIndex < 0 || logicalIndex >= d->sectionCount) 00804 return false; 00805 d->executePostedLayout(); 00806 int visual = visualIndex(logicalIndex); 00807 Q_ASSERT(visual != -1); 00808 return d->sectionHidden.testBit(visual); 00809 }
Here is the call graph for this function:

| void QHeaderView::setSectionHidden | ( | int | logicalIndex, | |
| bool | hide | |||
| ) |
If hide is true the section specified by logicalIndex is hidden, otherwise the section is shown.
Definition at line 831 of file qheaderview.cpp.
References count(), d, resizeSection(), resizeSections(), sectionSize(), QWidget::size(), and visualIndex().
Referenced by hideSection(), and showSection().
00832 { 00833 Q_D(QHeaderView); 00834 if (logicalIndex < 0 || logicalIndex >= count()) 00835 return; 00836 00837 d->executePostedLayout(); 00838 int visual = visualIndex(logicalIndex); 00839 Q_ASSERT(visual != -1); 00840 if (hide && d->isVisualIndexHidden(visual)) 00841 return; 00842 if (hide) { 00843 int size = sectionSize(logicalIndex); 00844 if (!d->hasAutoResizeSections()) 00845 resizeSection(logicalIndex, 0); 00846 d->hiddenSectionSize.insert(logicalIndex, size); 00847 if (d->sectionHidden.count() < count()) 00848 d->sectionHidden.resize(count()); 00849 d->sectionHidden.setBit(visual, true); 00850 if (d->hasAutoResizeSections()) 00851 resizeSections(); 00852 } else if (d->isVisualIndexHidden(visual)) { 00853 int size = d->hiddenSectionSize.value(logicalIndex, d->defaultSectionSize); 00854 d->hiddenSectionSize.remove(logicalIndex); 00855 if (d->hiddenSectionSize.isEmpty()) { 00856 d->sectionHidden.clear(); 00857 } else { 00858 Q_ASSERT(visual <= d->sectionHidden.count()); 00859 d->sectionHidden.setBit(visual, false); 00860 } 00861 resizeSection(logicalIndex, size); 00862 } 00863 }
Here is the call graph for this function:

| int QHeaderView::hiddenSectionCount | ( | ) | const |
Definition at line 818 of file qheaderview.cpp.
References d.
00819 { 00820 Q_D(const QHeaderView); 00821 return d->hiddenSectionSize.count(); 00822 }
| void QHeaderView::hideSection | ( | int | logicalIndex | ) | [inline] |
Hides the section specified by logicalIndex.
Definition at line 206 of file qheaderview.h.
References setSectionHidden().
00207 { setSectionHidden(alogicalIndex, true); }
Here is the call graph for this function:

| void QHeaderView::showSection | ( | int | logicalIndex | ) | [inline] |
Shows the section specified by logicalIndex.
Definition at line 208 of file qheaderview.h.
References setSectionHidden().
00209 { setSectionHidden(alogicalIndex, false); }
Here is the call graph for this function:

| int QHeaderView::count | ( | ) | const |
Returns the number of sections in the header.
Definition at line 871 of file qheaderview.cpp.
References d.
Referenced by QAccessibleHeader::childCount(), QTreeView::drawRow(), headerDataChanged(), initializeSections(), paintEvent(), QTableView::paintEvent(), paintSection(), resizeSection(), sectionsInserted(), sectionSize(), sectionSizeHint(), sectionViewportPosition(), setResizeMode(), setSectionHidden(), setSortIndicatorShown(), setStretchLastSection(), sizeHint(), QTreeViewPrivate::startAndEndColumns(), QTreeViewPrivate::updateScrollBars(), visualIndexAt(), and visualRegionForSelection().
00872 { 00873 Q_D(const QHeaderView); 00874 //Q_ASSERT(d->sectionCount == d->headerSectionCount()); 00875 // ### this may affect the lazy layout 00876 d->executePostedLayout(); 00877 return d->sectionCount; 00878 }
| int QHeaderView::visualIndex | ( | int | logicalIndex | ) | const |
Returns the visual index position of the section specified by the given logicalIndex, or -1 otherwise. Hidden sections still have valid visual indexes.
Definition at line 888 of file qheaderview.cpp.
References d.
Referenced by isSectionHidden(), mouseMoveEvent(), mouseReleaseEvent(), paintSection(), resizeMode(), resizeSection(), sectionPosition(), sectionSize(), setResizeMode(), setSectionHidden(), QTableWidget::visualColumn(), QTableViewPrivate::visualColumn(), visualRegionForSelection(), QTableWidget::visualRow(), and QTableViewPrivate::visualRow().
00889 { 00890 Q_D(const QHeaderView); 00891 if (logicalIndex < 0) 00892 return -1; 00893 d->executePostedLayout(); 00894 if (d->visualIndices.isEmpty()) { // nothing has been moved, so we have no mapping 00895 if (logicalIndex < d->sectionCount) 00896 return logicalIndex; 00897 } else if (logicalIndex < d->visualIndices.count()) { 00898 int visual = d->visualIndices.at(logicalIndex); 00899 Q_ASSERT(visual < d->sectionCount); 00900 return visual; 00901 } 00902 return -1; 00903 }
| int QHeaderView::logicalIndex | ( | int | visualIndex | ) | const |
Returns the logicalIndex for the section at the given visualIndex position, or -1 otherwise.
Definition at line 912 of file qheaderview.cpp.
References d.
Referenced by QTreeView::drawRow(), initializeSections(), QTableViewPrivate::logicalColumn(), logicalIndexAt(), QTableViewPrivate::logicalRow(), moveSection(), paintEvent(), QTableView::paintEvent(), QTreeViewPrivate::updateScrollBars(), and visualRegionForSelection().
00913 { 00914 Q_D(const QHeaderView); 00915 if (visualIndex < 0 || visualIndex >= d->sectionCount) 00916 return -1; 00917 return d->logicalIndex(visualIndex); 00918 }
| void QHeaderView::setMovable | ( | bool | movable | ) |
If movable is true, the header may be moved by the user; otherwise it is fixed in place.
Definition at line 928 of file qheaderview.cpp.
References d.
Referenced by QTreeViewPrivate::initialize(), main(), and MessagesTreeView::MessagesTreeView().
00929 { 00930 Q_D(QHeaderView); 00931 d->movableSections = movable; 00932 }
| bool QHeaderView::isMovable | ( | ) | const |
Returns true if the header can be moved by the user; otherwise returns false.
Definition at line 942 of file qheaderview.cpp.
References d.
00943 { 00944 Q_D(const QHeaderView); 00945 return d->movableSections; 00946 }
| void QHeaderView::setClickable | ( | bool | clickable | ) |
If clickable is true, the header will respond to single clicks.
Definition at line 955 of file qheaderview.cpp.
References d.
Referenced by QTableViewPrivate::init(), MessageEditor::MessageEditor(), MessagesTreeView::MessagesTreeView(), QTreeWidget::QTreeWidget(), MessagesTreeView::setModel(), QTreeView::setSortingEnabled(), and QFileDialogPrivate::setupTreeView().
00956 { 00957 Q_D(QHeaderView); 00958 d->clickableSections = clickable; 00959 }
| bool QHeaderView::isClickable | ( | ) | const |
Returns true if the header is clickable; otherwise returns false. A clickable header could be set up to allow the user to change the representation of the data in the view related to the header.
Definition at line 970 of file qheaderview.cpp.
References d.
00971 { 00972 Q_D(const QHeaderView); 00973 return d->clickableSections; 00974 }
| void QHeaderView::setHighlightSections | ( | bool | highlight | ) |
Definition at line 976 of file qheaderview.cpp.
References d.
Referenced by QTableViewPrivate::init().
00977 { 00978 Q_D(QHeaderView); 00979 d->highlightSelected = highlight; 00980 }
| bool QHeaderView::highlightSections | ( | ) | const |
Definition at line 982 of file qheaderview.cpp.
References d.
00983 { 00984 Q_D(const QHeaderView); 00985 return d->highlightSelected; 00986 }
| void QHeaderView::setResizeMode | ( | ResizeMode | mode | ) |
Sets the constraints on how the header can be resized to those described by the given mode.
Definition at line 995 of file qheaderview.cpp.
References count(), d, initializeSections(), resizeSections(), ResizeToContents, and Stretch.
Referenced by ConnectionWidget::ConnectionWidget(), Window::createFilesTable(), LocationDialog::LocationDialog(), MessageEditor::MessageEditor(), qdesigner_internal::ObjectInspector::ObjectInspector(), MessagesTreeView::setModel(), SettingsTree::SettingsTree(), MainWindow::updateModel(), qdesigner_internal::WidgetBoxTreeView::WidgetBoxTreeView(), and XbelTree::XbelTree().
00996 { 00997 Q_D(QHeaderView); 00998 initializeSections(); 00999 d->stretchSections = (mode == Stretch ? count() : 0); 01000 d->contentsSections = (mode == ResizeToContents ? count() : 0); 01001 d->setGlobalHeaderResizeMode(mode); 01002 if (d->hasAutoResizeSections()) 01003 resizeSections(); // section sizes may change as a result of the new mode 01004 }
Here is the call graph for this function:

| void QHeaderView::setResizeMode | ( | int | logicalIndex, | |
| ResizeMode | mode | |||
| ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Sets the constraints on how the section specified by logicalIndex in the header can be resized to those described by the given mode.
Definition at line 1014 of file qheaderview.cpp.
References d, QHeaderViewPrivate::NoState, resizeSections(), ResizeToContents, Stretch, and visualIndex().
01015 { 01016 Q_D(QHeaderView); 01017 int visual = visualIndex(logicalIndex); 01018 Q_ASSERT(visual != -1); 01019 01020 ResizeMode old = d->headerSectionResizeMode(visual); 01021 d->setHeaderSectionResizeMode(visual, mode); 01022 01023 if (mode == Stretch && old != Stretch) 01024 ++d->stretchSections; 01025 else if (mode == ResizeToContents && old != ResizeToContents) 01026 ++d->contentsSections; 01027 else if (mode != Stretch && old == Stretch) 01028 --d->stretchSections; 01029 else if (mode != ResizeToContents && old == ResizeToContents) 01030 --d->contentsSections; 01031 01032 if (d->hasAutoResizeSections() && d->state == QHeaderViewPrivate::NoState) 01033 resizeSections(); // section sizes may change as a result of the new mode 01034 }
Here is the call graph for this function:

| QHeaderView::ResizeMode QHeaderView::resizeMode | ( | int | logicalIndex | ) | const |
Returns the resize mode that applies to the section specified by the given logicalIndex.
Definition at line 1042 of file qheaderview.cpp.
References d, and visualIndex().
Referenced by mouseDoubleClickEvent(), mouseMoveEvent(), mousePressEvent(), and setSortIndicator().
01043 { 01044 Q_D(const QHeaderView); 01045 int visual = visualIndex(logicalIndex); 01046 Q_ASSERT(visual != -1); 01047 return d->visualIndexResizeMode(visual); 01048 }
Here is the call graph for this function:

| int QHeaderView::stretchSectionCount | ( | ) | const |
Definition at line 1059 of file qheaderview.cpp.
References d.
01060 { 01061 Q_D(const QHeaderView); 01062 return d->stretchSections; 01063 }
| void QHeaderView::setSortIndicatorShown | ( | bool | show | ) |
Definition at line 1072 of file qheaderview.cpp.
References count(), d, resizeSections(), ResizeToContents, and sortIndicatorSection().
Referenced by MessagesTreeView::MessagesTreeView(), TrWindow::revertSorting(), QTreeView::setSortingEnabled(), QTableView::setSortingEnabled(), and QFileDialogPrivate::setupTreeView().
01073 { 01074 Q_D(QHeaderView); 01075 d->sortIndicatorShown = show; 01076 01077 if (sortIndicatorSection() < 0 || sortIndicatorSection() > count()) 01078 return; 01079 01080 if (d->visualIndexResizeMode(sortIndicatorSection()) == ResizeToContents) { 01081 resizeSections(); 01082 d->viewport->update(); 01083 } 01084 }
Here is the call graph for this function:

| bool QHeaderView::isSortIndicatorShown | ( | ) | const |
Definition at line 1086 of file qheaderview.cpp.
References d.
Referenced by paintSection(), and sectionSizeFromContents().
01087 { 01088 Q_D(const QHeaderView); 01089 return d->sortIndicatorShown; 01090 }
| void QHeaderView::setSortIndicator | ( | int | logicalIndex, | |
| Qt::SortOrder | order | |||
| ) |
Sets the sort indicator for the section specified by the given logicalIndex in the direction specified by order, and removes the sort indicator from any other section that was showing it.
Definition at line 1100 of file qheaderview.cpp.
References d, resizeMode(), resizeSections(), ResizeToContents, and updateSection().
Referenced by TrWindow::revertSorting(), QFileDialogPrivate::setupTreeView(), QTableWidget::sortItems(), and QTreeWidget::sortItems().
01101 { 01102 Q_D(QHeaderView); 01103 01104 Q_ASSERT(logicalIndex >= 0); 01105 01106 // This is so that people can set the position of the sort indicator before the fill the model 01107 int old = d->sortIndicatorSection; 01108 d->sortIndicatorSection = logicalIndex; 01109 d->sortIndicatorOrder = order; 01110 01111 if (logicalIndex >= d->sectionCount) 01112 return; // nothing to do 01113 01114 if (old != logicalIndex && resizeMode(logicalIndex) == ResizeToContents) { 01115 resizeSections(); 01116 d->viewport->update(); 01117 } else { 01118 if (old != logicalIndex) 01119 updateSection(old); 01120 updateSection(logicalIndex); 01121 } 01122 }
Here is the call graph for this function:

| int QHeaderView::sortIndicatorSection | ( | ) | const |
Returns the logical index of the section that has a sort indicator. By default this is section 0.
Definition at line 1131 of file qheaderview.cpp.
References d.
Referenced by QTreeModel::executePendingSort(), paintSection(), sectionSizeFromContents(), QTableModel::setItem(), setSortIndicatorShown(), and QTreeWidget::sortColumn().
01132 { 01133 Q_D(const QHeaderView); 01134 return d->sortIndicatorSection; 01135 }
| Qt::SortOrder QHeaderView::sortIndicatorOrder | ( | ) | const |
Returns the order for the sort indicator. If no section has a sort indicator the return value of this function is undefined.
Definition at line 1144 of file qheaderview.cpp.
References d.
Referenced by QTreeModel::executePendingSort(), QTreeWidgetItem::insertChild(), paintSection(), and QTableModel::setItem().
01145 { 01146 Q_D(const QHeaderView); 01147 return d->sortIndicatorOrder; 01148 }
| bool QHeaderView::stretchLastSection | ( | ) | const |
Definition at line 1162 of file qheaderview.cpp.
References d.
Referenced by initializeSections(), and resizeSection().
01163 { 01164 Q_D(const QHeaderView); 01165 return d->stretchLastSection; 01166 }
| void QHeaderView::setStretchLastSection | ( | bool | stretch | ) |
Definition at line 1168 of file qheaderview.cpp.
References count(), d, QHeaderViewPrivate::NoState, resizeSection(), and resizeSections().
Referenced by DropSiteWindow::DropSiteWindow(), QTreeViewPrivate::initialize(), main(), QFileDialogPrivate::setupTreeView(), and MainWindow::updateModel().
01169 { 01170 Q_D(QHeaderView); 01171 d->stretchLastSection = stretch; 01172 if (d->state != QHeaderViewPrivate::NoState) 01173 return; 01174 if (stretch) 01175 resizeSections(); 01176 else if (count()) 01177 resizeSection(count() - 1, d->defaultSectionSize); 01178 }
Here is the call graph for this function:

| bool QHeaderView::cascadingSectionResizes | ( | ) | const |
Definition at line 1192 of file qheaderview.cpp.
References d.
01193 { 01194 Q_D(const QHeaderView); 01195 return d->cascadingResizing; 01196 }
| void QHeaderView::setCascadingSectionResizes | ( | bool | enable | ) |
Definition at line 1198 of file qheaderview.cpp.
References d.
01199 { 01200 Q_D(QHeaderView); 01201 d->cascadingResizing = enable; 01202 }
| int QHeaderView::defaultSectionSize | ( | ) | const |
Definition at line 1212 of file qheaderview.cpp.
References d.
01213 { 01214 Q_D(const QHeaderView); 01215 return d->defaultSectionSize; 01216 }
| void QHeaderView::setDefaultSectionSize | ( | int | size | ) |
Definition at line 1218 of file qheaderview.cpp.
References d.
01219 { 01220 Q_D(QHeaderView); 01221 d->defaultSectionSize = size; 01222 }
| int QHeaderView::minimumSectionSize | ( | ) | const |
Definition at line 1238 of file qheaderview.cpp.
References d, QWidget::fontMetrics(), QApplication::globalStrut(), QSize::height(), Qt::Horizontal, QFontMetrics::lineSpacing(), QFontMetrics::maxWidth(), orientation(), QStyle::pixelMetric(), QStyle::PM_HeaderMargin, qMax(), QWidget::style(), and QSize::width().
Referenced by mouseMoveEvent(), and sectionSizeHint().
01239 { 01240 Q_D(const QHeaderView); 01241 if (d->minimumSectionSize == -1) { 01242 QSize strut = QApplication::globalStrut(); 01243 int margin = style()->pixelMetric(QStyle::PM_HeaderMargin); 01244 if (orientation() == Qt::Horizontal) 01245 return qMax(strut.width(), (fontMetrics().maxWidth() + margin)); 01246 return qMax(strut.height(), (fontMetrics().lineSpacing() + margin)); 01247 } 01248 return d->minimumSectionSize; 01249 }
Here is the call graph for this function:

| void QHeaderView::setMinimumSectionSize | ( | int | size | ) |
Definition at line 1251 of file qheaderview.cpp.
References d.
01252 { 01253 Q_D(QHeaderView); 01254 d->minimumSectionSize = size; 01255 }
| Qt::Alignment QHeaderView::defaultAlignment | ( | ) | const |
Definition at line 1263 of file qheaderview.cpp.
References d.
01264 { 01265 Q_D(const QHeaderView); 01266 return d->defaultAlignment; 01267 }
| void QHeaderView::setDefaultAlignment | ( | Qt::Alignment | alignment | ) |
Definition at line 1269 of file qheaderview.cpp.
References d.
01270 { 01271 Q_D(QHeaderView); 01272 d->defaultAlignment = alignment; 01273 }
| void QHeaderView::doItemsLayout | ( | ) | [virtual] |
Reimplemented from QAbstractItemView.
Definition at line 1278 of file qheaderview.cpp.
References QAbstractItemView::doItemsLayout(), and initializeSections().
01279 { 01280 initializeSections(); 01281 QAbstractItemView::doItemsLayout(); 01282 }
Here is the call graph for this function:

| bool QHeaderView::sectionsMoved | ( | ) | const |
Returns true if sections in the header has been moved; otherwise returns false;
Definition at line 1290 of file qheaderview.cpp.
References d.
Referenced by QTableView::setSelection(), and QTableView::visualRegionForSelection().
01291 { 01292 Q_D(const QHeaderView); 01293 return !d->visualIndices.isEmpty(); 01294 }
| bool QHeaderView::sectionsHidden | ( | ) | const |
Definition at line 1304 of file qheaderview.cpp.
References d.
Referenced by QTableView::paintEvent().
01305 { 01306 Q_D(const QHeaderView); 01307 return !d->hiddenSectionSize.isEmpty(); 01308 }
| void QHeaderView::setOffset | ( | int | offset | ) | [slot] |
Sets the header's offset to offset.
Definition at line 353 of file qheaderview.cpp.
References d, Qt::Horizontal, QWidget::isRightToLeft(), QCursor::pos(), QHeaderViewPrivate::ResizeSection, QCursor::setPos(), QPoint::x(), and QPoint::y().
Referenced by setOffsetToSectionPosition().
00354 { 00355 Q_D(QHeaderView); 00356 if (d->offset == (uint)newOffset) 00357 return; 00358 int ndelta = d->offset - newOffset; 00359 d->offset = newOffset; 00360 if (d->orientation == Qt::Horizontal) 00361 d->viewport->scroll(isRightToLeft() ? -ndelta : ndelta, 0); 00362 else 00363 d->viewport->scroll(0, ndelta); 00364 if (d->state == QHeaderViewPrivate::ResizeSection) { 00365 QPoint cursorPos = QCursor::pos(); 00366 if (d->orientation == Qt::Horizontal) 00367 QCursor::setPos(cursorPos.x() + ndelta, cursorPos.y()); 00368 else 00369 QCursor::setPos(cursorPos.x(), cursorPos.y() + ndelta); 00370 d->firstPos += ndelta; 00371 d->lastPos += ndelta; 00372 } 00373 }
| void QHeaderView::setOffsetToSectionPosition | ( | int | visualIndex | ) | [slot] |
Definition at line 381 of file qheaderview.cpp.
References d, and setOffset().
00382 { 00383 Q_D(QHeaderView); 00384 if (visualIndex > -1 && visualIndex < d->sectionCount) { 00385 int position = d->headerSectionPosition(d->adjustedVisualIndex(visualIndex)); 00386 setOffset(position); 00387 } 00388 }
| void QHeaderView::headerDataChanged | ( | Qt::Orientation | orientation, | |
| int | logicalFirst, | |||
| int | logicalLast | |||
| ) | [slot] |
Updates the changed header sections with the given orientation, from logicalFirst to logicalLast inclusive.
Definition at line 1314 of file qheaderview.cpp.
References count(), d, Qt::Horizontal, left(), right(), sectionSize(), and sectionViewportPosition().
Referenced by setModel().
01315 { 01316 Q_D(QHeaderView); 01317 if (d->orientation != orientation) 01318 return; 01319 01320 if (logicalFirst < 0 || logicalLast < 0 || logicalFirst >= count() || logicalLast >= count()) 01321 return; 01322 01323 d->invalidateCachedSizeHint(); 01324 01325 if (orientation == Qt::Horizontal) { 01326 int left = sectionViewportPosition(logicalFirst); 01327 int right = sectionViewportPosition(logicalLast); 01328 right += sectionSize(logicalLast); 01329 d->viewport->update(left, 0, right - left, d->viewport->height()); 01330 } else { 01331 int top = sectionViewportPosition(logicalFirst); 01332 int bottom = sectionViewportPosition(logicalLast); 01333 bottom += sectionSize(logicalLast); 01334 d->viewport->update(0, top, d->viewport->width(), bottom - top); 01335 } 01336 }
| void QHeaderView::sectionMoved | ( | int | logicalIndex, | |
| int | oldVisualIndex, | |||
| int | newVisualIndex | |||
| ) | [signal] |
This signal is emitted when a section is moved. The section's logical index is specified by logicalIndex, the old index by oldVisualIndex, and the new index position by newVisualIndex.
Referenced by moveSection(), and swapSections().
| void QHeaderView::sectionResized | ( | int | logicalIndex, | |
| int | oldSize, | |||
| int | newSize | |||
| ) | [signal] |
This signal is emitted when a section is resized. The section's logical number is specified by logicalIndex, the old size by oldSize, and the new size by newSize.
Referenced by resizeSection().
| void QHeaderView::sectionPressed | ( | int | logicalIndex | ) | [signal] |
This signal is emitted when a section is pressed. The section's logical index is specified by logicalIndex.
Referenced by mousePressEvent().
| void QHeaderView::sectionClicked | ( | int | logicalIndex | ) | [signal] |
This signal is emitted when a section is clicked. The section's logical index is specified by logicalIndex.
Note that the sectionPressed signal will also be emitted.
Referenced by mouseReleaseEvent().
| void QHeaderView::sectionDoubleClicked | ( | int | logicalIndex | ) | [signal] |
This signal is emitted when a section is double-clicked. The section's logical index is specified by logicalIndex.
Referenced by mouseDoubleClickEvent().
| void QHeaderView::sectionCountChanged | ( | int | oldCount, | |
| int | newCount | |||
| ) | [signal] |
This signal is emitted when the number of sections changes; i.e. when sections are added or deleted. The original count is specified by oldCount, and the new count by newCount.
Referenced by initializeSections(), and sectionsInserted().
| void QHeaderView::sectionHandleDoubleClicked | ( | int | logicalIndex | ) | [signal] |
This signal is emitted when a section is double-clicked. The section's logical index is specified by logicalIndex.
Referenced by mouseDoubleClickEvent().
| void QHeaderView::sectionAutoResize | ( | int | logicalIndex, | |
| QHeaderView::ResizeMode | mode | |||
| ) | [signal] |
This signal is emitted when a section is automatically resized. The section's logical index is specified by logicalIndex, and the resize mode by mode.
| void QHeaderView::geometriesChanged | ( | ) | [signal] |
Referenced by viewportEvent().
| void QHeaderView::updateSection | ( | int | logicalIndex | ) | [protected, slot] |
Definition at line 1345 of file qheaderview.cpp.
References d, Qt::Horizontal, orientation(), sectionSize(), and sectionViewportPosition().
Referenced by event(), mousePressEvent(), mouseReleaseEvent(), moveSection(), and setSortIndicator().
01346 { 01347 Q_D(QHeaderView); 01348 if (orientation() == Qt::Horizontal) 01349 d->viewport->update(QRect(sectionViewportPosition(logicalIndex), 01350 0, sectionSize(logicalIndex), d->viewport->height())); 01351 else 01352 d->viewport->update(QRect(0, sectionViewportPosition(logicalIndex), 01353 d->viewport->width(), sectionSize(logicalIndex))); 01354 }
| void QHeaderView::resizeSections | ( | ) | [protected, slot] |
Resizes the sections according to their size hints. You should not normally need to call this function.
Definition at line 1361 of file qheaderview.cpp.
References d, and Interactive.
Referenced by resizeSection(), sectionsInserted(), setResizeMode(), setSectionHidden(), setSortIndicator(), setSortIndicatorShown(), setStretchLastSection(), updateGeometries(), and viewportEvent().
01362 { 01363 Q_D(QHeaderView); 01364 if (d->hasAutoResizeSections()) 01365 d->resizeSections(Interactive, false); // no global resize mode 01366 }
| void QHeaderView::sectionsInserted | ( | const QModelIndex & | parent, | |
| int | logicalFirst, | |||
| int | logicalLast | |||
| ) | [protected, slot] |
This slot is called when sections are inserted into the parent, logicalFirst and logicalLast indexes signify where the new sections are inserted.
logicalFirst and logicalLast will be the same if just one section is inserted.
Definition at line 1377 of file qheaderview.cpp.
References count(), d, emit, Qt::Horizontal, initializeSections(), QObject::parent(), qMax(), qMin(), resizeSections(), and sectionCountChanged().
Referenced by setModel().
01378 { 01379 Q_D(QHeaderView); 01380 if (parent != d->root) 01381 return; // we only handle changes in the top level 01382 int lastSection; 01383 if (d->orientation == Qt::Horizontal) 01384 lastSection = qMax(d->model->columnCount(d->root) - 1, 0); 01385 else 01386 lastSection = qMax(d->model->rowCount(d->root) - 1, 0); 01387 int oldCount = d->sectionCount; 01388 int oldLastSection = qMax(oldCount - 1, 0); 01389 initializeSections(qMin(oldLastSection + 1, logicalFirst), lastSection); 01390 resizeSections(); 01391 emit sectionCountChanged(oldCount, count()); 01392 }
| void QHeaderView::sectionsAboutToBeRemoved | ( | const QModelIndex & | parent, | |
| int | logicalFirst, | |||
| int | logicalLast | |||
| ) | [protected, slot] |
This slot is called when sections are removed from the parent, logicalFirst and logicalLast signify where the sections are removed from. (logicalFirst and logicalLast will be the same if just one section is removed.)
Definition at line 1401 of file qheaderview.cpp.
References QObject::parent().
Referenced by setModel().
01403 { 01404 Q_UNUSED(parent); 01405 Q_UNUSED(logicalFirst); 01406 Q_UNUSED(logicalLast); 01407 }
| void QHeaderView::initialize | ( | ) | [protected] |
Definition at line 252 of file qheaderview.cpp.
References QPalette::Button, d, Qt::ElideNone, QFrame::NoFrame, Qt::ScrollBarAlwaysOff, QFrame::setFrameStyle(), QAbstractScrollArea::setHorizontalScrollBarPolicy(), and QAbstractScrollArea::setVerticalScrollBarPolicy().
Referenced by QHeaderView().
00253 { 00254 Q_D(QHeaderView); 00255 setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); 00256 setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); 00257 setFrameStyle(NoFrame); 00258 d->viewport->setMouseTracking(true); 00259 d->viewport->setBackgroundRole(QPalette::Button); 00260 d->textElideMode = Qt::ElideNone; 00261 delete d->itemDelegate; 00262 }
Here is the call graph for this function:

| void QHeaderView::initializeSections | ( | ) | [protected] |
Definition at line 1458 of file qheaderview.cpp.
References c, count(), d, emit, Qt::Horizontal, logicalIndex(), sectionCountChanged(), sectionSizeHint(), and stretchLastSection().
Referenced by doItemsLayout(), sectionsInserted(), setModel(), and setResizeMode().
01459 { 01460 Q_D(QHeaderView); 01461 if (d->orientation == Qt::Horizontal) { 01462 int c = d->model->columnCount(d->root); 01463 if (c == 0) { 01464 int oldCount = count(); 01465 d->clear(); 01466 emit sectionCountChanged(oldCount, 0); 01467 } else if (c != count() && c > 0) { 01468 initializeSections(0, c - 1); 01469 } 01470 } else { 01471 int r = d->model->rowCount(d->root); 01472 if (r == 0) { 01473 int oldCount = count(); 01474 d->clear(); 01475 emit sectionCountChanged(oldCount, 0); 01476 } else if (r != count() && r > 0) { 01477 initializeSections(0, r - 1); 01478 } 01479 } 01480 if (stretchLastSection()) 01481 d->lastSectionSize = sectionSizeHint(logicalIndex(count() - 1)); 01482 }
Here is the call graph for this function:

| void QHeaderView::initializeSections | ( | int | start, | |
| int | end | |||
| ) | [protected] |
Definition at line 1488 of file qheaderview.cpp.
References count(), d, emit, i, ResizeToContents, sectionCountChanged(), and Stretch.
01489 { 01490 Q_D(QHeaderView); 01491 01492 Q_ASSERT(start >= 0); 01493 Q_ASSERT(end >= 0); 01494 01495 d->invalidateCachedSizeHint(); 01496 01497 // Edge case such as when a model emits layoutChanged when removing items 01498 if (end < count()) 01499 d->removeSectionsFromSpans(end + 1, count()); 01500 01501 int oldCount = d->sectionCount; 01502 d->sectionCount = end + 1; 01503 01504 if (!d->logicalIndices.isEmpty()) { 01505 d->logicalIndices.resize(d->sectionCount); 01506 d->visualIndices.resize(d->sectionCount); 01507 for (int i = start; i < d->sectionCount; ++i){ 01508 d->logicalIndices[i] = i; 01509 d->visualIndices[i] = i; 01510 } 01511 } 01512 01513 if (d->globalResizeMode == Stretch) 01514 d->stretchSections = d->sectionCount; 01515 else if (d->globalResizeMode == ResizeToContents) 01516 d->contentsSections = d->sectionCount; 01517 if (!d->sectionHidden.isEmpty()) 01518 d->sectionHidden.resize(d->sectionCount); 01519 01520 d->createSectionSpan(start, end, (end - start + 1) * d->defaultSectionSize, d->globalResizeMode); 01521 //Q_ASSERT(d->headerLength() == d->length); 01522 01523 emit sectionCountChanged(oldCount, d->sectionCount); 01524 d->viewport->update(); 01525 }
Here is the call graph for this function:

| void QHeaderView::currentChanged | ( | const QModelIndex & | current, | |
| const QModelIndex & | old | |||
| ) | [protected, virtual] |
Reimplemented from QAbstractItemView.
Definition at line 1531 of file qheaderview.cpp.
References QModelIndex::column(), d, Qt::Horizontal, QModelIndex::isValid(), QModelIndex::parent(), QModelIndex::row(), sectionSize(), sectionViewportPosition(), and Qt::Vertical.
01532 { 01533 Q_D(QHeaderView); 01534 01535 if (d->orientation == Qt::Horizontal && current.column() != old.column()) { 01536 if (old.isValid() && old.parent() == d->root) 01537 d->setDirtyRegion(QRect(sectionViewportPosition(old.column()), 0, 01538 sectionSize(old.column()), d->viewport->height())); 01539 if (current.isValid() && current.parent() == d->root) 01540 d->setDirtyRegion(QRect(sectionViewportPosition(current.column()), 0, 01541 sectionSize(current.column()), d->viewport->height())); 01542 } else if (d->orientation == Qt::Vertical && current.row() != old.row()) { 01543 if (old.isValid() && old.parent() == d->root) 01544 d->setDirtyRegion(QRect(0, sectionViewportPosition(old.row()), 01545 d->viewport->width(), sectionSize(old.row()))); 01546 if (current.isValid() && current.parent() == d->root) 01547 d->setDirtyRegion(QRect(0, sectionViewportPosition(current.row()), 01548 d->viewport->width(), sectionSize(current.row()))); 01549 } 01550 d->updateDirtyRegion(); 01551 }
Here is the call graph for this function:

| bool QHeaderView::event | ( | QEvent * | e | ) | [protected, virtual] |
Reimplemented from QAbstractItemView.
Definition at line 1558 of file qheaderview.cpp.
References d, QAbstractItemView::event(), QEvent::HoverEnter, QEvent::HoverLeave, QEvent::HoverMove, logicalIndexAt(), QHoverEvent::pos(), QEvent::type(), and updateSection().
01559 { 01560 Q_D(QHeaderView); 01561 switch (e->type()) { 01562 case QEvent::HoverEnter: { 01563 QHoverEvent *he = static_cast<QHoverEvent*>(e); 01564 d->hover = logicalIndexAt(he->pos()); 01565 if (d->hover != -1) 01566 updateSection(d->hover); 01567 break; } 01568 case QEvent::HoverLeave: { 01569 if (d->hover != -1) 01570 updateSection(d->hover); 01571 d->hover = -1; 01572 break; } 01573 case QEvent::HoverMove: { 01574 QHoverEvent *he = static_cast<QHoverEvent*>(e); 01575 int oldHover = d->hover; 01576 d->hover = logicalIndexAt(he->pos()); 01577 if (d->hover != oldHover) { 01578 if (oldHover != -1) 01579 updateSection(oldHover); 01580 if (d->hover != -1) 01581 updateSection(d->hover); 01582 } 01583 break; } 01584 default: 01585 break; 01586 } 01587 return QAbstractItemView::event(e); 01588 }
Here is the call graph for this function:

| void QHeaderView::paintEvent | ( | QPaintEvent * | e | ) | [protected, virtual] |
Reimplemented from QAbstractScrollArea.
Definition at line 1594 of file qheaderview.cpp.
References a, QPalette::background(), QRect::bottom(), count(), d, QPainter::fillRect(), Qt::FontRole, QWidget::height(), Qt::Horizontal, i, QWidget::isActiveWindow(), QRect::left(), logicalIndex(), offset(), orientation(), paintSection(), QWidget::palette(), qMax(), qMin(), QPaintEvent::rect(), QPainter::restore(), QRect::right(), QPainter::save(), sectionSize(), sectionViewportPosition(), QFont::setBold(), QPainter::setFont(), QRect::setRect(), start, QRect::top(), QRect::translate(), variant, visualIndexAt(), and QWidget::width().
01595 { 01596 Q_D(QHeaderView); 01597 01598 if (count() == 0) 01599 return; 01600 01601 QPainter painter(d->viewport); 01602 const QPoint offset = d->scrollDelayOffset; 01603 QRect translatedEventRect = e->rect(); 01604 translatedEventRect.translate(offset); 01605 01606 int start = -1; 01607 int end = -1; 01608 if (orientation() == Qt::Horizontal) { 01609 start = visualIndexAt(translatedEventRect.left()); 01610 end = visualIndexAt(translatedEventRect.right()); 01611 } else { 01612 start = visualIndexAt(translatedEventRect.top()); 01613 end = visualIndexAt(translatedEventRect.bottom()); 01614 } 01615 01616 if (d->reverse()) { 01617 start = (start == -1 ? count() - 1 : start); 01618 end = (end == -1 ? 0 : end); 01619 } else { 01620 start = (start == -1 ? 0 : start); 01621 end = (end == -1 ? count() - 1 : end); 01622 } 01623 01624 int tmp = start; 01625 start = qMin(start, end); 01626 end = qMax(tmp, end); 01627 01628 d->prepareSectionSelected(); // clear and resize the bit array 01629 01630 QRect currentSectionRect; 01631 int logical; 01632 const int width = d->viewport->width(); 01633 const int height = d->viewport->height(); 01634 const bool active = isActiveWindow(); 01635 for (int i = start; i <= end; ++i) { 01636 if (d->isVisualIndexHidden(i)) 01637 continue; 01638 painter.save(); 01639 logical = logicalIndex(i); 01640 bool highlight = false; 01641 if (orientation() == Qt::Horizontal) { 01642 currentSectionRect.setRect(sectionViewportPosition(logical), 0, sectionSize(logical), height); 01643 if (d->highlightSelected && active) 01644 highlight = d->columnIntersectsSelection(logical); 01645 } else { 01646 currentSectionRect.setRect(0, sectionViewportPosition(logical), width, sectionSize(logical)); 01647 if (d->highlightSelected && active) 01648 highlight = d->rowIntersectsSelection(logical); 01649 } 01650 currentSectionRect.translate(offset); 01651 01652 QVariant variant = d->model->headerData(logical, orientation(), 01653 Qt::FontRole); 01654 if (variant.isValid() && qVariantCanConvert<QFont>(variant)) { 01655 QFont sectionFont = qvariant_cast<QFont>(variant); 01656 if (highlight) 01657 sectionFont.setBold(true); 01658 painter.setFont(sectionFont); 01659 } 01660 paintSection(&painter, currentSectionRect, logical); 01661 painter.restore(); 01662 } 01663 01664 // Paint the area beyond where there are indexes 01665 if (d->reverse()) { 01666 if (currentSectionRect.left() > translatedEventRect.left()) 01667 painter.fillRect(translatedEventRect.left(), 0, 01668 currentSectionRect.left() - translatedEventRect.left(), height, 01669 palette().background()); 01670 } else if (currentSectionRect.right() < translatedEventRect.right()) { 01671 // paint to the right 01672 painter.fillRect(currentSectionRect.right() + 1, 0, 01673 translatedEventRect.right() - currentSectionRect.right(), height, 01674 palette().background()); 01675 } else if (currentSectionRect.bottom() < translatedEventRect.bottom()) { 01676 painter.fillRect(0, currentSectionRect.bottom() + 1, 01677 width, height - currentSectionRect.bottom() - 1, 01678 palette().background()); 01679 } 01680 01681 #if 0 01682 // ### visualize section spans 01683 for (int a = 0, i = 0; i < d->sectionSpans.count(); ++i) { 01684 QColor color((i & 4 ? 255 : 0), (i & 2 ? 255 : 0), (i & 1 ? 255 : 0)); 01685 if (orientation() == Qt::Horizontal) 01686 painter.fillRect(a - d->offset, 0, d->sectionSpans.at(i).size, 4, color); 01687 else 01688 painter.fillRect(0, a - d->offset, 4, d->sectionSpans.at(i).size, color); 01689 a += d->sectionSpans.at(i).size; 01690 } 01691 01692 #endif 01693 }
Here is the call graph for this function:

| void QHeaderView::mousePressEvent | ( | QMouseEvent * | e | ) | [protected, virtual] |
Reimplemented from QAbstractItemView.
Definition at line 1699 of file qheaderview.cpp.
References QMouseEvent::button(), d, emit, QWidget::handle(), Qt::Horizontal, Interactive, isSectionHidden(), Qt::LeftButton, logicalIndexAt(), QHeaderViewPrivate::MoveSection, QHeaderViewPrivate::NoState, orientation(), QWidget::pos(), resizeMode(), QHeaderViewPrivate::ResizeSection, sectionPressed(), sectionSize(), updateSection(), QMouseEvent::x(), and QMouseEvent::y().
01700 { 01701 Q_D(QHeaderView); 01702 if (d->state != QHeaderViewPrivate::NoState || e->button() != Qt::LeftButton) 01703 return; 01704 int pos = orientation() == Qt::Horizontal ? e->x() : e->y(); 01705 int handle = d->sectionHandleAt(pos); 01706 while (handle > -1 && isSectionHidden(handle)) --handle; 01707 if (handle == -1) { 01708 d->pressed = logicalIndexAt(pos); 01709 if (d->movableSections) { 01710 d->section = d->target = d->pressed; 01711 if (d->section == -1) 01712 return; 01713 d->state = QHeaderViewPrivate::MoveSection; 01714 d->setupSectionIndicator(d->section, pos); 01715 } 01716 if (d->clickableSections && d->pressed != -1) { 01717 updateSection(d->pressed); 01718 emit sectionPressed(d->pressed); 01719 } 01720 } else if (resizeMode(handle) == Interactive) { 01721 Q_ASSERT(d->originalSize == -1); 01722 d->originalSize = sectionSize(handle); 01723 d->state = QHeaderViewPrivate::ResizeSection; 01724 d->section = handle; 01725 } 01726 01727 d->firstPos = pos; 01728 d->lastPos = pos; 01729 01730 d->clearCascadingSections(); 01731 }
Here is the call graph for this function:

| void QHeaderView::mouseMoveEvent | ( | QMouseEvent * | e | ) | [protected, virtual] |
Reimplemented from QAbstractItemView.
Definition at line 1737 of file qheaderview.cpp.
References Qt::ArrowCursor, QMouseEvent::buttons(), d, QWidget::handle(), Qt::Horizontal, Interactive, minimumSectionSize(), QHeaderViewPrivate::MoveSection, Qt::NoButton, QHeaderViewPrivate::NoState, orientation(), QWidget::pos(), qMax(), resizeMode(), resizeSection(), QHeaderViewPrivate::ResizeSection, QWidget::setCursor(), Qt::SplitHCursor, Qt::SplitVCursor, QApplication::startDragDistance(), visualIndex(), visualIndexAt(), QMouseEvent::x(), and QMouseEvent::y().
01738 { 01739 Q_D(QHeaderView); 01740 int pos = orientation() == Qt::Horizontal ? e->x() : e->y(); 01741 if (pos < 0) 01742 return; 01743 if (e->buttons() == Qt::NoButton) { 01744 d->state = QHeaderViewPrivate::NoState; 01745 d->pressed = -1; 01746 } 01747 switch (d->state) { 01748 case QHeaderViewPrivate::ResizeSection: { 01749 Q_ASSERT(d->originalSize != -1); 01750 if (d->cascadingResizing) { 01751 int delta = d->reverse() ? d->lastPos - pos : pos - d->lastPos; 01752 int visual = visualIndex(d->section); 01753 d->cascadingResize(visual, d->headerSectionSize(visual) + delta); 01754 } else { 01755 int delta = d->reverse() ? d->firstPos - pos : pos - d->firstPos; 01756 resizeSection(d->section, qMax(d->originalSize + delta, minimumSectionSize())); 01757 } 01758 d->lastPos = pos; 01759 return; 01760 } 01761 case QHeaderViewPrivate::MoveSection: { 01762 if (qAbs(pos - d->firstPos) >= QApplication::startDragDistance()) { 01763 int indicatorCenter = (orientation() == Qt::Horizontal 01764 ? d->sectionIndicator->width() 01765 : d->sectionIndicator->height()) / 2; 01766 int centerOffset = indicatorCenter - d->sectionIndicatorOffset; 01767 // This will drop the moved section to the position under the center of the indicator. 01768 // If centerOffset is 0, the section will be moved to the position of the mouse cursor. 01769 int visual = visualIndexAt(pos + centerOffset); 01770 if (visual == -1) 01771 return; 01772 d->target = d->logicalIndex(visual); 01773 d->updateSectionIndicator(d->section, pos); 01774 } else { 01775 int visual = visualIndexAt(d->firstPos); 01776 if (visual == -1) 01777 return; 01778 d->target = d->logicalIndex(visual); 01779 d->updateSectionIndicator(d->section, d->firstPos); 01780 } 01781 return; 01782 } 01783 case QHeaderViewPrivate::NoState: { 01784 #ifndef QT_NO_CURSOR 01785 int handle = d->sectionHandleAt(pos); 01786 if (handle != -1 && (resizeMode(handle) == Interactive)) 01787 setCursor(orientation() == Qt::Horizontal ? Qt::SplitHCursor : Qt::SplitVCursor); 01788 else 01789 setCursor(Qt::ArrowCursor); 01790 #endif 01791 return; 01792 } 01793 } 01794 }
Here is the call graph for this function:

| void QHeaderView::mouseReleaseEvent | ( | QMouseEvent * | e | ) | [protected, virtual] |
Reimplemented from QAbstractItemView.
Definition at line 1800 of file qheaderview.cpp.
References d, emit, Qt::Horizontal, logicalIndexAt(), moveSection(), QHeaderViewPrivate::MoveSection, QHeaderViewPrivate::NoState, orientation(), QWidget::pos(), QHeaderViewPrivate::ResizeSection, sectionClicked(), updateSection(), visualIndex(), QMouseEvent::x(), and QMouseEvent::y().
01801 { 01802 Q_D(QHeaderView); 01803 int pos = orientation() == Qt::Horizontal ? e->x() : e->y(); 01804 switch (d->state) { 01805 case QHeaderViewPrivate::MoveSection: 01806 if (!d->sectionIndicator->isHidden()) { // moving 01807 int from = visualIndex(d->section); 01808 Q_ASSERT(from != -1); 01809 int to = visualIndex(d->target); 01810 Q_ASSERT(to != -1); 01811 moveSection(from, to); 01812 d->section = d->target = -1; 01813 d->updateSectionIndicator(d->section, pos); 01814 break; 01815 } // not moving 01816 case QHeaderViewPrivate::NoState: 01817 if (d->clickableSections) { 01818 int section = logicalIndexAt(pos); 01819 if (section != -1 && section == d->pressed) { 01820 if (d->sortIndicatorShown) 01821 d->flipSortIndicator(section); 01822 emit sectionClicked(logicalIndexAt(pos)); 01823 } 01824 if (d->pressed != -1) 01825 updateSection(d->pressed); 01826 } 01827 break; 01828 case QHeaderViewPrivate::ResizeSection: 01829 d->originalSize = -1; 01830 d->clearCascadingSections(); 01831 break; 01832 } 01833 d->state = QHeaderViewPrivate::NoState; 01834 d->pressed = -1; 01835 }
Here is the call graph for this function:

| void QHeaderView::mouseDoubleClickEvent | ( | QMouseEvent * | e | ) | [protected, virtual] |
Reimplemented from QAbstractItemView.
Definition at line 1841 of file qheaderview.cpp.
References Qt::ArrowCursor, QWidget::cursor(), d, emit, QWidget::handle(), Qt::Horizontal, Interactive, isSectionHidden(), logicalIndexAt(), orientation(), QMouseEvent::pos(), QWidget::pos(), resizeMode(), sectionDoubleClicked(), sectionHandleDoubleClicked(), QWidget::setCursor(), Qt::SplitHCursor, Qt::SplitVCursor, QMouseEvent::x(), and QMouseEvent::y().
01842 { 01843 Q_D(QHeaderView); 01844 int pos = orientation() == Qt::Horizontal ? e->x() : e->y(); 01845 int handle = d->sectionHandleAt(pos); 01846 while (handle > -1 && isSectionHidden(handle)) handle--; 01847 if (handle > -1 && resizeMode(handle) == Interactive) { 01848 emit sectionHandleDoubleClicked(handle); 01849 #ifndef QT_NO_CURSOR 01850 Qt::CursorShape splitCursor = (orientation() == Qt::Horizontal) 01851 ? Qt::SplitHCursor : Qt::SplitVCursor; 01852 if (cursor().shape() == splitCursor) { 01853 // signal handlers may have changed the section size 01854 handle = d->sectionHandleAt(pos); 01855 while (handle > -1 && isSectionHidden(handle)) handle--; 01856 if (!(handle > -1 && resizeMode(handle) == Interactive)) 01857 setCursor(Qt::ArrowCursor); 01858 } 01859 #endif 01860 } else { 01861 emit sectionDoubleClicked(logicalIndexAt(e->pos())); 01862 } 01863 }
Here is the call graph for this function:

| bool QHeaderView::viewportEvent | ( | QEvent * | e | ) | [protected, virtual] |
Reimplemented from QAbstractItemView.
Definition at line 1869 of file qheaderview.cpp.
References QEvent::ContextMenu, d, emit, QEvent::FontChange, geometriesChanged(), QHelpEvent::globalPos(), QEvent::Hide, QWidget::isActiveWindow(), QString::isEmpty(), QVariant::isValid(), logicalIndexAt(), QHeaderViewPrivate::NoState, orientation(), QHelpEvent::pos(), QEvent::QueryWhatsThis, resizeSections(), QWidget::setStatusTip(), QEvent::Show, QToolTip::showText(), QWhatsThis::showText(), QEvent::StatusTip, Qt::StatusTipRole, QEvent::ToolTip, Qt::ToolTipRole, QVariant::toString(), QEvent::type(), variant, QAbstractItemView::viewportEvent(), QEvent::WhatsThis, and Qt::WhatsThisRole.
01870 { 01871 Q_D(QHeaderView); 01872 switch (e->type()) { 01873 #ifndef QT_NO_TOOLTIP 01874 case QEvent::ToolTip: { 01875 if (!isActiveWindow()) 01876 break; 01877 QHelpEvent *he = static_cast<QHelpEvent*>(e); 01878 int logical = logicalIndexAt(he->pos()); 01879 if (logical != -1) { 01880 QVariant variant = d->model->headerData(logical, orientation(), Qt::ToolTipRole); 01881 if (variant.isValid()) { 01882 QToolTip::showText(he->globalPos(), variant.toString(), this); 01883 return true; 01884 } 01885 } 01886 break; } 01887 #endif 01888 #ifndef QT_NO_WHATSTHIS 01889 case QEvent::QueryWhatsThis: { 01890 QHelpEvent *he = static_cast<QHelpEvent*>(e); 01891 int logical = logicalIndexAt(he->pos()); 01892 if (logical != -1 01893 && d->model->headerData(logical, orientation(), Qt::WhatsThisRole).isValid()) 01894 return true; 01895 break; } 01896 case QEvent::WhatsThis: { 01897 QHelpEvent *he = static_cast<QHelpEvent*>(e); 01898 int logical = logicalIndexAt(he->pos()); 01899 if (logical != -1) { 01900 QVariant whatsthis = d->model->headerData(logical, orientation(), 01901 Qt::WhatsThisRole); 01902 if (whatsthis.isValid()) { 01903 QWhatsThis::showText(he->globalPos(), whatsthis.toString(), this); 01904 return true; 01905 } 01906 } 01907 break; } 01908 #endif // QT_NO_WHATSTHIS 01909 #ifndef QT_NO_STATUSTIP 01910 case QEvent::StatusTip: { 01911 QHelpEvent *he = static_cast<QHelpEvent*>(e); 01912 int logical = logicalIndexAt(he->pos()); 01913 if (logical != -1) { 01914 QString statustip = d->model->headerData(logical, orientation(), 01915 Qt::StatusTipRole).toString(); 01916 if (!statustip.isEmpty()) 01917 setStatusTip(statustip); 01918 } 01919 return true; } 01920 #endif // QT_NO_STATUSTIP 01921 case QEvent::Hide: 01922 case QEvent::Show: 01923 case QEvent::FontChange: 01924 resizeSections(); 01925 emit geometriesChanged(); 01926 break; 01927 case QEvent::ContextMenu: { 01928 d->state = QHeaderViewPrivate::NoState; 01929 d->pressed =d->section = d->target = -1; 01930 d->updateSectionIndicator(d->section, -1); 01931 } 01932 default: 01933 break; 01934 } 01935 return QAbstractItemView::viewportEvent(e); 01936 }
Here is the call graph for this function:

| void QHeaderView::paintSection | ( | QPainter * | painter, | |
| const QRect & | rect, | |||
| int | logicalIndex | |||
| ) | const [protected, virtual] |
Paints the section specified by the given logicalIndex, using the given painter and rect.
You normally would not need to use this function.
Definition at line 1944 of file qheaderview.cpp.
References Qt::AlignVCenter, Qt::AscendingOrder, Qt::BackgroundRole, QStyleOptionHeader::Beginning, QPainter::brushOrigin(), QPalette::Button, QPalette::ButtonText, QStyle::CE_Header, count(), d, Qt::DecorationRole, Qt::DisplayRole, QStyle::drawControl(), QFontMetrics::elidedText(), Qt::ElideNone, QStyleOptionHeader::End, QStyleOption::fontMetrics, Qt::ForegroundRole, QStyleOptionHeader::icon, QStyleOptionHeader::iconAlignment, QWidget::isActiveWindow(), QWidget::isEnabled(), QIcon::isNull(), isSortIndicatorShown(), QVariant::isValid(), QRect::isValid(), QStyleOptionHeader::Middle, QStyleOptionHeader::NextAndPreviousAreSelected, QStyleOptionHeader::NextIsSelected, QStyleOptionHeader::NotAdjacent, QStyleOptionHeader::OnlyOneSection, orientation(), QStyleOptionHeader::orientation, QStyleOption::palette, QStyleOptionHeader::position, QStyleOptionHeader::PreviousIsSelected, QStyleOption::rect, QWidget::rect(), QStyleOptionHeader::section, QStyleOptionHeader::selectedPosition, QPalette::setBrush(), QPainter::setBrushOrigin(), QStyleOptionHeader::SortDown, QStyleOptionHeader::sortIndicator, sortIndicatorOrder(), sortIndicatorSection(), QStyleOptionHeader::SortUp, QAbstractItemView::state(), QStyleOption::state, QStyle::State_Active, QStyle::State_Enabled, QStyle::State_MouseOver, QStyle::State_None, QStyle::State_On, QStyle::State_Sunken, QWidget::style(), QStyleOptionHeader::text, QStyleOptionHeader::textAlignment, Qt::TextAlignmentRole, QVariant::toInt(), QRect::topLeft(), variant, visualIndex(), QRect::width(), QPalette::Window, and QWidget::window().
Referenced by paintEvent().
01945 { 01946 Q_D(const QHeaderView); 01947 if (!rect.isValid()) 01948 return; 01949 // get the state of the section 01950 QStyleOptionHeader opt = d->getStyleOption(); 01951 QStyle::State state = QStyle::State_None; 01952 if (isEnabled()) 01953 state |= QStyle::State_Enabled; 01954 if (window()->isActiveWindow()) 01955 state |= QStyle::State_Active; 01956 if (d->clickableSections) { 01957 if (logicalIndex == d->hover) 01958 state |= QStyle::State_MouseOver; 01959 if (logicalIndex == d->pressed) 01960 state |= QStyle::State_Sunken; 01961 else if (d->highlightSelected && d->isSectionSelected(logicalIndex)) 01962 state |= QStyle::State_On | QStyle::State_Sunken; 01963 } 01964 if (isSortIndicatorShown() && sortIndicatorSection() == logicalIndex) 01965 opt.sortIndicator = (sortIndicatorOrder() == Qt::AscendingOrder) 01966 ? QStyleOptionHeader::SortDown : QStyleOptionHeader::SortUp; 01967 01968 // setup the style options structure 01969 QVariant textAlignment = d->model->headerData(logicalIndex, orientation(), 01970 Qt::TextAlignmentRole); 01971 opt.rect = rect; 01972 opt.section = logicalIndex; 01973 opt.state |= state; 01974 opt.textAlignment = Qt::Alignment(textAlignment.isValid() 01975 ? Qt::Alignment(textAlignment.toInt()) 01976 : d->defaultAlignment); 01977 opt.iconAlignment = Qt::AlignVCenter; 01978 opt.text = d->model->headerData(logicalIndex, orientation(), 01979 Qt::DisplayRole).toString(); 01980 if (d->textElideMode != Qt::ElideNone) 01981 opt.text = opt.fontMetrics.elidedText(opt.text, d->textElideMode , rect.width() - 4); 01982 01983 QVariant variant = d->model->headerData(logicalIndex, orientation(), 01984 Qt::DecorationRole); 01985 opt.icon = qvariant_cast<QIcon>(variant); 01986 if (opt.icon.isNull()) 01987 opt.icon = qvariant_cast<QPixmap>(variant); 01988 QVariant foregroundBrush = d->model->headerData(logicalIndex, orientation(), 01989 Qt::ForegroundRole); 01990 if (qVariantCanConvert<QBrush>(foregroundBrush)) 01991 opt.palette.setBrush(QPalette::ButtonText, qvariant_cast<QBrush>(foregroundBrush)); 01992 01993 QPointF oldBO = painter->brushOrigin(); 01994 QVariant backgroundBrush = d->model->headerData(logicalIndex, orientation(), 01995 Qt::BackgroundRole); 01996 if (qVariantCanConvert<QBrush>(backgroundBrush)) { 01997 opt.palette.setBrush(QPalette::Button, qvariant_cast<QBrush>(backgroundBrush)); 01998 opt.palette.setBrush(QPalette::Window, qvariant_cast<QBrush>(backgroundBrush)); 01999 painter->setBrushOrigin(opt.rect.topLeft()); 02000 } 02001 02002 // the section position 02003 int visual = visualIndex(logicalIndex); 02004 Q_ASSERT(visual != -1); 02005 if (count() == 1) 02006 opt.position = QStyleOptionHeader::OnlyOneSection; 02007 else if (visual == 0) 02008 opt.position = QStyleOptionHeader::Beginning; 02009 else if (visual == count() - 1) 02010 opt.position = QStyleOptionHeader::End; 02011 else 02012 opt.position = QStyleOptionHeader::Middle; 02013 opt.orientation = d->orientation; 02014 // the selected position 02015 bool previousSelected = d->isSectionSelected(this->logicalIndex(visual - 1)); 02016 bool nextSelected = d->isSectionSelected(this->logicalIndex(visual + 1)); 02017 if (previousSelected && nextSelected) 02018 opt.selectedPosition = QStyleOptionHeader::NextAndPreviousAreSelected; 02019 else if (previousSelected) 02020 opt.selectedPosition = QStyleOptionHeader::PreviousIsSelected; 02021 else if (nextSelected) 02022 opt.selectedPosition = QStyleOptionHeader::NextIsSelected; 02023 else 02024 opt.selectedPosition = QStyleOptionHeader::NotAdjacent; 02025 // draw the section 02026 style()->drawControl(QStyle::CE_Header, &opt, painter, this); 02027 02028 painter->setBrushOrigin(oldBO); 02029 }
Here is the call graph for this function:

| QSize QHeaderView::sectionSizeFromContents | ( | int | logicalIndex | ) | const [protected, virtual] |
Returns the size of the contents of the section specified by the give logicalIndex.
Definition at line 2037 of file qheaderview.cpp.
References QStyle::CT_HeaderSection, d, Qt::DecorationRole, Qt::DisplayRole, QWidget::font(), QStyleOption::fontMetrics, Qt::FontRole, QSize::height(), Qt::Horizontal, QStyleOptionHeader::icon, QIcon::isNull(), isSortIndicatorShown(), QVariant::isValid(), orientation(), QStyle::pixelMetric(), QStyle::PM_HeaderMargin, QWidget::QFontMetrics, QSize::rheight(), QSize::rwidth(), QWidget::size(), QStyle::sizeFromContents(), Qt::SizeHintRole, sortIndicatorSection(), QWidget::style(), QStyleOptionHeader::text, variant, and QSize::width().
Referenced by sectionSizeHint(), and sizeHint().
02038 { 02039 Q_D(const QHeaderView); 02040 Q_ASSERT(logicalIndex >= 0); 02041 QSize size(100, 30); // ### make this depend on the font size 02042 02043 // use SizeHintRole 02044 QVariant variant = d->model->headerData(logicalIndex, orientation(), Qt::SizeHintRole); 02045 if (variant.isValid()) 02046 return qvariant_cast<QSize>(variant); 02047 02048 // otherwise use the contents 02049 QStyleOptionHeader opt = d->getStyleOption(); 02050 QVariant var = d->model->headerData(logicalIndex, orientation(), 02051 Qt::FontRole); 02052 QFont fnt; 02053 if (var.isValid() && qVariantCanConvert<QFont>(var)) 02054 fnt = qvariant_cast<QFont>(var); 02055 else 02056 fnt = font(); 02057 fnt.setBold(true); 02058 opt.fontMetrics = QFontMetrics(fnt); 02059 opt.text = d->model->headerData(logicalIndex, orientation(), 02060 Qt::DisplayRole).toString(); 02061 variant = d->model->headerData(logicalIndex, orientation(), Qt::DecorationRole); 02062 opt.icon = qvariant_cast<QIcon>(variant); 02063 if (opt.icon.isNull()) 02064 opt.icon = qvariant_cast<QPixmap>(variant); 02065 size = style()->sizeFromContents(QStyle::CT_HeaderSection, &opt, size, this); 02066 02067 if (isSortIndicatorShown() && sortIndicatorSection() == logicalIndex) { 02068 int margin = style()->pixelMetric(QStyle::PM_HeaderMargin); 02069 if (orientation() == Qt::Horizontal) 02070 size.rwidth() += size.height() + margin; 02071 else 02072 size.rheight() += size.width() + margin; 02073 } 02074 return size; 02075 }
Here is the call graph for this function:

| int QHeaderView::horizontalOffset | ( | ) | const [protected, virtual] |
Returns the horizontal offset of the header. This is 0 for vertical headers.
Implements QAbstractItemView.
Definition at line 2084 of file qheaderview.cpp.
References d, Qt::Horizontal, and orientation().
02085 { 02086 Q_D(const QHeaderView); 02087 if (orientation() == Qt::Horizontal) 02088 return d->offset; 02089 return 0; 02090 }
Here is the call graph for this function:

| int QHeaderView::verticalOffset | ( | ) | const [protected, virtual] |
Returns the vertical offset of the header. This is 0 for horizontal headers.
Implements QAbstractItemView.
Definition at line 2099 of file qheaderview.cpp.
References d, orientation(), and Qt::Vertical.
02100 { 02101 Q_D(const QHeaderView); 02102 if (orientation() == Qt::Vertical) 02103 return d->offset; 02104 return 0; 02105 }
Here is the call graph for this function:

| void QHeaderView::updateGeometries | ( | ) | [protected, virtual] |
Reimplemented from QAbstractItemView.
Definition at line 2112 of file qheaderview.cpp.
References d, and resizeSections().
02113 { 02114 Q_D(QHeaderView); 02115 d->layoutChildren(); 02116 if (d->hasAutoResizeSections()) 02117 resizeSections(); 02118 }
| void QHeaderView::scrollContentsBy | ( | int | dx, | |
| int | dy | |||
| ) | [protected, virtual] |
Reimplemented from QAbstractScrollArea.
Definition at line 2125 of file qheaderview.cpp.
References d.
02126 { 02127 Q_D(QHeaderView); 02128 d->scrollDirtyRegion(dx, dy); 02129 }
| void QHeaderView::dataChanged | ( | const QModelIndex & | topLeft, | |
| const QModelIndex & | bottomRight | |||
| ) | [protected, virtual] |
Reimplemented from QAbstractItemView.
Definition at line 2135 of file qheaderview.cpp.
References d.
02136 { 02137 Q_D(QHeaderView); 02138 d->invalidateCachedSizeHint(); 02139 }
| void QHeaderView::rowsInserted | ( | const QModelIndex & | parent, | |
| int | start, | |||
| int | end | |||
| ) | [protected, virtual] |
Reimplemented from QAbstractItemView.
Definition at line 2147 of file qheaderview.cpp.
Referenced by setModel().
| QRect QHeaderView::visualRect | ( | const QModelIndex & | index | ) | const [protected, virtual] |
Implements QAbstractItemView.
Definition at line 2159 of file qheaderview.cpp.
02160 { 02161 return QRect(); 02162 }
| void QHeaderView::scrollTo | ( | const QModelIndex & | index, | |
| ScrollHint | hint | |||
| ) | [protected, virtual] |
| QModelIndex QHeaderView::indexAt | ( | const QPoint & | p | ) | const [protected, virtual] |
Implements QAbstractItemView.
Definition at line 2183 of file qheaderview.cpp.
02184 { 02185 return QModelIndex(); 02186 }
| bool QHeaderView::isIndexHidden | ( | const QModelIndex & | index |