File indexing completed on 2025-01-19 03:56:15
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2010-07-15 0007 * Description : Item delegate for image versions list view 0008 * 0009 * SPDX-FileCopyrightText: 2010-2011 by Martin Klapetek <martin dot klapetek at gmail dot com> 0010 * 0011 * SPDX-License-Identifier: GPL-2.0-or-later 0012 * 0013 * ============================================================ */ 0014 0015 #ifndef DIGIKAM_VERSIONS_DELEGATE_H 0016 #define DIGIKAM_VERSIONS_DELEGATE_H 0017 0018 // Qt includes 0019 0020 #include <QStyledItemDelegate> 0021 0022 // Local includes 0023 0024 #include "digikam_export.h" 0025 #include "itemdelegateoverlay.h" 0026 0027 namespace Digikam 0028 { 0029 0030 class VersionsDelegate : public QStyledItemDelegate, 0031 public ItemDelegateOverlayContainer 0032 { 0033 Q_OBJECT 0034 Q_PROPERTY(int animationState READ animationState 0035 WRITE setAnimationState 0036 NOTIFY animationStateChanged) 0037 0038 public: 0039 0040 explicit VersionsDelegate(QObject* const parent); 0041 ~VersionsDelegate() override; 0042 0043 QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const override; 0044 void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const override; 0045 0046 void beginPainting(); 0047 void finishPainting(); 0048 0049 int animationState() const; 0050 void setAnimationState(int animationState); 0051 0052 void setThumbnailSize(int size) const; 0053 int thumbnailSize() const; 0054 0055 Q_SIGNALS: 0056 0057 void animationStateChanged(); 0058 void visualChange(); // for ItemDelegateOverlayContainer 0059 0060 /// NOTE: for ItemDelegateOverlayContainer, unimplemented: 0061 void requestNotification(const QModelIndex& index, const QString& message); 0062 void hideNotification(); 0063 0064 protected Q_SLOTS: 0065 0066 void overlayDestroyed(QObject* o) override 0067 { 0068 ItemDelegateOverlayContainer::overlayDestroyed(o); 0069 } 0070 0071 protected: 0072 0073 void initStyleOption(QStyleOptionViewItem* option, const QModelIndex& index) const override; 0074 0075 /// Returns the delegate, typically, the derived class 0076 QAbstractItemDelegate* asDelegate() override 0077 { 0078 return this; 0079 } 0080 0081 private: 0082 0083 VersionsDelegate(); // Disable default constructor. 0084 0085 private: 0086 0087 class Private; 0088 Private* const d; 0089 }; 0090 0091 } // namespace Digikam 0092 0093 #endif // DIGIKAM_VERSIONS_DELEGATE_H