Changeset 846 for trunk/src/gui/itemviews/qheaderview.cpp
- Timestamp:
- May 5, 2011, 5:36:53 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/vendor/nokia/qt/4.7.2 (added) merged: 845 /branches/vendor/nokia/qt/current merged: 844 /branches/vendor/nokia/qt/4.6.3 removed
- Property svn:mergeinfo changed
-
trunk/src/gui/itemviews/qheaderview.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 1699 1699 QBitArray sectionHidden(d->sectionHidden); 1700 1700 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); 1705 1702 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)); 1708 1705 d->sectionHidden = sectionHidden; 1709 1706 } … … 1854 1851 return; 1855 1852 } 1853 1854 QBitArray oldSectionHidden = sectionHidden; 1856 1855 bool sectionCountChanged = false; 1857 for (int i = 0; i < sectionHidden.count(); ++i) {1858 if (sectionHidden.testBit(i))1859 q->setSectionHidden(logicalIndex(i), false);1860 }1861 1856 1862 1857 for (int i = 0; i < persistentHiddenSections.count(); ++i) { … … 1867 1862 : index.row()); 1868 1863 q->setSectionHidden(logical, true); 1864 oldSectionHidden.setBit(logical, false); 1869 1865 } else if (!sectionCountChanged && (modelSectionCount() != sectionCount)) { 1870 1866 sectionCountChanged = true; … … 1873 1869 } 1874 1870 persistentHiddenSections.clear(); 1871 1872 for (int i = 0; i < oldSectionHidden.count(); ++i) { 1873 if (oldSectionHidden.testBit(i)) 1874 q->setSectionHidden(i, false); 1875 } 1875 1876 1876 1877 // the number of sections changed; we need to reread the state of the model … … 2034 2035 } 2035 2036 break; } 2036 case QEvent::Timer: { // ### reimplement timerEvent() instead ?2037 case QEvent::Timer: { 2037 2038 QTimerEvent *te = static_cast<QTimerEvent*>(e); 2038 2039 if (te->timerId() == d->delayedResize.timerId()) { … … 2218 2219 } 2219 2220 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); 2228 2224 if (visual == -1) 2229 2225 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 } 2231 2241 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);2238 2242 } 2239 2243 return; … … 2301 2305 if (section != -1 && section == d->pressed) { 2302 2306 d->flipSortIndicator(section); 2303 emit sectionClicked( logicalIndexAt(pos));2307 emit sectionClicked(section); 2304 2308 } 2305 2309 if (d->pressed != -1) … … 2612 2616 d->layoutChildren(); 2613 2617 if (d->hasAutoResizeSections()) 2614 resizeSections();2618 d->doDelayedResizeSections(); 2615 2619 } 2616 2620
Note:
See TracChangeset
for help on using the changeset viewer.