File indexing completed on 2024-06-23 04:40:22

0001 /*
0002    SPDX-FileCopyrightText: 2023-2024 Laurent Montel <montel.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 #include "textemoticonswidgets_private_export.h"
0009 #include <QStyledItemDelegate>
0010 #include <TextEmoticonsCore/RunningAnimatedImage>
0011 #include <vector>
0012 namespace TextEmoticonsWidgets
0013 {
0014 class TEXTEMOTICONSWIDGETS_TESTS_EXPORT EmoticonItemDelegate : public QStyledItemDelegate
0015 {
0016     Q_OBJECT
0017 public:
0018     explicit EmoticonItemDelegate(QObject *parent = nullptr);
0019     ~EmoticonItemDelegate() override;
0020 
0021     void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
0022 
0023 private:
0024     [[nodiscard]] std::vector<TextEmoticonsCore::RunningAnimatedImage>::iterator findRunningAnimatedImage(const QModelIndex &index) const;
0025     void removeRunningAnimatedImage(const QModelIndex &index) const;
0026     mutable std::vector<TextEmoticonsCore::RunningAnimatedImage> mRunningAnimatedImages; // not a hash or map, since QPersistentModelIndex changes value
0027 };
0028 }