Use `value_or(-1)` for those functions that don't use `std::optional`.
m_view(nullptr),
m_selectionManager(new KItemListSelectionManager(this)),
m_keyboardManager(new KItemListKeyboardSearchManager(this)),
m_view(nullptr),
m_selectionManager(new KItemListSelectionManager(this)),
m_keyboardManager(new KItemListKeyboardSearchManager(this)),
+ m_pressedIndex(std::nullopt),
m_pressedMousePos(),
m_autoActivationTimer(nullptr),
m_swipeGesture(Qt::CustomGesture),
m_pressedMousePos(),
m_autoActivationTimer(nullptr),
m_swipeGesture(Qt::CustomGesture),
- if (m_pressedIndex >= 0) {
+ if (m_pressedIndex.has_value()) {
// Check whether a dragging should be started
if (event->buttons() & Qt::LeftButton) {
const QPointF pos = transform.map(event->pos());
if ((pos - m_pressedMousePos).manhattanLength() >= QApplication::startDragDistance()) {
// Check whether a dragging should be started
if (event->buttons() & Qt::LeftButton) {
const QPointF pos = transform.map(event->pos());
if ((pos - m_pressedMousePos).manhattanLength() >= QApplication::startDragDistance()) {
- if (!m_selectionManager->isSelected(m_pressedIndex)) {
+ if (!m_selectionManager->isSelected(m_pressedIndex.value())) {
// Always assure that the dragged item gets selected. Usually this is already
// done on the mouse-press event, but when using the selection-toggle on a
// selected item the dragged item is not selected yet.
// Always assure that the dragged item gets selected. Usually this is already
// done on the mouse-press event, but when using the selection-toggle on a
// selected item the dragged item is not selected yet.
- m_selectionManager->setSelected(m_pressedIndex, 1, KItemListSelectionManager::Toggle);
+ m_selectionManager->setSelected(m_pressedIndex.value(), 1, KItemListSelectionManager::Toggle);
} else {
// A selected item has been clicked to drag all selected items
// -> the selection should not be cleared when the mouse button is released.
} else {
// A selected item has been clicked to drag all selected items
// -> the selection should not be cleared when the mouse button is released.
QPointF endPos = transform.map(event->pos());
// Update the current item.
QPointF endPos = transform.map(event->pos());
// Update the current item.
- const int newCurrent = m_view->itemAt(endPos);
- if (newCurrent >= 0) {
+ const std::optional<int> newCurrent = m_view->itemAt(endPos);
+ if (newCurrent.has_value()) {
// It's expected that the new current index is also the new anchor (bug 163451).
m_selectionManager->endAnchoredSelection();
// It's expected that the new current index is also the new anchor (bug 163451).
m_selectionManager->endAnchoredSelection();
- m_selectionManager->setCurrentItem(newCurrent);
- m_selectionManager->beginAnchoredSelection(newCurrent);
+ m_selectionManager->setCurrentItem(newCurrent.value());
+ m_selectionManager->beginAnchoredSelection(newCurrent.value());
}
if (m_view->scrollOrientation() == Qt::Vertical) {
}
if (m_view->scrollOrientation() == Qt::Vertical) {
- Q_EMIT mouseButtonReleased(m_pressedIndex, event->buttons());
+ Q_EMIT mouseButtonReleased(m_pressedIndex.value_or(-1), event->buttons());
return onRelease(transform.map(event->pos()), event->modifiers(), event->button(), false);
}
return onRelease(transform.map(event->pos()), event->modifiers(), event->button(), false);
}
bool KItemListController::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event, const QTransform& transform)
{
const QPointF pos = transform.map(event->pos());
bool KItemListController::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event, const QTransform& transform)
{
const QPointF pos = transform.map(event->pos());
- const int index = m_view->itemAt(pos);
+ const std::optional<int> index = m_view->itemAt(pos);
// Expand item if desired - See Bug 295573
if (m_mouseDoubleClickAction != ActivateItemOnly) {
// Expand item if desired - See Bug 295573
if (m_mouseDoubleClickAction != ActivateItemOnly) {
- if (m_view && m_model && m_view->supportsItemExpanding() && m_model->isExpandable(index)) {
- const bool expanded = m_model->isExpanded(index);
- m_model->setExpanded(index, !expanded);
+ if (m_view && m_model && m_view->supportsItemExpanding() && m_model->isExpandable(index.value_or(-1))) {
+ const bool expanded = m_model->isExpanded(index.value());
+ m_model->setExpanded(index.value(), !expanded);
}
}
if (event->button() & Qt::RightButton) {
m_selectionManager->clearSelection();
}
}
if (event->button() & Qt::RightButton) {
m_selectionManager->clearSelection();
- if (index >= 0) {
- m_selectionManager->setSelected(index);
- Q_EMIT itemContextMenuRequested(index, event->screenPos());
+ if (index.has_value()) {
+ m_selectionManager->setSelected(index.value());
+ Q_EMIT itemContextMenuRequested(index.value(), event->screenPos());
} else {
const QRectF headerBounds = m_view->headerBoundaries();
if (headerBounds.contains(event->pos())) {
} else {
const QRectF headerBounds = m_view->headerBoundaries();
if (headerBounds.contains(event->pos())) {
bool emitItemActivated = !(m_view->style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick) || m_singleClickActivationEnforced) &&
(event->button() & Qt::LeftButton) &&
bool emitItemActivated = !(m_view->style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick) || m_singleClickActivationEnforced) &&
(event->button() & Qt::LeftButton) &&
- index >= 0 && index < m_model->count();
+ index.has_value() && index.value() < m_model->count();
- Q_EMIT itemActivated(index);
+ Q_EMIT itemActivated(index.value());
Q_EMIT aboveItemDropEvent(dropAboveIndex, event);
} else if (!event->mimeData()->hasFormat(m_model->blacklistItemDropEventMimeType())) {
// Something has been dropped on an item or on an empty part of the view.
Q_EMIT aboveItemDropEvent(dropAboveIndex, event);
} else if (!event->mimeData()->hasFormat(m_model->blacklistItemDropEventMimeType())) {
// Something has been dropped on an item or on an empty part of the view.
- Q_EMIT itemDropEvent(m_view->itemAt(pos), event);
+ Q_EMIT itemDropEvent(m_view->itemAt(pos).value_or(-1), event);
}
QAccessibleEvent accessibilityEvent(view(), QAccessible::DragDropEnd);
}
QAccessibleEvent accessibilityEvent(view(), QAccessible::DragDropEnd);
m_pressedMousePos = transform.map(event->mapToGraphicsScene(tap->position()));
m_pressedIndex = m_view->itemAt(m_pressedMousePos);
m_pressedMousePos = transform.map(event->mapToGraphicsScene(tap->position()));
m_pressedIndex = m_view->itemAt(m_pressedMousePos);
- if (m_pressedIndex >= 0 && !m_selectionManager->isSelected(m_pressedIndex)) {
+ if (m_pressedIndex.has_value() && !m_selectionManager->isSelected(m_pressedIndex.value())) {
m_selectionManager->clearSelection();
m_selectionManager->clearSelection();
- m_selectionManager->setSelected(m_pressedIndex);
- } else if (m_pressedIndex == -1) {
+ m_selectionManager->setSelected(m_pressedIndex.value());
+ } else if (!m_pressedIndex.has_value()) {
m_selectionManager->clearSelection();
startRubberBand();
}
m_selectionManager->clearSelection();
startRubberBand();
}
Q_EMIT scrollerStop();
if (swipe->swipeAngle() <= 20 || swipe->swipeAngle() >= 340) {
Q_EMIT scrollerStop();
if (swipe->swipeAngle() <= 20 || swipe->swipeAngle() >= 340) {
- Q_EMIT mouseButtonPressed(m_pressedIndex, Qt::BackButton);
+ Q_EMIT mouseButtonPressed(m_pressedIndex.value_or(-1), Qt::BackButton);
} else if (swipe->swipeAngle() <= 200 && swipe->swipeAngle() >= 160) {
} else if (swipe->swipeAngle() <= 200 && swipe->swipeAngle() >= 160) {
- Q_EMIT mouseButtonPressed(m_pressedIndex, Qt::ForwardButton);
+ Q_EMIT mouseButtonPressed(m_pressedIndex.value_or(-1), Qt::ForwardButton);
} else if (swipe->swipeAngle() <= 110 && swipe->swipeAngle() >= 60) {
Q_EMIT swipeUp();
}
} else if (swipe->swipeAngle() <= 110 && swipe->swipeAngle() >= 60) {
Q_EMIT swipeUp();
}
if (twoTap->state() == Qt::GestureStarted) {
m_pressedMousePos = transform.map(twoTap->pos());
m_pressedIndex = m_view->itemAt(m_pressedMousePos);
if (twoTap->state() == Qt::GestureStarted) {
m_pressedMousePos = transform.map(twoTap->pos());
m_pressedIndex = m_view->itemAt(m_pressedMousePos);
- if (m_pressedIndex >= 0) {
+ if (m_pressedIndex.has_value()) {
onPress(twoTap->screenPos().toPoint(), twoTap->pos().toPoint(), Qt::ControlModifier, Qt::LeftButton);
onRelease(transform.map(twoTap->pos()), Qt::ControlModifier, Qt::LeftButton, false);
}
onPress(twoTap->screenPos().toPoint(), twoTap->pos().toPoint(), Qt::ControlModifier, Qt::LeftButton);
onRelease(transform.map(twoTap->pos()), Qt::ControlModifier, Qt::LeftButton, false);
}
bool KItemListController::onPress(const QPoint& screenPos, const QPointF& pos, const Qt::KeyboardModifiers modifiers, const Qt::MouseButtons buttons)
{
bool KItemListController::onPress(const QPoint& screenPos, const QPointF& pos, const Qt::KeyboardModifiers modifiers, const Qt::MouseButtons buttons)
{
- Q_EMIT mouseButtonPressed(m_pressedIndex, buttons);
+ Q_EMIT mouseButtonPressed(m_pressedIndex.value_or(-1), buttons);
if (buttons & (Qt::BackButton | Qt::ForwardButton)) {
// Do not select items when clicking the back/forward buttons, see
if (buttons & (Qt::BackButton | Qt::ForwardButton)) {
// Do not select items when clicking the back/forward buttons, see
- if (m_view->isAboveExpansionToggle(m_pressedIndex, m_pressedMousePos)) {
+ if (m_view->isAboveExpansionToggle(m_pressedIndex.value_or(-1), m_pressedMousePos)) {
m_selectionManager->endAnchoredSelection();
m_selectionManager->endAnchoredSelection();
- m_selectionManager->setCurrentItem(m_pressedIndex);
- m_selectionManager->beginAnchoredSelection(m_pressedIndex);
+ m_selectionManager->setCurrentItem(m_pressedIndex.value());
+ m_selectionManager->beginAnchoredSelection(m_pressedIndex.value());
- m_selectionTogglePressed = m_view->isAboveSelectionToggle(m_pressedIndex, m_pressedMousePos);
+ m_selectionTogglePressed = m_view->isAboveSelectionToggle(m_pressedIndex.value_or(-1), m_pressedMousePos);
if (m_selectionTogglePressed) {
if (m_selectionTogglePressed) {
- m_selectionManager->setSelected(m_pressedIndex, 1, KItemListSelectionManager::Toggle);
+ m_selectionManager->setSelected(m_pressedIndex.value(), 1, KItemListSelectionManager::Toggle);
// The previous anchored selection has been finished already in
// KItemListSelectionManager::setSelected(). We can safely change
// the current item and start a new anchored selection now.
// The previous anchored selection has been finished already in
// KItemListSelectionManager::setSelected(). We can safely change
// the current item and start a new anchored selection now.
- m_selectionManager->setCurrentItem(m_pressedIndex);
- m_selectionManager->beginAnchoredSelection(m_pressedIndex);
+ m_selectionManager->setCurrentItem(m_pressedIndex.value());
+ m_selectionManager->beginAnchoredSelection(m_pressedIndex.value());
// - start dragging multiple items, or
// - open the context menu and perform an action for all selected items.
const bool shiftOrControlPressed = shiftPressed || controlPressed;
// - start dragging multiple items, or
// - open the context menu and perform an action for all selected items.
const bool shiftOrControlPressed = shiftPressed || controlPressed;
- const bool pressedItemAlreadySelected = m_pressedIndex >= 0 && m_selectionManager->isSelected(m_pressedIndex);
+ const bool pressedItemAlreadySelected = m_pressedIndex.has_value() && m_selectionManager->isSelected(m_pressedIndex.value());
const bool clearSelection = m_selectionBehavior == SingleSelection ||
(!shiftOrControlPressed && !pressedItemAlreadySelected);
if (clearSelection) {
const bool clearSelection = m_selectionBehavior == SingleSelection ||
(!shiftOrControlPressed && !pressedItemAlreadySelected);
if (clearSelection) {
// clear the selection in mouseReleaseEvent(), unless the items are dragged.
m_clearSelectionIfItemsAreNotDragged = true;
// clear the selection in mouseReleaseEvent(), unless the items are dragged.
m_clearSelectionIfItemsAreNotDragged = true;
- if (m_selectionManager->selectedItems().count() == 1 && m_view->isAboveText(m_pressedIndex, m_pressedMousePos)) {
- Q_EMIT selectedItemTextPressed(m_pressedIndex);
+ if (m_selectionManager->selectedItems().count() == 1 && m_view->isAboveText(m_pressedIndex.value_or(-1), m_pressedMousePos)) {
+ Q_EMIT selectedItemTextPressed(m_pressedIndex.value_or(-1));
- if (m_pressedIndex >= 0) {
- m_selectionManager->setCurrentItem(m_pressedIndex);
+ if (m_pressedIndex.has_value()) {
+ m_selectionManager->setCurrentItem(m_pressedIndex.value());
switch (m_selectionBehavior) {
case NoSelection:
break;
case SingleSelection:
switch (m_selectionBehavior) {
case NoSelection:
break;
case SingleSelection:
- m_selectionManager->setSelected(m_pressedIndex);
+ m_selectionManager->setSelected(m_pressedIndex.value());
break;
case MultiSelection:
if (controlPressed && !shiftPressed) {
break;
case MultiSelection:
if (controlPressed && !shiftPressed) {
- m_selectionManager->setSelected(m_pressedIndex, 1, KItemListSelectionManager::Toggle);
- m_selectionManager->beginAnchoredSelection(m_pressedIndex);
+ m_selectionManager->setSelected(m_pressedIndex.value(), 1, KItemListSelectionManager::Toggle);
+ m_selectionManager->beginAnchoredSelection(m_pressedIndex.value());
} else if (!shiftPressed || !m_selectionManager->isAnchoredSelectionActive()) {
// Select the pressed item and start a new anchored selection
} else if (!shiftPressed || !m_selectionManager->isAnchoredSelectionActive()) {
// Select the pressed item and start a new anchored selection
- m_selectionManager->setSelected(m_pressedIndex, 1, KItemListSelectionManager::Select);
- m_selectionManager->beginAnchoredSelection(m_pressedIndex);
+ m_selectionManager->setSelected(m_pressedIndex.value(), 1, KItemListSelectionManager::Select);
+ m_selectionManager->beginAnchoredSelection(m_pressedIndex.value());
}
if (buttons & Qt::RightButton) {
}
if (buttons & Qt::RightButton) {
- Q_EMIT itemContextMenuRequested(m_pressedIndex, screenPos);
+ Q_EMIT itemContextMenuRequested(m_pressedIndex.value(), screenPos);
bool KItemListController::onRelease(const QPointF& pos, const Qt::KeyboardModifiers modifiers, const Qt::MouseButtons buttons, bool touch)
{
bool KItemListController::onRelease(const QPointF& pos, const Qt::KeyboardModifiers modifiers, const Qt::MouseButtons buttons, bool touch)
{
- const bool isAboveSelectionToggle = m_view->isAboveSelectionToggle(m_pressedIndex, m_pressedMousePos);
+ const bool isAboveSelectionToggle = m_view->isAboveSelectionToggle(m_pressedIndex.value_or(-1), m_pressedMousePos);
if (isAboveSelectionToggle) {
m_selectionTogglePressed = false;
return true;
}
if (!isAboveSelectionToggle && m_selectionTogglePressed) {
if (isAboveSelectionToggle) {
m_selectionTogglePressed = false;
return true;
}
if (!isAboveSelectionToggle && m_selectionTogglePressed) {
- m_selectionManager->setSelected(m_pressedIndex, 1, KItemListSelectionManager::Toggle);
+ m_selectionManager->setSelected(m_pressedIndex.value_or(-1), 1, KItemListSelectionManager::Toggle);
m_selectionTogglePressed = false;
return true;
}
m_selectionTogglePressed = false;
return true;
}
m_view->setAutoScroll(false);
}
m_view->setAutoScroll(false);
}
- const int index = m_view->itemAt(pos);
+ const std::optional<int> index = m_view->itemAt(pos);
- if (index >= 0 && index == m_pressedIndex) {
+ if (index.has_value() && index == m_pressedIndex) {
// The release event is done above the same item as the press event
if (m_clearSelectionIfItemsAreNotDragged) {
// A selected item has been clicked, but no drag operation has been started
// -> clear the rest of the selection.
m_selectionManager->clearSelection();
// The release event is done above the same item as the press event
if (m_clearSelectionIfItemsAreNotDragged) {
// A selected item has been clicked, but no drag operation has been started
// -> clear the rest of the selection.
m_selectionManager->clearSelection();
- m_selectionManager->setSelected(m_pressedIndex, 1, KItemListSelectionManager::Select);
- m_selectionManager->beginAnchoredSelection(m_pressedIndex);
+ m_selectionManager->setSelected(m_pressedIndex.value(), 1, KItemListSelectionManager::Select);
+ m_selectionManager->beginAnchoredSelection(m_pressedIndex.value());
}
if (buttons & Qt::LeftButton) {
bool emitItemActivated = true;
}
if (buttons & Qt::LeftButton) {
bool emitItemActivated = true;
- if (m_view->isAboveExpansionToggle(index, pos)) {
- const bool expanded = m_model->isExpanded(index);
- m_model->setExpanded(index, !expanded);
+ if (m_view->isAboveExpansionToggle(index.value(), pos)) {
+ const bool expanded = m_model->isExpanded(index.value());
+ m_model->setExpanded(index.value(), !expanded);
- Q_EMIT itemExpansionToggleClicked(index);
+ Q_EMIT itemExpansionToggleClicked(index.value());
emitItemActivated = false;
} else if (shiftOrControlPressed && m_selectionBehavior != SingleSelection) {
// The mouse click should only update the selection, not trigger the item, except when
emitItemActivated = false;
} else if (shiftOrControlPressed && m_selectionBehavior != SingleSelection) {
// The mouse click should only update the selection, not trigger the item, except when
}
}
if (emitItemActivated) {
}
}
if (emitItemActivated) {
- Q_EMIT itemActivated(index);
+ Q_EMIT itemActivated(index.value());
}
} else if (buttons & Qt::MiddleButton) {
}
} else if (buttons & Qt::MiddleButton) {
- Q_EMIT itemMiddleClicked(index);
+ Q_EMIT itemMiddleClicked(index.value());
}
}
m_pressedMousePos = QPointF();
}
}
m_pressedMousePos = QPointF();
+ m_pressedIndex = std::nullopt;
m_clearSelectionIfItemsAreNotDragged = false;
return false;
}
m_clearSelectionIfItemsAreNotDragged = false;
return false;
}
#ifndef KITEMLISTCONTROLLER_H
#define KITEMLISTCONTROLLER_H
#ifndef KITEMLISTCONTROLLER_H
#define KITEMLISTCONTROLLER_H
#include "dolphin_export.h"
#include "kitemset.h"
#include "dolphin_export.h"
#include "kitemset.h"
KItemListView* m_view;
KItemListSelectionManager* m_selectionManager;
KItemListKeyboardSearchManager* m_keyboardManager;
KItemListView* m_view;
KItemListSelectionManager* m_selectionManager;
KItemListKeyboardSearchManager* m_keyboardManager;
+ std::optional<int> m_pressedIndex;
QPointF m_pressedMousePos;
QTimer* m_autoActivationTimer;
QPointF m_pressedMousePos;
QTimer* m_autoActivationTimer;
return size().height() - headerHeight;
}
return size().height() - headerHeight;
}
-int KItemListView::itemAt(const QPointF& pos) const
+std::optional<int> KItemListView::itemAt(const QPointF& pos) const
{
QHashIterator<int, KItemListWidget*> it(m_visibleItems);
while (it.hasNext()) {
{
QHashIterator<int, KItemListWidget*> it(m_visibleItems);
while (it.hasNext()) {
}
bool KItemListView::isAboveSelectionToggle(int index, const QPointF& pos) const
}
bool KItemListView::isAboveSelectionToggle(int index, const QPointF& pos) const
#ifndef KITEMLISTVIEW_H
#define KITEMLISTVIEW_H
#ifndef KITEMLISTVIEW_H
#define KITEMLISTVIEW_H
#include "dolphin_export.h"
#include "kitemviews/kitemliststyleoption.h"
#include "kitemviews/kitemlistwidget.h"
#include "dolphin_export.h"
#include "kitemviews/kitemliststyleoption.h"
#include "kitemviews/kitemlistwidget.h"
* @return Index of the item that is below the point \a pos.
* The position is relative to the upper right of
* the visible area. Only (at least partly) visible
* @return Index of the item that is below the point \a pos.
* The position is relative to the upper right of
* the visible area. Only (at least partly) visible
- * items are considered. -1 is returned if no item is
- * below the position.
+ * items are considered. std::nullopt is returned if
+ * no item is below the position.
- int itemAt(const QPointF& pos) const;
+ std::optional<int> itemAt(const QPointF& pos) const;
bool isAboveSelectionToggle(int index, const QPointF& pos) const;
bool isAboveExpansionToggle(int index, const QPointF& pos) const;
bool isAboveText(int index, const QPointF& pos) const;
bool isAboveSelectionToggle(int index, const QPointF& pos) const;
bool isAboveExpansionToggle(int index, const QPointF& pos) const;
bool isAboveText(int index, const QPointF& pos) const;
*/
#ifndef QT_NO_ACCESSIBILITY
*/
#ifndef QT_NO_ACCESSIBILITY
#include "kitemlistviewaccessible.h"
#include "kitemlistcontainer.h"
#include "kitemlistviewaccessible.h"
#include "kitemlistcontainer.h"
QAccessibleInterface* KItemListViewAccessible::childAt(int x, int y) const
{
const QPointF point = QPointF(x, y);
QAccessibleInterface* KItemListViewAccessible::childAt(int x, int y) const
{
const QPointF point = QPointF(x, y);
- int itemIndex = view()->itemAt(view()->mapFromScene(point));
- return child(itemIndex);
+ const std::optional<int> itemIndex = view()->itemAt(view()->mapFromScene(point));
+ return child(itemIndex.value_or(-1));
}
QAccessibleInterface* KItemListViewAccessible::parent() const
}
QAccessibleInterface* KItemListViewAccessible::parent() const
if (!isDevice) {
menu.addSeparator();
}
if (!isDevice) {
menu.addSeparator();
}
if (isDevice) {
ejectAction = m_model->ejectAction(index);
if (ejectAction) {
if (isDevice) {
ejectAction = m_model->ejectAction(index);
if (ejectAction) {
void PlacesPanel::slotShowTooltip()
{
void PlacesPanel::slotShowTooltip()
{
- const QUrl url = m_model->data(m_hoveredIndex).value("url").value<QUrl>();
+ const QUrl url = m_model->data(m_hoveredIndex.value_or(-1)).value("url").value<QUrl>();
const QString text = url.toDisplayString(QUrl::PreferLocalFile);
QToolTip::showText(m_hoverPos, text);
}
const QString text = url.toDisplayString(QUrl::PreferLocalFile);
QToolTip::showText(m_hoverPos, text);
}
#ifndef PLACESPANEL_H
#define PLACESPANEL_H
#ifndef PLACESPANEL_H
#define PLACESPANEL_H
#include "panels/panel.h"
#include <QUrl>
#include "panels/panel.h"
#include <QUrl>
QMimeData* m_itemDropEventMimeData;
QDropEvent* m_itemDropEvent;
QTimer m_tooltipTimer;
QMimeData* m_itemDropEventMimeData;
QDropEvent* m_itemDropEvent;
QTimer m_tooltipTimer;
+ std::optional<int> m_hoveredIndex;
{
if (!GeneralSettings::showToolTips() && m_mode == DolphinView::IconsView) {
QHelpEvent *hoverEvent = reinterpret_cast<QHelpEvent *>(event);
{
if (!GeneralSettings::showToolTips() && m_mode == DolphinView::IconsView) {
QHelpEvent *hoverEvent = reinterpret_cast<QHelpEvent *>(event);
- const int index = m_view->itemAt(hoverEvent->pos());
+ const std::optional<int> index = m_view->itemAt(hoverEvent->pos());
+ if (!index.has_value()) {
return;
}
// Check whether the filename has been elided
return;
}
// Check whether the filename has been elided
- const bool isElided = m_view->isElided(index);
+ const bool isElided = m_view->isElided(index.value());
- const KFileItem item = m_model->fileItem(index);
+ const KFileItem item = m_model->fileItem(index.value());
const QString text = item.text();
const QPoint pos = mapToGlobal(hoverEvent->pos());
QToolTip::showText(pos, text);
const QString text = item.text();
const QPoint pos = mapToGlobal(hoverEvent->pos());
QToolTip::showText(pos, text);