summaryrefslogtreecommitdiffstats
path: root/tests/auto/qabstractitemview
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@trolltech.com>2009-07-16 19:13:13 (GMT)
committerOlivier Goffart <ogoffart@trolltech.com>2009-07-17 11:49:16 (GMT)
commit1aa43fc4af995374c577a951fd2054d696aa3b14 (patch)
tree45b78871f99212a3100d879d3a52cf5ee0b4c7a4 /tests/auto/qabstractitemview
parent8ab072aff0527d3ef3e44cf1ceba7dca985a6f94 (diff)
downloadQt-1aa43fc4af995374c577a951fd2054d696aa3b14.zip
Qt-1aa43fc4af995374c577a951fd2054d696aa3b14.tar.gz
Qt-1aa43fc4af995374c577a951fd2054d696aa3b14.tar.bz2
Fixes: ItemView text editor is not visible with empty text and icons
It was not visible wicause its height was 0 Task-number: 257481 Reviewed-by: mbm
Diffstat (limited to 'tests/auto/qabstractitemview')
-rw-r--r--tests/auto/qabstractitemview/tst_qabstractitemview.cpp83
1 files changed, 60 insertions, 23 deletions
diff --git a/tests/auto/qabstractitemview/tst_qabstractitemview.cpp b/tests/auto/qabstractitemview/tst_qabstractitemview.cpp
index 0bc459e..e7b94d1 100644
--- a/tests/auto/qabstractitemview/tst_qabstractitemview.cpp
+++ b/tests/auto/qabstractitemview/tst_qabstractitemview.cpp
@@ -55,6 +55,7 @@
#include <qpushbutton.h>
#include <qscrollbar.h>
#include <qboxlayout.h>
+#include <qlineedit.h>
#include "../../shared/util.h"
//TESTED_CLASS=
@@ -209,10 +210,11 @@ private slots:
void noFallbackToRoot();
void setCurrentIndex_data();
void setCurrentIndex();
-
+
void task221955_selectedEditor();
void task250754_fontChange();
void task200665_itemEntered();
+ void task257481_emptyEditor();
};
class MyAbstractItemDelegate : public QAbstractItemDelegate
@@ -945,12 +947,12 @@ void tst_QAbstractItemView::dragAndDropOnChild()
class TestModel : public QStandardItemModel
{
public:
- TestModel(int rows, int columns) : QStandardItemModel(rows, columns)
+ TestModel(int rows, int columns) : QStandardItemModel(rows, columns)
{
setData_count = 0;
}
- virtual bool setData(const QModelIndex &/*index*/, const QVariant &/*value*/, int /*role = Qt::EditRole*/)
+ virtual bool setData(const QModelIndex &/*index*/, const QVariant &/*value*/, int /*role = Qt::EditRole*/)
{
++setData_count;
return true;
@@ -967,20 +969,20 @@ void tst_QAbstractItemView::setItemDelegate_data()
// default is rows, a -1 will switch to columns
QTest::addColumn<IntList>("rowsOrColumnsWithDelegate");
QTest::addColumn<QPoint>("cellToEdit");
- QTest::newRow("4 columndelegates")
- << (IntList() << -1 << 0 << 1 << 2 << 3)
+ QTest::newRow("4 columndelegates")
+ << (IntList() << -1 << 0 << 1 << 2 << 3)
<< QPoint(0, 0);
- QTest::newRow("2 identical rowdelegates on the same row")
- << (IntList() << 0 << 0)
+ QTest::newRow("2 identical rowdelegates on the same row")
+ << (IntList() << 0 << 0)
<< QPoint(0, 0);
- QTest::newRow("2 identical columndelegates on the same column")
- << (IntList() << -1 << 2 << 2)
+ QTest::newRow("2 identical columndelegates on the same column")
+ << (IntList() << -1 << 2 << 2)
<< QPoint(2, 0);
- QTest::newRow("2 duplicate delegates, 1 row and 1 column")
- << (IntList() << 0 << -1 << 2)
+ QTest::newRow("2 duplicate delegates, 1 row and 1 column")
+ << (IntList() << 0 << -1 << 2)
<< QPoint(2, 0);
- QTest::newRow("4 duplicate delegates, 2 row and 2 column")
- << (IntList() << 0 << 0 << -1 << 2 << 2)
+ QTest::newRow("4 duplicate delegates, 2 row and 2 column")
+ << (IntList() << 0 << 0 << -1 << 2 << 2)
<< QPoint(2, 0);
}
@@ -1002,7 +1004,7 @@ void tst_QAbstractItemView::setItemDelegate()
if (row) {
v.setItemDelegateForRow(rc, delegate);
} else {
- v.setItemDelegateForColumn(rc, delegate);
+ v.setItemDelegateForColumn(rc, delegate);
}
}
}
@@ -1120,42 +1122,42 @@ void tst_QAbstractItemView::setCurrentIndex()
void tst_QAbstractItemView::task221955_selectedEditor()
{
QPushButton *button;
-
+
QTreeWidget tree;
tree.setColumnCount(2);
tree.addTopLevelItem(new QTreeWidgetItem(QStringList() << "Foo" <<"1"));
tree.addTopLevelItem(new QTreeWidgetItem(QStringList() << "Bar" <<"2"));
tree.addTopLevelItem(new QTreeWidgetItem(QStringList() << "Baz" <<"3"));
-
+
QTreeWidgetItem *dummy = new QTreeWidgetItem();
tree.addTopLevelItem(dummy);
tree.setItemWidget(dummy, 0, button = new QPushButton("More..."));
button->setAutoFillBackground(true); // as recommended in doc
-
+
tree.show();
tree.setFocus();
tree.setCurrentIndex(tree.model()->index(1,0));
QTest::qWait(100);
QApplication::setActiveWindow(&tree);
-
+
QVERIFY(! tree.selectionModel()->selectedIndexes().contains(tree.model()->index(3,0)));
//We set the focus to the button, the index need to be selected
- button->setFocus();
+ button->setFocus();
QTest::qWait(100);
QVERIFY(tree.selectionModel()->selectedIndexes().contains(tree.model()->index(3,0)));
-
+
tree.setCurrentIndex(tree.model()->index(1,0));
QVERIFY(! tree.selectionModel()->selectedIndexes().contains(tree.model()->index(3,0)));
-
+
//Same thing but with the flag NoSelection, nothing can be selected.
tree.setFocus();
tree.setSelectionMode(QAbstractItemView::NoSelection);
tree.clearSelection();
QVERIFY(tree.selectionModel()->selectedIndexes().isEmpty());
QTest::qWait(10);
- button->setFocus();
+ button->setFocus();
QTest::qWait(50);
QVERIFY(tree.selectionModel()->selectedIndexes().isEmpty());
}
@@ -1196,7 +1198,7 @@ void tst_QAbstractItemView::task250754_fontChange()
QTest::qWait(30);
//now with the huge items, the scrollbar must be visible
QVERIFY(tree.verticalScrollBar()->isVisible());
-
+
qApp->setStyleSheet(app_css);
}
@@ -1217,6 +1219,41 @@ void tst_QAbstractItemView::task200665_itemEntered()
}
+void tst_QAbstractItemView::task257481_emptyEditor()
+{
+ QIcon icon = qApp->style()->standardIcon(QStyle::SP_ComputerIcon);
+
+ QStandardItemModel model;
+
+ model.appendRow( new QStandardItem(icon, QString()) );
+ model.appendRow( new QStandardItem(icon, "Editor works") );
+ model.appendRow( new QStandardItem( QString() ) );
+
+ QTreeView treeView;
+ treeView.setRootIsDecorated(false);
+ treeView.setModel(&model);
+ treeView.show();
+
+ treeView.edit(model.index(0,0));
+ QList<QLineEdit *> lineEditors = qFindChildren<QLineEdit *>(treeView.viewport());
+ QCOMPARE(lineEditors.count(), 1);
+ QVERIFY(!lineEditors.first()->size().isEmpty());
+
+ QTest::qWait(30);
+
+ treeView.edit(model.index(1,0));
+ lineEditors = qFindChildren<QLineEdit *>(treeView.viewport());
+ QCOMPARE(lineEditors.count(), 1);
+ QVERIFY(!lineEditors.first()->size().isEmpty());
+
+ QTest::qWait(30);
+
+ treeView.edit(model.index(2,0));
+ lineEditors = qFindChildren<QLineEdit *>(treeView.viewport());
+ QCOMPARE(lineEditors.count(), 1);
+ QVERIFY(!lineEditors.first()->size().isEmpty());
+}
+
QTEST_MAIN(tst_QAbstractItemView)
#include "tst_qabstractitemview.moc"