From: Janne Koschinski Date: Mon, 5 Aug 2019 10:37:13 +0000 (+0200) Subject: Replace deprecated QModelIndex::child with QAbstractItemModel::index X-Git-Tag: test-travis-01~38 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=a453c963cf1872e14c83adf1d40a31821c166805;ds=sidebyside Replace deprecated QModelIndex::child with QAbstractItemModel::index --- diff --git a/src/client/buffermodel.cpp b/src/client/buffermodel.cpp index d4a94eac..0836b06b 100644 --- a/src/client/buffermodel.cpp +++ b/src/client/buffermodel.cpp @@ -138,7 +138,7 @@ void BufferModel::newBuffers(const QModelIndex& parent, int start, int end) return; for (int row = start; row <= end; row++) { - QModelIndex child = parent.child(row, 0); + QModelIndex child = parent.model()->index(row, 0, parent); newBuffer(child.data(NetworkModel::BufferIdRole).value()); } } diff --git a/src/client/networkmodel.cpp b/src/client/networkmodel.cpp index 47139325..837601f6 100644 --- a/src/client/networkmodel.cpp +++ b/src/client/networkmodel.cpp @@ -1520,7 +1520,7 @@ void NetworkModel::checkForRemovedBuffers(const QModelIndex& parent, int start, return; for (int row = start; row <= end; row++) { - _bufferItemCache.remove(parent.child(row, 0).data(BufferIdRole).value()); + _bufferItemCache.remove(index(row, 0, parent).data(BufferIdRole).value()); } } @@ -1530,7 +1530,7 @@ void NetworkModel::checkForNewBuffers(const QModelIndex& parent, int start, int return; for (int row = start; row <= end; row++) { - QModelIndex child = parent.child(row, 0); + QModelIndex child = parent.model()->index(row, 0, parent); _bufferItemCache[child.data(BufferIdRole).value()] = static_cast(child.internalPointer()); } } diff --git a/src/client/treemodel.cpp b/src/client/treemodel.cpp index d1cc465d..2819353a 100644 --- a/src/client/treemodel.cpp +++ b/src/client/treemodel.cpp @@ -571,7 +571,7 @@ void TreeModel::debug_rowsAboutToBeRemoved(const QModelIndex& parent, int start, QModelIndex child; for (int i = end; i >= start; i--) { - child = parent.child(i, 0); + child = parent.model()->index(i, 0, parent); Q_ASSERT(parentItem->child(i)); qDebug() << ">>>" << i << child << child.data().toString(); } @@ -587,7 +587,7 @@ void TreeModel::debug_rowsInserted(const QModelIndex& parent, int start, int end QModelIndex child; for (int i = start; i <= end; i++) { - child = parent.child(i, 0); + child = parent.model()->index(i, 0, parent); Q_ASSERT(parentItem->child(i)); qDebug() << "<<<" << i << child << child.data().toString(); } diff --git a/src/qtui/nicklistwidget.cpp b/src/qtui/nicklistwidget.cpp index fed49114..6ee47528 100644 --- a/src/qtui/nicklistwidget.cpp +++ b/src/qtui/nicklistwidget.cpp @@ -177,7 +177,7 @@ void NickListWidget::rowsAboutToBeRemoved(const QModelIndex& parent, int start, else { // check if there are explicitly buffers removed for (int i = start; i <= end; i++) { - QVariant variant = parent.child(i, 0).data(NetworkModel::BufferIdRole); + QVariant variant = parent.model()->index(i, 0, parent).data(NetworkModel::BufferIdRole); if (!variant.isValid()) continue; diff --git a/src/uisupport/abstractbuffercontainer.cpp b/src/uisupport/abstractbuffercontainer.cpp index f986c0b2..ee34905c 100644 --- a/src/uisupport/abstractbuffercontainer.cpp +++ b/src/uisupport/abstractbuffercontainer.cpp @@ -47,7 +47,7 @@ void AbstractBufferContainer::rowsAboutToBeRemoved(const QModelIndex& parent, in else { // check if there are explicitly buffers removed for (int i = start; i <= end; i++) { - QVariant variant = parent.child(i, 0).data(NetworkModel::BufferIdRole); + QVariant variant = parent.model()->index(i, 0, parent).data(NetworkModel::BufferIdRole); if (!variant.isValid()) continue; diff --git a/src/uisupport/bufferview.cpp b/src/uisupport/bufferview.cpp index a17c1a0d..f603bf58 100644 --- a/src/uisupport/bufferview.cpp +++ b/src/uisupport/bufferview.cpp @@ -494,13 +494,13 @@ void BufferView::changeBuffer(Direction direction) if (currentIndex.row() == 0) newParent = lastNetIndex; if (model()->hasChildren(newParent)) - resultingIndex = newParent.child(model()->rowCount(newParent) - 1, 0); + resultingIndex = newParent.model()->index(model()->rowCount(newParent) - 1, 0, newParent); else resultingIndex = newParent; } else { if (model()->hasChildren(currentIndex)) - resultingIndex = currentIndex.child(0, 0); + resultingIndex = currentIndex.model()->index(0, 0, currentIndex); else resultingIndex = currentIndex.sibling(currentIndex.row() + 1, 0); } @@ -510,7 +510,7 @@ void BufferView::changeBuffer(Direction direction) if (direction == Forward) resultingIndex = model()->index(0, 0, QModelIndex()); else - resultingIndex = lastNetIndex.child(model()->rowCount(lastNetIndex) - 1, 0); + resultingIndex = lastNetIndex.model()->index(model()->rowCount(lastNetIndex) - 1, 0, lastNetIndex); } selectionModel()->setCurrentIndex(resultingIndex, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows); diff --git a/src/uisupport/nickviewfilter.cpp b/src/uisupport/nickviewfilter.cpp index 3bb42f8c..5058de7c 100644 --- a/src/uisupport/nickviewfilter.cpp +++ b/src/uisupport/nickviewfilter.cpp @@ -44,7 +44,7 @@ bool NickViewFilter::filterAcceptsRow(int source_row, const QModelIndex& source_ if (!source_parent.isValid()) return true; - QModelIndex source_child = source_parent.child(source_row, 0); + QModelIndex source_child = source_parent.model()->index(source_row, 0, source_parent); return (sourceModel()->data(source_child, NetworkModel::BufferIdRole).value() == _bufferId); }