#include "dolphinitemlistview.h"
#include "dolphinnewfilemenuobserver.h"
#include "draganddrophelper.h"
+#ifndef QT_NO_ACCESSIBILITY
+#include "kitemviews/accessibility/kitemlistviewaccessible.h"
+#endif
#include "kitemviews/kfileitemlistview.h"
#include "kitemviews/kfileitemmodel.h"
#include "kitemviews/kitemlistcontainer.h"
#include <kwidgetsaddons_version.h>
#include <QAbstractItemView>
+#ifndef QT_NO_ACCESSIBILITY
+#include <QAccessible>
+#endif
#include <QActionGroup>
#include <QApplication>
#include <QClipboard>
m_view->setAccessibleParentsObject(m_container);
#endif
setFocusProxy(m_container);
- connect(m_container->horizontalScrollBar(), &QScrollBar::valueChanged, this, [=] {
+ connect(m_container->horizontalScrollBar(), &QScrollBar::valueChanged, this, [this] {
hideToolTip();
});
- connect(m_container->verticalScrollBar(), &QScrollBar::valueChanged, this, [=] {
+ connect(m_container->verticalScrollBar(), &QScrollBar::valueChanged, this, [this] {
hideToolTip();
});
m_view->setEnabledSelectionToggles(DolphinItemListView::SelectionTogglesEnabled::FollowSetting);
}
m_container->controller()->setSelectionModeEnabled(enabled);
+#ifndef QT_NO_ACCESSIBILITY
+ if (QAccessible::isActive()) {
+ auto accessibleViewInterface = static_cast<KItemListViewAccessible *>(QAccessible::queryAccessibleInterface(m_view));
+ accessibleViewInterface->announceSelectionModeEnabled(enabled);
+ }
+#endif
}
bool DolphinView::selectionMode() const
KIO::CopyJob *job = KIO::copy(selection.urlList(), destinationUrl, KIO::DefaultFlags);
KJobWidgets::setWindow(job, this);
- connect(job, &KIO::DropJob::result, this, &DolphinView::slotJobResult);
+ connect(job, &KIO::CopyJob::result, this, &DolphinView::slotJobResult);
connect(job, &KIO::CopyJob::copying, this, &DolphinView::slotItemCreatedFromJob);
connect(job, &KIO::CopyJob::copyingDone, this, &DolphinView::slotItemCreatedFromJob);
KIO::FileUndoManager::self()->recordCopyJob(job);
KIO::CopyJob *job = KIO::move(selection.urlList(), destinationUrl, KIO::DefaultFlags);
KJobWidgets::setWindow(job, this);
- connect(job, &KIO::DropJob::result, this, &DolphinView::slotJobResult);
+ connect(job, &KIO::CopyJob::result, this, &DolphinView::slotJobResult);
connect(job, &KIO::CopyJob::moving, this, &DolphinView::slotItemCreatedFromJob);
connect(job, &KIO::CopyJob::copyingDone, this, &DolphinView::slotItemCreatedFromJob);
KIO::FileUndoManager::self()->recordCopyJob(job);
if (m_selectionChangedTimer->isActive()) {
emitSelectionChangedSignal();
}
+ if (m_twoClicksRenamingTimer->isActive()) {
+ abortTwoClicksRenaming();
+ }
const KFileItem item = m_model->fileItem(index);
Q_EMIT requestContextMenu(pos.toPoint(), item, selectedItems(), url());
QAction *toggleSidePaddingAction = menu->addAction(i18nc("@action:inmenu", "Side Padding"));
toggleSidePaddingAction->setCheckable(true);
- toggleSidePaddingAction->setChecked(view->header()->sidePadding() > 0);
+ toggleSidePaddingAction->setChecked(layoutDirection() == Qt::LeftToRight ? view->header()->leftPadding() > 0 : view->header()->rightPadding() > 0);
QAction *autoAdjustWidthsAction = menu->addAction(i18nc("@action:inmenu", "Automatic Column Widths"));
autoAdjustWidthsAction->setCheckable(true);
props.setHeaderColumnWidths(columnWidths);
header->setAutomaticColumnResizing(false);
} else if (action == toggleSidePaddingAction) {
- header->setSidePadding(toggleSidePaddingAction->isChecked() ? 20 : 0);
+ if (toggleSidePaddingAction->isChecked()) {
+ header->setSidePadding(20, 20);
+ } else {
+ header->setSidePadding(0, 0);
+ }
} else {
// Show or hide the selected role
const QByteArray selectedRole = action->data().toByteArray();
props.setHeaderColumnWidths(columnWidths);
}
-void DolphinView::slotSidePaddingWidthChanged(qreal width)
+void DolphinView::slotSidePaddingWidthChanged(qreal leftPaddingWidth, qreal rightPaddingWidth)
{
ViewProperties props(viewPropertiesUrl());
- DetailsModeSettings::setSidePadding(int(width));
+ DetailsModeSettings::setLeftPadding(int(leftPaddingWidth));
+ DetailsModeSettings::setRightPadding(int(rightPaddingWidth));
m_view->writeSettings();
}
if (!selectedItems.isEmpty()) {
selectionManager->beginAnchoredSelection(selectionManager->currentItem());
selectionManager->setSelectedItems(selectedItems);
- selectionManager->endAnchoredSelection();
if (shouldScrollToCurrentItem) {
m_view->scrollToItem(selectedItems.first());
}
Q_ASSERT_X(false, "DolphinView", "Selecting the next item failed.");
return;
}
- const auto lastSelectedIndex = m_model->index(selectedItems().last());
+ const auto lastSelectedIndex = m_model->index(selectedItems().constLast());
if (lastSelectedIndex < 0) {
Q_ASSERT_X(false, "DolphinView", "Selecting the next item failed.");
return;
}
if (nextItem >= 0) {
selectionManager->setSelected(nextItem, 1);
+ selectionManager->beginAnchoredSelection(nextItem);
}
m_selectNextItem = false;
}
void DolphinView::slotRenamingResult(KJob *job)
{
- if (job->error()) {
+ // Change model data after renaming has succeeded. On failure we do nothing.
+ // If there is already an item with the newUrl, the copyjob will open a dialog for it, and
+ // KFileItemModel will update the data when the dir lister signals that the file name has changed.
+ if (!job->error()) {
KIO::CopyJob *copyJob = qobject_cast<KIO::CopyJob *>(job);
Q_ASSERT(copyJob);
const QUrl newUrl = copyJob->destUrl();
+ const QUrl oldUrl = copyJob->srcUrls().at(0);
const int index = m_model->index(newUrl);
- if (index >= 0) {
+ if (m_model->index(oldUrl) == index) {
QHash<QByteArray, QVariant> data;
- const QUrl oldUrl = copyJob->srcUrls().at(0);
- data.insert("text", oldUrl.fileName());
+ data.insert("text", newUrl.fileName());
m_model->setData(index, data);
}
}
}
#endif
- const bool newNameExistsAlready = (m_model->index(newUrl) >= 0);
- if (!newNameExistsAlready && m_model->index(oldUrl) == index) {
- // Only change the data in the model if no item with the new name
- // is in the model yet. If there is an item with the new name
- // already, calling KIO::CopyJob will open a dialog
- // asking for a new name, and KFileItemModel will update the
- // data when the dir lister signals that the file name has changed.
- QHash<QByteArray, QVariant> data;
- data.insert(role, retVal.newName);
- m_model->setData(index, data);
- }
-
KIO::Job *job = KIO::moveAs(oldUrl, newUrl);
KJobWidgets::setWindow(job, this);
KIO::FileUndoManager::self()->recordJob(KIO::FileUndoManager::Rename, {oldUrl}, newUrl, job);
job->uiDelegate()->setAutoErrorHandlingEnabled(true);
- if (!newNameExistsAlready) {
+ if (m_model->index(newUrl) < 0) {
forceUrlsSelection(newUrl, {newUrl});
updateSelectionState();
} else {
header->setAutomaticColumnResizing(true);
}
- header->setSidePadding(DetailsModeSettings::sidePadding());
+ header->setSidePadding(DetailsModeSettings::leftPadding(), DetailsModeSettings::rightPadding());
}
m_view->endTransaction();
return m_isFolderWritable;
}
+int DolphinView::horizontalScrollBarHeight() const
+{
+ if (m_container && m_container->horizontalScrollBar() && m_container->horizontalScrollBar()->isVisible()) {
+ return m_container->horizontalScrollBar()->height();
+ }
+ return 0;
+}
+
+void DolphinView::setStatusBarOffset(int offset)
+{
+ KItemListView *view = m_container->controller()->view();
+ if (view) {
+ view->setStatusBarOffset(offset);
+ }
+}
+
QUrl DolphinView::viewPropertiesUrl() const
{
if (m_viewPropertiesContext.isEmpty()) {
{
m_placeholderLabel->setText(i18n("Loading…"));
m_placeholderLabel->setVisible(true);
+#ifndef QT_NO_ACCESSIBILITY
+ if (QAccessible::isActive()) {
+ static_cast<KItemListViewAccessible *>(QAccessible::queryAccessibleInterface(m_view))->announceNewlyLoadedLocation(m_placeholderLabel->text());
+ }
+#endif
}
void DolphinView::updatePlaceholderLabel()
{
m_showLoadingPlaceholderTimer->stop();
if (itemsCount() > 0) {
+#ifndef QT_NO_ACCESSIBILITY
+ if (QAccessible::isActive()) {
+ static_cast<KItemListViewAccessible *>(QAccessible::queryAccessibleInterface(m_view))->announceNewlyLoadedLocation(QString());
+ }
+#endif
m_placeholderLabel->setVisible(false);
return;
}
}
m_placeholderLabel->setVisible(true);
+#ifndef QT_NO_ACCESSIBILITY
+ if (QAccessible::isActive()) {
+ static_cast<KItemListViewAccessible *>(QAccessible::queryAccessibleInterface(m_view))->announceNewlyLoadedLocation(m_placeholderLabel->text());
+ }
+#endif
}
bool DolphinView::tryShowNameToolTip(QHelpEvent *event)
const KFileItem item = m_model->fileItem(index.value());
const QString text = item.text();
const QPoint pos = mapToGlobal(event->pos());
- QToolTip::showText(pos, text);
+ QToolTip::showText(pos, text, this);
return true;
}
}