]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Don't reinterpret_cast QEvent
authorKai Uwe Broulik <kde@privat.broulik.de>
Tue, 5 Jul 2022 11:18:45 +0000 (13:18 +0200)
committerKai Uwe Broulik <kde@privat.broulik.de>
Wed, 6 Jul 2022 17:33:42 +0000 (17:33 +0000)
We know that we'll be a `QHelpEvent` from `QEvent::ToolTip`, so do a
static_cast from the event handler (where it's obvious from context),
and then pass it along to `tryShowNameToolTip`.

src/views/dolphinview.cpp
src/views/dolphinview.h

index 168e282b535f874aab36cc4cea2e2eb032ecc9be..a6c90e990772b8784a5437c76d62589a8394544a 100644 (file)
@@ -925,7 +925,7 @@ bool DolphinView::eventFilter(QObject* watched, QEvent* event)
         break;
 
     case QEvent::ToolTip:
-        tryShowNameToolTip(event);
+        tryShowNameToolTip(static_cast<QHelpEvent*>(event));
 
     default:
         break;
@@ -2196,11 +2196,10 @@ void DolphinView::updatePlaceholderLabel()
     m_placeholderLabel->setVisible(true);
 }
 
-void DolphinView::tryShowNameToolTip(QEvent* event)
+void DolphinView::tryShowNameToolTip(QHelpEvent* event)
 {
     if (!GeneralSettings::showToolTips() && m_mode == DolphinView::IconsView) {
-        QHelpEvent *hoverEvent = reinterpret_cast<QHelpEvent *>(event);
-        const std::optional<int> index = m_view->itemAt(hoverEvent->pos());
+        const std::optional<int> index = m_view->itemAt(event->pos());
 
         if (!index.has_value()) {
             return;
@@ -2212,7 +2211,7 @@ void DolphinView::tryShowNameToolTip(QEvent* event)
         if(isElided) {
             const KFileItem item = m_model->fileItem(index.value());
             const QString text = item.text();
-            const QPoint pos = mapToGlobal(hoverEvent->pos());
+            const QPoint pos = mapToGlobal(event->pos());
             QToolTip::showText(pos, text);
         }
     }
index 33d432c9e347e087115467afc612be0342a4d8e0..62ced31acd15b20a8ba7f910b68ea71b87889fdb 100644 (file)
@@ -35,6 +35,7 @@ class VersionControlObserver;
 class ViewProperties;
 class QLabel;
 class QGraphicsSceneDragDropEvent;
+class QHelpEvent;
 class QRegularExpression;
 
 /**
@@ -862,7 +863,7 @@ private:
 
     void updatePlaceholderLabel();
 
-    void tryShowNameToolTip(QEvent* event);
+    void tryShowNameToolTip(QHelpEvent* event);
 
 private:
     void updatePalette();