44 #ifndef QT_NO_ITEMVIEWS 60 #include <private/qheaderview_p.h> 61 #include <private/qabstractitemmodel_p.h> 63 #ifndef QT_NO_DATASTREAM 69 #ifndef QT_NO_DATASTREAM 81 #endif // QT_NO_DATASTREAM 359 d->setDefaultValues(orientation);
371 d->setDefaultValues(orientation);
393 d->viewport->setMouseTracking(
true);
396 delete d->itemDelegate;
404 if (model == this->
model())
426 this,
SLOT(_q_layoutAboutToBeChanged()));
448 this,
SLOT(_q_layoutAboutToBeChanged()));
470 return d->orientation;
500 if (
d->offset == (
int)newOffset)
502 int ndelta =
d->offset - newOffset;
503 d->offset = newOffset;
507 d->viewport->scroll(0, ndelta);
514 d->firstPos += ndelta;
515 d->lastPos += ndelta;
531 if (visualIndex > -1 && visualIndex < d->sectionCount) {
532 int position =
d->headerSectionPosition(
d->adjustedVisualIndex(visualIndex));
563 d->executePostedLayout();
564 d->executePostedResize();
578 if (
d->cachedSizeHint.isValid())
579 return d->cachedSizeHint;
580 d->cachedSizeHint =
QSize(0, 0);
581 const int sectionCount =
count();
585 for (
int checked = 0; checked < 100 && i < sectionCount; ++i) {
590 d->cachedSizeHint =
d->cachedSizeHint.expandedTo(hint);
593 i =
qMax(i, sectionCount - 100 );
594 for (
int j = sectionCount - 1, checked = 0; j >= i && checked < 100; --j) {
599 d->cachedSizeHint =
d->cachedSizeHint.expandedTo(hint);
601 return d->cachedSizeHint;
616 if (logicalIndex < 0 || logicalIndex >=
count())
621 size = qvariant_cast<QSize>(value);
639 d->executePostedLayout();
640 d->executePostedResize();
641 const int count =
d->sectionCount;
646 vposition =
d->viewport->width() - vposition;
647 vposition +=
d->offset;
649 if (vposition >
d->length)
651 int visual =
d->headerVisualIndexAt(vposition);
655 while (
d->isVisualIndexHidden(visual)){
689 if (logicalIndex < 0 || logicalIndex >=
count())
694 d->executePostedResize();
695 return d->headerSectionSize(visual);
717 d->executePostedResize();
718 return d->headerSectionPosition(visual);
732 if (logicalIndex >=
count())
737 int offsetPosition = position -
d->offset;
739 return d->viewport->width() - (offsetPosition +
sectionSize(logicalIndex));
740 return offsetPosition;
777 d->executePostedLayout();
778 if (from < 0 || from >=
d->sectionCount || to < 0 || to >=
d->sectionCount)
792 d->initializeIndexMapping();
795 int *visualIndices =
d->visualIndices.data();
796 int *logicalIndices =
d->logicalIndices.data();
797 int logical = logicalIndices[from];
800 int affected_count =
qAbs(to - from) + 1;
806 sizes[to - from] =
d->headerSectionSize(from);
807 modes[to - from] =
d->headerSectionResizeMode(from);
808 while (visual < to) {
809 sizes[visual - from] =
d->headerSectionSize(visual + 1);
810 modes[visual - from] =
d->headerSectionResizeMode(visual + 1);
812 sectionHidden.
setBit(visual, sectionHidden.
testBit(visual + 1));
813 visualIndices[logicalIndices[visual + 1]] = visual;
814 logicalIndices[visual] = logicalIndices[visual + 1];
818 sizes[0] =
d->headerSectionSize(from);
819 modes[0] =
d->headerSectionResizeMode(from);
820 while (visual > to) {
821 sizes[visual - to] =
d->headerSectionSize(visual - 1);
822 modes[visual - to] =
d->headerSectionResizeMode(visual - 1);
824 sectionHidden.
setBit(visual, sectionHidden.
testBit(visual - 1));
825 visualIndices[logicalIndices[visual - 1]] = visual;
826 logicalIndices[visual] = logicalIndices[visual - 1];
830 if (!sectionHidden.
isEmpty()) {
831 sectionHidden.
setBit(to,
d->sectionHidden.testBit(from));
832 d->sectionHidden = sectionHidden;
834 visualIndices[logical] = to;
835 logicalIndices[to] = logical;
841 for (visual = from; visual <= to; ++visual) {
842 int size = sizes[visual - from];
844 d->createSectionSpan(visual, visual, size, mode);
847 for (visual = to; visual <= from; ++visual) {
848 int size = sizes[visual - to];
850 d->createSectionSpan(visual, visual, size, mode);
857 if (
d->hasAutoResizeSections())
858 d->doDelayedResizeSections();
859 d->viewport->update();
880 d->executePostedLayout();
881 if (first < 0 || first >=
d->sectionCount || second < 0 || second >=
d->sectionCount)
884 int firstSize =
d->headerSectionSize(first);
885 ResizeMode firstMode =
d->headerSectionResizeMode(first);
886 int firstLogical =
d->logicalIndex(first);
888 int secondSize =
d->headerSectionSize(second);
889 ResizeMode secondMode =
d->headerSectionResizeMode(second);
890 int secondLogical =
d->logicalIndex(second);
892 d->createSectionSpan(second, second, firstSize, firstMode);
893 d->createSectionSpan(first, first, secondSize, secondMode);
895 d->initializeIndexMapping();
897 d->visualIndices[firstLogical] = second;
898 d->logicalIndices[second] = firstLogical;
900 d->visualIndices[secondLogical] = first;
901 d->logicalIndices[first] = secondLogical;
903 if (!
d->sectionHidden.isEmpty()) {
904 bool firstHidden =
d->sectionHidden.testBit(first);
905 bool secondHidden =
d->sectionHidden.testBit(second);
906 d->sectionHidden.setBit(first, secondHidden);
907 d->sectionHidden.setBit(second, firstHidden);
910 d->viewport->update();
930 if (logical < 0 || logical >=
count())
934 d->hiddenSectionSize.insert(logical, size);
942 int oldSize =
d->headerSectionSize(visual);
946 d->executePostedLayout();
947 d->invalidateCachedSizeHint();
950 d->lastSectionSize = size;
953 d->createSectionSpan(visual, visual, size,
d->headerSectionResizeMode(visual));
956 if (
d->hasAutoResizeSections())
957 d->doDelayedResizeSections();
962 int w =
d->viewport->width();
963 int h =
d->viewport->height();
968 r.
setRect(0, 0, pos + size, h);
974 if (
d->hasAutoResizeSections()) {
975 d->doDelayedResizeSections();
976 r =
d->viewport->rect();
992 d->resizeSections(mode,
true);
1027 d->executePostedLayout();
1028 if (logicalIndex >=
d->sectionHidden.count() || logicalIndex < 0 || logicalIndex >=
d->sectionCount)
1032 return d->sectionHidden.testBit(visual);
1048 return d->hiddenSectionSize.count();
1061 if (logicalIndex < 0 || logicalIndex >=
count())
1064 d->executePostedLayout();
1067 if (hide ==
d->isVisualIndexHidden(visual))
1070 int size =
d->headerSectionSize(visual);
1071 if (!
d->hasAutoResizeSections())
1073 d->hiddenSectionSize.insert(logicalIndex, size);
1074 if (
d->sectionHidden.count() <
count())
1075 d->sectionHidden.resize(
count());
1076 d->sectionHidden.setBit(visual,
true);
1077 if (
d->hasAutoResizeSections())
1078 d->doDelayedResizeSections();
1080 int size =
d->hiddenSectionSize.value(logicalIndex,
d->defaultSectionSize);
1081 d->hiddenSectionSize.remove(logicalIndex);
1082 if (
d->hiddenSectionSize.isEmpty()) {
1083 d->sectionHidden.clear();
1085 Q_ASSERT(visual <= d->sectionHidden.count());
1086 d->sectionHidden.setBit(visual,
false);
1103 d->executePostedLayout();
1104 return d->sectionCount;
1119 if (logicalIndex < 0)
1121 d->executePostedLayout();
1122 if (
d->visualIndices.isEmpty()) {
1123 if (logicalIndex < d->sectionCount)
1125 }
else if (logicalIndex < d->visualIndices.count()) {
1126 int visual =
d->visualIndices.at(logicalIndex);
1127 Q_ASSERT(visual < d->sectionCount);
1145 if (visualIndex < 0 || visualIndex >=
d->sectionCount)
1147 return d->logicalIndex(visualIndex);
1161 d->movableSections = movable;
1175 return d->movableSections;
1189 d->clickableSections = clickable;
1204 return d->clickableSections;
1210 d->highlightSelected = highlight;
1216 return d->highlightSelected;
1232 d->setGlobalHeaderResizeMode(mode);
1233 if (
d->hasAutoResizeSections())
1234 d->doDelayedResizeSections();
1261 ResizeMode old =
d->headerSectionResizeMode(visual);
1262 d->setHeaderSectionResizeMode(visual, mode);
1265 ++
d->stretchSections;
1267 ++
d->contentsSections;
1269 --
d->stretchSections;
1271 --
d->contentsSections;
1274 d->doDelayedResizeSections();
1290 return d->headerSectionResizeMode(visual);
1309 return d->stretchSections;
1327 if (
d->sortIndicatorShown == show)
1330 d->sortIndicatorShown =
show;
1338 d->viewport->update();
1344 return d->sortIndicatorShown;
1364 int old =
d->sortIndicatorSection;
1366 d->sortIndicatorOrder = order;
1368 if (logicalIndex >=
d->sectionCount) {
1373 if (old != logicalIndex
1377 d->viewport->update();
1379 if (old >= 0 && old != logicalIndex)
1381 if (logicalIndex >= 0)
1398 return d->sortIndicatorSection;
1411 return d->sortIndicatorOrder;
1435 return d->stretchLastSection;
1441 d->stretchLastSection = stretch;
1470 return d->cascadingResizing;
1476 d->cascadingResizing = enable;
1494 return d->defaultSectionSize;
1500 d->setDefaultSectionSize(size);
1523 if (
d->minimumSectionSize == -1) {
1530 return d->minimumSectionSize;
1536 d->minimumSectionSize =
size;
1551 return d->defaultAlignment;
1557 if (
d->defaultAlignment == alignment)
1560 d->defaultAlignment = alignment;
1561 d->viewport->update();
1582 return !
d->visualIndices.isEmpty();
1596 return !
d->hiddenSectionSize.isEmpty();
1599 #ifndef QT_NO_DATASTREAM 1650 if (
d->read(stream)) {
1652 d->viewport->update();
1657 #endif // QT_NO_DATASTREAM 1678 if (
d->orientation != orientation)
1681 if (logicalFirst < 0 || logicalLast < 0 || logicalFirst >=
count() || logicalLast >=
count())
1684 d->invalidateCachedSizeHint();
1686 int firstVisualIndex =
INT_MAX, lastVisualIndex = -1;
1688 for (
int section = logicalFirst; section <= logicalLast; ++section) {
1690 firstVisualIndex =
qMin(firstVisualIndex, visual);
1691 lastVisualIndex =
qMax(lastVisualIndex, visual);
1694 d->executePostedResize();
1695 const int first =
d->headerSectionPosition(firstVisualIndex),
1696 last =
d->headerSectionPosition(lastVisualIndex)
1697 +
d->headerSectionSize(lastVisualIndex);
1700 d->viewport->update(first, 0, last - first,
d->viewport->height());
1702 d->viewport->update(0, first,
d->viewport->width(), last - first);
1735 if (
d->hasAutoResizeSections())
1749 int logicalFirst,
int logicalLast)
1752 if (parent !=
d->root)
1754 int oldCount =
d->sectionCount;
1756 d->invalidateCachedSizeHint();
1760 for (
int spanStart = 0; insertAt <
d->sectionSpans.count() && spanStart < logicalFirst; ++insertAt)
1761 spanStart +=
d->sectionSpans.at(insertAt).count;
1763 int insertCount = logicalLast - logicalFirst + 1;
1764 d->sectionCount += insertCount;
1766 if (
d->sectionSpans.isEmpty() || insertAt >=
d->sectionSpans.count()) {
1767 int insertLength =
d->defaultSectionSize * insertCount;
1768 d->length += insertLength;
1770 d->sectionSpans.append(span);
1771 }
else if ((
d->sectionSpans.at(insertAt).sectionSize() ==
d->defaultSectionSize)
1772 &&
d->sectionSpans.at(insertAt).resizeMode ==
d->globalResizeMode) {
1774 int insertLength =
d->sectionSpans.at(insertAt).sectionSize() * insertCount;
1775 d->length += insertLength;
1776 d->sectionSpans[insertAt].size += insertLength;
1777 d->sectionSpans[insertAt].count += insertCount;
1780 int insertLength =
d->defaultSectionSize * insertCount;
1781 d->length += insertLength;
1783 d->sectionSpans.insert(insertAt, span);
1787 if (
d->sortIndicatorSection >= logicalFirst)
1788 d->sortIndicatorSection += insertCount;
1791 if (
d->globalResizeMode ==
Stretch)
1792 d->stretchSections =
d->sectionCount;
1794 d->contentsSections =
d->sectionCount;
1797 d->sectionSelected.clear();
1800 if (!
d->visualIndices.isEmpty() && !
d->logicalIndices.isEmpty()) {
1801 Q_ASSERT(
d->visualIndices.count() ==
d->logicalIndices.count());
1802 int mappingCount =
d->visualIndices.count();
1803 for (
int i = 0; i < mappingCount; ++i) {
1804 if (
d->visualIndices.at(i) >= logicalFirst)
1805 d->visualIndices[i] += insertCount;
1806 if (
d->logicalIndices.at(i) >= logicalFirst)
1807 d->logicalIndices[i] += insertCount;
1809 for (
int j = logicalFirst; j <= logicalLast; ++j) {
1810 d->visualIndices.insert(j, j);
1811 d->logicalIndices.insert(j, j);
1816 if (!
d->sectionHidden.isEmpty()) {
1818 sectionHidden.
resize(sectionHidden.
count() + insertCount);
1819 sectionHidden.
fill(
false, logicalFirst, logicalLast + 1);
1820 for (
int j = logicalLast + 1; j < sectionHidden.
count(); ++j)
1822 sectionHidden.
setBit(j,
d->sectionHidden.testBit(j - insertCount));
1823 d->sectionHidden = sectionHidden;
1828 for (
int i = 0; i < logicalFirst; ++i)
1830 newHiddenSectionSize[i] =
d->hiddenSectionSize[i];
1831 for (
int j = logicalLast + 1; j <
d->sectionCount; ++j)
1833 newHiddenSectionSize[j] =
d->hiddenSectionSize[j - insertCount];
1834 d->hiddenSectionSize = newHiddenSectionSize;
1836 d->doDelayedResizeSections();
1840 if (!
d->hasAutoResizeSections())
1841 d->viewport->update();
1853 int logicalFirst,
int logicalLast)
1863 const int changeCount = logicalLast - logicalFirst + 1;
1867 for (
int i = 0; i < logicalFirst; ++i)
1868 if (q->isSectionHidden(i))
1869 newHiddenSectionSize[i] = hiddenSectionSize[i];
1870 for (
int j = logicalLast + 1; j < sectionCount; ++j)
1871 if (q->isSectionHidden(j))
1872 newHiddenSectionSize[j - changeCount] = hiddenSectionSize[j];
1873 hiddenSectionSize = newHiddenSectionSize;
1876 if (!sectionHidden.isEmpty()) {
1877 const int newsize =
qMin(sectionCount - changeCount, sectionHidden.size());
1879 for (
int j = 0, k = 0; j < sectionHidden.size(); ++j) {
1881 if (logical < logicalFirst || logical > logicalLast) {
1882 newSectionHidden[k++] = sectionHidden[j];
1885 sectionHidden = newSectionHidden;
1890 int logicalFirst,
int logicalLast)
1895 if (
qMin(logicalFirst, logicalLast) < 0
1896 ||
qMax(logicalLast, logicalFirst) >= sectionCount)
1898 int oldCount = q->count();
1899 int changeCount = logicalLast - logicalFirst + 1;
1901 updateHiddenSections(logicalFirst, logicalLast);
1903 if (visualIndices.isEmpty() && logicalIndices.isEmpty()) {
1905 removeSectionsFromSpans(logicalFirst, logicalLast);
1907 for (
int l = logicalLast;
l >= logicalFirst; --
l) {
1908 int visual = visualIndices.at(
l);
1909 for (
int v = 0; v < sectionCount; ++v) {
1910 if (v >= logicalIndices.count())
1913 int logical = logicalIndices.at(v);
1914 --(visualIndices[logical]);
1917 --(logicalIndices[v]);
1919 logicalIndices.remove(visual);
1920 visualIndices.remove(
l);
1922 removeSectionsFromSpans(visual, visual);
1926 sectionCount -= changeCount;
1937 if (sectionCount <= 0)
1939 invalidateCachedSizeHint();
1940 emit q->sectionCountChanged(oldCount, q->count());
1954 for (
int i = 0; i < sectionHidden.count(); ++i)
1955 if (sectionHidden.testBit(i))
1965 if (persistentHiddenSections.isEmpty() || modelIsEmpty()) {
1966 if (modelSectionCount() != sectionCount)
1967 q->initializeSections();
1968 persistentHiddenSections.clear();
1972 QBitArray oldSectionHidden = sectionHidden;
1975 for (
int i = 0; i < persistentHiddenSections.count(); ++i) {
1981 q->setSectionHidden(logical,
true);
1982 oldSectionHidden.
setBit(logical,
false);
1983 }
else if (!sectionCountChanged && (modelSectionCount() != sectionCount)) {
1984 sectionCountChanged =
true;
1988 persistentHiddenSections.clear();
1990 for (
int i = 0; i < oldSectionHidden.
count(); ++i) {
1991 if (oldSectionHidden.
testBit(i))
1992 q->setSectionHidden(i,
false);
1996 if (sectionCountChanged)
1997 q->initializeSections();
2007 const int oldCount =
d->sectionCount;
2008 const int newCount =
d->modelSectionCount();
2009 if (newCount <= 0) {
2012 }
else if (newCount != oldCount) {
2013 const int min =
qBound(0, oldCount, newCount - 1);
2019 if (newCount < oldCount)
2020 d->updateHiddenSections(0, newCount-1);
2035 d->invalidateCachedSizeHint();
2037 if (end + 1 <
d->sectionCount) {
2038 int newCount = end + 1;
2039 d->removeSectionsFromSpans(newCount,
d->sectionCount);
2040 if (!
d->hiddenSectionSize.isEmpty()) {
2041 if (
d->sectionCount - newCount >
d->hiddenSectionSize.count()) {
2042 for (
int i = end + 1; i <
d->sectionCount; ++i)
2043 d->hiddenSectionSize.remove(i);
2046 while (it !=
d->hiddenSectionSize.end()) {
2048 it =
d->hiddenSectionSize.erase(it);
2056 int oldCount =
d->sectionCount;
2057 d->sectionCount = end + 1;
2059 if (!
d->logicalIndices.isEmpty()) {
2060 if (oldCount <= d->sectionCount) {
2061 d->logicalIndices.resize(
d->sectionCount);
2062 d->visualIndices.resize(
d->sectionCount);
2063 for (
int i = oldCount; i <
d->sectionCount; ++i) {
2064 d->logicalIndices[i] = i;
2065 d->visualIndices[i] = i;
2069 for (
int i = 0; i < oldCount; ++i) {
2070 int v =
d->logicalIndices.at(i);
2071 if (v < d->sectionCount) {
2072 d->logicalIndices[j] = v;
2073 d->visualIndices[v] = j;
2077 d->logicalIndices.resize(
d->sectionCount);
2078 d->visualIndices.resize(
d->sectionCount);
2082 if (
d->globalResizeMode ==
Stretch)
2083 d->stretchSections =
d->sectionCount;
2085 d->contentsSections =
d->sectionCount;
2086 if (!
d->sectionHidden.isEmpty())
2087 d->sectionHidden.resize(
d->sectionCount);
2089 if (
d->sectionCount > oldCount)
2090 d->createSectionSpan(start, end, (end - start + 1) *
d->defaultSectionSize,
d->globalResizeMode);
2093 if (
d->sectionCount != oldCount)
2095 d->viewport->update();
2131 switch (e->
type()) {
2146 int oldHover =
d->hover;
2148 if (
d->hover != oldHover) {
2157 if (te->
timerId() ==
d->delayedResize.timerId()) {
2158 d->delayedResize.stop();
2195 start = (start == -1 ?
count() - 1 : start);
2196 end = (end == -1 ? 0 :
end);
2198 start = (start == -1 ? 0 : start);
2199 end = (end == -1 ?
count() - 1 :
end);
2203 start =
qMin(start, end);
2204 end =
qMax(tmp, end);
2206 d->prepareSectionSelected();
2208 QRect currentSectionRect;
2210 const int width =
d->viewport->width();
2211 const int height =
d->viewport->height();
2212 for (
int i = start; i <=
end; ++i) {
2213 if (
d->isVisualIndexHidden(i))
2239 if (currentSectionRect.
left() > translatedEventRect.
left()) {
2244 }
else if (currentSectionRect.
right() < translatedEventRect.
right()) {
2250 }
else if (currentSectionRect.
bottom() < translatedEventRect.
bottom()) {
2260 for (
int a = 0, i = 0; i <
d->sectionSpans.count(); ++i) {
2261 QColor color((i & 4 ? 255 : 0), (i & 2 ? 255 : 0), (i & 1 ? 255 : 0));
2263 painter.
fillRect(
a -
d->offset, 0,
d->sectionSpans.at(i).size, 4, color);
2265 painter.
fillRect(0,
a -
d->offset, 4,
d->sectionSpans.at(i).size, color);
2266 a +=
d->sectionSpans.at(i).size;
2282 int handle =
d->sectionHandleAt(pos);
2283 d->originalSize = -1;
2286 if (
d->clickableSections)
2288 if (
d->movableSections) {
2289 d->section =
d->target =
d->pressed;
2290 if (
d->section == -1)
2293 d->setupSectionIndicator(
d->section, pos);
2294 }
else if (
d->clickableSections &&
d->pressed != -1) {
2301 d->section = handle;
2307 d->clearCascadingSections();
2321 #if !defined(Q_WS_MAC) 2334 if (
d->cascadingResizing) {
2335 int delta =
d->reverse() ?
d->lastPos -
pos : pos -
d->lastPos;
2337 d->cascadingResize(visual,
d->headerSectionSize(visual) + delta);
2339 int delta =
d->reverse() ?
d->firstPos -
pos : pos -
d->firstPos;
2347 || !
d->sectionIndicator->isHidden()) {
2351 int posThreshold =
d->headerSectionPosition(visual) -
d->offset +
d->headerSectionSize(visual) / 2;
2353 if (visual < moving) {
2354 if (pos < posThreshold)
2355 d->target =
d->logicalIndex(visual);
2357 d->target =
d->logicalIndex(visual + 1);
2358 }
else if (visual > moving) {
2359 if (pos > posThreshold)
2360 d->target =
d->logicalIndex(visual);
2362 d->target =
d->logicalIndex(visual - 1);
2364 d->target =
d->section;
2366 d->updateSectionIndicator(
d->section, pos);
2372 if (logical ==
d->pressed)
2374 else if (
d->pressed != -1)
2376 d->pressed = logical;
2377 if (
d->clickableSections && logical != -1) {
2384 #ifndef QT_NO_CURSOR 2385 int handle =
d->sectionHandleAt(pos);
2390 }
else if (hasCursor) {
2411 if (!
d->sectionIndicator->isHidden()) {
2417 d->section =
d->target = -1;
2418 d->updateSectionIndicator(
d->section, pos);
2422 if (!
d->clickableSections) {
2428 if (
d->clickableSections) {
2430 if (section != -1 && section ==
d->pressed) {
2431 d->flipSortIndicator(section);
2434 if (
d->pressed != -1)
2439 d->originalSize = -1;
2440 d->clearCascadingSections();
2457 int handle =
d->sectionHandleAt(pos);
2460 #ifndef QT_NO_CURSOR 2465 handle =
d->sectionHandleAt(pos);
2482 switch (e->
type()) {
2483 #ifndef QT_NO_TOOLTIP 2487 if (logical != -1) {
2496 #ifndef QT_NO_WHATSTHIS 2507 if (logical != -1) {
2508 QVariant whatsthis =
d->model->headerData(logical,
d->orientation,
2516 #endif // QT_NO_WHATSTHIS 2517 #ifndef QT_NO_STATUSTIP 2521 if (logical != -1) {
2522 QString statustip =
d->model->headerData(logical,
d->orientation,
2528 #endif // QT_NO_STATUSTIP 2533 d->invalidateCachedSizeHint();
2539 d->pressed =
d->section =
d->target = -1;
2540 d->updateSectionIndicator(
d->section, -1);
2573 if (
d->clickableSections) {
2574 if (logicalIndex ==
d->hover)
2576 if (logicalIndex ==
d->pressed)
2578 else if (
d->highlightSelected) {
2579 if (
d->sectionIntersectsSelection(logicalIndex))
2581 if (
d->isSectionSelected(logicalIndex))
2591 QVariant textAlignment =
d->model->headerData(logicalIndex,
d->orientation,
2597 ? Qt::Alignment(textAlignment.
toInt())
2598 :
d->defaultAlignment);
2601 opt.
text =
d->model->headerData(logicalIndex,
d->orientation,
2610 opt.
icon = qvariant_cast<QPixmap>(variant);
2611 QVariant foregroundBrush =
d->model->headerData(logicalIndex,
d->orientation,
2617 QVariant backgroundBrush =
d->model->headerData(logicalIndex,
d->orientation,
2630 else if (visual == 0)
2632 else if (visual ==
count() - 1)
2638 bool previousSelected =
d->isSectionSelected(this->
logicalIndex(visual - 1));
2639 bool nextSelected =
d->isSectionSelected(this->
logicalIndex(visual + 1));
2640 if (previousSelected && nextSelected)
2642 else if (previousSelected)
2644 else if (nextSelected)
2671 return qvariant_cast<QSize>(variant);
2677 QVariant var =
d->model->headerData(logicalIndex,
d->orientation,
2686 opt.
text =
d->model->headerData(logicalIndex,
d->orientation,
2691 opt.
icon = qvariant_cast<QPixmap>(variant);
2741 d->layoutChildren();
2742 if (
d->hasAutoResizeSections())
2743 d->doDelayedResizeSections();
2754 d->scrollDirtyRegion(dx, dy);
2764 d->invalidateCachedSizeHint();
2765 if (
d->hasAutoResizeSections()) {
2769 for (
int i = first; i <= last && !resizeRequired; ++i)
2772 d->doDelayedResizeSections();
2889 const int max =
d->modelSectionCount();
2893 int rangeLeft, rangeRight;
2895 for (
int i = 0; i < selection.
count(); ++i) {
2901 if (rangeLeft == -1)
2904 if (rangeRight == -1)
2906 if (rangeLeft < left)
2908 if (rangeRight > right)
2915 if (logicalLeft < 0 || logicalLeft >=
count() ||
2916 logicalRight < 0 || logicalRight >=
count())
2922 return QRect(leftPos, 0, rightPos - leftPos,
height());
2927 int rangeTop, rangeBottom;
2929 for (
int i = 0; i < selection.
count(); ++i) {
2938 if (rangeBottom == -1)
2942 if (rangeBottom > bottom)
2943 bottom = rangeBottom;
2949 if (logicalTop == -1 || logicalBottom == -1)
2955 return QRect(0, topPos,
width(), bottomPos - topPos);
2964 int visual = q->visualIndexAt(position);
2968 int pos = q->sectionViewportPosition(log);
2971 bool atLeft = position < pos + grip;
2972 bool atRight = (position > pos + q->sectionSize(log) - grip);
2974 qSwap(atLeft, atRight);
2978 while(visual > -1) {
2979 int logical = q->logicalIndex(--visual);
2980 if (!q->isSectionHidden(logical))
2983 }
else if (atRight) {
2993 if (!sectionIndicator) {
2998 int p = q->sectionViewportPosition(section);
3000 w = q->sectionSize(section);
3004 h = q->sectionSize(section);
3006 sectionIndicator->resize(w, h);
3014 q->paintSection(&painter, rect, section);
3017 sectionIndicator->setPixmap(pm);
3018 sectionIndicatorOffset = position -
qMax(p, 0);
3023 if (!sectionIndicator)
3026 if (section == -1 || target == -1) {
3027 sectionIndicator->hide();
3032 sectionIndicator->move(position - sectionIndicatorOffset, 0);
3034 sectionIndicator->move(0, position - sectionIndicatorOffset);
3036 sectionIndicator->show();
3061 int i = section * 2;
3062 if (i < 0 || i >= sectionSelected.count())
3064 if (sectionSelected.testBit(i))
3065 return sectionSelected.testBit(i + 1);
3068 s = isColumnSelected(section);
3070 s = isRowSelected(section);
3071 sectionSelected.setBit(i + 1, s);
3072 sectionSelected.setBit(i,
true);
3086 for (
int visual = q->count()-1; visual >= 0; --visual) {
3087 if (!q->isSectionHidden(q->logicalIndex(visual)))
3115 delayedResize.stop();
3117 executePostedLayout();
3118 if (sectionCount == 0)
3121 if (resizeRecursionBlock)
3123 resizeRecursionBlock =
true;
3125 invalidateCachedSizeHint();
3127 const int lastVisibleSection = lastVisibleVisualIndex();
3130 int stretchSection = -1;
3132 stretchSection = lastVisibleVisualIndex();
3136 int numberOfStretchedSections = 0;
3138 for (
int i = 0; i < sectionCount; ++i) {
3139 if (isVisualIndexHidden(i))
3143 if (useGlobalMode && (i != stretchSection))
3144 resizeMode = globalMode;
3149 ++numberOfStretchedSections;
3150 section_sizes.
append(headerSectionSize(i));
3157 sectionSize = headerSectionSize(i);
3160 sectionSize =
qMax(viewSectionSizeHint(logicalIndex),
3161 q->sectionSizeHint(logicalIndex));
3163 section_sizes.
append(sectionSize);
3168 int stretchSectionLength = -1;
3169 int pixelReminder = 0;
3170 if (numberOfStretchedSections > 0 && lengthToStrech > 0) {
3171 int hintLengthForEveryStretchedSection = lengthToStrech / numberOfStretchedSections;
3172 stretchSectionLength =
qMax(hintLengthForEveryStretchedSection, q->minimumSectionSize());
3173 pixelReminder = lengthToStrech % numberOfStretchedSections;
3176 int spanStartSection = 0;
3177 int previousSectionLength = 0;
3182 for (
int i = 0; i < sectionCount; ++i) {
3183 int oldSectionLength = headerSectionSize(i);
3184 int newSectionLength = -1;
3187 if (isVisualIndexHidden(i)) {
3188 newSectionLength = 0;
3192 resizeMode = globalMode;
3194 resizeMode = (i == stretchSection
3196 : newSectionResizeMode);
3198 if (i == lastVisibleSection)
3199 newSectionLength =
qMax(stretchSectionLength, lastSectionSize);
3201 newSectionLength = stretchSectionLength;
3202 if (pixelReminder > 0) {
3203 newSectionLength += 1;
3208 newSectionLength = section_sizes.
front();
3214 if ((previousSectionResizeMode != newSectionResizeMode
3215 || previousSectionLength != newSectionLength) && i > 0) {
3216 int spanLength = (i - spanStartSection) * previousSectionLength;
3217 createSectionSpan(spanStartSection, i - 1, spanLength, previousSectionResizeMode);
3219 spanStartSection = i;
3222 if (newSectionLength != oldSectionLength)
3223 emit q->sectionResized(
logicalIndex(i), oldSectionLength, newSectionLength);
3225 previousSectionLength = newSectionLength;
3226 previousSectionResizeMode = newSectionResizeMode;
3229 createSectionSpan(spanStartSection, sectionCount - 1,
3230 (sectionCount - spanStartSection) * previousSectionLength,
3231 previousSectionResizeMode);
3233 resizeRecursionBlock =
false;
3243 int start_section = 0;
3245 int initial_section_count = headerSectionCount();
3249 for (
int i = 0; i < sectionSpans.count(); ++i) {
3250 int end_section = start_section + sectionSpans.
at(i).count - 1;
3251 int section_count = sectionSpans.at(i).count;
3252 if (start <= start_section && end > end_section) {
3255 }
else if (start < start_section && end >= end_section) {
3258 }
else if (start == start_section && end == end_section) {
3260 length -= sectionSpans.at(i).size;
3262 sectionSpans[i].size =
size;
3263 sectionSpans[i].resizeMode = mode;
3265 removeSpans(spansToRemove);
3266 Q_ASSERT(initial_section_count == headerSectionCount());
3268 }
else if (start > start_section && end < end_section) {
3269 if (sectionSpans.at(i).sectionSize() == span.
sectionSize()
3270 && sectionSpans.at(i).resizeMode == span.
resizeMode) {
3271 Q_ASSERT(initial_section_count == headerSectionCount());
3275 length -= sectionSpans.at(i).size;
3276 int section_size = sectionSpans.at(i).sectionSize();
3278 int span_count = sectionSpans.at(i).count;
3282 int first_span_count = start - start_section;
3283 int first_span_size = section_size * first_span_count;
3284 sectionSpans[i].count = first_span_count;
3285 sectionSpans[i].size = first_span_size;
3286 sectionSpans[i].resizeMode = span_mode;
3287 length += first_span_size;
3290 int mid_span_count = span.
count;
3292 int mid_span_size = span.
size;
3293 sectionSpans.insert(i + 1, span);
3296 int last_span_count = end_section -
end;
3297 int last_span_size = section_size * last_span_count;
3298 sectionSpans.insert(i + 2,
SectionSpan(last_span_size, last_span_count, span_mode));
3299 length += last_span_size;
3300 Q_ASSERT(span_count == first_span_count + mid_span_count + last_span_count);
3301 removeSpans(spansToRemove);
3302 Q_ASSERT(initial_section_count == headerSectionCount());
3304 }
else if (start > start_section && start <= end_section && end >= end_section) {
3306 length -= sectionSpans.at(i).size;
3307 int removed_count = (end_section - start + 1);
3308 int span_count = sectionSpans.at(i).count - removed_count;
3309 int section_size = sectionSpans.at(i).sectionSize();
3310 int span_size = section_size * span_count;
3311 sectionSpans[i].count = span_count;
3312 sectionSpans[i].size = span_size;
3314 if (end == end_section) {
3315 sectionSpans.insert(i + 1, span);
3317 removeSpans(spansToRemove);
3318 Q_ASSERT(initial_section_count == headerSectionCount());
3321 }
else if (end < end_section && end >= start_section && start <= start_section) {
3323 length -= sectionSpans.at(i).size;
3324 int removed_count = (end - start_section + 1);
3325 int section_size = sectionSpans.at(i).sectionSize();
3326 int span_count = sectionSpans.at(i).count - removed_count;
3327 int span_size = section_size * span_count;
3328 sectionSpans[i].count = span_count;
3329 sectionSpans[i].size = span_size;
3331 sectionSpans.insert(i, span);
3333 removeSpans(spansToRemove);
3334 Q_ASSERT(initial_section_count == headerSectionCount());
3337 start_section += section_count;
3343 if (spansToRemove.
isEmpty()) {
3344 if (!sectionSpans.isEmpty()
3345 && sectionSpans.last().sectionSize() == span.
sectionSize()
3346 && sectionSpans.last().resizeMode == span.
resizeMode) {
3348 int last = sectionSpans.count() - 1;
3349 sectionSpans[last].count += span.
count;
3350 sectionSpans[last].size += span.
size;
3351 sectionSpans[last].resizeMode = span.
resizeMode;
3354 sectionSpans.append(span);
3357 removeSpans(spansToRemove);
3359 sectionSpans.insert(spansToRemove.
first(), span);
3367 int start_section = 0;
3369 for (
int i = 0; i < sectionSpans.count(); ++i) {
3370 int end_section = start_section + sectionSpans.
at(i).count - 1;
3371 int section_size = sectionSpans.at(i).sectionSize();
3372 int section_count = sectionSpans.at(i).count;
3373 if (start <= start_section && end >= end_section) {
3376 if (end == end_section)
3378 }
else if (start > start_section && end < end_section) {
3380 int change = (end - start + 1);
3381 sectionSpans[i].count -= change;
3382 sectionSpans[i].size = section_size * sectionSpans.at(i).count;
3383 length -= (change * section_size);
3385 }
else if (start >= start_section && start <= end_section) {
3387 int change =
qMin(end_section - start + 1, end - start + 1);
3388 sectionSpans[i].count -= change;
3389 sectionSpans[i].size = section_size * sectionSpans.at(i).count;
3391 length -= (change * section_size);
3393 }
else if (end >= start_section && end <= end_section) {
3395 int change =
qMin((end - start_section + 1), end - start + 1);
3396 sectionSpans[i].count -= change;
3397 sectionSpans[i].size = section_size * sectionSpans.at(i).count;
3398 length -= (change * section_size);
3401 start_section += section_count;
3404 for (
int i = spansToRemove.
count() - 1; i >= 0; --i) {
3405 int s = spansToRemove.
at(i);
3406 length -= sectionSpans.at(s).size;
3407 sectionSpans.remove(s);
3414 if (
state != NoClear) {
3417 visualIndices.clear();
3418 logicalIndices.clear();
3419 sectionSelected.clear();
3420 sectionHidden.clear();
3421 hiddenSectionSize.clear();
3422 sectionSpans.clear();
3423 invalidateCachedSizeHint();
3436 sortOrder = static_cast<Qt::SortOrder>(value.
toInt());
3440 q->setSortIndicator(section, sortOrder);
3447 const int oldSize = headerSectionSize(visual);
3448 int delta = newSize - oldSize;
3454 for (
int i = firstCascadingSection; i < visual; ++i) {
3455 if (cascadingSectionSize.contains(i)) {
3456 int currentSectionSize = headerSectionSize(i);
3457 int originalSectionSize = cascadingSectionSize.value(i);
3458 if (currentSectionSize < originalSectionSize) {
3459 int newSectionSize = currentSectionSize + delta;
3460 resizeSectionSpan(i, currentSectionSize, newSectionSize);
3461 if (newSectionSize >= originalSectionSize &&
false)
3462 cascadingSectionSize.remove(i);
3463 sectionResized =
true;
3471 if (!sectionResized) {
3472 newSize =
qMax(newSize, minimumSize);
3473 if (oldSize != newSize)
3474 resizeSectionSpan(visual, oldSize, newSize);
3478 for (
int i = visual + 1; i < sectionCount; ++i) {
3479 if (!sectionIsCascadable(i))
3481 int currentSectionSize = headerSectionSize(i);
3482 if (currentSectionSize <= minimumSize)
3484 int newSectionSize =
qMax(currentSectionSize - delta, minimumSize);
3486 resizeSectionSpan(i, currentSectionSize, newSectionSize);
3487 saveCascadingSectionSize(i, currentSectionSize);
3488 delta = delta - (currentSectionSize - newSectionSize);
3498 for (
int i = lastCascadingSection; i > visual; --i) {
3499 if (!cascadingSectionSize.contains(i))
3501 int currentSectionSize = headerSectionSize(i);
3502 int originalSectionSize = cascadingSectionSize.value(i);
3503 if (currentSectionSize >= originalSectionSize)
3505 int newSectionSize = currentSectionSize - delta;
3506 resizeSectionSpan(i, currentSectionSize, newSectionSize);
3507 if (newSectionSize >= originalSectionSize &&
false) {
3509 cascadingSectionSize.remove(i);
3511 sectionResized =
true;
3516 resizeSectionSpan(visual, oldSize,
qMax(newSize, minimumSize));
3519 if (delta < 0 && newSize < minimumSize) {
3520 for (
int i = visual - 1; i >= 0; --i) {
3521 if (!sectionIsCascadable(i))
3524 if (sectionSize <= minimumSize)
3526 resizeSectionSpan(i, sectionSize,
qMax(sectionSize + delta, minimumSize));
3527 saveCascadingSectionSize(i, sectionSize);
3533 if (!sectionResized) {
3534 for (
int i = visual + 1; i < sectionCount; ++i) {
3535 if (!sectionIsCascadable(i))
3537 int currentSectionSize = headerSectionSize(i);
3538 int newSectionSize =
qMax(currentSectionSize - delta, minimumSize);
3539 resizeSectionSpan(i, currentSectionSize, newSectionSize);
3545 if (hasAutoResizeSections())
3546 doDelayedResizeSections();
3555 int currentVisualIndex = 0;
3556 for (
int i = 0; i < sectionSpans.count(); ++i) {
3558 if (span.
size > 0) {
3561 if (newSize != span.
size) {
3565 for (
int i = currentVisualIndex; i < currentVisualIndex + span.
count; ++i) {
3570 currentVisualIndex += span.
count;
3578 createSectionSpan(visualIndex, visualIndex, newSize, mode);
3585 int section_start = 0;
3586 const int sectionSpansCount = sectionSpans.count();
3587 for (
int i = 0; i < sectionSpansCount; ++i) {
3589 int section_end = section_start + currentSection.
count - 1;
3590 if (visual >= section_start && visual <= section_end)
3592 section_start = section_end + 1;
3600 int section_start = 0;
3601 int span_position = 0;
3602 const int sectionSpansCount = sectionSpans.count();
3603 for (
int i = 0; i < sectionSpansCount; ++i) {
3605 int section_end = section_start + currentSection.
count - 1;
3606 if (visual >= section_start && visual <= section_end)
3607 return span_position + (visual - section_start) * currentSection.
sectionSize();
3608 section_start = section_end + 1;
3609 span_position += currentSection.
size;
3617 int span_start_section = 0;
3618 int span_position = 0;
3619 const int sectionSpansCount = sectionSpans.count();
3620 for (
int i = 0; i < sectionSpansCount; ++i) {
3622 int next_span_start_section = span_start_section + currentSection.
count;
3623 int next_span_position = span_position + currentSection.
size;
3624 if (position == span_position && currentSection.
size > 0)
3625 return span_start_section;
3626 if (position > span_position && position < next_span_position) {
3627 int position_in_span = position - span_position;
3628 return span_start_section + (position_in_span / currentSection.
sectionSize());
3630 span_start_section = next_span_start_section;
3631 span_position = next_span_position;
3638 int size = headerSectionSize(visual);
3639 createSectionSpan(visual, visual, size, mode);
3644 int span = sectionSpanIndex(visual);
3646 return globalResizeMode;
3647 return sectionSpans.at(span).resizeMode;
3652 globalResizeMode = mode;
3653 for (
int i = 0; i < sectionSpans.count(); ++i)
3661 ? view->sizeHintForColumn(logical)
3662 : view->sizeHintForRow(logical));
3669 if (hiddenSectionSize.count() > 0) {
3671 int currentVisualIndex = 0;
3672 for (
int i = 0; i < sectionSpans.count(); ++i) {
3673 if (sectionSpans.at(i).size == 0)
3674 adjustedVisualIndex += sectionSpans.at(i).count;
3676 currentVisualIndex += sectionSpans.at(i).count;
3677 if (currentVisualIndex >= visualIndex)
3680 visualIndex = adjustedVisualIndex;
3685 #ifndef QT_NO_DATASTREAM 3691 out << sortIndicatorShown;
3693 out << visualIndices;
3694 out << logicalIndices;
3696 out << sectionHidden;
3697 out << hiddenSectionSize;
3700 out << sectionCount;
3701 out << movableSections;
3702 out << clickableSections;
3703 out << highlightSelected;
3705 out << cascadingResizing;
3706 out << stretchSections;
3707 out << contentsSections;
3712 out << int(globalResizeMode);
3714 out << sectionSpans;
3719 int orient, order, align, global;
3727 in >> sortIndicatorShown;
3729 in >> visualIndices;
3730 in >> logicalIndices;
3732 in >> sectionHidden;
3733 in >> hiddenSectionSize;
3737 in >> movableSections;
3738 in >> clickableSections;
3739 in >> highlightSelected;
3741 in >> cascadingResizing;
3742 in >> stretchSections;
3743 in >> contentsSections;
3758 #endif // QT_NO_DATASTREAM 3762 #endif // QT_NO_ITEMVIEWS 3764 #include "moc_qheaderview.cpp" The QVariant class acts like a union for the most common Qt data types.
The QPainter class performs low-level painting on widgets and other paint devices.
The QColor class provides colors based on RGB, HSV or CMYK values.
Status status() const
Returns the status of the data stream.
virtual int columnCount(const QModelIndex &parent=QModelIndex()) const =0
Returns the number of columns for the children of the given parent.
virtual void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end)
This slot is called when rows are about to be removed.
static QAbstractItemModel * staticEmptyModel()
int left() const
Returns the column index corresponding to the leftmost selected column in the selection range...
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
void setBit(int i)
Sets the bit at index position i to 1.
#define QT_END_NAMESPACE
This macro expands to.
int maxWidth() const
Returns the width of the widest character in the font.
QStyle::State state
the style flags that are used when drawing the control
#define it(className, varName)
static QSize globalStrut()
bool isValid() const
Returns true if the selection range is valid; otherwise returns false.
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=0, const QWidget *widget=0) const =0
Returns the value of the given pixel metric.
virtual int rowCount(const QModelIndex &parent=QModelIndex()) const =0
Returns the number of rows under the given parent.
The QByteArray class provides an array of bytes.
static C reverse(const C &l)
The QHoverEvent class contains parameters that describe a mouse event.
The QPointF class defines a point in the plane using floating point precision.
static qreal position(QGraphicsObject *item, QDeclarativeAnchorLine::AnchorLine anchorLine)
void restore()
Restores the current painter state (pops a saved state off the stack).
QRect normalized() const
Returns a normalized rectangle; i.e., a rectangle that has a non-negative width and height...
static void clear(QVariant::Private *d)
The QItemSelectionRange class manages information about a range of selected items in a model...
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
int left() const
Returns the x-coordinate of the rectangle's left edge.
int width() const
Returns the width of the rectangle.
void init(const QWidget *w)
Use initFrom(widget) instead.
int bottom() const
Returns the row index corresponding to the lowermost selected row in the selection range...
long ASN1_INTEGER_get ASN1_INTEGER * a
int count(const T &t) const
Returns the number of occurrences of value in the list.
int right() const
Returns the column index corresponding to the rightmost selected column in the selection range...
int bottom() const
Returns the y-coordinate of the rectangle's bottom edge.
The QString class provides a Unicode character string.
QFontMetrics fontMetrics
the font metrics that should be used when drawing text in the control
T * qobject_cast(QObject *object)
virtual void doItemsLayout()
This function is intended to lay out the items in the view.
static void setPos(int x, int y)
Moves the cursor (hot spot) to the global screen position (x, y).
bool testBit(int i) const
Returns true if the bit at index position i is 1; otherwise returns false.
Q_DECL_CONSTEXPR T qAbs(const T &t)
void setBrushOrigin(int x, int y)
Sets the brush's origin to point (x, y).
QModelIndex parent() const
Returns the parent model item index of the items in the selection range.
QModelIndex parent() const
Returns the parent of the model index, or QModelIndex() if it has no parent.
Q_CORE_EXPORT QTextStream & right(QTextStream &s)
virtual QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
Returns the data for the given role and section in the header with the specified orientation.
void save()
Saves the current painter state (pushes the state onto a stack).
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
QString elidedText(const QString &text, Qt::TextElideMode mode, int width, int flags=0) const
If the string text is wider than width, returns an elided version of the string (i.
const QPoint & pos() const
Returns the position of the mouse cursor, relative to the widget that received the event...
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
int toInt(bool *ok=0) const
Returns the variant as an int if the variant has type() Int , Bool , ByteArray , Char ...
virtual void setModel(QAbstractItemModel *model)
Sets the model for the view to present.
virtual QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const =0
Returns the index of the item in the model specified by the given row, column and parent index...
int width() const
Returns the width.
void append(const T &t)
Inserts value at the end of the list.
bool fill(bool val, int size=-1)
Sets every bit in the bit array to value, returning true if successful; otherwise returns false...
#define QT_BEGIN_NAMESPACE
This macro expands to.
void setBrush(ColorRole cr, const QBrush &brush)
Sets the brush for the given color role to the specified brush for all groups in the palette...
T & front()
This function is provided for STL compatibility.
QPoint brushOrigin() const
Returns the currently set brush origin.
bool canConvert(Type t) const
Returns true if the variant's type can be cast to the requested type, t.
The QStyleOption class stores the parameters used by QStyle functions.
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
void initFrom(const QWidget *w)
int row() const
Returns the row this model index refers to.
const T & at(int i) const
Returns the item at index position i in the list.
bool isNull() const
Returns true if the icon is empty; otherwise returns false.
void resize(int size)
Resizes the bit array to size bits.
int timerId() const
Returns the unique timer identifier, which is the same identifier as returned from QObject::startTime...
void removeFirst()
Removes the first item in the list.
virtual void reset()
Reset the internal state of the view.
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
The QRegion class specifies a clip region for a painter.
static int startDragDistance()
Qt::MouseButton button() const
Returns the button that caused the event.
bool isValid() const
Returns true if this model index is valid; otherwise returns false.
void qSwap(T &value1, T &value2)
The QAbstractItemModel class provides the abstract interface for item model classes.
The QMouseEvent class contains parameters that describe a mouse event.
virtual QSize sizeFromContents(ContentsType ct, const QStyleOption *opt, const QSize &contentsSize, const QWidget *w=0) const =0
Returns the size of the element described by the specified option and type, based on the provided con...
The QBitArray class provides an array of bits.
T & first()
Returns a reference to the first item in the list.
void fill(const QColor &fillColor=Qt::white)
Fills the pixmap with the given color.
QPalette palette
the palette that should be used when painting the control
The QBrush class defines the fill pattern of shapes drawn by QPainter.
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
Disconnects signal in object sender from method in object receiver.
The QAbstractItemView class provides the basic functionality for item view classes.
int top() const
Returns the y-coordinate of the rectangle's top edge.
The QItemSelection class manages information about selected items in a model.
const QPoint & pos() const
Returns the position of the mouse cursor, relative to the widget that received the event...
Qt::MouseButtons buttons() const
Returns the button state when the event was generated.
int right() const
Returns the x-coordinate of the rectangle's right edge.
The QTimerEvent class contains parameters that describe a timer event.
The QFont class specifies a font used for drawing text.
int y() const
Returns the y position of the mouse cursor, relative to the widget that received the event...
const Key key(const T &value) const
Returns the first key mapped to value.
QObject * parent() const
Returns a pointer to the parent object.
void setRect(int x, int y, int w, int h)
Sets the coordinates of the rectangle's top-left corner to ({x}, {y}), and its size to the given widt...
The QPoint class defines a point in the plane using integer precision.
void setFrameStyle(int)
Sets the frame style to style.
Q_DECL_CONSTEXPR const T & qBound(const T &min, const T &val, const T &max)
The QModelIndex class is used to locate data in a data model.
virtual void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p, const QWidget *w=0) const =0
Draws the given element with the provided painter with the style options specified by option...
The QStyle class is an abstract base class that encapsulates the look and feel of a GUI...
int & rheight()
Returns a reference to the height.
int height() const
Returns the height.
const QPoint & globalPos() const
Returns the mouse cursor position when the event was generated in global coordinates.
if(void) toggleToolbarShown
The QRect class defines a rectangle in the plane using integer precision.
The QLabel widget provides a text or image display.
int count() const
Same as size().
T qvariant_cast(const QVariant &)
State state() const
Returns the item view's state.
int y() const
Returns the y coordinate of this point.
The QPixmap class is an off-screen image representation that can be used as a paint device...
int top() const
Returns the row index corresponding to the uppermost selected row in the selection range...
bool isEmpty() const
Returns true if the byte array has size 0; otherwise returns false.
The QSize class defines the size of a two-dimensional object using integer point precision.
void setFont(const QFont &f)
Sets the painter's font to the given font.
The QDataStream class provides serialization of binary data to a QIODevice.
CursorAction
This enum describes the different ways to navigate between items,.
int x() const
Returns the x coordinate of this point.
void setOpacity(qreal opacity)
Sets the opacity of the painter to opacity.
const QRect & rect() const
Returns the rectangle that needs to be updated.
bool isValid() const
Returns true if the rectangle is valid, otherwise returns false.
int height() const
Returns the height of the font.
static void showText(const QPoint &pos, const QString &text, QWidget *w=0)
Shows text as a "What's This?" window, at global position pos.
bool isValid() const
Returns true if the storage type of this variant is not QVariant::Invalid; otherwise returns false...
The QPaintEvent class contains event parameters for paint events.
QAbstractItemModel * model() const
Returns the model that this view is presenting.
void translate(int dx, int dy)
Moves the rectangle dx along the x axis and dy along the y axis, relative to the current position...
static const KeyPair *const end
bool event(QEvent *event)
Reimplemented Function
The QEvent class is the base class of all event classes.
Type type() const
Returns the event type.
Q_CORE_EXPORT QTextStream & left(QTextStream &s)
QDataStream & operator<<(QDataStream &out, const QUrl &url)
Writes url url to the stream out and returns a reference to the stream.
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
QRect rect
the area that should be used for various calculations and painting
bool isEmpty() const
Returns true if this bit array has size 0; otherwise returns false.
bool viewportEvent(QEvent *event)
This function is used to handle tool tips, and What's This? mode, if the given event is a QEvent::Too...
int & rwidth()
Returns a reference to the width.
void fillRect(const QRectF &, const QBrush &)
Fills the given rectangle with the brush specified.
static QPoint pos()
Returns the position of the cursor (hot spot) in global screen coordinates.
int column() const
Returns the column this model index refers to.
int x() const
Returns the x position of the mouse cursor, relative to the widget that received the event...
Qt::CursorShape shape() const
Returns the cursor shape identifier.
QPoint topLeft() const
Returns the position of the rectangle's top-left corner.
The QHelpEvent class provides an event that is used to request helpful information about a particular...
QDataStream & operator>>(QDataStream &in, QUrl &url)
Reads a url into url from the stream in and returns a reference to the stream.
The QIcon class provides scalable icons in different modes and states.
const QPoint & pos() const
Returns the mouse cursor position when the event was generated, relative to the widget to which the e...