summaryrefslogtreecommitdiffstats
path: root/src/widgets/itemviews/qheaderview.cpp
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2013-08-22 00:11:16 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-08-22 02:04:39 +0200
commitc374f4441ab42d1849431bb42fec91a976a8e502 (patch)
tree0733146c5df48b91a39097730c445dbe9cd2359a /src/widgets/itemviews/qheaderview.cpp
parent85b24bb2dea97c3a9b013bacd5a422b26fe5d14b (diff)
parentc8ca300e491c186304d0864a9e870337e891e6f7 (diff)
Merge "Merge remote-tracking branch 'origin/stable' into dev" into refs/staging/dev
Diffstat (limited to 'src/widgets/itemviews/qheaderview.cpp')
-rw-r--r--src/widgets/itemviews/qheaderview.cpp24
1 files changed, 21 insertions, 3 deletions
diff --git a/src/widgets/itemviews/qheaderview.cpp b/src/widgets/itemviews/qheaderview.cpp
index e0034d1298..75cd07bb80 100644
--- a/src/widgets/itemviews/qheaderview.cpp
+++ b/src/widgets/itemviews/qheaderview.cpp
@@ -2711,11 +2711,13 @@ void QHeaderView::paintSection(QPainter *painter, const QRect &rect, int logical
// the section position
int visual = visualIndex(logicalIndex);
Q_ASSERT(visual != -1);
- if (count() == 1)
+ bool first = d->isFirstVisibleSection(visual);
+ bool last = d->isLastVisibleSection(visual);
+ if (first && last)
opt.position = QStyleOptionHeader::OnlyOneSection;
- else if (visual == 0)
+ else if (first)
opt.position = QStyleOptionHeader::Beginning;
- else if (visual == count() - 1)
+ else if (last)
opt.position = QStyleOptionHeader::End;
else
opt.position = QStyleOptionHeader::Middle;
@@ -3138,6 +3140,22 @@ bool QHeaderViewPrivate::isSectionSelected(int section) const
return s;
}
+bool QHeaderViewPrivate::isFirstVisibleSection(int section) const
+{
+ if (sectionStartposRecalc)
+ recalcSectionStartPos();
+ const SectionItem &item = sectionItems.at(section);
+ return item.size > 0 && item.calculated_startpos == 0;
+}
+
+bool QHeaderViewPrivate::isLastVisibleSection(int section) const
+{
+ if (sectionStartposRecalc)
+ recalcSectionStartPos();
+ const SectionItem &item = sectionItems.at(section);
+ return item.size > 0 && item.calculatedEndPos() == length;
+}
+
/*!
\internal
Returns the last visible (ie. not hidden) visual index