File indexing completed on 2024-05-19 05:39:42
0001 /* 0002 * SPDX-FileCopyrightText: 2008 Konstantin Heil <konst.heil@stud.uni-heidelberg.de> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #ifndef TOOLTIPMANAGER_H 0008 #define TOOLTIPMANAGER_H 0009 0010 #include <QModelIndex> 0011 #include <QObject> 0012 0013 class QLayout; 0014 class QAbstractItemView; 0015 0016 /** 0017 * @brief Manages the tooltips for an item view. 0018 * 0019 * When hovering an item, a tooltip is shown after 0020 * a short timeout. The tooltip is hidden again when the 0021 * viewport is hovered or the item view has been left. 0022 */ 0023 class ToolTipManager : public QObject 0024 { 0025 Q_OBJECT 0026 0027 public: 0028 /** 0029 * Standard constructor. The ToolTipManager will start handling ToolTip events on the provided 0030 * view immediately. 0031 * 0032 * @param parent The view which will have the tooltips displayed for. 0033 */ 0034 explicit ToolTipManager(QAbstractItemView *parent); 0035 ~ToolTipManager() override; 0036 0037 public Q_SLOTS: 0038 /** 0039 * Hides the currently shown tooltip. Invoking this method is 0040 * only needed when the tooltip should be hidden although 0041 * an item is hovered. 0042 */ 0043 void hideToolTip(); 0044 0045 protected: 0046 bool eventFilter(QObject *watched, QEvent *event) override; 0047 0048 private Q_SLOTS: 0049 void prepareToolTip(); 0050 void requestToolTip(const QModelIndex &index); 0051 0052 private: 0053 void showToolTip(const QModelIndex &menuItem); 0054 QWidget *createTipContent(QModelIndex item); 0055 QLayout *generateToolTipLine(QModelIndex *item, QWidget *toolTip, QSize iconSize, bool comment); 0056 0057 class Private; 0058 ToolTipManager::Private *d; 0059 }; 0060 0061 #endif