⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qheaderview.cpp

📁 奇趣公司比较新的qt/emd版本
💻 CPP
📖 第 1 页 / 共 5 页
字号:
    if (oldSize == size)        return;    d->executePostedLayout();    d->invalidateCachedSizeHint();    int visual = visualIndex(logical);    Q_ASSERT(visual != -1);    if (stretchLastSection() && visual == d->lastVisibleVisualIndex())        d->lastSectionSize = size;    if (size != oldSize)        d->createSectionSpan(visual, visual, size, d->headerSectionResizeMode(visual));    int w = d->viewport->width();    int h = d->viewport->height();    int pos = sectionViewportPosition(logical);    QRect r;    if (d->orientation == Qt::Horizontal)        if (isRightToLeft())            r.setRect(0, 0, pos + size, h);        else            r.setRect(pos, 0, w - pos, h);    else        r.setRect(0, pos, w, h - pos);    if (d->hasAutoResizeSections()) {        resizeSections();        r = d->viewport->rect();    }    d->viewport->update(r.normalized());    emit sectionResized(logical, oldSize, size);}/*!    Resizes the sections according to the given \a mode, ignoring the current    resize mode.    \sa resizeMode(), sectionResized()*/void QHeaderView::resizeSections(QHeaderView::ResizeMode mode){    Q_D(QHeaderView);    d->resizeSections(mode, true);}/*!  \fn void QHeaderView::hideSection(int logicalIndex)    Hides the section specified by \a logicalIndex.    \sa showSection(), isSectionHidden(), hiddenSectionCount(), setSectionHidden()*//*!  \fn void QHeaderView::showSection(int logicalIndex)   Shows the section specified by \a logicalIndex.   \sa hideSection(), isSectionHidden(), hiddenSectionCount(), setSectionHidden()*//*!    Returns true if the section specified by \a logicalIndex is    explicitly hidden from the user; otherwise returns false.    \sa hideSection(), showSection(), setSectionHidden(), hiddenSectionCount()*/bool QHeaderView::isSectionHidden(int logicalIndex) const{    Q_D(const QHeaderView);    if (logicalIndex >= d->sectionHidden.count() || logicalIndex < 0 || logicalIndex >= d->sectionCount)        return false;    d->executePostedLayout();    int visual = visualIndex(logicalIndex);    Q_ASSERT(visual != -1);    return d->sectionHidden.testBit(visual);}/*!    \since 4.1    Returns the number of sections in the header that has been hidden.    \sa setSectionHidden(), isSectionHidden()*/int QHeaderView::hiddenSectionCount() const{    Q_D(const QHeaderView);    return d->hiddenSectionSize.count();}/*!  If \a hide is true the section specified by \a logicalIndex is hidden,  otherwise the section is shown.  \sa isSectionHidden(), hiddenSectionCount()*/void QHeaderView::setSectionHidden(int logicalIndex, bool hide){    Q_D(QHeaderView);    if (logicalIndex < 0 || logicalIndex >= count())        return;    d->executePostedLayout();    int visual = visualIndex(logicalIndex);    Q_ASSERT(visual != -1);    if (hide && d->isVisualIndexHidden(visual))        return;    if (hide) {        int size = sectionSize(logicalIndex);        if (!d->hasAutoResizeSections())            resizeSection(logicalIndex, 0);        d->hiddenSectionSize.insert(logicalIndex, size);        if (d->sectionHidden.count() < count())            d->sectionHidden.resize(count());        d->sectionHidden.setBit(visual, true);        if (d->hasAutoResizeSections())            resizeSections();    } else if (d->isVisualIndexHidden(visual)) {        int size = d->hiddenSectionSize.value(logicalIndex, d->defaultSectionSize);        d->hiddenSectionSize.remove(logicalIndex);        if (d->hiddenSectionSize.isEmpty()) {            d->sectionHidden.clear();        } else {            Q_ASSERT(visual <= d->sectionHidden.count());            d->sectionHidden.setBit(visual, false);        }        resizeSection(logicalIndex, size);    }}/*!    Returns the number of sections in the header.    \sa  sectionCountChanged(), length()*/int QHeaderView::count() const{    Q_D(const QHeaderView);    //Q_ASSERT(d->sectionCount == d->headerSectionCount());    // ### this may affect the lazy layout    d->executePostedLayout();    return d->sectionCount;}/*!    Returns the visual index position of the section specified by the    given \a logicalIndex, or -1 otherwise.    Hidden sections still have valid visual indexes.    \sa logicalIndex()*/int QHeaderView::visualIndex(int logicalIndex) const{    Q_D(const QHeaderView);    if (logicalIndex < 0)        return -1;    d->executePostedLayout();    if (d->visualIndices.isEmpty()) { // nothing has been moved, so we have no mapping        if (logicalIndex < d->sectionCount)            return logicalIndex;    } else if (logicalIndex < d->visualIndices.count()) {        int visual = d->visualIndices.at(logicalIndex);        Q_ASSERT(visual < d->sectionCount);        return visual;    }    return -1;}/*!    Returns the logicalIndex for the section at the given \a    visualIndex position, or -1 otherwise.    \sa visualIndex(), sectionPosition()*/int QHeaderView::logicalIndex(int visualIndex) const{    Q_D(const QHeaderView);    if (visualIndex < 0 || visualIndex >= d->sectionCount)        return -1;    return d->logicalIndex(visualIndex);}/*!    If \a movable is true, the header may be moved by the user;    otherwise it is fixed in place.    \sa isMovable(), sectionMoved()*/// ### Qt 5: change to setSectionsMovable()void QHeaderView::setMovable(bool movable){    Q_D(QHeaderView);    d->movableSections = movable;}/*!    Returns true if the header can be moved by the user; otherwise    returns false.    \sa setMovable()*/// ### Qt 5: change to sectionsMovable()bool QHeaderView::isMovable() const{    Q_D(const QHeaderView);    return d->movableSections;}/*!    If \a clickable is true, the header will respond to single clicks.    \sa isClickable(), sectionClicked(), sectionPressed(), setSortIndicatorShown()*/// ### Qt 5: change to setSectionsClickable()void QHeaderView::setClickable(bool clickable){    Q_D(QHeaderView);    d->clickableSections = clickable;}/*!    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.    \sa setClickable()*/// ### Qt 5: change to sectionsClickable()bool QHeaderView::isClickable() const{    Q_D(const QHeaderView);    return d->clickableSections;}void QHeaderView::setHighlightSections(bool highlight){    Q_D(QHeaderView);    d->highlightSelected = highlight;}bool QHeaderView::highlightSections() const{    Q_D(const QHeaderView);    return d->highlightSelected;}/*!    Sets the constraints on how the header can be resized to those    described by the given \a mode.    \sa resizeMode(), length(), sectionResized(), sectionAutoResize()*/void QHeaderView::setResizeMode(ResizeMode mode){    Q_D(QHeaderView);    initializeSections();    d->stretchSections = (mode == Stretch ? count() : 0);    d->contentsSections = (mode == ResizeToContents ? count() : 0);    d->setGlobalHeaderResizeMode(mode);    if (d->hasAutoResizeSections())        resizeSections(); // section sizes may change as a result of the new mode}/*!    \overload    Sets the constraints on how the section specified by \a logicalIndex    in the header can be resized to those described by the given \a mode.*/// ### Qt 5: change to setSectionResizeMode()void QHeaderView::setResizeMode(int logicalIndex, ResizeMode mode){    Q_D(QHeaderView);    int visual = visualIndex(logicalIndex);    Q_ASSERT(visual != -1);    ResizeMode old = d->headerSectionResizeMode(visual);    d->setHeaderSectionResizeMode(visual, mode);    if (mode == Stretch && old != Stretch)        ++d->stretchSections;    else if (mode == ResizeToContents && old != ResizeToContents)        ++d->contentsSections;    else if (mode != Stretch && old == Stretch)        --d->stretchSections;    else if (mode != ResizeToContents && old == ResizeToContents)        --d->contentsSections;    if (d->hasAutoResizeSections() && d->state == QHeaderViewPrivate::NoState)        resizeSections(); // section sizes may change as a result of the new mode}/*!    Returns the resize mode that applies to the section specified by the given \a logicalIndex.    \sa setResizeMode()*/QHeaderView::ResizeMode QHeaderView::resizeMode(int logicalIndex) const{    Q_D(const QHeaderView);    int visual = visualIndex(logicalIndex);    Q_ASSERT(visual != -1);    return d->visualIndexResizeMode(visual);}/*!    \since 4.1    Returns the number of sections that are set to resize mode stretch.    In views this can be used to see if the headerview needs to resize the sections when the view geometry changes.    \sa stretchLastSection, resizeMode()*/int QHeaderView::stretchSectionCount() const{    Q_D(const QHeaderView);    return d->stretchSections;}/*!  \property QHeaderView::showSortIndicator  \brief whether the sort indicator is shown  \sa setClickable()*/void QHeaderView::setSortIndicatorShown(bool show){    Q_D(QHeaderView);    d->sortIndicatorShown = show;    if (sortIndicatorSection() < 0 || sortIndicatorSection() > count())        return;    if (d->visualIndexResizeMode(sortIndicatorSection()) == ResizeToContents) {        resizeSections();        d->viewport->update();    }}bool QHeaderView::isSortIndicatorShown() const{    Q_D(const QHeaderView);    return d->sortIndicatorShown;}/*!    Sets the sort indicator for the section specified by the given \a logicalIndex in the direction    specified by \a order, and removes the sort indicator from any    other section that was showing it.    \sa sortIndicatorSection() sortIndicatorOrder()*/void QHeaderView::setSortIndicator(int logicalIndex, Qt::SortOrder order){    Q_D(QHeaderView);    Q_ASSERT(logicalIndex >= 0);    // This is so that people can set the position of the sort indicator before the fill the model    int old = d->sortIndicatorSection;    d->sortIndicatorSection = logicalIndex;    d->sortIndicatorOrder = order;    if (logicalIndex >= d->sectionCount)        return; // nothing to do    if (old != logicalIndex && resizeMode(logicalIndex) == ResizeToContents) {        resizeSections();        d->viewport->update();    } else {        if (old != logicalIndex)            updateSection(old);        updateSection(logicalIndex);    }    emit sortIndicatorChanged(logicalIndex, order);}/*!    Returns the logical index of the section that has a sort    indicator. By default this is section 0.    \sa setSortIndicator() sortIndicatorOrder() setSortIndicatorShown()*/int QHeaderView::sortIndicatorSection() const{    Q_D(const QHeaderView);    return d->sortIndicatorSection;}/*!    Returns the order for the sort indicator. If no section has a sort    indicator the return value of this function is undefined.    \sa setSortIndicator() sortIndicatorSection()*/Qt::SortOrder QHeaderView::sortIndicatorOrder() const{

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -