33 #include <QStandardItem>
43 void rowsColumnsCtor();
46 void getSetRowAndColumnCount();
47 void getSetChild_data();
50 void insertColumn_data();
52 void insertRow_data();
54 void insertRows_data();
56 void appendColumn_data();
58 void appendRow_data();
61 void takeColumn_data();
74 void tst_QStandardItem::clearData()
85 void tst_QStandardItem::ctor()
91 void tst_QStandardItem::textCtor()
99 void tst_QStandardItem::iconTextCtor()
111 void tst_QStandardItem::rowsColumnsCtor()
114 const int columns = 12;
120 void tst_QStandardItem::getSetData()
123 for (
int x = 0;
x < 2; ++
x) {
124 for (
int i = 1;
i <= 2; ++
i) {
137 item.setToolTip(toolTip);
141 item.setStatusTip(statusTip);
145 item.setWhatsThis(whatsThis);
149 item.setSizeHint(sizeHint);
159 item.setTextAlignment(textAlignment);
167 item.setForeground(textColor);
175 item.setAccessibleText(accessibleText);
179 item.setAccessibleDescription(accessibleDescription);
180 QCOMPARE(
item.accessibleDescription(), accessibleDescription);
194 QCOMPARE(
item.accessibleDescription(), accessibleDescription);
244 void tst_QStandardItem::getSetFlags()
250 item.setEditable(
true);
253 item.setSelectable(
true);
256 item.setCheckable(
true);
260 item.setUserTristate(
true);
263 item.setAutoTristate(
true);
266 #if QT_CONFIG(draganddrop)
267 item.setDragEnabled(
true);
270 item.setDropEnabled(
true);
280 item.setEditable(
false);
284 item.setSelectable(
false);
288 item.setCheckable(
false);
291 item.setUserTristate(
false);
294 item.setAutoTristate(
false);
297 #if QT_CONFIG(draganddrop)
299 item.setDragEnabled(
false);
303 item.setDropEnabled(
false);
308 item.setCheckable(
false);
310 item.setCheckable(
true);
314 void tst_QStandardItem::getSetRowAndColumnCount()
318 item.setRowCount(-1);
321 item.setColumnCount(-1);
328 item.setColumnCount(1);
332 item.setColumnCount(10);
336 item.setRowCount(20);
340 item.setRowCount(-1);
343 item.setColumnCount(-1);
346 item.setColumnCount(0);
354 void tst_QStandardItem::getSetChild_data()
356 QTest::addColumn<int>(
"rows");
357 QTest::addColumn<int>(
"columns");
358 QTest::addColumn<int>(
"row");
359 QTest::addColumn<int>(
"column");
361 QTest::newRow(
"0x0 children, child at (-1,-1)") << 0 << 0 << -1 << -1;
362 QTest::newRow(
"0x0 children, child at (0,0)") << 0 << 0 << 0 << 0;
365 void tst_QStandardItem::getSetChild()
373 bool shouldHaveChildren = (rows > 0) && (columns > 0);
399 void tst_QStandardItem::parent()
409 child->setChild(0, 0, childOfChild);
422 void tst_QStandardItem::insertColumn_data()
424 QTest::addColumn<int>(
"rows");
425 QTest::addColumn<int>(
"columns");
426 QTest::addColumn<int>(
"column");
427 QTest::addColumn<int>(
"count");
455 void tst_QStandardItem::insertColumn()
486 void tst_QStandardItem::insertRow_data()
488 QTest::addColumn<int>(
"rows");
489 QTest::addColumn<int>(
"columns");
490 QTest::addColumn<int>(
"row");
491 QTest::addColumn<int>(
"count");
519 void tst_QStandardItem::insertRow()
550 void tst_QStandardItem::insertRows_data()
552 QTest::addColumn<int>(
"rows");
553 QTest::addColumn<int>(
"columns");
554 QTest::addColumn<int>(
"insertAt");
555 QTest::addColumn<int>(
"insertCount");
557 QTest::newRow(
"insert {0,1} at 0 in 0x0") << 0 << 0 << 0 << 2;
560 void tst_QStandardItem::insertRows()
570 for (
int i = 0;
i < insertCount; ++
i)
577 void tst_QStandardItem::appendColumn_data()
579 QTest::addColumn<int>(
"rows");
580 QTest::addColumn<int>(
"columns");
581 QTest::addColumn<int>(
"count");
613 void tst_QStandardItem::appendColumn()
622 for (
int i = 0;
i < rows; ++
i) {
623 for (
int j = 0;
j < columns; ++
j) {
635 item.appendColumn(columnItems);
646 for (
int i = 0;
i < rows; ++
i) {
647 for (
int j = 0;
j < columns; ++
j)
652 void tst_QStandardItem::appendRow_data()
654 QTest::addColumn<int>(
"rows");
655 QTest::addColumn<int>(
"columns");
656 QTest::addColumn<int>(
"count");
688 void tst_QStandardItem::appendRow()
697 for (
int i = 0;
i < rows; ++
i) {
698 for (
int j = 0;
j < columns; ++
j) {
710 item.appendRow(rowItems);
721 for (
int i = 0;
i < rows; ++
i) {
722 for (
int j = 0;
j < columns; ++
j)
727 void tst_QStandardItem::takeChild()
730 for (
int i = 0;
i < 10; ++
i)
733 item.appendColumn(itemList);
735 for (
int i = 0;
i <
item.rowCount(); ++
i) {
738 for (
int j =
i + 1;
j <
item.rowCount(); ++
j)
744 void tst_QStandardItem::takeColumn_data()
746 QTest::addColumn<int>(
"rows");
747 QTest::addColumn<int>(
"columns");
748 QTest::addColumn<int>(
"column");
749 QTest::addColumn<bool>(
"expectSuccess");
765 void tst_QStandardItem::takeColumn()
770 QFETCH(
bool, expectSuccess);
775 for (
int i = 0;
i < rows; ++
i) {
776 for (
int j = 0;
j < columns; ++
j) {
788 for (
int i = 0;
i < taken.
count(); ++
i) {
793 for (
int i = 0;
i <
item.rowCount(); ++
i) {
794 for (
int j = 0;
j <
item.columnCount(); ++
j) {
805 void tst_QStandardItem::takeRow_data()
807 QTest::addColumn<int>(
"rows");
808 QTest::addColumn<int>(
"columns");
809 QTest::addColumn<int>(
"row");
810 QTest::addColumn<bool>(
"expectSuccess");
826 void tst_QStandardItem::takeRow()
831 QFETCH(
bool, expectSuccess);
836 for (
int i = 0;
i < rows; ++
i) {
837 for (
int j = 0;
j < columns; ++
j) {
849 for (
int i = 0;
i < taken.
count(); ++
i) {
853 for (
int i = 0;
i <
item.rowCount(); ++
i) {
854 for (
int j = 0;
j <
item.columnCount(); ++
j) {
865 void tst_QStandardItem::streamItem()
907 void tst_QStandardItem::deleteItem()
927 void tst_QStandardItem::clone()
962 void tst_QStandardItem::sortChildren()
964 for (
int x = 0;
x < 2; ++
x) {
975 item->appendRow(one);
976 item->appendRow(two);
1012 QCOMPARE(layoutAboutToBeChangedSpy.count(), (
x == 0) ? 0 : 3);
1013 QCOMPARE(layoutChangedSpy.count(), (
x == 0) ? 0 : 3);
1038 void tst_QStandardItem::subclassing()
1040 qMetaTypeId<QStandardItem*>();
1048 item->emitDataChanged();
1054 item->emitDataChanged();
1055 QCOMPARE(itemChangedSpy.count(), 1);
1056 QCOMPARE(itemChangedSpy.at(0).count(), 1);
1057 QCOMPARE(qvariant_cast<QStandardItem*>(itemChangedSpy.at(0).at(0)),
item);
1062 item->appendRow(child0);
1063 item->appendRow(child1);
1064 item->appendRow(child2);
1065 item->sortChildren(0);
1071 void tst_QStandardItem::lessThan()
1078 QVERIFY(!(stringB < stringA));
1081 QVERIFY(!(invalid1 < stringA));
1082 QVERIFY(!(invalid1 < invalid2));
1086 #include "tst_qstandarditem.moc"
small capitals from c petite p scientific i
[1]
bool operator<(const QStandardItem &other) const override
int type() const override
void layoutAboutToBeChanged(const QList< QPersistentModelIndex > &parents=QList< QPersistentModelIndex >(), QAbstractItemModel::LayoutChangeHint hint=QAbstractItemModel::NoLayoutChangeHint)
void layoutChanged(const QList< QPersistentModelIndex > &parents=QList< QPersistentModelIndex >(), QAbstractItemModel::LayoutChangeHint hint=QAbstractItemModel::NoLayoutChangeHint)
The QBrush class defines the fill pattern of shapes drawn by QPainter.
The QByteArray class provides an array of bytes.
The QColor class provides colors based on RGB, HSV or CMYK values.
The QDataStream class provides serialization of binary data to a QIODevice.
The QFont class specifies a query for a font used for drawing text.
void setData(int key, const QVariant &value)
void setFlags(GraphicsItemFlags flags)
void setEnabled(bool enabled)
QVariant data(int key) const
GraphicsItemFlags flags() const
The QIcon class provides scalable icons in different modes and states.
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal.
bool isEmpty() const noexcept
const_reference at(qsizetype i) const noexcept
qsizetype count() const noexcept
void append(parameter_type t)
The QObject class is the base class of all Qt objects.
The QPixmap class is an off-screen image representation that can be used as a paint device.
The QSize class defines the size of a two-dimensional object using integer point precision.
int rowCount(const QModelIndex &parent=QModelIndex()) const override
int columnCount(const QModelIndex &parent=QModelIndex()) const override
The QStandardItem class provides an item for use with the QStandardItemModel class.
QStandardItem * child(int row, int column=0) const
Qt::ItemFlags flags() const
QString statusTip() const
QString accessibleDescription() const
void sortChildren(int column, Qt::SortOrder order=Qt::AscendingOrder)
QBrush background() const
QStandardItem * parent() const
Qt::CheckState checkState() const
QString accessibleText() const
Qt::Alignment textAlignment() const
QBrush foreground() const
void appendRow(const QList< QStandardItem * > &items)
virtual QStandardItem * clone() const
The QStandardItemModel class provides a generic model for storing custom data.\inmodule QtGui.
void itemChanged(QStandardItem *item)
The QString class provides a Unicode character string.
static QString fromLatin1(QByteArrayView ba)
static QString number(int, int base=10)
The QVariant class acts like a union for the most common Qt data types.
qDeleteAll(list.begin(), list.end())
union Alignment_ Alignment
QColor backgroundColor(const QPalette &pal, const QWidget *widget)
Q_TESTLIB_EXPORT QTestData & newRow(const char *dataTag)
@ AccessibleDescriptionRole
GLint GLint GLint GLint GLint x
[0]
GLenum GLenum GLsizei count
GLenum GLenum GLsizei void GLsizei void * column
GLenum GLenum GLsizei void * row
#define QStringLiteral(str)
#define QTEST_MAIN(TestObject)
#define QFETCH(Type, name)
#define QVERIFY(statement)
QSqlQueryModel * model
[16]