+ connect(m_selectionChangedTimer, &QTimer::timeout, this, &DolphinView::emitSelectionChangedSignal);
+
+ m_model = new KFileItemModel(this);
+ m_view = new DolphinItemListView();
+ m_view->setEnabledSelectionToggles(DolphinItemListView::SelectionTogglesEnabled::FollowSetting);
+ m_view->setVisibleRoles({"text"});
+ applyModeToView();
+
+ KItemListController *controller = new KItemListController(m_model, m_view, this);
+ controller->setAutoActivationEnabled(GeneralSettings::autoExpandFolders());
+ 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.
+ m_view->setEnlargeSmallPreviews(GeneralSettings::enlargeSmallPreviews());
+
+ m_container = new KItemListContainer(controller, this);
+ m_container->installEventFilter(this);
+#ifndef QT_NO_ACCESSIBILITY
+ m_view->setAccessibleParentsObject(m_container);
+#endif
+ setFocusProxy(m_container);
+ connect(m_container->horizontalScrollBar(), &QScrollBar::valueChanged, this, [this] {
+ hideToolTip();
+ });
+ connect(m_container->verticalScrollBar(), &QScrollBar::valueChanged, this, [this] {
+ hideToolTip();
+ });
+
+ m_showLoadingPlaceholderTimer = new QTimer(this);
+ m_showLoadingPlaceholderTimer->setInterval(500);
+ m_showLoadingPlaceholderTimer->setSingleShot(true);
+ connect(m_showLoadingPlaceholderTimer, &QTimer::timeout, this, &DolphinView::showLoadingPlaceholder);
+
+ // Show some placeholder text for empty folders
+ // 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->setWordWrap(true);
+ m_placeholderLabel->setAlignment(Qt::AlignCenter);
+ // Match opacity of QML placeholder label component
+ auto *effect = new QGraphicsOpacityEffect(m_placeholderLabel);
+ effect->setOpacity(0.5);
+ m_placeholderLabel->setGraphicsEffect(effect);
+ // Set initial text and visibility
+ updatePlaceholderLabel();
+
+ auto *centeringLayout = new QVBoxLayout(m_container);
+ centeringLayout->addWidget(m_placeholderLabel);
+ centeringLayout->setAlignment(m_placeholderLabel, Qt::AlignCenter);
+
+ controller->setSelectionBehavior(KItemListController::MultiSelection);
+ connect(controller, &KItemListController::itemActivated, this, &DolphinView::slotItemActivated);
+ connect(controller, &KItemListController::itemsActivated, this, &DolphinView::slotItemsActivated);
+ connect(controller, &KItemListController::itemMiddleClicked, this, &DolphinView::slotItemMiddleClicked);
+ connect(controller, &KItemListController::itemContextMenuRequested, this, &DolphinView::slotItemContextMenuRequested);
+ connect(controller, &KItemListController::viewContextMenuRequested, this, &DolphinView::slotViewContextMenuRequested);
+ connect(controller, &KItemListController::headerContextMenuRequested, this, &DolphinView::slotHeaderContextMenuRequested);
+ connect(controller, &KItemListController::mouseButtonPressed, this, &DolphinView::slotMouseButtonPressed);
+ connect(controller, &KItemListController::itemHovered, this, &DolphinView::slotItemHovered);
+ connect(controller, &KItemListController::itemUnhovered, this, &DolphinView::slotItemUnhovered);
+ connect(controller, &KItemListController::itemDropEvent, this, &DolphinView::slotItemDropEvent);
+ connect(controller, &KItemListController::escapePressed, this, &DolphinView::stopLoading);
+ connect(controller, &KItemListController::modelChanged, this, &DolphinView::slotModelChanged);
+ connect(controller, &KItemListController::selectedItemTextPressed, this, &DolphinView::slotSelectedItemTextPressed);
+ connect(controller, &KItemListController::increaseZoom, this, &DolphinView::slotIncreaseZoom);
+ connect(controller, &KItemListController::decreaseZoom, this, &DolphinView::slotDecreaseZoom);
+ connect(controller, &KItemListController::swipeUp, this, &DolphinView::slotSwipeUp);
+ connect(controller, &KItemListController::selectionModeChangeRequested, this, &DolphinView::selectionModeChangeRequested);
+
+ connect(m_model, &KFileItemModel::directoryLoadingStarted, this, &DolphinView::slotDirectoryLoadingStarted);
+ connect(m_model, &KFileItemModel::directoryLoadingCompleted, this, &DolphinView::slotDirectoryLoadingCompleted);
+ connect(m_model, &KFileItemModel::directoryLoadingCanceled, this, &DolphinView::slotDirectoryLoadingCanceled);
+ connect(m_model, &KFileItemModel::directoryLoadingProgress, this, &DolphinView::directoryLoadingProgress);
+ connect(m_model, &KFileItemModel::directorySortingProgress, this, &DolphinView::directorySortingProgress);
+ connect(m_model, &KFileItemModel::itemsChanged, this, &DolphinView::slotItemsChanged);
+ connect(m_model, &KFileItemModel::itemsRemoved, this, &DolphinView::itemCountChanged);
+ connect(m_model, &KFileItemModel::itemsInserted, this, &DolphinView::itemCountChanged);
+ connect(m_model, &KFileItemModel::infoMessage, this, &DolphinView::infoMessage);
+ connect(m_model, &KFileItemModel::errorMessage, this, &DolphinView::errorMessage);
+ 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);
+
+ connect(this, &DolphinView::itemCountChanged, this, &DolphinView::updatePlaceholderLabel);
+
+ m_view->installEventFilter(this);
+ connect(m_view, &DolphinItemListView::sortOrderChanged, this, &DolphinView::slotSortOrderChangedByHeader);
+ connect(m_view, &DolphinItemListView::sortRoleChanged, this, &DolphinView::slotSortRoleChangedByHeader);
+ connect(m_view, &DolphinItemListView::visibleRolesChanged, this, &DolphinView::slotVisibleRolesChangedByHeader);
+ connect(m_view, &DolphinItemListView::roleEditingCanceled, this, &DolphinView::slotRoleEditingCanceled);
+
+ connect(m_view, &DolphinItemListView::columnHovered, this, [this](int columnIndex) {
+ m_hoveredColumnHeaderIndex = columnIndex;
+ });
+ connect(m_view, &DolphinItemListView::columnUnHovered, this, [this](int /* columnIndex */) {
+ m_hoveredColumnHeaderIndex = std::nullopt;
+ });
+ connect(m_view->header(), &KItemListHeader::columnWidthChangeFinished, this, &DolphinView::slotHeaderColumnWidthChangeFinished);
+ connect(m_view->header(), &KItemListHeader::sidePaddingChanged, this, &DolphinView::slotSidePaddingWidthChanged);
+
+ KItemListSelectionManager *selectionManager = controller->selectionManager();
+ connect(selectionManager, &KItemListSelectionManager::selectionChanged, this, &DolphinView::slotSelectionChanged);
+
+#if HAVE_BALOO
+ m_toolTipManager = new ToolTipManager(this);
+ connect(m_toolTipManager, &ToolTipManager::urlActivated, this, &DolphinView::urlActivated);
+#endif
+
+ m_versionControlObserver = new VersionControlObserver(this);
+ m_versionControlObserver->setView(this);
+ m_versionControlObserver->setModel(m_model);
+ connect(m_versionControlObserver, &VersionControlObserver::infoMessage, this, &DolphinView::infoMessage);
+ 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);
+ m_twoClicksRenamingTimer->setSingleShot(true);
+ connect(m_twoClicksRenamingTimer, &QTimer::timeout, this, &DolphinView::slotTwoClicksRenamingTimerTimeout);