File indexing completed on 2025-01-19 03:50:47

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2015-08-07
0007  * Description : Trash view
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_TRASH_VIEW_H
0016 #define DIGIKAM_TRASH_VIEW_H
0017 
0018 // Qt includes
0019 
0020 #include <QWidget>
0021 #include <QStyledItemDelegate>
0022 
0023 namespace Digikam
0024 {
0025 
0026 class DTrashItemModel;
0027 class ThumbnailSize;
0028 
0029 class TrashView : public QWidget
0030 {
0031     Q_OBJECT
0032 
0033 public:
0034 
0035     explicit TrashView(QWidget* const parent = nullptr);
0036     ~TrashView()                              override;
0037 
0038     /**
0039      * @return model used for the view
0040      */
0041     DTrashItemModel* model()            const;
0042 
0043     /**
0044      * @return current thumbnail size
0045      */
0046     ThumbnailSize getThumbnailSize()    const;
0047 
0048     /**
0049      * @brief set thumbnail size to give to model
0050      * @param thumbSize: size to set
0051      */
0052     void setThumbnailSize(const ThumbnailSize& thumbSize);
0053 
0054     /**
0055      * @return QUrl to the last selected item in view
0056      */
0057     QUrl lastSelectedItemUrl()          const;
0058 
0059     /**
0060      * @brief Highlights the last selected item when the view gets focus
0061      */
0062     void selectLastSelected();
0063 
0064     /**
0065      * @return text for the main status bar
0066      */
0067     QString statusBarText()             const;
0068 
0069 private Q_SLOTS:
0070 
0071     void slotSelectionChanged();
0072     void slotUndoLastDeletedItems();
0073     void slotRestoreSelectedItems();
0074     void slotDeleteSelectedItems();
0075     void slotRemoveItemsFromModel();
0076     void slotRemoveAllItemsFromModel();
0077     void slotDeleteAllItems();
0078     void slotDataChanged();
0079     void slotLoadingStarted();
0080     void slotLoadingFinished();
0081     void slotChangeLastSelectedItem(const QModelIndex& curr, const QModelIndex& prev);
0082     void slotContextMenuEmptyTrash(const QPoint& pos);
0083 
0084 Q_SIGNALS:
0085 
0086     void selectionChanged();
0087     void signalEmptytrash();
0088 
0089 private:
0090 
0091     class Private;
0092     Private* const d;
0093 };
0094 
0095 // --------------------------------------------------
0096 
0097 class ThumbnailAligningDelegate : public QStyledItemDelegate
0098 {
0099     Q_OBJECT
0100 
0101 public:
0102 
0103     explicit ThumbnailAligningDelegate(QObject* const parent = nullptr);
0104 
0105     void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const override;
0106 };
0107 
0108 } // namespace Digikam
0109 
0110 #endif // DIGIKAM_TRASH_VIEW_H