diff --git a/containments/desktop/plugins/folder/foldermodel.cpp b/containments/desktop/plugins/folder/foldermodel.cpp --- a/containments/desktop/plugins/folder/foldermodel.cpp +++ b/containments/desktop/plugins/folder/foldermodel.cpp @@ -150,9 +150,21 @@ m_dirModel->setDropsAllowed(KDirModel::DropOnDirectory | KDirModel::DropOnLocalExecutable); /* - * position dropped items at the desired target position - * delay this via queued connection, such that the row is available and can be mapped - * when we emit the move request + * If we have dropped items queued for moving, go unsorted now. + * Delay this via queued connection, such that the row is available and can be mapped + * when we emit the move request. + */ + connect(this, &QAbstractItemModel::rowsAboutToBeInserted, + this, [this]() { + if (!m_dropTargetPositions.isEmpty()) { + setSortMode(-1); + } + }, Qt::QueuedConnection); + + /* + * Position dropped items at the desired target position. + * Delay this via queued connection, such that the row is available and can be mapped + * when we emit the move request. */ connect(this, &QAbstractItemModel::rowsInserted, this, [this](const QModelIndex &parent, int first, int last) { @@ -163,11 +175,10 @@ if (it != m_dropTargetPositions.end()) { const auto pos = it.value(); m_dropTargetPositions.erase(it); - setSortMode(-1); emit move(pos.x(), pos.y(), {url}); } } - }); + }, Qt::QueuedConnection); /* * Dropped files may not actually show up as new files, e.g. when we overwrite * an existing file. Or files that fail to be listed by the dirLister, or...