Commit 4a3fbf91 authored by Eike Hein's avatar Eike Hein

Fix new file creation leading to dupe items on a fresh view

This was a regression caused by the code attempting to insert new items
at drop position, if available. `setSortMode` was being called in a slot
connected to the dir model's rowsInserted, but the Positioner has to be
initialized earlier as a proxy needs to handle
`sourceRowsAboutToBeInserted` as well.

Thanks to an investigation and patch by Oleg Solovyov in D17689 for
helping to get to the bottom of this.

This is aimed at 5.12+.


Reviewers: #plasma, McPain, davidedmundson

Reviewed By: #plasma, davidedmundson

Subscribers: ngraham, davidedmundson, fvogt, plasma-devel

Tags: #plasma

Differential Revision:
parent 4d8057ae
......@@ -149,11 +149,15 @@ FolderModel::FolderModel(QObject *parent) : QSortFilterProxyModel(parent),
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.
connect(this, &QAbstractItemModel::rowsAboutToBeInserted,
this, [this]() {
if (!m_dropTargetPositions.isEmpty()) {
// Position dropped items at the desired target position.
connect(this, &QAbstractItemModel::rowsInserted,
this, [this](const QModelIndex &parent, int first, int last) {
for (int i = first; i <= last; ++i) {
......@@ -163,11 +167,11 @@ FolderModel::FolderModel(QObject *parent) : QSortFilterProxyModel(parent),
if (it != m_dropTargetPositions.end()) {
const auto pos = it.value();
emit move(pos.x(), pos.y(), {url});
* 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...
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment