File indexing completed on 2025-01-19 03:59:25
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2012-06-13 0007 * Description : Qt item model for camera thumbnails entries 0008 * 0009 * SPDX-FileCopyrightText: 2009-2012 by Islam Wazery <wazery at ubuntu dot com> 0010 * 0011 * SPDX-License-Identifier: GPL-2.0-or-later 0012 * 0013 * ============================================================ */ 0014 0015 #ifndef DIGIKAM_IMPORT_THUMBNAIL_MODEL_H 0016 #define DIGIKAM_IMPORT_THUMBNAIL_MODEL_H 0017 0018 // Local includes 0019 0020 #include "importimagemodel.h" 0021 #include "thumbnailsize.h" 0022 #include "camerathumbsctrl.h" 0023 #include "digikam_export.h" 0024 0025 namespace Digikam 0026 { 0027 0028 typedef QPair<CamItemInfo, QPixmap> CachedItem; 0029 0030 class DIGIKAM_GUI_EXPORT ImportThumbnailModel : public ImportItemModel 0031 { 0032 Q_OBJECT 0033 0034 public: 0035 0036 /** 0037 * This model provides thumbnail loading, it uses the Camera Controller 0038 * to retrieve thumbnails for CamItemInfos. It also provides preloading of thumbnails, 0039 * and caching facility. Thumbnails size can be adjusted. 0040 */ 0041 explicit ImportThumbnailModel(QObject* const parent); 0042 ~ImportThumbnailModel() override; 0043 0044 /// Sets the camera thumbs controller which is used to get the thumbnails for item infos. 0045 void setCameraThumbsController(CameraThumbsCtrl* const thumbsCtrl) override; 0046 0047 /// Get the thumbnail size 0048 ThumbnailSize thumbnailSize() const; 0049 0050 /** 0051 * Enable emitting dataChanged() when a thumbnail becomes available. 0052 * The thumbnailAvailable() signal will be emitted in any case. 0053 * Default is true. 0054 */ 0055 void setEmitDataChanged(bool emitSignal); 0056 0057 /** 0058 * Handles the ThumbnailRole. 0059 * If the pixmap is available, returns it in the QVariant. 0060 * If it still needs to be loaded, returns a null QVariant and emits 0061 * thumbnailAvailable() as soon as it is available. 0062 */ 0063 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; 0064 0065 /** 0066 * You can override the current thumbnail size by giving an integer value for ThumbnailRole. 0067 * Set a null QVariant to use the thumbnail size set by setThumbnailSize() again. 0068 * The index given here is ignored for this purpose. 0069 */ 0070 bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::DisplayRole) override; 0071 0072 Q_SIGNALS: 0073 0074 void thumbnailAvailable(const QModelIndex& index, int requestedSize); 0075 void thumbnailFailed(const QModelIndex& index, int requestedSize); 0076 0077 private Q_SLOTS: 0078 0079 void slotThumbInfoReady(const CamItemInfo&); 0080 0081 private: 0082 0083 // Disable 0084 ImportThumbnailModel(const ImportThumbnailModel&) = delete; 0085 ImportThumbnailModel& operator=(const ImportThumbnailModel&) = delete; 0086 0087 private: 0088 0089 class Private; 0090 Private* const d; 0091 }; 0092 0093 } // namespace Digikam 0094 0095 #endif // DIGIKAM_IMPORT_THUMBNAIL_MODEL_H