From eb0a7da653493db272ee6039d5202c5702acffc3 Mon Sep 17 00:00:00 2001 From: Fushan Wen Date: Tue, 28 Dec 2021 00:51:10 +0800 Subject: kitemlistview: Port KItemListView::itemAt to std::optional Use `value_or(-1)` for those functions that don't use `std::optional`. --- src/kitemviews/kitemlistview.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/kitemviews/kitemlistview.h') diff --git a/src/kitemviews/kitemlistview.h b/src/kitemviews/kitemlistview.h index 404cf320f..cbb178119 100644 --- a/src/kitemviews/kitemlistview.h +++ b/src/kitemviews/kitemlistview.h @@ -9,6 +9,8 @@ #ifndef KITEMLISTVIEW_H #define KITEMLISTVIEW_H +#include + #include "dolphin_export.h" #include "kitemviews/kitemliststyleoption.h" #include "kitemviews/kitemlistwidget.h" @@ -160,10 +162,10 @@ public: * @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 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; -- cgit v1.3.1