Iterate KFilePlacesModel instead of using closestItem to remove SFTP entries

Fixes bug where we could miss entries due to `closestItem()` skipping hidden items. It is also more performant.

BUG: 461872
This commit is contained in:
Albert Vaca Cintora 2023-09-22 19:51:25 +00:00
parent 643a1c9dc2
commit d721f72a9b

View file

@ -49,10 +49,13 @@ void SftpPlugin::addToDolphin()
void SftpPlugin::removeFromDolphin()
{
QUrl kioUrl(QStringLiteral("kdeconnect://") + deviceId + QStringLiteral("/"));
QModelIndex index = m_placesModel.closestItem(kioUrl);
while (index.row() != -1) {
m_placesModel.removePlace(index);
index = m_placesModel.closestItem(kioUrl);
for (int i = 0; i < m_placesModel.rowCount(); ++i) {
QModelIndex index = m_placesModel.index(i, 0);
QUrl url = m_placesModel.url(index);
if (url == kioUrl) {
m_placesModel.removePlace(index);
--i;
}
}
}