File indexing completed on 2024-05-19 08:31:05
0001 /* 0002 SPDX-FileCopyrightText: 2013 Aleix Pol <aleixpol@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #ifndef KDEVPLATFORM_PLUGIN_PROJECTMODELITEMDELEGATE_H 0008 #define KDEVPLATFORM_PLUGIN_PROJECTMODELITEMDELEGATE_H 0009 0010 #include <QItemDelegate> 0011 #include <QPointer> 0012 0013 namespace KDevelop 0014 { 0015 class NavigationToolTip; 0016 } 0017 0018 class ProjectModelItemDelegate : public QItemDelegate 0019 { 0020 Q_OBJECT 0021 public: 0022 explicit ProjectModelItemDelegate(QObject* parent = nullptr); 0023 0024 void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const override; 0025 void drawDisplay(QPainter *painter, const QStyleOptionViewItem &option, 0026 const QRect &rect, const QString &text) const override; 0027 bool helpEvent(QHelpEvent* event, QAbstractItemView* view, const QStyleOptionViewItem& option, 0028 const QModelIndex& index) override; 0029 0030 private: 0031 void drawBranchName(QPainter* painter, const QStyleOptionViewItem& option, const QRect& rect, 0032 const QString& branchName) const; 0033 void drawStyledBackground(QPainter* painter, const QStyleOptionViewItem& option) const; 0034 0035 private: 0036 QPointer<KDevelop::NavigationToolTip> m_tooltip; 0037 QPersistentModelIndex m_tooltippedIndex; 0038 }; 0039 0040 #endif // KDEVPLATFORM_PLUGIN_PROJECTMODELITEMDELEGATE_H