62 for (
int i = 0;
i < m_pExpectedStringlist->size();
i++) {
76 void rowsAboutToBeRemoved_rowsRemoved();
77 void rowsAboutToBeRemoved_rowsRemoved_data();
79 void rowsAboutToBeInserted_rowsInserted();
80 void rowsAboutToBeInserted_rowsInserted_data();
82 void setData_emits_both_roles_data();
83 void setData_emits_both_roles();
85 void setData_emits_on_change_only();
87 void supportedDragDropActions();
91 void moveRowsInvalid_data();
92 void moveRowsInvalid();
96 void createPersistentOnLayoutAboutToBeChanged();
99 void tst_QStringListModel::moveRowsInvalid_data()
101 QTest::addColumn<QStringListModel*>(
"baseModel");
102 QTest::addColumn<QModelIndex>(
"startParent");
103 QTest::addColumn<int>(
"startRow");
104 QTest::addColumn<int>(
"count");
105 QTest::addColumn<QModelIndex>(
"destinationParent");
106 QTest::addColumn<int>(
"destination");
108 const auto createModel = [
this]() {
117 tempModel = createModel();
129 void tst_QStringListModel::moveRowsInvalid()
133 QFETCH(
const int, startRow);
140 QVERIFY(rowMovedSpy.isValid());
141 QVERIFY(rowAboutMovedSpy.isValid());
144 QCOMPARE(rowAboutMovedSpy.size(), 0);
148 void tst_QStringListModel::moveRows_data()
150 QTest::addColumn<int>(
"startRow");
151 QTest::addColumn<int>(
"count");
152 QTest::addColumn<int>(
"destination");
153 QTest::addColumn<QStringList>(
"expected");
174 void tst_QStringListModel::moveRows()
176 QFETCH(
const int, startRow);
184 QCOMPARE(baseModel.stringList(), expected);
186 QCOMPARE(rowAboutMovedSpy.size(), 1);
189 QCOMPARE(signalArgs.at(1).toInt(), startRow);
196 void tst_QStringListModel::rowsAboutToBeRemoved_rowsRemoved_data()
198 QTest::addColumn<QStringList>(
"input");
199 QTest::addColumn<int>(
"row");
200 QTest::addColumn<int>(
"count");
201 QTest::addColumn<QStringList>(
"aboutto");
202 QTest::addColumn<QStringList>(
"res");
204 QStringList strings0; strings0 <<
"One" <<
"Two" <<
"Three" <<
"Four" <<
"Five";
205 QStringList aboutto0; aboutto0 <<
"Two" <<
"Three";
206 QStringList res0; res0 <<
"One" <<
"Four" <<
"Five";
207 QTest::newRow(
"data0" ) << strings0 << 1 << 2 << aboutto0 << res0;
209 QStringList strings1; strings1 <<
"One" <<
"Two" <<
"Three" <<
"Four" <<
"Five";
211 QStringList res1; res1 <<
"Three" <<
"Four" <<
"Five";
212 QTest::newRow(
"data1" ) << strings1 << 0 << 2 << aboutto1 << res1;
214 QStringList strings2; strings2 <<
"One" <<
"Two" <<
"Three" <<
"Four" <<
"Five";
215 QStringList aboutto2; aboutto2 <<
"Four" <<
"Five";
216 QStringList res2; res2 <<
"One" <<
"Two" <<
"Three";
217 QTest::newRow(
"data2" ) << strings2 << 3 << 2 << aboutto2 << res2;
219 QStringList strings3; strings3 <<
"One" <<
"Two" <<
"Three" <<
"Four" <<
"Five";
220 QStringList aboutto3; aboutto3 <<
"One" <<
"Two" <<
"Three" <<
"Four" <<
"Five";
222 QTest::newRow(
"data3" ) << strings3 << 0 << 5 << aboutto3 << res3;
234 void tst_QStringListModel::rowsAboutToBeRemoved_rowsRemoved()
257 void tst_QStringListModel::rowsAboutToBeInserted_rowsInserted_data()
259 QTest::addColumn<QStringList>(
"input");
260 QTest::addColumn<int>(
"row");
261 QTest::addColumn<int>(
"count");
262 QTest::addColumn<QStringList>(
"aboutto");
263 QTest::addColumn<QStringList>(
"res");
265 QStringList strings0; strings0 <<
"One" <<
"Two" <<
"Three" <<
"Four" <<
"Five";
266 QStringList aboutto0; aboutto0 <<
"Two" <<
"Three";
267 QStringList res0; res0 <<
"One" <<
"" <<
"" <<
"Two" <<
"Three" <<
"Four" <<
"Five";
268 QTest::newRow(
"data0" ) << strings0 << 1 << 2 << aboutto0 << res0;
270 QStringList strings1; strings1 <<
"One" <<
"Two" <<
"Three" <<
"Four" <<
"Five";
272 QStringList res1; res1 <<
"" <<
"" <<
"One" <<
"Two" <<
"Three" <<
"Four" <<
"Five";
273 QTest::newRow(
"data1" ) << strings1 << 0 << 2 << aboutto1 << res1;
275 QStringList strings2; strings2 <<
"One" <<
"Two" <<
"Three" <<
"Four" <<
"Five";
276 QStringList aboutto2; aboutto2 <<
"Four" <<
"Five";
277 QStringList res2; res2 <<
"One" <<
"Two" <<
"Three" <<
"" <<
"" <<
"Four" <<
"Five";
278 QTest::newRow(
"data2" ) << strings2 << 3 << 2 << aboutto2 << res2;
280 QStringList strings3; strings3 <<
"One" <<
"Two" <<
"Three" <<
"Four" <<
"Five";
281 QStringList aboutto3; aboutto3 <<
"One" <<
"Two" <<
"Three" <<
"Four" <<
"Five";
282 QStringList res3; res3 <<
"" <<
"" <<
"" <<
"" <<
"" <<
"One" <<
"Two" <<
"Three" <<
"Four" <<
"Five";
283 QTest::newRow(
"data3" ) << strings3 << 0 << 5 << aboutto3 << res3;
295 void tst_QStringListModel::rowsAboutToBeInserted_rowsInserted()
318 void tst_QStringListModel::setData_emits_both_roles_data()
320 QTest::addColumn<int>(
"row");
321 QTest::addColumn<QString>(
"data");
322 QTest::addColumn<int>(
"role");
324 #define ROW(row, string, role) \
325 QTest::newRow(#row " -> " string) << row << QString(string) << int(Qt::role)
334 std::sort(
c.begin(),
c.end());
338 void tst_QStringListModel::setData_emits_both_roles()
358 void tst_QStringListModel::itemData()
371 QCOMPARE(testModel.itemData(testModel.index(1, 0)), compareMap);
374 void tst_QStringListModel::setItemData()
386 const QString changedString(
"Changed");
391 QVERIFY(testModel.setItemData(changeIndex, newItemData));
402 QVERIFY(!testModel.setItemData(changeIndex, newItemData));
406 changeIndex = testModel.index(2, 0);
407 QVERIFY(!testModel.setItemData(changeIndex, newItemData));
415 changeIndex = testModel.index(3, 0);
416 QVERIFY(testModel.setItemData(changeIndex, newItemData));
420 dataChangedArguments = dataChangedSpy.
takeFirst();
426 void tst_QStringListModel::setData_emits_on_change_only()
430 QVERIFY(dataChangedSpy.isValid());
434 QCOMPARE(dataChangedSpy.count(), 1);
441 QVERIFY(dataChangedSpy.isEmpty());
444 void tst_QStringListModel::supportedDragDropActions()
451 void tst_QStringListModel::createPersistentOnLayoutAboutToBeChanged()
465 QCOMPARE(idxList.at(0).column(), 0);
468 QCOMPARE(idxList.at(1).column(), 0);
471 QCOMPARE(idxList.at(2).column(), 0);
476 QCOMPARE(layoutAboutToBeChangedSpy.size(), 1);
477 QCOMPARE(layoutChangedSpy.size(), 1);
481 #include "tst_qstringlistmodel.moc"
small capitals from c petite p scientific i
[1]
void rowsMoved(const QModelIndex &parent, int start, int end, const QModelIndex &destination, int row, QPrivateSignal)
virtual Qt::DropActions supportedDropActions() const
virtual void sort(int column, Qt::SortOrder order=Qt::AscendingOrder)
void layoutAboutToBeChanged(const QList< QPersistentModelIndex > &parents=QList< QPersistentModelIndex >(), QAbstractItemModel::LayoutChangeHint hint=QAbstractItemModel::NoLayoutChangeHint)
void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QList< int > &roles=QList< int >())
virtual bool removeRows(int row, int count, const QModelIndex &parent=QModelIndex())
void layoutChanged(const QList< QPersistentModelIndex > &parents=QList< QPersistentModelIndex >(), QAbstractItemModel::LayoutChangeHint hint=QAbstractItemModel::NoLayoutChangeHint)
virtual Q_INVOKABLE bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole)
virtual bool insertRows(int row, int count, const QModelIndex &parent=QModelIndex())
virtual Qt::DropActions supportedDragActions() const
void rowsAboutToBeMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationRow, QPrivateSignal)
QModelIndex index(int row, int column=0, const QModelIndex &parent=QModelIndex()) const override
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
qsizetype size() const noexcept
const_reference at(qsizetype i) const noexcept
void reserve(qsizetype size)
void append(parameter_type t)
iterator insert(const Key &key, const T &value)
The QModelIndex class is used to locate data in a data model.
QVariant data(int role=Qt::DisplayRole) const
constexpr bool isValid() const noexcept
void rowsAboutToBeRemovedOrInserted(const QModelIndex &parent, int start, int end)
void rowsRemovedOrInserted(const QModelIndex &parent, int start, int end)
The QObject class is the base class of all Qt objects.
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
The QPersistentModelIndex class is used to locate data in a data model.
The QString class provides a Unicode character string.
The QStringList class provides a list of strings.
The QStringListModel class provides a model that supplies strings to views.
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
The QVariant class acts like a union for the most common Qt data types.
QSignalSpy spy(myCustomObject, SIGNAL(mySignal(int, QString, double)))
[0]
Q_TESTLIB_EXPORT QTestData & newRow(const char *dataTag)
Q_TESTLIB_EXPORT QTestData & addRow(const char *format,...) Q_ATTRIBUTE_FORMAT_PRINTF(1
QList< QString > QStringList
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char return DBusMessage return DBusMessage const char * destination
GLenum GLenum GLsizei count
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLenum GLsizei void * row
GLenum GLenum GLenum input
#define QStringLiteral(str)
#define QTEST_MAIN(TestObject)
#define QFETCH(Type, name)
#define QVERIFY(statement)
QSqlQueryModel * model
[16]
#define ROW(row, string, role)
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent