File indexing completed on 2025-01-05 03:56:11
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2015-08-09 0007 * Description : DTrash item info model 0008 * 0009 * SPDX-FileCopyrightText: 2015 by Mohamed_Anwer <m_dot_anwer at gmx dot com> 0010 * 0011 * SPDX-License-Identifier: GPL-2.0-or-later 0012 * 0013 * ============================================================ */ 0014 0015 #ifndef DIGIKAM_DTRASH_ITEM_MODEL_H 0016 #define DIGIKAM_DTRASH_ITEM_MODEL_H 0017 0018 // Qt includes 0019 0020 #include <QWidget> 0021 #include <QAbstractTableModel> 0022 0023 // Local includes 0024 0025 #include "dtrashiteminfo.h" 0026 #include "thumbnailloadthread.h" 0027 0028 namespace Digikam 0029 { 0030 0031 class DTrashItemModel : public QAbstractTableModel 0032 { 0033 Q_OBJECT 0034 0035 public: 0036 0037 enum DTrashColumn 0038 { 0039 DTrashThumb = 0, 0040 DTrashRelPath, 0041 DTrashTimeStamp, 0042 DTrashNumCol 0043 }; 0044 0045 public: 0046 0047 explicit DTrashItemModel(QObject* const parent, QWidget* const widget); 0048 ~DTrashItemModel() override; 0049 0050 /** 0051 * @brief loads a thumbnail for item in trash for showing 0052 * @param path: path of image in trash 0053 * @param pix: Pixmap to fill 0054 * @return true if there is an available thumbnail 0055 */ 0056 bool pixmapForItem(const QString& path, QPixmap& pix) const; 0057 0058 /** 0059 * @brief Clears all data from model and informs the view 0060 */ 0061 void clearCurrentData(); 0062 0063 /** 0064 * @brief Runs a thread to list all items from a collection trash 0065 * @param colPath: path to collection to load items for 0066 */ 0067 void loadItemsForCollection(const QString& colPath); 0068 0069 /** 0070 * @brief returns DTrashItemInfo for specific index in model 0071 */ 0072 DTrashItemInfo itemForIndex(const QModelIndex& index); 0073 0074 /** 0075 * @brief returns DTrashItemInfoList for given indexes in model 0076 */ 0077 DTrashItemInfoList itemsForIndexes(const QList<QModelIndex>& indexes); 0078 0079 /** 0080 * @brief returns the index for the DTrashItemInfo in model 0081 */ 0082 QModelIndex indexForItem(const DTrashItemInfo& itemInfo) const; 0083 0084 /** 0085 * @brief returns a list of all items in model 0086 */ 0087 DTrashItemInfoList allItems(); 0088 0089 /** 0090 * @return true if there is no data in the model 0091 */ 0092 bool isEmpty(); 0093 0094 /** 0095 * @brief Changes the thumbnail size 0096 * @param size: size to change to 0097 */ 0098 void changeThumbSize(int size); 0099 0100 /** 0101 * @brief Stop loading of trash 0102 */ 0103 void stopLoadingTrash(); 0104 0105 /// QAbstractItemModel interface 0106 public: 0107 0108 int rowCount(const QModelIndex&) const override; 0109 int columnCount(const QModelIndex&) const override; 0110 0111 QVariant data(const QModelIndex& index, int role) const override; 0112 QVariant headerData(int section, Qt::Orientation orientation, int role) const override; 0113 0114 void sort(int column, Qt::SortOrder order = Qt::AscendingOrder) override; 0115 QString trashAlbumPath() const; 0116 0117 public Q_SLOTS: 0118 0119 /** 0120 * @brief appends item to model data and informs the view 0121 * @param itemInfo: item to append 0122 */ 0123 void append(const DTrashItemInfo& itemInfo); 0124 0125 /** 0126 * @brief removes list of items for given indexes from model 0127 * data and informs the view 0128 * @param indexes: indexes to remove 0129 */ 0130 void removeItems(const QModelIndexList& indexes); 0131 0132 /** 0133 * @brief refreshes the view layout 0134 */ 0135 void refreshLayout(); 0136 0137 /** 0138 * @brief refreshes the thumbnails 0139 * @param desc: loading description from thumbnail load thread 0140 * @param pix: pixmap from thumbnail load thread 0141 */ 0142 void refreshThumbnails(const LoadingDescription& desc, const QPixmap& pix); 0143 0144 Q_SIGNALS: 0145 0146 void dataChange(); 0147 void signalLoadingStarted(); 0148 void signalLoadingFinished(); 0149 0150 private Q_SLOTS: 0151 0152 void slotLoadItemsFinished(); 0153 0154 private: 0155 0156 class Private; 0157 Private* const d; 0158 }; 0159 0160 } // namespace Digikam 0161 0162 #endif // DIGIKAM_DTRASH_ITEM_MODEL_H