summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/corelib/global/qnamespace.h1
-rw-r--r--src/corelib/global/qnamespace.qdoc29
-rw-r--r--src/gui/dialogs/qfiledialog.cpp1
-rw-r--r--src/gui/graphicsview/qgridlayoutengine.cpp2
-rw-r--r--src/gui/itemviews/qheaderview.cpp14
-rw-r--r--src/gui/painting/qdrawingprimitive_sse2_p.h4
-rw-r--r--src/gui/widgets/qeffects.cpp29
-rw-r--r--src/gui/widgets/qtoolbarlayout.cpp8
-rw-r--r--tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp112
-rw-r--r--tests/auto/qheaderview/tst_qheaderview.cpp37
-rw-r--r--tests/auto/qwidget/tst_qwidget.cpp2
11 files changed, 136 insertions, 103 deletions
diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h
index 1b22c77..bd9d554 100644
--- a/src/corelib/global/qnamespace.h
+++ b/src/corelib/global/qnamespace.h
@@ -1626,6 +1626,7 @@ public:
AccessibleDescriptionRole = 12,
// More general purpose
SizeHintRole = 13,
+ InitialSortOrderRole = 14,
// Internal UiLib roles. Start worrying when public roles go that high.
DisplayPropertyRole = 27,
DecorationPropertyRole = 28,
diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc
index 9facad7..1efe0a5 100644
--- a/src/corelib/global/qnamespace.qdoc
+++ b/src/corelib/global/qnamespace.qdoc
@@ -2682,19 +2682,22 @@
Roles describing appearance and meta data (with associated types):
- \value FontRole The font used for items rendered with the default
- delegate. (QFont)
- \value TextAlignmentRole The alignment of the text for items rendered with the
- default delegate. (Qt::AlignmentFlag)
- \value BackgroundRole The background brush used for items rendered with
- the default delegate. (QBrush)
- \value BackgroundColorRole This role is obsolete. Use BackgroundRole instead.
- \value ForegroundRole The foreground brush (text color, typically)
- used for items rendered with the default delegate.
- (QBrush)
- \value TextColorRole This role is obsolete. Use ForegroundRole instead.
- \value CheckStateRole This role is used to obtain the checked state of
- an item. (Qt::CheckState)
+ \value FontRole The font used for items rendered with the default
+ delegate. (QFont)
+ \value TextAlignmentRole The alignment of the text for items rendered with the
+ default delegate. (Qt::AlignmentFlag)
+ \value BackgroundRole The background brush used for items rendered with
+ the default delegate. (QBrush)
+ \value BackgroundColorRole This role is obsolete. Use BackgroundRole instead.
+ \value ForegroundRole The foreground brush (text color, typically)
+ used for items rendered with the default delegate.
+ (QBrush)
+ \value TextColorRole This role is obsolete. Use ForegroundRole instead.
+ \value CheckStateRole This role is used to obtain the checked state of
+ an item. (Qt::CheckState)
+ \value InitialSortOrderRole This role is used to obtain the initial sort order
+ of a header view section. (Qt::SortOrder). This
+ role was introduced in Qt 4.8.
Accessibility roles (with associated types):
diff --git a/src/gui/dialogs/qfiledialog.cpp b/src/gui/dialogs/qfiledialog.cpp
index e81773b..e1b92c5 100644
--- a/src/gui/dialogs/qfiledialog.cpp
+++ b/src/gui/dialogs/qfiledialog.cpp
@@ -2996,6 +2996,7 @@ void QFileDialogPrivate::_q_useNameFilter(int index)
const int fileNameExtensionLength = fileNameExtension.count();
fileName.replace(fileName.count() - fileNameExtensionLength,
fileNameExtensionLength, newNameFilterExtension);
+ qFileDialogUi->listView->clearSelection();
lineEdit()->setText(fileName);
}
}
diff --git a/src/gui/graphicsview/qgridlayoutengine.cpp b/src/gui/graphicsview/qgridlayoutengine.cpp
index 375c723..b8586ce 100644
--- a/src/gui/graphicsview/qgridlayoutengine.cpp
+++ b/src/gui/graphicsview/qgridlayoutengine.cpp
@@ -1175,7 +1175,7 @@ QSizeF QGridLayoutEngine::sizeHint(const QLayoutStyleInfo &styleInfo, Qt::SizeHi
//constraints to find the column widths
q_rowData.calculateGeometries(0, rowCount(), height, sizehint_yy.data(), sizehint_heights.data(),
0, sizehint_totalBoxes[Ver], q_infos[Ver]);
- ensureColumnAndRowData(&q_columnData, &sizehint_totalBoxes[Hor], styleInfo, sizehint_yy.data(), sizehint_heights.data(), Qt::Vertical);
+ ensureColumnAndRowData(&q_columnData, &sizehint_totalBoxes[Hor], styleInfo, sizehint_yy.data(), sizehint_heights.data(), Qt::Horizontal);
sizeHintCalculated = true;
}
}
diff --git a/src/gui/itemviews/qheaderview.cpp b/src/gui/itemviews/qheaderview.cpp
index 6359f0b..d6d9536 100644
--- a/src/gui/itemviews/qheaderview.cpp
+++ b/src/gui/itemviews/qheaderview.cpp
@@ -3274,9 +3274,17 @@ void QHeaderViewPrivate::clear()
void QHeaderViewPrivate::flipSortIndicator(int section)
{
Q_Q(QHeaderView);
- bool ascending = (sortIndicatorSection != section
- || sortIndicatorOrder == Qt::DescendingOrder);
- q->setSortIndicator(section, ascending ? Qt::AscendingOrder : Qt::DescendingOrder);
+ Qt::SortOrder sortOrder;
+ if (sortIndicatorSection == section) {
+ sortOrder = (sortIndicatorOrder == Qt::DescendingOrder) ? Qt::AscendingOrder : Qt::DescendingOrder;
+ } else {
+ const QVariant value = model->headerData(section, orientation, Qt::InitialSortOrderRole);
+ if (value.canConvert(QVariant::Int))
+ sortOrder = static_cast<Qt::SortOrder>(value.toInt());
+ else
+ sortOrder = Qt::AscendingOrder;
+ }
+ q->setSortIndicator(section, sortOrder);
}
void QHeaderViewPrivate::cascadingResize(int visual, int newSize)
diff --git a/src/gui/painting/qdrawingprimitive_sse2_p.h b/src/gui/painting/qdrawingprimitive_sse2_p.h
index 2d61cc5..d8793c3 100644
--- a/src/gui/painting/qdrawingprimitive_sse2_p.h
+++ b/src/gui/painting/qdrawingprimitive_sse2_p.h
@@ -78,7 +78,7 @@ QT_BEGIN_NAMESPACE
pixelVectorAG = _mm_mullo_epi16(pixelVectorAG, alphaChannel); \
pixelVectorRB = _mm_mullo_epi16(pixelVectorRB, alphaChannel); \
\
- /* 3. devide by 255, that's the tricky part. \
+ /* 3. divide by 255, that's the tricky part. \
we do it like for BYTE_MUL(), with bit shift: X/255 ~= (X + X/256 + rounding)/256 */ \
/** so first (X + X/256 + rounding) */\
pixelVectorRB = _mm_add_epi16(pixelVectorRB, _mm_srli_epi16(pixelVectorRB, 8)); \
@@ -86,7 +86,7 @@ QT_BEGIN_NAMESPACE
pixelVectorAG = _mm_add_epi16(pixelVectorAG, _mm_srli_epi16(pixelVectorAG, 8)); \
pixelVectorAG = _mm_add_epi16(pixelVectorAG, half); \
\
- /** second devide by 256 */\
+ /** second divide by 256 */\
pixelVectorRB = _mm_srli_epi16(pixelVectorRB, 8); \
/** for AG, we could >> 8 to divide followed by << 8 to put the \
bytes in the correct position. By masking instead, we execute \
diff --git a/src/gui/widgets/qeffects.cpp b/src/gui/widgets/qeffects.cpp
index 8e1e7c3..6b64d48 100644
--- a/src/gui/widgets/qeffects.cpp
+++ b/src/gui/widgets/qeffects.cpp
@@ -55,19 +55,6 @@
QT_BEGIN_NAMESPACE
/*
- Internal class to get access to protected QWidget-members
-*/
-
-class QAccessWidget : public QWidget
-{
- friend class QAlphaWidget;
- friend class QRollEffect;
-public:
- QAccessWidget(QWidget* parent=0, Qt::WindowFlags f = 0)
- : QWidget(parent, f) {}
-};
-
-/*
Internal class QAlphaWidget.
The QAlphaWidget is shown while the animation lasts
@@ -98,13 +85,12 @@ private:
QImage backImage;
QImage frontImage;
QImage mixedImage;
- QPointer<QAccessWidget> widget;
+ QPointer<QWidget> widget;
int duration;
int elapsed;
bool showWidget;
QTimer anim;
QElapsedTimer checkTime;
- double windowOpacity;
};
static QAlphaWidget* q_blend = 0;
@@ -119,8 +105,7 @@ QAlphaWidget::QAlphaWidget(QWidget* w, Qt::WindowFlags f)
setEnabled(false);
#endif
setAttribute(Qt::WA_NoSystemBackground, true);
- widget = (QAccessWidget*)w;
- windowOpacity = w->windowOpacity();
+ widget = w;
alpha = 0;
}
@@ -129,7 +114,7 @@ QAlphaWidget::~QAlphaWidget()
#if defined(Q_WS_WIN) && !defined(Q_WS_WINCE)
// Restore user-defined opacity value
if (widget)
- widget->setWindowOpacity(windowOpacity);
+ widget->setWindowOpacity(1);
#endif
}
@@ -268,10 +253,10 @@ void QAlphaWidget::render()
alpha = 1;
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
- if (alpha >= windowOpacity || !showWidget) {
+ if (alpha >= 1 || !showWidget) {
anim.stop();
qApp->removeEventFilter(this);
- widget->setWindowOpacity(windowOpacity);
+ widget->setWindowOpacity(1);
q_blend = 0;
deleteLater();
} else {
@@ -370,7 +355,7 @@ private slots:
void scroll();
private:
- QPointer<QAccessWidget> widget;
+ QPointer<QWidget> widget;
int currentHeight;
int currentWidth;
@@ -401,7 +386,7 @@ QRollEffect::QRollEffect(QWidget* w, Qt::WindowFlags f, DirFlags orient)
setEnabled(false);
#endif
- widget = (QAccessWidget*) w;
+ widget = w;
Q_ASSERT(widget);
setAttribute(Qt::WA_NoSystemBackground, true);
diff --git a/src/gui/widgets/qtoolbarlayout.cpp b/src/gui/widgets/qtoolbarlayout.cpp
index 813ec3e..531acb4 100644
--- a/src/gui/widgets/qtoolbarlayout.cpp
+++ b/src/gui/widgets/qtoolbarlayout.cpp
@@ -647,15 +647,15 @@ QSize QToolBarLayout::expandedSize(const QSize &size) const
void QToolBarLayout::setExpanded(bool exp)
{
- if (exp == expanded)
+ QWidget *tb = qobject_cast<QToolBar*>(parentWidget());
+ if (!tb)
+ return;
+ if (exp == expanded && !tb->isWindow())
return;
expanded = exp;
extension->setChecked(expanded);
- QToolBar *tb = qobject_cast<QToolBar*>(parentWidget());
- if (!tb)
- return;
if (QMainWindow *win = qobject_cast<QMainWindow*>(tb->parentWidget())) {
#ifdef QT_NO_DOCKWIDGET
animating = false;
diff --git a/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp b/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp
index bac17b1..837df78 100644
--- a/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp
+++ b/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp
@@ -2541,7 +2541,7 @@ void tst_QGraphicsGridLayout::geometries_data()
<< QRectF(0, 0, 50,10) << QRectF(50, 0, 50,10)
<< QRectF(0, 10, 50,100) << QRectF(50, 10, 50,400)
);
-#if 0
+
QTest::newRow("hfw-100x470") << (ItemList()
<< ItemDesc(0,0)
.minSize(QSizeF(1,1))
@@ -2556,9 +2556,9 @@ void tst_QGraphicsGridLayout::geometries_data()
.preferredSize(QSizeF(50,10))
.maxSize(QSizeF(100, 100))
<< ItemDesc(1,1)
- .minSize(QSizeF(40,40))
- .preferredSize(QSizeF(50,400))
- .maxSize(QSizeF(500, 500))
+ .sizeHint(Qt::MinimumSize, QSizeF(40,40))
+ .sizeHint(Qt::PreferredSize, QSizeF(50,400))
+ .sizeHint(Qt::MaximumSize, QSizeF(500,500))
.dynamicConstraint(hfw1, Qt::Vertical)
)
<< QSizeF(100, 470)
@@ -2567,7 +2567,6 @@ void tst_QGraphicsGridLayout::geometries_data()
<< QRectF(0, 70, 50,100) << QRectF(50, 70, 50,400)
);
-
// change layout width and verify
QTest::newRow("hfw-100x401") << (ItemList()
<< ItemDesc(0,0)
@@ -2583,9 +2582,9 @@ void tst_QGraphicsGridLayout::geometries_data()
.preferredSize(QSizeF(50,10))
.maxSize(QSizeF(100, 100))
<< ItemDesc(1,1)
- .minSize(QSizeF(40,40))
- .preferredSize(QSizeF(50,400))
- .maxSize(QSizeF(5000, 5000))
+ .minSize(QSizeF(-1,-1))
+ .preferredSize(QSizeF(-1,-1))
+ .maxSize(QSizeF(-1, -1))
.dynamicConstraint(hfw1, Qt::Vertical)
)
<< QSizeF(100, 401)
@@ -2594,7 +2593,7 @@ void tst_QGraphicsGridLayout::geometries_data()
<< QRectF( 0, 1, 50, 100) << QRectF( 50, 1, 50, 400)
);
- QTest::newRow("hfw-160x400") << (ItemList()
+ QTest::newRow("hfw-160x350") << (ItemList()
<< ItemDesc(0,0)
.minSize(QSizeF(1,1))
.preferredSize(QSizeF(50,10))
@@ -2608,18 +2607,17 @@ void tst_QGraphicsGridLayout::geometries_data()
.preferredSize(QSizeF(50,10))
.maxSize(QSizeF(100, 100))
<< ItemDesc(1,1)
- .minSize(QSizeF(40,40))
- .preferredSize(QSizeF(50,400))
- .maxSize(QSizeF(5000, 5000))
- .dynamicConstraint(hfw1, Qt::Vertical)
+ .sizeHint(Qt::MinimumSize, QSizeF(40,40))
+ .sizeHint(Qt::PreferredSize, QSizeF(50,400))
+ .sizeHint(Qt::MaximumSize, QSizeF(5000,5000))
+ .dynamicConstraint(hfw1, Qt::Vertical)
)
- << QSizeF(160, 400)
+ << QSizeF(160, 350)
<< (RectList()
<< QRectF( 0, 0, 80, 100) << QRectF( 80, 0, 80, 100)
<< QRectF( 0, 100, 80, 100) << QRectF( 80, 100, 80, 250)
);
-
QTest::newRow("hfw-160x300") << (ItemList()
<< ItemDesc(0,0)
.minSize(QSizeF(1,1))
@@ -2634,9 +2632,9 @@ void tst_QGraphicsGridLayout::geometries_data()
.preferredSize(QSizeF(50,10))
.maxSize(QSizeF(100, 100))
<< ItemDesc(1,1)
- .minSize(QSizeF(40,40))
- .preferredSize(QSizeF(50,400))
- .maxSize(QSizeF(5000, 5000))
+ .sizeHint(Qt::MinimumSize, QSizeF(40,40))
+ .sizeHint(Qt::PreferredSize, QSizeF(50,400))
+ .sizeHint(Qt::MaximumSize, QSizeF(5000, 5000))
.dynamicConstraint(hfw1, Qt::Vertical)
)
<< QSizeF(160, 300)
@@ -2647,11 +2645,11 @@ void tst_QGraphicsGridLayout::geometries_data()
QTest::newRow("hfw-20x40") << (ItemList()
<< ItemDesc(0,0)
- .minSize(QSizeF(1,1))
+ .minSize(QSizeF(1,10))
.preferredSize(QSizeF(50,50))
.maxSize(QSizeF(100, 100))
<< ItemDesc(0,1)
- .minSize(QSizeF(1,10))
+ .minSize(QSizeF(1,1))
.preferredSize(QSizeF(50,50))
.maxSize(QSizeF(100, 100))
<< ItemDesc(1,0)
@@ -2659,9 +2657,9 @@ void tst_QGraphicsGridLayout::geometries_data()
.preferredSize(QSizeF(50,50))
.maxSize(QSizeF(100, 100))
<< ItemDesc(1,1)
- .minSize(QSizeF(1,1))
- .preferredSize(QSizeF(50,50))
- .maxSize(QSizeF(100, 100))
+ .sizeHint(Qt::MinimumSize, QSizeF(1, 1))
+ .sizeHint(Qt::PreferredSize, QSizeF(50, 50))
+ .sizeHint(Qt::MaximumSize, QSizeF(100, 100))
.dynamicConstraint(hfw3, Qt::Vertical)
)
<< QSizeF(20, 40)
@@ -2684,9 +2682,9 @@ void tst_QGraphicsGridLayout::geometries_data()
.preferredSize(QSizeF(10,50))
.maxSize(QSizeF(100, 100))
<< ItemDesc(1,1)
- .minSize(QSizeF(10,10))
- .preferredSize(QSizeF(400,50))
- .maxSize(QSizeF(5000, 5000))
+ .sizeHint(Qt::MinimumSize, QSizeF(10,10))
+ .sizeHint(Qt::PreferredSize, QSizeF(400,50))
+ .sizeHint(Qt::MaximumSize, QSizeF(5000, 5000))
.dynamicConstraint(wfh1, Qt::Horizontal)
)
<< QSizeF(300, 160)
@@ -2711,9 +2709,9 @@ void tst_QGraphicsGridLayout::geometries_data()
.preferredSize(QSizeF(50,50))
.maxSize(QSizeF(100, 100))
<< ItemDesc(1,1)
- .minSize(QSizeF(1,1))
- .preferredSize(QSizeF(50,50))
- .maxSize(QSizeF(100, 100))
+ .sizeHint(Qt::MinimumSize, QSizeF(1,1))
+ .sizeHint(Qt::PreferredSize, QSizeF(50,50))
+ .sizeHint(Qt::MaximumSize, QSizeF(100, 100))
.dynamicConstraint(wfh2, Qt::Horizontal)
)
<< QSizeF(40, 20)
@@ -2736,9 +2734,9 @@ void tst_QGraphicsGridLayout::geometries_data()
.preferredSize(QSizeF(50,50))
.maxSize(QSizeF(100, 100))
<< ItemDesc(1,1)
- .minSize(QSizeF(1,1))
- .preferredSize(QSizeF(50,50))
- .maxSize(QSizeF(100, 100))
+ .sizeHint(Qt::MinimumSize, QSizeF(1,1))
+ .sizeHint(Qt::PreferredSize, QSizeF(50,50))
+ .sizeHint(Qt::MaximumSize, QSizeF(100, 100))
.dynamicConstraint(wfh2, Qt::Horizontal)
)
@@ -2767,9 +2765,9 @@ void tst_QGraphicsGridLayout::geometries_data()
.preferredSize(QSizeF(10,50))
.maxSize(QSizeF(100, 100))
<< ItemDesc(1,1)
- .minSize(QSizeF(1,1))
- .preferredSize(QSizeF(10,50))
- .maxSize(QSizeF(500, 500))
+ .sizeHint(Qt::MinimumSize, QSizeF(1,1))
+ .sizeHint(Qt::PreferredSize, QSizeF(10,50))
+ .sizeHint(Qt::MaximumSize, QSizeF(500, 500))
.dynamicConstraint(wfh2, Qt::Horizontal)
)
<< QSizeF(160, 100)
@@ -2777,7 +2775,6 @@ void tst_QGraphicsGridLayout::geometries_data()
<< QRectF(0, 0, 80, 50) << QRectF( 80, 0, 80, 50)
<< QRectF(0, 50, 80, 50) << QRectF( 80, 50, 50, 50)
);
-#endif
QTest::newRow("hfw-h470") << (ItemList()
<< ItemDesc(0,0)
@@ -2804,7 +2801,6 @@ void tst_QGraphicsGridLayout::geometries_data()
<< QRectF(0, 70, 50,100) << QRectF(50, 70, 50,400)
);
-
// change layout width and verify
QTest::newRow("hfw-w100") << (ItemList()
<< ItemDesc(0,0)
@@ -3069,25 +3065,24 @@ void tst_QGraphicsGridLayout::heightForWidth()
layout->setSpacing(0);
RectWidget *w00 = new RectWidget;
w00->setSizeHint(Qt::MinimumSize, QSizeF(1,1));
- w00->setSizeHint(Qt::PreferredSize, QSizeF(50,50));
+ w00->setSizeHint(Qt::PreferredSize, QSizeF(10,10));
w00->setSizeHint(Qt::MaximumSize, QSizeF(100,100));
layout->addItem(w00, 0, 0);
RectWidget *w01 = new RectWidget;
w01->setSizeHint(Qt::MinimumSize, QSizeF(1,1));
- w01->setSizeHint(Qt::PreferredSize, QSizeF(50,50));
+ w01->setSizeHint(Qt::PreferredSize, QSizeF(10,10));
w01->setSizeHint(Qt::MaximumSize, QSizeF(100,100));
layout->addItem(w01, 0, 1);
RectWidget *w10 = new RectWidget;
w10->setSizeHint(Qt::MinimumSize, QSizeF(1,1));
- w10->setSizeHint(Qt::PreferredSize, QSizeF(50,50));
+ w10->setSizeHint(Qt::PreferredSize, QSizeF(10,10));
w10->setSizeHint(Qt::MaximumSize, QSizeF(100,100));
layout->addItem(w10, 1, 0);
RectWidget *w11 = new RectWidget;
w11->setSizeHint(Qt::MinimumSize, QSizeF(1,1));
- w11->setSizeHint(Qt::PreferredSize, QSizeF(50,400));
w11->setSizeHint(Qt::MaximumSize, QSizeF(30000,30000));
w11->setConstraintFunction(hfw);
QSizePolicy sp(QSizePolicy::Preferred, QSizePolicy::Preferred);
@@ -3096,34 +3091,37 @@ void tst_QGraphicsGridLayout::heightForWidth()
layout->addItem(w11, 1, 1);
QCOMPARE(layout->effectiveSizeHint(Qt::MinimumSize, QSizeF(-1, -1)), QSizeF(2, 2));
- QEXPECT_FAIL("", "QTBUG-14693", Continue);
QCOMPARE(layout->effectiveSizeHint(Qt::PreferredSize, QSizeF(-1, -1)), QSizeF(210, 110));
QCOMPARE(layout->effectiveSizeHint(Qt::MaximumSize, QSizeF(-1, -1)), QSizeF(30100, 30100));
QCOMPARE(layout->effectiveSizeHint(Qt::MinimumSize, QSizeF(2, -1)), QSizeF(2, 20001));
- QCOMPARE(layout->effectiveSizeHint(Qt::PreferredSize, QSizeF(2, -1)), QSizeF(2, 20050));
+ QCOMPARE(layout->effectiveSizeHint(Qt::PreferredSize, QSizeF(2, -1)), QSizeF(2, 20010));
QCOMPARE(layout->effectiveSizeHint(Qt::MaximumSize, QSizeF(2, -1)), QSizeF(2, 20100));
- QCOMPARE(layout->effectiveSizeHint(Qt::MinimumSize, QSizeF(20, -1)), QSizeF(20, 1 + 2000));
- QCOMPARE(layout->effectiveSizeHint(Qt::PreferredSize, QSizeF(20, -1)), QSizeF(20, 50 + 2000));
- QCOMPARE(layout->effectiveSizeHint(Qt::MaximumSize, QSizeF(20, -1)), QSizeF(20, 100 + 2000));
+ // Since 20 is somewhere between "minimum width hint" (2) and
+ // "preferred width hint" (210), it will try to do distribution by
+ // stretching them with different factors.
+ // Since column 1 has a "preferred width" of 200 it means that
+ // column 1 will be a bit wider than column 0. Thus it will also be a bit
+ // shorter than 2001, (the expected height if all columns had width=10)
+ QSizeF sh = layout->effectiveSizeHint(Qt::MinimumSize, QSizeF(20, -1));
+ // column 1 cannot be wider than 19, which means that it must be taller than 20000/19~=1052
+ QVERIFY(sh.height() < 2000 + 1 && sh.height() > 1052 + 1);
+
+ sh = layout->effectiveSizeHint(Qt::PreferredSize, QSizeF(20, -1));
+ QVERIFY(sh.height() < 2000 + 10 && sh.height() > 1052 + 10);
- QCOMPARE(layout->effectiveSizeHint(Qt::MinimumSize, QSizeF(300, -1)), QSizeF(300, 1 + 100));
- QCOMPARE(layout->effectiveSizeHint(Qt::PreferredSize, QSizeF(300, -1)), QSizeF(300, 50 + 100));
- QCOMPARE(layout->effectiveSizeHint(Qt::MaximumSize, QSizeF(300, -1)), QSizeF(300, 100 + 100));
+ sh = layout->effectiveSizeHint(Qt::MaximumSize, QSizeF(20, -1));
+ QVERIFY(sh.height() < 2000 + 100 && sh.height() > 1052 + 100);
// the height of the hfw widget is shorter than the one to the left, which is 100, so
// the total height of the last row is 100 (which leaves the layout height to be 200)
QCOMPARE(layout->effectiveSizeHint(Qt::MaximumSize, QSizeF(500, -1)), QSizeF(500, 100 + 100));
- // hfw item size: (500, 40) -> preferred size is maxed up to preferred size of item w10 (50)
- QCOMPARE(layout->effectiveSizeHint(Qt::PreferredSize, QSizeF(600, -1)), QSizeF(600, 50 + 50));
-
}
void tst_QGraphicsGridLayout::widthForHeight()
{
-#if 0
QGraphicsWidget *widget = new QGraphicsWidget;
QGraphicsGridLayout *layout = new QGraphicsGridLayout;
widget->setLayout(layout);
@@ -3150,9 +3148,10 @@ void tst_QGraphicsGridLayout::widthForHeight()
layout->addItem(w10, 1, 0);
RectWidget *w11 = new RectWidget;
- w11->setMinimumSize(1,1);
- w11->setPreferredSize(50, 50);
- w11->setMaximumSize(30000,30000);
+ w11->setSizeHint(Qt::MinimumSize, QSizeF(1,1));
+ w11->setSizeHint(Qt::PreferredSize, QSizeF(50,50));
+ w11->setSizeHint(Qt::MaximumSize, QSizeF(30000,30000));
+
// This will make sure its always square.
w11->setConstraintFunction(wfh);
QSizePolicy sp(QSizePolicy::Preferred, QSizePolicy::Preferred);
@@ -3196,7 +3195,6 @@ void tst_QGraphicsGridLayout::widthForHeight()
QCOMPARE(layout->effectiveSizeHint(Qt::MinimumSize, QSizeF(-1, 300)), QSizeF(1 + 200, 300));
QCOMPARE(layout->effectiveSizeHint(Qt::PreferredSize, QSizeF(-1, 300)), QSizeF(50 + 200, 300));
QCOMPARE(layout->effectiveSizeHint(Qt::MaximumSize, QSizeF(-1, 300)), QSizeF(100 + 200, 300));
-#endif
}
void tst_QGraphicsGridLayout::heightForWidthWithSpanning()
diff --git a/tests/auto/qheaderview/tst_qheaderview.cpp b/tests/auto/qheaderview/tst_qheaderview.cpp
index db71e39..9a25fb6 100644
--- a/tests/auto/qheaderview/tst_qheaderview.cpp
+++ b/tests/auto/qheaderview/tst_qheaderview.cpp
@@ -195,6 +195,8 @@ private slots:
void QTBUG8650_crashOnInsertSections();
void QTBUG12268_hiddenMovedSectionSorting();
+ void initialSortOrderRole();
+
protected:
QWidget *topLevel;
QHeaderView *view;
@@ -2097,5 +2099,40 @@ void tst_QHeaderView::QTBUG12268_hiddenMovedSectionSorting()
QCOMPARE(view.horizontalHeader()->hiddenSectionCount(), 1);
}
+void tst_QHeaderView::initialSortOrderRole()
+{
+ QTableView view;
+ QStandardItemModel *model = new QStandardItemModel(4, 3, &view);
+ for (int i = 0; i< model->rowCount(); ++i)
+ for (int j = 0; j< model->columnCount(); ++j)
+ model->setData(model->index(i,j), QString("item [%1,%2]").arg(i).arg(j));
+ QStandardItem *ascendingItem = new QStandardItem();
+ QStandardItem *descendingItem = new QStandardItem();
+ ascendingItem->setData(Qt::AscendingOrder, Qt::InitialSortOrderRole);
+ descendingItem->setData(Qt::DescendingOrder, Qt::InitialSortOrderRole);
+ model->setHorizontalHeaderItem(1, ascendingItem);
+ model->setHorizontalHeaderItem(2, descendingItem);
+ view.setModel(model);
+ view.setSortingEnabled(true);
+ view.sortByColumn(0, Qt::AscendingOrder);
+ view.show();
+ QTest::qWaitForWindowShown(&view);
+
+ const int column1Pos = view.horizontalHeader()->sectionViewportPosition(1) + 5; // +5 not to be on the handle
+ QTest::mouseClick(view.horizontalHeader()->viewport(), Qt::LeftButton, Qt::NoModifier, QPoint(column1Pos, 0));
+ QCOMPARE(view.horizontalHeader()->sortIndicatorSection(), 1);
+ QCOMPARE(view.horizontalHeader()->sortIndicatorOrder(), Qt::AscendingOrder);
+
+ const int column2Pos = view.horizontalHeader()->sectionViewportPosition(2) + 5; // +5 not to be on the handle
+ QTest::mouseClick(view.horizontalHeader()->viewport(), Qt::LeftButton, Qt::NoModifier, QPoint(column2Pos, 0));
+ QCOMPARE(view.horizontalHeader()->sortIndicatorSection(), 2);
+ QCOMPARE(view.horizontalHeader()->sortIndicatorOrder(), Qt::DescendingOrder);
+
+ const int column0Pos = view.horizontalHeader()->sectionViewportPosition(0) + 5; // +5 not to be on the handle
+ QTest::mouseClick(view.horizontalHeader()->viewport(), Qt::LeftButton, Qt::NoModifier, QPoint(column0Pos, 0));
+ QCOMPARE(view.horizontalHeader()->sortIndicatorSection(), 0);
+ QCOMPARE(view.horizontalHeader()->sortIndicatorOrder(), Qt::AscendingOrder);
+}
+
QTEST_MAIN(tst_QHeaderView)
#include "tst_qheaderview.moc"
diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp
index 2208bea..35014c9 100644
--- a/tests/auto/qwidget/tst_qwidget.cpp
+++ b/tests/auto/qwidget/tst_qwidget.cpp
@@ -10576,7 +10576,7 @@ void tst_QWidget::nativeChildFocus()
QTest::qWaitForWindowShown(&w);
QCOMPARE(QApplication::activeWindow(), &w);
- QCOMPARE(QApplication::focusWidget(), p1);
+ QCOMPARE(QApplication::focusWidget(), static_cast<QWidget*>(p1));
}
QTEST_MAIN(tst_QWidget)