QtBase  v6.3.1
tst_qstringlistmodel.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2016 The Qt Company Ltd.
4 ** Contact: https://www.qt.io/licensing/
5 **
6 ** This file is part of the test suite of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:GPL-EXCEPT$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and The Qt Company. For licensing terms
14 ** and conditions see https://www.qt.io/terms-conditions. For further
15 ** information use the contact form at https://www.qt.io/contact-us.
16 **
17 ** GNU General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU
19 ** General Public License version 3 as published by the Free Software
20 ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
21 ** included in the packaging of this file. Please review the following
22 ** information to ensure the GNU General Public License requirements will
23 ** be met: https://www.gnu.org/licenses/gpl-3.0.html.
24 **
25 ** $QT_END_LICENSE$
26 **
27 ****************************************************************************/
28 
29 #include <QTest>
30 #include <QSignalSpy>
31 #include <qabstractitemmodel.h>
32 #include <qcoreapplication.h>
33 #include <qmap.h>
34 #include <qstringlistmodel.h>
35 #include <qstringlist.h>
36 #include "qmodellistener.h"
37 #include <qstringlistmodel.h>
38 
39 #include <algorithm>
40 
42 {
43  for (int i = 0; start + i <= end; i++) {
44  QModelIndex mIndex = m_pModel->index(start + i, 0, parent);
45  QVariant var = m_pModel->data(mIndex, Qt::DisplayRole);
46  QString str = var.toString();
47 
48  QCOMPARE(str, m_pAboutToStringlist->at(i));
49  }
50 }
51 
53 {
54  // Can the rows that *are* removed be iterated now ?
55 
56  // What about rowsAboutToBeInserted - what will the indices be?
57  // will insertRow() overwrite existing, or insert (and conseq. grow the model?)
58  // What will the item then contain? empty data?
59 
60  // RemoveColumn. Does that also fire the rowsRemoved-family signals?
61 
62  for (int i = 0; i < m_pExpectedStringlist->size(); i++) {
63  QModelIndex mIndex = m_pModel->index(i, 0, parent);
64  QVariant var = m_pModel->data(mIndex, Qt::DisplayRole);
65  QString str = var.toString();
66 
67  QCOMPARE(str, m_pExpectedStringlist->at(i));
68  }
69 }
70 
72 {
73  Q_OBJECT
74 
75 private slots:
76  void rowsAboutToBeRemoved_rowsRemoved();
77  void rowsAboutToBeRemoved_rowsRemoved_data();
78 
79  void rowsAboutToBeInserted_rowsInserted();
80  void rowsAboutToBeInserted_rowsInserted_data();
81 
82  void setData_emits_both_roles_data();
83  void setData_emits_both_roles();
84 
85  void setData_emits_on_change_only();
86 
87  void supportedDragDropActions();
88 
89  void moveRows_data();
90  void moveRows();
91  void moveRowsInvalid_data();
92  void moveRowsInvalid();
93 
94  void itemData();
95  void setItemData();
96  void createPersistentOnLayoutAboutToBeChanged();
97 };
98 
99 void tst_QStringListModel::moveRowsInvalid_data()
100 {
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");
107 
108  const auto createModel = [this]() {
109  return new QStringListModel(QStringList{"A", "B", "C", "D", "E", "F"}, this);
110  };
111  constexpr int rowCount = 6;
112 
113  QTest::addRow("destination_equal_source") << createModel() << QModelIndex() << 0 << 1 << QModelIndex() << 0;
114  QTest::addRow("count_equal_0") << createModel() << QModelIndex() << 0 << 0 << QModelIndex() << 2;
115  QStringListModel *tempModel = createModel();
116  QTest::addRow("move_child") << tempModel << tempModel->index(0, 0) << 0 << 1 << QModelIndex() << 2;
117  tempModel = createModel();
118  QTest::addRow("move_to_child") << tempModel << QModelIndex() << 0 << 1 << tempModel->index(0, 0) << 2;
119  QTest::addRow("negative_count") << createModel() << QModelIndex() << 0 << -1 << QModelIndex() << 2;
120  QTest::addRow("negative_source_row") << createModel() << QModelIndex() << -1 << 1 << QModelIndex() << 2;
121  QTest::addRow("negative_destination_row") << createModel() << QModelIndex() << 0 << 1 << QModelIndex() << -1;
122  QTest::addRow("source_row_equal_rowCount") << createModel() << QModelIndex() << rowCount << 1 << QModelIndex() << 1;
123  QTest::addRow("source_row_equal_destination_row") << createModel() << QModelIndex() << 2 << 1 << QModelIndex() << 2;
124  QTest::addRow("source_row_equal_destination_row_plus_1") << createModel() << QModelIndex() << 2 << 1 << QModelIndex() << 3;
125  QTest::addRow("destination_row_greater_rowCount") << createModel() << QModelIndex() << 0 << 1 << QModelIndex() << rowCount + 1;
126  QTest::addRow("move_row_within_source_range") << createModel() << QModelIndex() << 0 << 3 << QModelIndex() << 2;
127 }
128 
129 void tst_QStringListModel::moveRowsInvalid()
130 {
131  QFETCH(QStringListModel* const, baseModel);
132  QFETCH(const QModelIndex, startParent);
133  QFETCH(const int, startRow);
134  QFETCH(const int, count);
135  QFETCH(const QModelIndex, destinationParent);
136  QFETCH(const int, destination);
137 
138  QSignalSpy rowMovedSpy(baseModel, &QAbstractItemModel::rowsMoved);
139  QSignalSpy rowAboutMovedSpy(baseModel, &QAbstractItemModel::rowsAboutToBeMoved);
140  QVERIFY(rowMovedSpy.isValid());
141  QVERIFY(rowAboutMovedSpy.isValid());
142  QVERIFY(!baseModel->moveRows(startParent, startRow, count, destinationParent, destination));
143  QCOMPARE(rowMovedSpy.size(), 0);
144  QCOMPARE(rowAboutMovedSpy.size(), 0);
145  delete baseModel;
146 }
147 
148 void tst_QStringListModel::moveRows_data()
149 {
150  QTest::addColumn<int>("startRow");
151  QTest::addColumn<int>("count");
152  QTest::addColumn<int>("destination");
153  QTest::addColumn<QStringList>("expected");
154 
155  QTest::newRow("1_Item_from_top_to_middle") << 0 << 1 << 3 << QStringList{"B", "C", "A", "D", "E", "F"};
156  QTest::newRow("1_Item_from_top_to_bottom") << 0 << 1 << 6 << QStringList{"B", "C", "D", "E", "F", "A"};
157  QTest::newRow("1_Item_from_middle_to_top") << 2 << 1 << 0 << QStringList{"C", "A", "B", "D", "E", "F"};
158  QTest::newRow("1_Item_from_bottom_to_middle") << 5 << 1 << 2 << QStringList{"A", "B", "F", "C", "D", "E"};
159  QTest::newRow("1_Item_from_bottom to_top") << 5 << 1 << 0 << QStringList{"F", "A", "B", "C", "D", "E"};
160  QTest::newRow("1_Item_from_middle_to_bottom") << 2 << 1 << 6 << QStringList{"A", "B", "D", "E", "F", "C"};
161  QTest::newRow("1_Item_from_middle_to_middle_before") << 2 << 1 << 1 << QStringList{"A", "C", "B", "D", "E", "F"};
162  QTest::newRow("1_Item_from_middle_to_middle_after") << 2 << 1 << 4 << QStringList{"A", "B", "D", "C", "E", "F"};
163 
164  QTest::newRow("2_Items_from_top_to_middle") << 0 << 2 << 3 << QStringList{"C", "A", "B", "D", "E", "F"};
165  QTest::newRow("2_Items_from_top_to_bottom") << 0 << 2 << 6 << QStringList{"C", "D", "E", "F", "A", "B"};
166  QTest::newRow("2_Items_from_middle_to_top") << 2 << 2 << 0 << QStringList{"C", "D", "A", "B", "E", "F"};
167  QTest::newRow("2_Items_from_bottom_to_middle") << 4 << 2 << 2 << QStringList{"A", "B", "E", "F", "C", "D"};
168  QTest::newRow("2_Items_from_bottom_to_top") << 4 << 2 << 0 << QStringList{"E", "F", "A", "B", "C", "D"};
169  QTest::newRow("2_Items_from_middle_to_bottom") << 2 << 2 << 6 << QStringList{"A", "B", "E", "F", "C", "D"};
170  QTest::newRow("2_Items_from_middle_to_middle_before") << 3 << 2 << 1 << QStringList{"A", "D", "E", "B", "C", "F"};
171  QTest::newRow("2_Items_from_middle_to_middle_after") << 1 << 2 << 5 << QStringList{"A", "D", "E", "B", "C", "F"};
172 }
173 
174 void tst_QStringListModel::moveRows()
175 {
176  QFETCH(const int, startRow);
177  QFETCH(const int, count);
178  QFETCH(const int, destination);
179  QFETCH(const QStringList, expected);
180  QStringListModel baseModel(QStringList{"A", "B", "C", "D", "E", "F"});
181  QSignalSpy rowMovedSpy(&baseModel, &QAbstractItemModel::rowsMoved);
182  QSignalSpy rowAboutMovedSpy(&baseModel, &QAbstractItemModel::rowsAboutToBeMoved);
183  QVERIFY(baseModel.moveRows(QModelIndex(), startRow, count, QModelIndex(), destination));
184  QCOMPARE(baseModel.stringList(), expected);
185  QCOMPARE(rowMovedSpy.size(), 1);
186  QCOMPARE(rowAboutMovedSpy.size(), 1);
187  for (const QList<QVariant> &signalArgs : {rowMovedSpy.first(), rowAboutMovedSpy.first()}){
188  QVERIFY(!signalArgs.at(0).value<QModelIndex>().isValid());
189  QCOMPARE(signalArgs.at(1).toInt(), startRow);
190  QCOMPARE(signalArgs.at(2).toInt(), startRow + count - 1);
191  QVERIFY(!signalArgs.at(3).value<QModelIndex>().isValid());
192  QCOMPARE(signalArgs.at(4).toInt(), destination);
193  }
194 }
195 
196 void tst_QStringListModel::rowsAboutToBeRemoved_rowsRemoved_data()
197 {
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");
203 
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;
208 
209  QStringList strings1; strings1 << "One" << "Two" << "Three" << "Four" << "Five";
210  QStringList aboutto1; aboutto1 << "One" << "Two";
211  QStringList res1; res1 << "Three" << "Four" << "Five";
212  QTest::newRow( "data1" ) << strings1 << 0 << 2 << aboutto1 << res1;
213 
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;
218 
219  QStringList strings3; strings3 << "One" << "Two" << "Three" << "Four" << "Five";
220  QStringList aboutto3; aboutto3 << "One" << "Two" << "Three" << "Four" << "Five";
221  QStringList res3;
222  QTest::newRow( "data3" ) << strings3 << 0 << 5 << aboutto3 << res3;
223 
224  /*
225  * Keep this, template to add more data
226  QStringList strings2; strings2 << "One" << "Two" << "Three" << "Four" << "Five";
227  QStringList aboutto2; aboutto2 << "One" << "Two" << "Three" << "Four" << "Five";
228  QStringList res2; res2 << "One" << "Two" << "Three" << "Four" << "Five";
229  QTest::newRow( "data2" ) << strings2 << 0 << 5 << aboutto2 << res2;
230 */
231 
232 }
233 
234 void tst_QStringListModel::rowsAboutToBeRemoved_rowsRemoved()
235 {
237  QFETCH(int, row);
238  QFETCH(int, count);
239  QFETCH(QStringList, aboutto);
241 
243  QModelListener listener(&aboutto, &res, &model);
244  connect(&model, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)),
245  &listener, SLOT(rowsAboutToBeRemovedOrInserted(QModelIndex,int,int)));
246 
247  connect(&model, SIGNAL(rowsRemoved(QModelIndex,int,int)),
248  &listener, SLOT(rowsRemovedOrInserted(QModelIndex,int,int)));
249 
251  // At this point, control goes to our connected slots inn this order:
252  // 1. rowsAboutToBeRemovedOrInserted
253  // 2. rowsRemovedOrInserted
254  // Control returns here
255 }
256 
257 void tst_QStringListModel::rowsAboutToBeInserted_rowsInserted_data()
258 {
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");
264 
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;
269 
270  QStringList strings1; strings1 << "One" << "Two" << "Three" << "Four" << "Five";
271  QStringList aboutto1; aboutto1 << "One" << "Two";
272  QStringList res1; res1 << "" << "" << "One" << "Two" << "Three" << "Four" << "Five";
273  QTest::newRow( "data1" ) << strings1 << 0 << 2 << aboutto1 << res1;
274 
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;
279 
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;
284 
285  /*
286  * Keep this, template to add more data
287  QStringList strings2; strings2 << "One" << "Two" << "Three" << "Four" << "Five";
288  QStringList aboutto2; aboutto2 << "One" << "Two" << "Three" << "Four" << "Five";
289  QStringList res2; res2 << "One" << "Two" << "Three" << "Four" << "Five";
290  QTest::newRow( "data2" ) << strings2 << 0 << 5 << aboutto2 << res2;
291 */
292 
293 }
294 
295 void tst_QStringListModel::rowsAboutToBeInserted_rowsInserted()
296 {
298  QFETCH(int, row);
299  QFETCH(int, count);
300  QFETCH(QStringList, aboutto);
302 
304  QModelListener listener(&aboutto, &res, &model);
305  connect(&model, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int)),
306  &listener, SLOT(rowsAboutToBeRemovedOrInserted(QModelIndex,int,int)));
307 
308  connect(&model, SIGNAL(rowsInserted(QModelIndex,int,int)),
309  &listener, SLOT(rowsRemovedOrInserted(QModelIndex,int,int)));
310 
312  // At this point, control goes to our connected slots inn this order:
313  // 1. rowsAboutToBeRemovedOrInserted
314  // 2. rowsRemovedOrInserted
315  // Control returns here
316 }
317 
318 void tst_QStringListModel::setData_emits_both_roles_data()
319 {
320  QTest::addColumn<int>("row");
321  QTest::addColumn<QString>("data");
322  QTest::addColumn<int>("role");
323 
324 #define ROW(row, string, role) \
325  QTest::newRow(#row " -> " string) << row << QString(string) << int(Qt::role)
326  ROW(0, "1", EditRole);
327  ROW(1, "2", DisplayRole);
328 #undef ROW
329 }
330 
331 template <class C>
333 {
334  std::sort(c.begin(), c.end());
335  return c;
336 }
337 
338 void tst_QStringListModel::setData_emits_both_roles()
339 {
340  QFETCH(int, row);
341  QFETCH(QString, data);
342  QFETCH(int, role);
343 
344  QStringListModel model(QStringList() << "one" << "two");
345  QList<int> expected;
346  expected.reserve(2);
347  expected.append(Qt::DisplayRole);
348  expected.append(Qt::EditRole);
349 
351  QVERIFY(spy.isValid());
352  model.setData(model.index(row, 0), data, role);
353  QCOMPARE(spy.size(), 1);
354  QCOMPARE(sorted(spy.at(0).at(2).value<QList<int> >()),
355  expected);
356 }
357 
358 void tst_QStringListModel::itemData()
359 {
360  QStringListModel testModel{ QStringList {
361  QStringLiteral("One"),
362  QStringLiteral("Two"),
363  QStringLiteral("Three"),
364  QStringLiteral("Four"),
365  QStringLiteral("Five")
366  }};
367  QMap<int, QVariant> compareMap;
368  QCOMPARE(testModel.itemData(QModelIndex()), compareMap);
369  compareMap.insert(Qt::DisplayRole, QStringLiteral("Two"));
370  compareMap.insert(Qt::EditRole, QStringLiteral("Two"));
371  QCOMPARE(testModel.itemData(testModel.index(1, 0)), compareMap);
372 }
373 
374 void tst_QStringListModel::setItemData()
375 {
376  QStringListModel testModel{ QStringList {
377  QStringLiteral("One"),
378  QStringLiteral("Two"),
379  QStringLiteral("Three"),
380  QStringLiteral("Four"),
381  QStringLiteral("Five")
382  }};
383  QSignalSpy dataChangedSpy(&testModel, &QAbstractItemModel::dataChanged);
384  QModelIndex changeIndex = testModel.index(1, 0);
385  const QList<int> changeRoles{Qt::DisplayRole, Qt::EditRole};
386  const QString changedString("Changed");
387  QMap<int, QVariant> newItemData{std::make_pair<int>(Qt::DisplayRole, changedString)};
388  // invalid index does nothing and returns false
389  QVERIFY(!testModel.setItemData(QModelIndex(), newItemData));
390  // valid data is set, return value is true and dataChanged is emitted once
391  QVERIFY(testModel.setItemData(changeIndex, newItemData));
392  QCOMPARE(changeIndex.data(Qt::DisplayRole).toString(), changedString);
393  QCOMPARE(changeIndex.data(Qt::EditRole).toString(), changedString);
394  QCOMPARE(dataChangedSpy.size(), 1);
395  QVariantList dataChangedArguments = dataChangedSpy.takeFirst();
396  QCOMPARE(dataChangedArguments.at(0).value<QModelIndex>(), changeIndex);
397  QCOMPARE(dataChangedArguments.at(1).value<QModelIndex>(), changeIndex);
398  QCOMPARE(dataChangedArguments.at(2).value<QList<int> >(), changeRoles);
399  // Unsupported roles do nothing return false
400  newItemData.clear();
401  newItemData.insert(Qt::UserRole, changedString);
402  QVERIFY(!testModel.setItemData(changeIndex, newItemData));
403  QCOMPARE(dataChangedSpy.size(), 0);
404  // If some but not all the roles are supported it returns false and does nothing
405  newItemData.insert(Qt::EditRole, changedString);
406  changeIndex = testModel.index(2, 0);
407  QVERIFY(!testModel.setItemData(changeIndex, newItemData));
408  QCOMPARE(changeIndex.data(Qt::DisplayRole).toString(), QStringLiteral("Three"));
409  QCOMPARE(changeIndex.data(Qt::EditRole).toString(), QStringLiteral("Three"));
410  QCOMPARE(dataChangedSpy.size(), 0);
411  // Qt::EditRole and Qt::DisplayRole are both set, Qt::EditRole takes precedence
412  newItemData.clear();
413  newItemData.insert(Qt::EditRole, changedString);
414  newItemData.insert(Qt::DisplayRole, QStringLiteral("Ignored"));
415  changeIndex = testModel.index(3, 0);
416  QVERIFY(testModel.setItemData(changeIndex, newItemData));
417  QCOMPARE(changeIndex.data(Qt::DisplayRole).toString(), changedString);
418  QCOMPARE(changeIndex.data(Qt::EditRole).toString(), changedString);
419  QCOMPARE(dataChangedSpy.size(), 1);
420  dataChangedArguments = dataChangedSpy.takeFirst();
421  QCOMPARE(dataChangedArguments.at(0).value<QModelIndex>(), changeIndex);
422  QCOMPARE(dataChangedArguments.at(1).value<QModelIndex>(), changeIndex);
423  QCOMPARE(dataChangedArguments.at(2).value<QList<int> >(), changeRoles);
424 }
425 
426 void tst_QStringListModel::setData_emits_on_change_only()
427 {
430  QVERIFY(dataChangedSpy.isValid());
431  const QModelIndex modelIdx = model.index(0, 0);
432  const QString newStringData = QStringLiteral("test");
433  QVERIFY(model.setData(modelIdx, newStringData));
434  QCOMPARE(dataChangedSpy.count(), 1);
435  const QList<QVariant> spyList = dataChangedSpy.takeFirst();
436  QCOMPARE(spyList.at(0).value<QModelIndex>(), modelIdx);
437  QCOMPARE(spyList.at(1).value<QModelIndex>(), modelIdx);
438  const QList<int> expectedRoles{Qt::DisplayRole, Qt::EditRole};
439  QCOMPARE(spyList.at(2).value<QList<int> >(), expectedRoles);
440  QVERIFY(model.setData(modelIdx, newStringData));
441  QVERIFY(dataChangedSpy.isEmpty());
442 }
443 
444 void tst_QStringListModel::supportedDragDropActions()
445 {
449 }
450 
451 void tst_QStringListModel::createPersistentOnLayoutAboutToBeChanged() // QTBUG-93466
452 {
455  QSignalSpy layoutAboutToBeChangedSpy(&model, &QAbstractItemModel::layoutAboutToBeChanged);
458  idxList.clear();
459  for (int row = 0; row < 3; ++row)
460  idxList << QPersistentModelIndex(model.index(row, 0));
461  });
462  connect(&model, &QAbstractItemModel::layoutChanged, this, [&idxList](){
463  QCOMPARE(idxList.size(), 3);
464  QCOMPARE(idxList.at(0).row(), 1);
465  QCOMPARE(idxList.at(0).column(), 0);
466  QCOMPARE(idxList.at(0).data().toString(), QStringLiteral("1"));
467  QCOMPARE(idxList.at(1).row(), 0);
468  QCOMPARE(idxList.at(1).column(), 0);
469  QCOMPARE(idxList.at(1).data().toString(), QStringLiteral("0"));
470  QCOMPARE(idxList.at(2).row(), 2);
471  QCOMPARE(idxList.at(2).column(), 0);
472  QCOMPARE(idxList.at(2).data().toString(), QStringLiteral("3"));
473  });
474  model.setData(model.index(1, 0), QStringLiteral("0"));
475  model.sort(0);
476  QCOMPARE(layoutAboutToBeChangedSpy.size(), 1);
477  QCOMPARE(layoutChangedSpy.size(), 1);
478 }
479 
481 #include "tst_qstringlistmodel.moc"
small capitals from c petite p scientific i
[1]
Definition: afcover.h:80
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
Definition: qlist.h:414
const_reference at(qsizetype i) const noexcept
Definition: qlist.h:457
value_type takeFirst()
Definition: qlist.h:564
void reserve(qsizetype size)
Definition: qlist.h:757
T & first()
Definition: qlist.h:643
void append(parameter_type t)
Definition: qlist.h:469
Definition: qmap.h:222
iterator insert(const Key &key, const T &value)
Definition: qmap.h:719
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.
Definition: qobject.h:125
QObject * parent() const
Definition: qobject.h:409
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Definition: qobject.cpp:2772
The QPersistentModelIndex class is used to locate data in a data model.
bool isValid() const
Definition: qsignalspy.h:130
The QString class provides a Unicode character string.
Definition: qstring.h:388
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.
Definition: qvariant.h:95
QString toString() const
Definition: qvariant.cpp:1416
T value() const
Definition: qvariant.h:378
QString str
[2]
QSignalSpy spy(myCustomObject, SIGNAL(mySignal(int, QString, double)))
[0]
QCOMPARE(spy.count(), 1)
Q_TESTLIB_EXPORT QTestData & newRow(const char *dataTag)
Definition: qtestcase.cpp:2658
Q_TESTLIB_EXPORT QTestData & addRow(const char *format,...) Q_ATTRIBUTE_FORMAT_PRINTF(1
Definition: qtestcase.cpp:2690
@ UserRole
Definition: qnamespace.h:1527
@ EditRole
Definition: qnamespace.h:1504
@ DisplayRole
Definition: qnamespace.h:1502
@ CopyAction
Definition: qnamespace.h:1485
@ MoveAction
Definition: qnamespace.h:1486
QList< QString > QStringList
Definition: qcontainerfwd.h:64
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
#define SLOT(a)
Definition: qobjectdefs.h:87
#define SIGNAL(a)
Definition: qobjectdefs.h:88
GLuint GLuint end
GLenum GLenum GLsizei count
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLuint start
GLuint res
Definition: qopenglext.h:8867
const GLubyte * c
Definition: qopenglext.h:12701
GLenum GLenum GLsizei void * row
Definition: qopenglext.h:2747
GLenum GLenum GLenum input
Definition: qopenglext.h:10816
#define QStringLiteral(str)
#define QTEST_MAIN(TestObject)
Definition: qtest.h:664
#define QFETCH(Type, name)
Definition: qtestcase.h:230
#define QVERIFY(statement)
Definition: qtestcase.h:64
#define Q_OBJECT
Definition: qtmetamacros.h:158
#define slots
Definition: qtmetamacros.h:76
QSqlQueryModel * model
[16]
const int rowCount
Definition: testtable1.cpp:31
C sorted(C c)
#define ROW(row, string, role)
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent