Ignore:
Timestamp:
May 5, 2011, 5:36:53 AM (14 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/gui/itemviews/qheaderview.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    16991699        QBitArray sectionHidden(d->sectionHidden);
    17001700        sectionHidden.resize(sectionHidden.count() + insertCount);
    1701         //sectionHidden.fill(false, logicalFirst, logicalLast + 1);
    1702         for (int i = logicalFirst; i <= logicalLast; ++i)
    1703             // visual == logical in this range (see previous block)
    1704             sectionHidden.setBit(i, false);
     1701        sectionHidden.fill(false, logicalFirst, logicalLast + 1);
    17051702        for (int j = logicalLast + 1; j < sectionHidden.count(); ++j)
    1706             sectionHidden.setBit(d->visualIndex(j),
    1707                     d->sectionHidden.testBit(d->visualIndex(j - insertCount)));
     1703            //here we simply copy the old sectionHidden
     1704            sectionHidden.setBit(j, d->sectionHidden.testBit(j - insertCount));
    17081705        d->sectionHidden = sectionHidden;
    17091706    }
     
    18541851        return;
    18551852    }
     1853
     1854    QBitArray oldSectionHidden = sectionHidden;
    18561855    bool sectionCountChanged = false;
    1857     for (int i = 0; i < sectionHidden.count(); ++i) {
    1858         if (sectionHidden.testBit(i))
    1859             q->setSectionHidden(logicalIndex(i), false);
    1860     }
    18611856
    18621857    for (int i = 0; i < persistentHiddenSections.count(); ++i) {
     
    18671862                                 : index.row());
    18681863            q->setSectionHidden(logical, true);
     1864            oldSectionHidden.setBit(logical, false);
    18691865        } else if (!sectionCountChanged && (modelSectionCount() != sectionCount)) {
    18701866            sectionCountChanged = true;
     
    18731869    }
    18741870    persistentHiddenSections.clear();
     1871
     1872    for (int i = 0; i < oldSectionHidden.count(); ++i) {
     1873        if (oldSectionHidden.testBit(i))
     1874            q->setSectionHidden(i, false);
     1875    }
    18751876
    18761877    // the number of sections changed; we need to reread the state of the model
     
    20342035        }
    20352036        break; }
    2036     case QEvent::Timer: { // ### reimplement timerEvent() instead ?
     2037    case QEvent::Timer: {
    20372038        QTimerEvent *te = static_cast<QTimerEvent*>(e);
    20382039        if (te->timerId() == d->delayedResize.timerId()) {
     
    22182219        }
    22192220        case QHeaderViewPrivate::MoveSection: {
    2220             if (qAbs(pos - d->firstPos) >= QApplication::startDragDistance()) {
    2221                 int indicatorCenter = (d->orientation == Qt::Horizontal
    2222                                        ? d->sectionIndicator->width()
    2223                                        : d->sectionIndicator->height()) / 2;
    2224                 int centerOffset = indicatorCenter - d->sectionIndicatorOffset;
    2225                 // This will drop the moved section to the position under the center of the indicator.
    2226                 // If centerOffset is 0, the section will be moved to the position of the mouse cursor.
    2227                 int visual = visualIndexAt(pos + centerOffset);
     2221            if (qAbs(pos - d->firstPos) >= QApplication::startDragDistance()
     2222                || !d->sectionIndicator->isHidden()) {
     2223                int visual = visualIndexAt(pos);
    22282224                if (visual == -1)
    22292225                    return;
    2230                 d->target = d->logicalIndex(visual);
     2226                int posThreshold = d->headerSectionPosition(visual) + d->headerSectionSize(visual) / 2;
     2227                int moving = visualIndex(d->section);
     2228                if (visual < moving) {
     2229                    if (pos < posThreshold)
     2230                        d->target = d->logicalIndex(visual);
     2231                    else
     2232                        d->target = d->logicalIndex(visual + 1);
     2233                } else if (visual > moving) {
     2234                    if (pos > posThreshold)
     2235                        d->target = d->logicalIndex(visual);
     2236                    else
     2237                        d->target = d->logicalIndex(visual - 1);
     2238                } else {
     2239                    d->target = d->section;
     2240                }
    22312241                d->updateSectionIndicator(d->section, pos);
    2232             } else {
    2233                 int visual = visualIndexAt(d->firstPos);
    2234                 if (visual == -1)
    2235                     return;
    2236                 d->target = d->logicalIndex(visual);
    2237                 d->updateSectionIndicator(d->section, d->firstPos);
    22382242            }
    22392243            return;
     
    23012305            if (section != -1 && section == d->pressed) {
    23022306                d->flipSortIndicator(section);
    2303                 emit sectionClicked(logicalIndexAt(pos));
     2307                emit sectionClicked(section);
    23042308            }
    23052309            if (d->pressed != -1)
     
    26122616    d->layoutChildren();
    26132617    if (d->hasAutoResizeSections())
    2614         resizeSections();
     2618        d->doDelayedResizeSections();
    26152619}
    26162620
Note: See TracChangeset for help on using the changeset viewer.