Replace deprecated QModelIndex::child with QAbstractItemModel::index
authorJanne Koschinski <janne@kuschku.de>
Mon, 5 Aug 2019 10:37:13 +0000 (12:37 +0200)
committerManuel Nickschas <sputnick@quassel-irc.org>
Wed, 28 Aug 2019 19:45:23 +0000 (21:45 +0200)
src/client/buffermodel.cpp
src/client/networkmodel.cpp
src/client/treemodel.cpp
src/qtui/nicklistwidget.cpp
src/uisupport/abstractbuffercontainer.cpp
src/uisupport/bufferview.cpp
src/uisupport/nickviewfilter.cpp

index d4a94ea..0836b06 100644 (file)
@@ -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<BufferId>());
     }
 }
index 4713932..837601f 100644 (file)
@@ -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<BufferId>());
+        _bufferItemCache.remove(index(row, 0, parent).data(BufferIdRole).value<BufferId>());
     }
 }
 
@@ -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<BufferId>()] = static_cast<BufferItem*>(child.internalPointer());
     }
 }
index d1cc465..2819353 100644 (file)
@@ -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();
     }
index fed4911..6ee4752 100644 (file)
@@ -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;
 
index f986c0b..ee34905 100644 (file)
@@ -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;
 
index a17c1a0..f603bf5 100644 (file)
@@ -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);
index 3bb42f8..5058de7 100644 (file)
@@ -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>() == _bufferId);
 }