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.
// This is made using a heavily-modified QLabel rather than a KTitleWidget
// because KTitleWidget can't be told to turn off mouse-selectable text
m_placeholderLabel = new QLabel(this);
+ // Don't consume mouse events
+ m_placeholderLabel->setAttribute(Qt::WA_TransparentForMouseEvents);
+
QFont placeholderLabelFont;
// To match the size of a level 2 Heading/KTitleWidget
placeholderLabelFont.setPointSize(qRound(placeholderLabelFont.pointSize() * 1.3));
m_placeholderLabel->setFont(placeholderLabelFont);
- m_placeholderLabel->setTextInteractionFlags(Qt::NoTextInteraction);
m_placeholderLabel->setWordWrap(true);
m_placeholderLabel->setAlignment(Qt::AlignCenter);
// Match opacity of QML placeholder label component
auto *centeringLayout = new QVBoxLayout(m_container);
centeringLayout->addWidget(m_placeholderLabel);
centeringLayout->setAlignment(m_placeholderLabel, Qt::AlignCenter);
- m_placeholderLabel->setContextMenuPolicy(Qt::CustomContextMenu);
- connect(m_placeholderLabel, &QWidget::customContextMenuRequested, this, [this](const QPoint &pos) {
- slotViewContextMenuRequested(m_placeholderLabel->mapToGlobal(pos));
- });
controller->setSelectionBehavior(KItemListController::MultiSelection);
connect(controller, &KItemListController::itemActivated, this, &DolphinView::slotItemActivated);
connect(m_model, &KFileItemModel::directoryRedirection, this, &DolphinView::slotDirectoryRedirection);
connect(m_model, &KFileItemModel::urlIsFileError, this, &DolphinView::urlIsFileError);
connect(m_model, &KFileItemModel::fileItemsChanged, this, &DolphinView::fileItemsChanged);
- connect(m_model, &KFileItemModel::currentDirectoryRemoved, this, &DolphinView::currentDirectoryRemoved);
+ // #473377: Use a QueuedConnection to avoid modifying KCoreDirLister before KCoreDirListerCache::deleteDir() returns.
+ connect(m_model, &KFileItemModel::currentDirectoryRemoved, this, &DolphinView::currentDirectoryRemoved, Qt::QueuedConnection);
connect(this, &DolphinView::itemCountChanged, this, &DolphinView::updatePlaceholderLabel);
if (items.count() == 1 && GeneralSettings::renameInline()) {
const int index = m_model->index(items.first());
- QMetaObject::Connection *const connection = new QMetaObject::Connection;
- *connection = connect(m_view, &KItemListView::scrollingStopped, this, [=]() {
- QObject::disconnect(*connection);
- delete connection;
-
- m_view->editRole(index, "text");
+ connect(
+ m_view,
+ &KItemListView::scrollingStopped,
+ this,
+ [this, index]() {
+ m_view->editRole(index, "text");
- hideToolTip();
+ hideToolTip();
- connect(m_view, &DolphinItemListView::roleEditingFinished, this, &DolphinView::slotRoleEditingFinished);
- });
+ connect(m_view, &DolphinItemListView::roleEditingFinished, this, &DolphinView::slotRoleEditingFinished);
+ },
+ Qt::SingleShotConnection);
m_view->scrollToItem(index);
} else {
const QMimeDatabase db;
+ m_clearSelectionBeforeSelectingNewItems = true;
+ m_markFirstNewlySelectedItemAsCurrent = true;
+ m_selectJobCreatedItems = true;
+
// Duplicate all selected items and append "copy" to the end of the file name
// but before the filename extension, if present
- QList<QUrl> newSelection;
for (const auto &item : itemList) {
const QUrl originalURL = item.url();
const QString originalDirectoryPath = originalURL.adjusted(QUrl::RemoveFilename).path();
}
KIO::CopyJob *job = KIO::copyAs(originalURL, duplicateURL);
+ job->setAutoRename(true);
KJobWidgets::setWindow(job, this);
- if (job) {
- newSelection << duplicateURL;
- KIO::FileUndoManager::self()->recordCopyJob(job);
- }
+ connect(job, &KIO::CopyJob::result, this, &DolphinView::slotJobResult);
+ connect(job, &KIO::CopyJob::copyingDone, this, &DolphinView::slotItemCreatedFromJob);
+ connect(job, &KIO::CopyJob::copyingLinkDone, this, &DolphinView::slotItemLinkCreatedFromJob);
+ KIO::FileUndoManager::self()->recordCopyJob(job);
}
-
- forceUrlsSelection(newSelection.first(), newSelection);
}
void DolphinView::stopLoading()
const KFileItem &item = m_model->fileItem(index);
const QUrl &url = openItemAsFolderUrl(item);
const auto modifiers = QGuiApplication::keyboardModifiers();
- const QString &archiveProtocol = KProtocolManager::protocolForArchiveMimetype(item.mimetype());
if (!url.isEmpty()) {
// keep in sync with KUrlNavigator::slotNavigatorButtonClicked
if (modifiers & Qt::ShiftModifier) {
} else {
Q_EMIT tabRequested(url);
}
- } else if (!archiveProtocol.isEmpty() && isTabsForFilesEnabled()) {
+ } else if (isTabsForFilesEnabled()) {
// keep in sync with KUrlNavigator::slotNavigatorButtonClicked
if (modifiers & Qt::ShiftModifier) {
Q_EMIT activeTabRequested(item.url());
slotItemCreated(to);
}
+void DolphinView::slotItemLinkCreatedFromJob(KIO::Job *, const QUrl &, const QString &, const QUrl &to)
+{
+ slotItemCreated(to);
+}
+
void DolphinView::slotItemCreated(const QUrl &url)
{
if (m_markFirstNewlySelectedItemAsCurrent) {
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());
+ }
}
}
}
Q_UNUSED(previous)
Q_ASSERT(m_model->sortRole() == current);
- setSortRole(current);
+ ViewProperties props(viewPropertiesUrl());
+ props.setSortRole(current);
+
+ Q_EMIT sortRoleChanged(current);
}
void DolphinView::slotVisibleRolesChangedByHeader(const QList<QByteArray> ¤t, const QList<QByteArray> &previous)
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);
}