KItemListController *controller = new KItemListController(m_model, m_view, this);
const int delay = GeneralSettings::autoExpandFolders() ? 750 : -1;
controller->setAutoActivationDelay(delay);
+ connect(controller, &KItemListController::doubleClickViewBackground, this, &DolphinView::doubleClickViewBackground);
// The EnlargeSmallPreviews setting can only be changed after the model
// has been set in the view by KItemListController.
connect(m_model, &KFileItemModel::directoryRedirection, this, &DolphinView::slotDirectoryRedirection);
connect(m_model, &KFileItemModel::urlIsFileError, this, &DolphinView::urlIsFileError);
connect(m_model, &KFileItemModel::fileItemsChanged, this, &DolphinView::fileItemsChanged);
- // #473377: Use a QueuedConnection to avoid modifying KCoreDirLister before KCoreDirListerCache::deleteDir() returns.
- connect(m_model, &KFileItemModel::currentDirectoryRemoved, this, &DolphinView::currentDirectoryRemoved, Qt::QueuedConnection);
+ connect(m_model, &KFileItemModel::currentDirectoryRemoved, this, &DolphinView::currentDirectoryRemoved);
connect(this, &DolphinView::itemCountChanged, this, &DolphinView::updatePlaceholderLabel);
m_versionControlObserver->setView(this);
m_versionControlObserver->setModel(m_model);
connect(m_versionControlObserver, &VersionControlObserver::infoMessage, this, &DolphinView::infoMessage);
- connect(m_versionControlObserver, &VersionControlObserver::errorMessage, this, &DolphinView::errorMessage);
+ connect(m_versionControlObserver, &VersionControlObserver::errorMessage, this, [this](const QString &message) {
+ Q_EMIT errorMessage(message, KIO::ERR_UNKNOWN);
+ });
connect(m_versionControlObserver, &VersionControlObserver::operationCompletedMessage, this, &DolphinView::operationCompletedMessage);
m_twoClicksRenamingTimer = new QTimer(this);
ViewProperties props(viewPropertiesUrl());
props.setGroupedSorting(grouped);
- props.save();
- m_container->controller()->model()->setGroupedSorting(grouped);
+ m_model->setGroupedSorting(grouped);
Q_EMIT groupedSortingChanged(grouped);
}
} else {
KIO::RenameFileDialog *dialog = new KIO::RenameFileDialog(items, this);
- connect(dialog, &KIO::RenameFileDialog::renamingFinished, this, &DolphinView::slotRenameDialogRenamingFinished);
+ connect(dialog, &KIO::RenameFileDialog::renamingFinished, this, [this, items](const QList<QUrl> &urls) {
+ // The model may have already been updated, so it's possible that we don't find the old items.
+ for (int i = 0; i < items.count(); ++i) {
+ const int index = m_model->index(items[i]);
+ if (index >= 0) {
+ QHash<QByteArray, QVariant> data;
+ data.insert("text", urls[i].fileName());
+ m_model->setData(index, data);
+ }
+ }
+
+ forceUrlsSelection(urls.first(), urls);
+ updateSelectionState();
+ });
+ connect(dialog, &KIO::RenameFileDialog::error, this, [this](KJob *job) {
+ KMessageBox::error(this, job->errorString());
+ });
dialog->open();
}
void DolphinView::slotItemMiddleClicked(int index)
{
const KFileItem &item = m_model->fileItem(index);
- const QUrl &url = openItemAsFolderUrl(item);
+ const QUrl &url = openItemAsFolderUrl(item, GeneralSettings::browseThroughArchives());
const auto modifiers = QGuiApplication::keyboardModifiers();
if (!url.isEmpty()) {
// keep in sync with KUrlNavigator::slotNavigatorButtonClicked
void DolphinView::slotJobResult(KJob *job)
{
if (job->error() && job->error() != KIO::ERR_USER_CANCELED) {
- Q_EMIT errorMessage(job->errorString());
+ Q_EMIT errorMessage(job->errorString(), job->error());
}
if (!m_selectJobCreatedItems) {
m_selectedUrls.clear();
if (!m_selectedUrls.isEmpty()) {
KItemListSelectionManager *selectionManager = m_container->controller()->selectionManager();
+ const bool shouldScrollToCurrentItem = m_clearSelectionBeforeSelectingNewItems;
// if there is a selection already, leave it that way
// unless some drop/paste job are in the process of creating items
if (!selectionManager->hasSelection() || m_selectJobCreatedItems) {
if (!selectedItems.isEmpty()) {
selectionManager->beginAnchoredSelection(selectionManager->currentItem());
selectionManager->setSelectedItems(selectedItems);
+ selectionManager->endAnchoredSelection();
+ if (shouldScrollToCurrentItem) {
+ m_view->scrollToItem(selectedItems.first());
+ }
}
}
}
selectNextItem(); // Fixes BUG: 419914 via selecting next item
Q_EMIT operationCompletedMessage(i18nc("@info:status", "Trash operation completed."));
} else if (job->error() != KIO::ERR_USER_CANCELED) {
- Q_EMIT errorMessage(job->errorString());
+ Q_EMIT errorMessage(job->errorString(), job->error());
}
}
selectNextItem(); // Fixes BUG: 419914 via selecting next item
Q_EMIT operationCompletedMessage(i18nc("@info:status", "Delete operation completed."));
} else if (job->error() != KIO::ERR_USER_CANCELED) {
- Q_EMIT errorMessage(job->errorString());
+ Q_EMIT errorMessage(job->errorString(), job->error());
}
}
if (!newNameExistsAlready) {
forceUrlsSelection(newUrl, {newUrl});
+ updateSelectionState();
// Only connect the result signal if there is no item with the new name
// in the model yet, see bug 328262.
if (!url.isValid()) {
const QString location(url.toDisplayString(QUrl::PreferLocalFile));
if (location.isEmpty()) {
- Q_EMIT errorMessage(i18nc("@info:status", "The location is empty."));
+ Q_EMIT errorMessage(i18nc("@info:status", "The location is empty."), KIO::ERR_UNKNOWN);
} else {
- Q_EMIT errorMessage(i18nc("@info:status", "The location '%1' is invalid.", location));
+ Q_EMIT errorMessage(i18nc("@info:status", "The location '%1' is invalid.", location), KIO::ERR_UNKNOWN);
}
return;
}
m_clearSelectionBeforeSelectingNewItems = true;
m_markFirstNewlySelectedItemAsCurrent = true;
m_selectJobCreatedItems = true;
- // TODO KF6 use KIO::PasteJob::copyJobStarted to hook to earlier events copying/moving
connect(job, &KIO::PasteJob::itemCreated, this, &DolphinView::slotItemCreated);
+ connect(job, &KIO::PasteJob::copyJobStarted, this, [this](const KIO::CopyJob *copyJob) {
+ connect(copyJob, &KIO::CopyJob::copying, this, &DolphinView::slotItemCreatedFromJob);
+ connect(copyJob, &KIO::CopyJob::moving, this, &DolphinView::slotItemCreatedFromJob);
+ connect(copyJob, &KIO::CopyJob::linking, this, [this](KIO::Job *job, const QString &src, const QUrl &dest) {
+ Q_UNUSED(job)
+ Q_UNUSED(src)
+ slotItemCreated(dest);
+ });
+ });
connect(job, &KIO::PasteJob::result, this, &DolphinView::slotJobResult);
}
return url;
}
-void DolphinView::slotRenameDialogRenamingFinished(const QList<QUrl> &urls)
-{
- forceUrlsSelection(urls.first(), urls);
-}
-
void DolphinView::forceUrlsSelection(const QUrl ¤t, const QList<QUrl> &selected)
{
clearSelection();