QHeaderView - remove sectionCount variable
A previous patch ensures that we have exactly one section in a Span. ( see SHA : b800d8b94a7861ecf8853621f6556fca186fb5b7 ) Therefore we no longer need the sectionCount variable. We have assess to it through the sectionSpan.count. To keep this patch quite simple the variable sectionCount has been changed to a function returning the count value. Change-Id: Ibc419eafa38ab64b08f93074cb6ae4b8518995f6 Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
This commit is contained in:
parent
6363672163
commit
e500946de9
@ -490,7 +490,7 @@ void QHeaderView::setOffset(int newOffset)
|
|||||||
void QHeaderView::setOffsetToSectionPosition(int visualSectionNumber)
|
void QHeaderView::setOffsetToSectionPosition(int visualSectionNumber)
|
||||||
{
|
{
|
||||||
Q_D(QHeaderView);
|
Q_D(QHeaderView);
|
||||||
if (visualSectionNumber > -1 && visualSectionNumber < d->sectionCount) {
|
if (visualSectionNumber > -1 && visualSectionNumber < d->sectionCount()) {
|
||||||
int position = d->headerSectionPosition(d->adjustedVisualIndex(visualSectionNumber));
|
int position = d->headerSectionPosition(d->adjustedVisualIndex(visualSectionNumber));
|
||||||
setOffset(position);
|
setOffset(position);
|
||||||
}
|
}
|
||||||
@ -597,7 +597,7 @@ int QHeaderView::visualIndexAt(int position) const
|
|||||||
int vposition = position;
|
int vposition = position;
|
||||||
d->executePostedLayout();
|
d->executePostedLayout();
|
||||||
d->executePostedResize();
|
d->executePostedResize();
|
||||||
const int count = d->sectionCount;
|
const int count = d->sectionCount();
|
||||||
if (count < 1)
|
if (count < 1)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
@ -728,7 +728,7 @@ void QHeaderView::moveSection(int from, int to)
|
|||||||
Q_D(QHeaderView);
|
Q_D(QHeaderView);
|
||||||
|
|
||||||
d->executePostedLayout();
|
d->executePostedLayout();
|
||||||
if (from < 0 || from >= d->sectionCount || to < 0 || to >= d->sectionCount)
|
if (from < 0 || from >= d->sectionCount() || to < 0 || to >= d->sectionCount())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (from == to) {
|
if (from == to) {
|
||||||
@ -828,7 +828,7 @@ void QHeaderView::swapSections(int first, int second)
|
|||||||
if (first == second)
|
if (first == second)
|
||||||
return;
|
return;
|
||||||
d->executePostedLayout();
|
d->executePostedLayout();
|
||||||
if (first < 0 || first >= d->sectionCount || second < 0 || second >= d->sectionCount)
|
if (first < 0 || first >= d->sectionCount() || second < 0 || second >= d->sectionCount())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int firstSize = d->headerSectionSize(first);
|
int firstSize = d->headerSectionSize(first);
|
||||||
@ -965,7 +965,7 @@ bool QHeaderView::isSectionHidden(int logicalIndex) const
|
|||||||
{
|
{
|
||||||
Q_D(const QHeaderView);
|
Q_D(const QHeaderView);
|
||||||
d->executePostedLayout();
|
d->executePostedLayout();
|
||||||
if (logicalIndex >= d->sectionHidden.count() || logicalIndex < 0 || logicalIndex >= d->sectionCount)
|
if (logicalIndex >= d->sectionHidden.count() || logicalIndex < 0 || logicalIndex >= d->sectionCount())
|
||||||
return false;
|
return false;
|
||||||
int visual = visualIndex(logicalIndex);
|
int visual = visualIndex(logicalIndex);
|
||||||
Q_ASSERT(visual != -1);
|
Q_ASSERT(visual != -1);
|
||||||
@ -1038,7 +1038,7 @@ int QHeaderView::count() const
|
|||||||
//Q_ASSERT(d->sectionCount == d->headerSectionCount());
|
//Q_ASSERT(d->sectionCount == d->headerSectionCount());
|
||||||
// ### this may affect the lazy layout
|
// ### this may affect the lazy layout
|
||||||
d->executePostedLayout();
|
d->executePostedLayout();
|
||||||
return d->sectionCount;
|
return d->sectionCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -1057,11 +1057,11 @@ int QHeaderView::visualIndex(int logicalIndex) const
|
|||||||
return -1;
|
return -1;
|
||||||
d->executePostedLayout();
|
d->executePostedLayout();
|
||||||
if (d->visualIndices.isEmpty()) { // nothing has been moved, so we have no mapping
|
if (d->visualIndices.isEmpty()) { // nothing has been moved, so we have no mapping
|
||||||
if (logicalIndex < d->sectionCount)
|
if (logicalIndex < d->sectionCount())
|
||||||
return logicalIndex;
|
return logicalIndex;
|
||||||
} else if (logicalIndex < d->visualIndices.count()) {
|
} else if (logicalIndex < d->visualIndices.count()) {
|
||||||
int visual = d->visualIndices.at(logicalIndex);
|
int visual = d->visualIndices.at(logicalIndex);
|
||||||
Q_ASSERT(visual < d->sectionCount);
|
Q_ASSERT(visual < d->sectionCount());
|
||||||
return visual;
|
return visual;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
@ -1079,7 +1079,7 @@ int QHeaderView::visualIndex(int logicalIndex) const
|
|||||||
int QHeaderView::logicalIndex(int visualIndex) const
|
int QHeaderView::logicalIndex(int visualIndex) const
|
||||||
{
|
{
|
||||||
Q_D(const QHeaderView);
|
Q_D(const QHeaderView);
|
||||||
if (visualIndex < 0 || visualIndex >= d->sectionCount)
|
if (visualIndex < 0 || visualIndex >= d->sectionCount())
|
||||||
return -1;
|
return -1;
|
||||||
return d->logicalIndex(visualIndex);
|
return d->logicalIndex(visualIndex);
|
||||||
}
|
}
|
||||||
@ -1293,14 +1293,14 @@ void QHeaderView::setSortIndicator(int logicalIndex, Qt::SortOrder order)
|
|||||||
d->sortIndicatorSection = logicalIndex;
|
d->sortIndicatorSection = logicalIndex;
|
||||||
d->sortIndicatorOrder = order;
|
d->sortIndicatorOrder = order;
|
||||||
|
|
||||||
if (logicalIndex >= d->sectionCount) {
|
if (logicalIndex >= d->sectionCount()) {
|
||||||
emit sortIndicatorChanged(logicalIndex, order);
|
emit sortIndicatorChanged(logicalIndex, order);
|
||||||
return; // nothing to do
|
return; // nothing to do
|
||||||
}
|
}
|
||||||
|
|
||||||
if (old != logicalIndex
|
if (old != logicalIndex
|
||||||
&& ((logicalIndex >= 0 && resizeMode(logicalIndex) == ResizeToContents)
|
&& ((logicalIndex >= 0 && resizeMode(logicalIndex) == ResizeToContents)
|
||||||
|| old >= d->sectionCount || (old >= 0 && resizeMode(old) == ResizeToContents))) {
|
|| old >= d->sectionCount() || (old >= 0 && resizeMode(old) == ResizeToContents))) {
|
||||||
resizeSections();
|
resizeSections();
|
||||||
d->viewport->update();
|
d->viewport->update();
|
||||||
} else {
|
} else {
|
||||||
@ -1655,15 +1655,14 @@ void QHeaderView::sectionsInserted(const QModelIndex &parent,
|
|||||||
Q_D(QHeaderView);
|
Q_D(QHeaderView);
|
||||||
if (parent != d->root)
|
if (parent != d->root)
|
||||||
return; // we only handle changes in the top level
|
return; // we only handle changes in the top level
|
||||||
int oldCount = d->sectionCount;
|
int oldCount = d->sectionCount();
|
||||||
|
|
||||||
d->invalidateCachedSizeHint();
|
d->invalidateCachedSizeHint();
|
||||||
|
|
||||||
// add the new sections
|
// add the new sections
|
||||||
int insertAt = logicalFirst;
|
int insertAt = logicalFirst;
|
||||||
|
|
||||||
int insertCount = logicalLast - logicalFirst + 1;
|
int insertCount = logicalLast - logicalFirst + 1;
|
||||||
d->sectionCount += insertCount;
|
|
||||||
QHeaderViewPrivate::SectionSpan span(d->defaultSectionSize, d->globalResizeMode);
|
QHeaderViewPrivate::SectionSpan span(d->defaultSectionSize, d->globalResizeMode);
|
||||||
d->sectionStartposRecalc = true;
|
d->sectionStartposRecalc = true;
|
||||||
|
|
||||||
@ -1684,9 +1683,9 @@ void QHeaderView::sectionsInserted(const QModelIndex &parent,
|
|||||||
|
|
||||||
// update resize mode section counts
|
// update resize mode section counts
|
||||||
if (d->globalResizeMode == Stretch)
|
if (d->globalResizeMode == Stretch)
|
||||||
d->stretchSections = d->sectionCount;
|
d->stretchSections = d->sectionCount();
|
||||||
else if (d->globalResizeMode == ResizeToContents)
|
else if (d->globalResizeMode == ResizeToContents)
|
||||||
d->contentsSections = d->sectionCount;
|
d->contentsSections = d->sectionCount();
|
||||||
|
|
||||||
// clear selection cache
|
// clear selection cache
|
||||||
d->sectionSelected.clear();
|
d->sectionSelected.clear();
|
||||||
@ -1723,7 +1722,7 @@ void QHeaderView::sectionsInserted(const QModelIndex &parent,
|
|||||||
for (int i = 0; i < logicalFirst; ++i)
|
for (int i = 0; i < logicalFirst; ++i)
|
||||||
if (isSectionHidden(i))
|
if (isSectionHidden(i))
|
||||||
newHiddenSectionSize[i] = d->hiddenSectionSize[i];
|
newHiddenSectionSize[i] = d->hiddenSectionSize[i];
|
||||||
for (int j = logicalLast + 1; j < d->sectionCount; ++j)
|
for (int j = logicalLast + 1; j < d->sectionCount(); ++j)
|
||||||
if (isSectionHidden(j))
|
if (isSectionHidden(j))
|
||||||
newHiddenSectionSize[j] = d->hiddenSectionSize[j - insertCount];
|
newHiddenSectionSize[j] = d->hiddenSectionSize[j - insertCount];
|
||||||
d->hiddenSectionSize = newHiddenSectionSize;
|
d->hiddenSectionSize = newHiddenSectionSize;
|
||||||
@ -1762,14 +1761,14 @@ void QHeaderViewPrivate::updateHiddenSections(int logicalFirst, int logicalLast)
|
|||||||
for (int i = 0; i < logicalFirst; ++i)
|
for (int i = 0; i < logicalFirst; ++i)
|
||||||
if (q->isSectionHidden(i))
|
if (q->isSectionHidden(i))
|
||||||
newHiddenSectionSize[i] = hiddenSectionSize[i];
|
newHiddenSectionSize[i] = hiddenSectionSize[i];
|
||||||
for (int j = logicalLast + 1; j < sectionCount; ++j)
|
for (int j = logicalLast + 1; j < sectionCount(); ++j)
|
||||||
if (q->isSectionHidden(j))
|
if (q->isSectionHidden(j))
|
||||||
newHiddenSectionSize[j - changeCount] = hiddenSectionSize[j];
|
newHiddenSectionSize[j - changeCount] = hiddenSectionSize[j];
|
||||||
hiddenSectionSize = newHiddenSectionSize;
|
hiddenSectionSize = newHiddenSectionSize;
|
||||||
|
|
||||||
// remove sections from sectionsHidden
|
// remove sections from sectionsHidden
|
||||||
if (!sectionHidden.isEmpty()) {
|
if (!sectionHidden.isEmpty()) {
|
||||||
const int newsize = qMin(sectionCount - changeCount, sectionHidden.size());
|
const int newsize = qMin(sectionCount() - changeCount, sectionHidden.size());
|
||||||
QBitArray newSectionHidden(newsize);
|
QBitArray newSectionHidden(newsize);
|
||||||
for (int j = 0, k = 0; j < sectionHidden.size(); ++j) {
|
for (int j = 0, k = 0; j < sectionHidden.size(); ++j) {
|
||||||
const int logical = logicalIndex(j);
|
const int logical = logicalIndex(j);
|
||||||
@ -1788,7 +1787,7 @@ void QHeaderViewPrivate::_q_sectionsRemoved(const QModelIndex &parent,
|
|||||||
if (parent != root)
|
if (parent != root)
|
||||||
return; // we only handle changes in the top level
|
return; // we only handle changes in the top level
|
||||||
if (qMin(logicalFirst, logicalLast) < 0
|
if (qMin(logicalFirst, logicalLast) < 0
|
||||||
|| qMax(logicalLast, logicalFirst) >= sectionCount)
|
|| qMax(logicalLast, logicalFirst) >= sectionCount())
|
||||||
return;
|
return;
|
||||||
int oldCount = q->count();
|
int oldCount = q->count();
|
||||||
int changeCount = logicalLast - logicalFirst + 1;
|
int changeCount = logicalLast - logicalFirst + 1;
|
||||||
@ -1802,8 +1801,8 @@ void QHeaderViewPrivate::_q_sectionsRemoved(const QModelIndex &parent,
|
|||||||
if (logicalFirst == logicalLast) { // Remove just one index.
|
if (logicalFirst == logicalLast) { // Remove just one index.
|
||||||
int l = logicalFirst;
|
int l = logicalFirst;
|
||||||
int visual = visualIndices.at(l);
|
int visual = visualIndices.at(l);
|
||||||
Q_ASSERT(sectionCount == logicalIndices.count());
|
Q_ASSERT(sectionCount() == logicalIndices.count());
|
||||||
for (int v = 0; v < sectionCount; ++v) {
|
for (int v = 0; v < sectionCount(); ++v) {
|
||||||
if (v > visual) {
|
if (v > visual) {
|
||||||
int logical = logicalIndices.at(v);
|
int logical = logicalIndices.at(v);
|
||||||
--(visualIndices[logical]);
|
--(visualIndices[logical]);
|
||||||
@ -1837,7 +1836,6 @@ void QHeaderViewPrivate::_q_sectionsRemoved(const QModelIndex &parent,
|
|||||||
}
|
}
|
||||||
// ### handle sectionSelection (sectionHidden is handled by updateHiddenSections)
|
// ### handle sectionSelection (sectionHidden is handled by updateHiddenSections)
|
||||||
}
|
}
|
||||||
sectionCount -= changeCount;
|
|
||||||
|
|
||||||
// update sorting column
|
// update sorting column
|
||||||
if (sortIndicatorSection >= logicalFirst) {
|
if (sortIndicatorSection >= logicalFirst) {
|
||||||
@ -1848,7 +1846,7 @@ void QHeaderViewPrivate::_q_sectionsRemoved(const QModelIndex &parent,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// if we only have the last section (the "end" position) left, the header is empty
|
// if we only have the last section (the "end" position) left, the header is empty
|
||||||
if (sectionCount <= 0)
|
if (sectionCount() <= 0)
|
||||||
clear();
|
clear();
|
||||||
invalidateCachedSizeHint();
|
invalidateCachedSizeHint();
|
||||||
emit q->sectionCountChanged(oldCount, q->count());
|
emit q->sectionCountChanged(oldCount, q->count());
|
||||||
@ -1877,7 +1875,7 @@ void QHeaderViewPrivate::_q_layoutChanged()
|
|||||||
Q_Q(QHeaderView);
|
Q_Q(QHeaderView);
|
||||||
viewport->update();
|
viewport->update();
|
||||||
if (persistentHiddenSections.isEmpty() || modelIsEmpty()) {
|
if (persistentHiddenSections.isEmpty() || modelIsEmpty()) {
|
||||||
if (modelSectionCount() != sectionCount)
|
if (modelSectionCount() != sectionCount())
|
||||||
q->initializeSections();
|
q->initializeSections();
|
||||||
persistentHiddenSections.clear();
|
persistentHiddenSections.clear();
|
||||||
return;
|
return;
|
||||||
@ -1894,7 +1892,7 @@ void QHeaderViewPrivate::_q_layoutChanged()
|
|||||||
: index.row());
|
: index.row());
|
||||||
q->setSectionHidden(logical, true);
|
q->setSectionHidden(logical, true);
|
||||||
oldSectionHidden.setBit(logical, false);
|
oldSectionHidden.setBit(logical, false);
|
||||||
} else if (!sectionCountChanged && (modelSectionCount() != sectionCount)) {
|
} else if (!sectionCountChanged && (modelSectionCount() != sectionCount())) {
|
||||||
sectionCountChanged = true;
|
sectionCountChanged = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1918,7 +1916,7 @@ void QHeaderViewPrivate::_q_layoutChanged()
|
|||||||
void QHeaderView::initializeSections()
|
void QHeaderView::initializeSections()
|
||||||
{
|
{
|
||||||
Q_D(QHeaderView);
|
Q_D(QHeaderView);
|
||||||
const int oldCount = d->sectionCount;
|
const int oldCount = d->sectionCount();
|
||||||
const int newCount = d->modelSectionCount();
|
const int newCount = d->modelSectionCount();
|
||||||
if (newCount <= 0) {
|
if (newCount <= 0) {
|
||||||
d->clear();
|
d->clear();
|
||||||
@ -1927,7 +1925,7 @@ void QHeaderView::initializeSections()
|
|||||||
const int min = qBound(0, oldCount, newCount - 1);
|
const int min = qBound(0, oldCount, newCount - 1);
|
||||||
initializeSections(min, newCount - 1);
|
initializeSections(min, newCount - 1);
|
||||||
if (stretchLastSection()) // we've already gotten the size hint
|
if (stretchLastSection()) // we've already gotten the size hint
|
||||||
d->lastSectionSize = sectionSize(logicalIndex(d->sectionCount - 1));
|
d->lastSectionSize = sectionSize(logicalIndex(d->sectionCount() - 1));
|
||||||
|
|
||||||
//make sure we update the hidden sections
|
//make sure we update the hidden sections
|
||||||
if (newCount < oldCount)
|
if (newCount < oldCount)
|
||||||
@ -1947,13 +1945,14 @@ void QHeaderView::initializeSections(int start, int end)
|
|||||||
Q_ASSERT(end >= 0);
|
Q_ASSERT(end >= 0);
|
||||||
|
|
||||||
d->invalidateCachedSizeHint();
|
d->invalidateCachedSizeHint();
|
||||||
|
int oldCount = d->sectionCount();
|
||||||
|
|
||||||
if (end + 1 < d->sectionCount) {
|
if (end + 1 < d->sectionCount()) {
|
||||||
int newCount = end + 1;
|
int newCount = end + 1;
|
||||||
d->removeSectionsFromSpans(newCount, d->sectionCount - 1);
|
d->removeSectionsFromSpans(newCount, d->sectionCount() - 1);
|
||||||
if (!d->hiddenSectionSize.isEmpty()) {
|
if (!d->hiddenSectionSize.isEmpty()) {
|
||||||
if (d->sectionCount - newCount > d->hiddenSectionSize.count()) {
|
if (oldCount - newCount > d->hiddenSectionSize.count()) {
|
||||||
for (int i = end + 1; i < d->sectionCount; ++i)
|
for (int i = end + 1; i < d->sectionCount(); ++i)
|
||||||
d->hiddenSectionSize.remove(i);
|
d->hiddenSectionSize.remove(i);
|
||||||
} else {
|
} else {
|
||||||
QHash<int, int>::iterator it = d->hiddenSectionSize.begin();
|
QHash<int, int>::iterator it = d->hiddenSectionSize.begin();
|
||||||
@ -1967,14 +1966,13 @@ void QHeaderView::initializeSections(int start, int end)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int oldCount = d->sectionCount;
|
int newSectionCount = end + 1;
|
||||||
d->sectionCount = end + 1;
|
|
||||||
|
|
||||||
if (!d->logicalIndices.isEmpty()) {
|
if (!d->logicalIndices.isEmpty()) {
|
||||||
if (oldCount <= d->sectionCount) {
|
if (oldCount <= newSectionCount) {
|
||||||
d->logicalIndices.resize(d->sectionCount);
|
d->logicalIndices.resize(newSectionCount);
|
||||||
d->visualIndices.resize(d->sectionCount);
|
d->visualIndices.resize(newSectionCount);
|
||||||
for (int i = oldCount; i < d->sectionCount; ++i) {
|
for (int i = oldCount; i < newSectionCount; ++i) {
|
||||||
d->logicalIndices[i] = i;
|
d->logicalIndices[i] = i;
|
||||||
d->visualIndices[i] = i;
|
d->visualIndices[i] = i;
|
||||||
}
|
}
|
||||||
@ -1982,30 +1980,30 @@ void QHeaderView::initializeSections(int start, int end)
|
|||||||
int j = 0;
|
int j = 0;
|
||||||
for (int i = 0; i < oldCount; ++i) {
|
for (int i = 0; i < oldCount; ++i) {
|
||||||
int v = d->logicalIndices.at(i);
|
int v = d->logicalIndices.at(i);
|
||||||
if (v < d->sectionCount) {
|
if (v < newSectionCount) {
|
||||||
d->logicalIndices[j] = v;
|
d->logicalIndices[j] = v;
|
||||||
d->visualIndices[v] = j;
|
d->visualIndices[v] = j;
|
||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
d->logicalIndices.resize(d->sectionCount);
|
d->logicalIndices.resize(newSectionCount);
|
||||||
d->visualIndices.resize(d->sectionCount);
|
d->visualIndices.resize(newSectionCount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (d->globalResizeMode == Stretch)
|
if (d->globalResizeMode == Stretch)
|
||||||
d->stretchSections = d->sectionCount;
|
d->stretchSections = newSectionCount;
|
||||||
else if (d->globalResizeMode == ResizeToContents)
|
else if (d->globalResizeMode == ResizeToContents)
|
||||||
d->contentsSections = d->sectionCount;
|
d->contentsSections = newSectionCount;
|
||||||
if (!d->sectionHidden.isEmpty())
|
if (!d->sectionHidden.isEmpty())
|
||||||
d->sectionHidden.resize(d->sectionCount);
|
d->sectionHidden.resize(newSectionCount);
|
||||||
|
|
||||||
if (d->sectionCount > oldCount)
|
if (newSectionCount > oldCount)
|
||||||
d->createSectionSpan(start, end, (end - start + 1) * d->defaultSectionSize, d->globalResizeMode);
|
d->createSectionSpan(start, end, (end - start + 1) * d->defaultSectionSize, d->globalResizeMode);
|
||||||
//Q_ASSERT(d->headerLength() == d->length);
|
//Q_ASSERT(d->headerLength() == d->length);
|
||||||
|
|
||||||
if (d->sectionCount != oldCount)
|
if (d->sectionCount() != oldCount)
|
||||||
emit sectionCountChanged(oldCount, d->sectionCount);
|
emit sectionCountChanged(oldCount, d->sectionCount());
|
||||||
d->viewport->update();
|
d->viewport->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2996,7 +2994,7 @@ void QHeaderViewPrivate::resizeSections(QHeaderView::ResizeMode globalMode, bool
|
|||||||
delayedResize.stop();
|
delayedResize.stop();
|
||||||
|
|
||||||
executePostedLayout();
|
executePostedLayout();
|
||||||
if (sectionCount == 0)
|
if (sectionCount() == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (resizeRecursionBlock)
|
if (resizeRecursionBlock)
|
||||||
@ -3016,7 +3014,7 @@ void QHeaderViewPrivate::resizeSections(QHeaderView::ResizeMode globalMode, bool
|
|||||||
int lengthToStrech = (orientation == Qt::Horizontal ? viewport->width() : viewport->height());
|
int lengthToStrech = (orientation == Qt::Horizontal ? viewport->width() : viewport->height());
|
||||||
int numberOfStretchedSections = 0;
|
int numberOfStretchedSections = 0;
|
||||||
QList<int> section_sizes;
|
QList<int> section_sizes;
|
||||||
for (int i = 0; i < sectionCount; ++i) {
|
for (int i = 0; i < sectionCount(); ++i) {
|
||||||
if (isVisualIndexHidden(i))
|
if (isVisualIndexHidden(i))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -3060,7 +3058,7 @@ void QHeaderViewPrivate::resizeSections(QHeaderView::ResizeMode globalMode, bool
|
|||||||
QHeaderView::ResizeMode previousSectionResizeMode = QHeaderView::Interactive;
|
QHeaderView::ResizeMode previousSectionResizeMode = QHeaderView::Interactive;
|
||||||
|
|
||||||
// resize each section along the total length
|
// resize each section along the total length
|
||||||
for (int i = 0; i < sectionCount; ++i) {
|
for (int i = 0; i < sectionCount(); ++i) {
|
||||||
int oldSectionLength = headerSectionSize(i);
|
int oldSectionLength = headerSectionSize(i);
|
||||||
int newSectionLength = -1;
|
int newSectionLength = -1;
|
||||||
QHeaderView::ResizeMode newSectionResizeMode = headerSectionResizeMode(i);
|
QHeaderView::ResizeMode newSectionResizeMode = headerSectionResizeMode(i);
|
||||||
@ -3107,8 +3105,8 @@ void QHeaderViewPrivate::resizeSections(QHeaderView::ResizeMode globalMode, bool
|
|||||||
previousSectionResizeMode = newSectionResizeMode;
|
previousSectionResizeMode = newSectionResizeMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
createSectionSpan(spanStartSection, sectionCount - 1,
|
createSectionSpan(spanStartSection, sectionCount() - 1,
|
||||||
(sectionCount - spanStartSection) * previousSectionLength,
|
(sectionCount() - spanStartSection) * previousSectionLength,
|
||||||
previousSectionResizeMode);
|
previousSectionResizeMode);
|
||||||
//Q_ASSERT(headerLength() == length);
|
//Q_ASSERT(headerLength() == length);
|
||||||
resizeRecursionBlock = false;
|
resizeRecursionBlock = false;
|
||||||
@ -3144,7 +3142,6 @@ void QHeaderViewPrivate::clear()
|
|||||||
{
|
{
|
||||||
if (state != NoClear) {
|
if (state != NoClear) {
|
||||||
length = 0;
|
length = 0;
|
||||||
sectionCount = 0;
|
|
||||||
visualIndices.clear();
|
visualIndices.clear();
|
||||||
logicalIndices.clear();
|
logicalIndices.clear();
|
||||||
sectionSelected.clear();
|
sectionSelected.clear();
|
||||||
@ -3205,7 +3202,7 @@ void QHeaderViewPrivate::cascadingResize(int visual, int newSize)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// cascade the section size change
|
// cascade the section size change
|
||||||
for (int i = visual + 1; i < sectionCount; ++i) {
|
for (int i = visual + 1; i < sectionCount(); ++i) {
|
||||||
if (!sectionIsCascadable(i))
|
if (!sectionIsCascadable(i))
|
||||||
continue;
|
continue;
|
||||||
int currentSectionSize = headerSectionSize(i);
|
int currentSectionSize = headerSectionSize(i);
|
||||||
@ -3261,7 +3258,7 @@ void QHeaderViewPrivate::cascadingResize(int visual, int newSize)
|
|||||||
|
|
||||||
// let the next section get the space from the resized section
|
// let the next section get the space from the resized section
|
||||||
if (!sectionResized) {
|
if (!sectionResized) {
|
||||||
for (int i = visual + 1; i < sectionCount; ++i) {
|
for (int i = visual + 1; i < sectionCount(); ++i) {
|
||||||
if (!sectionIsCascadable(i))
|
if (!sectionIsCascadable(i))
|
||||||
continue;
|
continue;
|
||||||
int currentSectionSize = headerSectionSize(i);
|
int currentSectionSize = headerSectionSize(i);
|
||||||
@ -3317,14 +3314,14 @@ void QHeaderViewPrivate::resizeSectionSpan(int visualIndex, int oldSize, int new
|
|||||||
|
|
||||||
int QHeaderViewPrivate::headerSectionSize(int visual) const
|
int QHeaderViewPrivate::headerSectionSize(int visual) const
|
||||||
{
|
{
|
||||||
if (visual < sectionCount && visual >= 0)
|
if (visual < sectionCount() && visual >= 0)
|
||||||
return sectionSpans.at(visual).sectionSize();
|
return sectionSpans.at(visual).sectionSize();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int QHeaderViewPrivate::headerSectionPosition(int visual) const
|
int QHeaderViewPrivate::headerSectionPosition(int visual) const
|
||||||
{
|
{
|
||||||
if (visual < sectionCount && visual >= 0) {
|
if (visual < sectionCount() && visual >= 0) {
|
||||||
if (sectionStartposRecalc)
|
if (sectionStartposRecalc)
|
||||||
recalcSectionStartPos();
|
recalcSectionStartPos();
|
||||||
return sectionSpans.at(visual).calculated_startpos;
|
return sectionSpans.at(visual).calculated_startpos;
|
||||||
@ -3416,7 +3413,7 @@ void QHeaderViewPrivate::write(QDataStream &out) const
|
|||||||
out << hiddenSectionSize;
|
out << hiddenSectionSize;
|
||||||
|
|
||||||
out << length;
|
out << length;
|
||||||
out << sectionCount;
|
out << sectionCount();
|
||||||
out << movableSections;
|
out << movableSections;
|
||||||
out << clickableSections;
|
out << clickableSections;
|
||||||
out << highlightSelected;
|
out << highlightSelected;
|
||||||
@ -3452,7 +3449,8 @@ bool QHeaderViewPrivate::read(QDataStream &in)
|
|||||||
in >> hiddenSectionSize;
|
in >> hiddenSectionSize;
|
||||||
|
|
||||||
in >> length;
|
in >> length;
|
||||||
in >> sectionCount;
|
int unusedSectionCount; // For compability
|
||||||
|
in >> unusedSectionCount;
|
||||||
in >> movableSections;
|
in >> movableSections;
|
||||||
in >> clickableSections;
|
in >> clickableSections;
|
||||||
in >> highlightSelected;
|
in >> highlightSelected;
|
||||||
|
@ -84,7 +84,6 @@ public:
|
|||||||
pressed(-1),
|
pressed(-1),
|
||||||
hover(-1),
|
hover(-1),
|
||||||
length(0),
|
length(0),
|
||||||
sectionCount(0),
|
|
||||||
movableSections(false),
|
movableSections(false),
|
||||||
clickableSections(false),
|
clickableSections(false),
|
||||||
highlightSelected(false),
|
highlightSelected(false),
|
||||||
@ -137,11 +136,13 @@ public:
|
|||||||
inline void prepareSectionSelected() {
|
inline void prepareSectionSelected() {
|
||||||
if (!selectionModel || !selectionModel->hasSelection())
|
if (!selectionModel || !selectionModel->hasSelection())
|
||||||
sectionSelected.clear();
|
sectionSelected.clear();
|
||||||
else if (sectionSelected.count() != sectionCount * 2)
|
else if (sectionSelected.count() != sectionCount() * 2)
|
||||||
sectionSelected.fill(false, sectionCount * 2);
|
sectionSelected.fill(false, sectionCount() * 2);
|
||||||
else sectionSelected.fill(false);
|
else sectionSelected.fill(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline int sectionCount() const {return sectionSpans.count();}
|
||||||
|
|
||||||
inline bool reverse() const {
|
inline bool reverse() const {
|
||||||
return orientation == Qt::Horizontal && q_func()->isRightToLeft();
|
return orientation == Qt::Horizontal && q_func()->isRightToLeft();
|
||||||
}
|
}
|
||||||
@ -182,11 +183,11 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline void initializeIndexMapping() const {
|
inline void initializeIndexMapping() const {
|
||||||
if (visualIndices.count() != sectionCount
|
if (visualIndices.count() != sectionCount()
|
||||||
|| logicalIndices.count() != sectionCount) {
|
|| logicalIndices.count() != sectionCount()) {
|
||||||
visualIndices.resize(sectionCount);
|
visualIndices.resize(sectionCount());
|
||||||
logicalIndices.resize(sectionCount);
|
logicalIndices.resize(sectionCount());
|
||||||
for (int s = 0; s < sectionCount; ++s) {
|
for (int s = 0; s < sectionCount(); ++s) {
|
||||||
visualIndices[s] = s;
|
visualIndices[s] = s;
|
||||||
logicalIndices[s] = s;
|
logicalIndices[s] = s;
|
||||||
}
|
}
|
||||||
@ -194,7 +195,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline void clearCascadingSections() {
|
inline void clearCascadingSections() {
|
||||||
firstCascadingSection = sectionCount;
|
firstCascadingSection = sectionSpans.count();
|
||||||
lastCascadingSection = 0;
|
lastCascadingSection = 0;
|
||||||
cascadingSectionSize.clear();
|
cascadingSectionSize.clear();
|
||||||
}
|
}
|
||||||
@ -265,7 +266,6 @@ public:
|
|||||||
int hover;
|
int hover;
|
||||||
|
|
||||||
int length;
|
int length;
|
||||||
int sectionCount;
|
|
||||||
bool movableSections;
|
bool movableSections;
|
||||||
bool clickableSections;
|
bool clickableSections;
|
||||||
bool highlightSelected;
|
bool highlightSelected;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user