diff options
| author | Fushan Wen <[email protected]> | 2021-12-28 00:51:10 +0800 |
|---|---|---|
| committer | Fushan Wen <[email protected]> | 2021-12-28 22:48:28 +0800 |
| commit | eb0a7da653493db272ee6039d5202c5702acffc3 (patch) | |
| tree | c0d630e5123d546d6c244a362b6eb53c141435ff /src/views/dolphinview.cpp | |
| parent | c071150b7d30c8826496f130b792aed47d4f8326 (diff) | |
kitemlistview: Port KItemListView::itemAt to std::optional
Use `value_or(-1)` for those functions that don't use `std::optional`.
Diffstat (limited to 'src/views/dolphinview.cpp')
| -rw-r--r-- | src/views/dolphinview.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp index 573505e76..0cd38c9eb 100644 --- a/src/views/dolphinview.cpp +++ b/src/views/dolphinview.cpp @@ -2171,17 +2171,17 @@ void DolphinView::tryShowNameToolTip(QEvent* 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 == -1) { + if (!index.has_value()) { return; } // Check whether the filename has been elided - const bool isElided = m_view->isElided(index); + const bool isElided = m_view->isElided(index.value()); if(isElided) { - 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); |
