File indexing completed on 2025-04-27 03:58:30

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2009-04-24
0007  * Description : A DItemToolTip prepared for use in QAbstractItemViews
0008  *
0009  * SPDX-FileCopyrightText: 2009-2011 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
0010  *
0011  * SPDX-License-Identifier: GPL-2.0-or-later
0012  *
0013  * ============================================================ */
0014 
0015 #ifndef DIGIKAM_ITEM_VIEW_TOOL_TIP_H
0016 #define DIGIKAM_ITEM_VIEW_TOOL_TIP_H
0017 
0018 // Qt includes
0019 
0020 #include <QAbstractItemView>
0021 
0022 // Local includes
0023 
0024 #include "ditemtooltip.h"
0025 #include "digikam_export.h"
0026 
0027 namespace Digikam
0028 {
0029 
0030 class DIGIKAM_EXPORT ItemViewToolTip : public DItemToolTip
0031 {
0032     Q_OBJECT
0033 
0034 public:
0035 
0036     explicit ItemViewToolTip(QAbstractItemView* const view);
0037     ~ItemViewToolTip()                      override;
0038 
0039     QAbstractItemView* view()   const;
0040     QAbstractItemModel* model() const;
0041     QModelIndex currentIndex()  const;
0042 
0043     /**
0044      * Show the tooltip for the given item.
0045      * The rect of the given option is taken as area for which
0046      * the tooltip is shown.
0047      */
0048     void show(const QStyleOptionViewItem& option, const QModelIndex& index);
0049 
0050     void setTipContents(const QString& tipContents);
0051 
0052     /**
0053      * Default implementation is based on setTipContents().
0054      * Reimplement if you dynamically provide the contents.
0055      */
0056     QString tipContents()                   override;
0057 
0058 protected:
0059 
0060     QRect repositionRect()                  override;
0061 
0062     bool eventFilter(QObject* o, QEvent* e) override;
0063     void hideEvent(QHideEvent*)             override;
0064     void mouseMoveEvent(QMouseEvent* e)     override;
0065 
0066 private:
0067 
0068     class Private;
0069     Private* const d;
0070 };
0071 
0072 } // namespace Digikam
0073 
0074 #endif // DIGIKAM_ITEM_VIEW_TOOL_TIP_H