Port away from deprecated methods in Qt

wilder
David Faure 7 years ago
parent 81529406d8
commit 072dc8f0f7
  1. 4
      autotests/kextracolumnsproxymodeltest.cpp
  2. 13
      autotests/proxymodeltestsuite/dynamictreemodel.cpp
  3. 4
      tests/proxymodeltestapp/kreparentingproxymodel.cpp

@ -112,7 +112,7 @@ private Q_SLOTS:
QCOMPARE(extractRowTexts(&mod, 0), QStringLiteral("ABCD")); QCOMPARE(extractRowTexts(&mod, 0), QStringLiteral("ABCD"));
QCOMPARE(extractRowTexts(&mod, 0, mod.index(0, 0)), QStringLiteral("mnop")); QCOMPARE(extractRowTexts(&mod, 0, mod.index(0, 0)), QStringLiteral("mnop"));
QCOMPARE(extractRowTexts(&mod, 1, mod.index(0, 0)), QStringLiteral("qrst")); QCOMPARE(extractRowTexts(&mod, 1, mod.index(0, 0)), QStringLiteral("qrst"));
QCOMPARE(extractRowTexts(&mod, 0, mod.index(0, 0).child(1, 0)), QStringLiteral("uvww")); QCOMPARE(extractRowTexts(&mod, 0, mod.index(1, 0, mod.index(0, 0))), QStringLiteral("uvww"));
QCOMPARE(extractRowTexts(&mod, 1), QStringLiteral("EFGH")); QCOMPARE(extractRowTexts(&mod, 1), QStringLiteral("EFGH"));
QCOMPARE(extractRowTexts(&mod, 0, mod.index(1, 0)), QStringLiteral("xyz.")); QCOMPARE(extractRowTexts(&mod, 0, mod.index(1, 0)), QStringLiteral("xyz."));
QCOMPARE(extractHorizontalHeaderTexts(&mod), QStringLiteral("H1H2H3H4")); QCOMPARE(extractHorizontalHeaderTexts(&mod), QStringLiteral("H1H2H3H4"));
@ -325,7 +325,7 @@ private Q_SLOTS:
// And a selection // And a selection
QItemSelectionModel selection(&pm); QItemSelectionModel selection(&pm);
selection.select(pm.index(0, 0), QItemSelectionModel::Select | QItemSelectionModel::Rows); selection.select(pm.index(0, 0), QItemSelectionModel::Select | QItemSelectionModel::Rows);
const QModelIndex grandChild = pm.index(0, 0).child(1, 0).child(0, 0); const QModelIndex grandChild = pm.index(0, 0, pm.index(1, 0, pm.index(0, 0)));
QCOMPARE(grandChild.data().toString(), QStringLiteral("u")); QCOMPARE(grandChild.data().toString(), QStringLiteral("u"));
selection.select(grandChild, QItemSelectionModel::Select | QItemSelectionModel::Rows); selection.select(grandChild, QItemSelectionModel::Select | QItemSelectionModel::Rows);
const QModelIndexList lst = selection.selectedIndexes(); const QModelIndexList lst = selection.selectedIndexes();

@ -433,10 +433,9 @@ void ModelInsertCommand::interpret(const QString &treeString)
{ {
m_treeString = treeString; m_treeString = treeString;
QList<int> depths = getDepths(m_treeString); const QList<int> depths = getDepths(m_treeString);
int size = 0; const int size = std::count(depths.begin(), depths.end(), 0);
qCount(depths, 0, size);
Q_ASSERT(size != 0); Q_ASSERT(size != 0);
m_endRow = m_startRow + size - 1; m_endRow = m_startRow + size - 1;
@ -480,10 +479,8 @@ void ModelInsertCommand::doCommand()
QModelIndex parent = findIndex(m_rowNumbers); QModelIndex parent = findIndex(m_rowNumbers);
if (!m_treeString.isEmpty()) { if (!m_treeString.isEmpty()) {
QList<int> depths = getDepths(m_treeString); const QList<int> depths = getDepths(m_treeString);
const int size = std::count(depths.begin(), depths.end(), 0);
int size = 0;
qCount(depths, 0, size);
Q_ASSERT(size != 0); Q_ASSERT(size != 0);
m_endRow = m_startRow + size - 1; m_endRow = m_startRow + size - 1;
} }
@ -512,7 +509,7 @@ void ModelInsertCommand::doCommand()
void ModelInsertCommand::doInsertTree(const QModelIndex &fragmentParent) void ModelInsertCommand::doInsertTree(const QModelIndex &fragmentParent)
{ {
QList<int> depths = getDepths(m_treeString); const QList<int> depths = getDepths(m_treeString);
qint64 fragmentParentIdentifier = fragmentParent.internalId(); qint64 fragmentParentIdentifier = fragmentParent.internalId();

@ -220,7 +220,7 @@ QModelIndex KReparentingProxyModelPrivate::getLastDescendant(const QModelIndex &
QModelIndex proxyIndex = q->mapFromSource(index); QModelIndex proxyIndex = q->mapFromSource(index);
while (q->hasChildren(proxyIndex)) { while (q->hasChildren(proxyIndex)) {
proxyIndex = proxyIndex.child(q->rowCount(proxyIndex), proxyIndex.column()); proxyIndex = q->index(q->rowCount(proxyIndex), proxyIndex.column(), proxyIndex);
if (!proxyIndex.isValid()) { if (!proxyIndex.isValid()) {
break; break;
} }
@ -308,7 +308,7 @@ QHash<QModelIndex, QModelIndexList> KReparentingProxyModelPrivate::recreateMappi
break; break;
} }
const QVector<QModelIndex>::iterator ancestorIt = qLowerBound(ancestors.begin(), ancestors.end(), nextIndex, LessThan(q)); const QVector<QModelIndex>::iterator ancestorIt = std::lower_bound(ancestors.begin(), ancestors.end(), nextIndex, LessThan(q));
ancestors.erase(ancestorIt, ancestors.end()); ancestors.erase(ancestorIt, ancestors.end());

Loading…
Cancel
Save