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

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2009-04-24
0007  * Description : Qt model-view for items
0008  *
0009  * SPDX-FileCopyrightText: 2009-2011 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
0010  * SPDX-FileCopyrightText: 2009-2024 by Gilles Caulier <caulier dot gilles at gmail dot com>
0011  *
0012  * SPDX-License-Identifier: GPL-2.0-or-later
0013  *
0014  * ============================================================ */
0015 
0016 #ifndef DIGIKAM_DIGIKAMITEM_VIEW_H
0017 #define DIGIKAM_DIGIKAMITEM_VIEW_H
0018 
0019 // Local includes
0020 
0021 #include "applicationsettings.h"
0022 #include "itemcategorizedview.h"
0023 #include "itemviewutilities.h"
0024 #include "groupingviewimplementation.h"
0025 
0026 namespace Digikam
0027 {
0028 
0029 class ItemViewUtilities;
0030 class ItemInfoList;
0031 
0032 class DigikamItemView : public ItemCategorizedView,
0033                         public GroupingViewImplementation
0034 {
0035     Q_OBJECT
0036 
0037 public:
0038 
0039     explicit DigikamItemView(QWidget* const parent = nullptr);
0040     ~DigikamItemView()                                                                             override;
0041 
0042     ItemViewUtilities* utilities()                                                           const;
0043 
0044     int  fitToWidthIcons();
0045     bool getFaceMode()                                                                       const;
0046     QList<int> getFaceIds(const QList<QModelIndex>& indexes)                                 const;
0047 
0048     void setThumbnailSize(const ThumbnailSize& size)                                               override;
0049 
0050     ItemInfoList  allItemInfos(bool grouping = false)                                        const;
0051     ItemInfoList  selectedItemInfos(bool grouping = false)                                   const;
0052     ItemInfoList  selectedItemInfosCurrentFirst(bool grouping = false)                       const;
0053     bool          allNeedGroupResolving(const ApplicationSettings::OperationType type)       const;
0054     bool          selectedNeedGroupResolving(const ApplicationSettings::OperationType type)  const;
0055 
0056 public Q_SLOTS:
0057 
0058     void openFile(const ItemInfo& info);
0059 
0060     void deleteSelected(const ItemViewUtilities::DeleteMode deleteMode = ItemViewUtilities::DeleteUseTrash);
0061     void deleteSelectedDirectly(const ItemViewUtilities::DeleteMode deleteMode = ItemViewUtilities::DeleteUseTrash);
0062 
0063     void rename();
0064 
0065     void assignRating(const QList<QModelIndex>& index, int rating);
0066 
0067     void setFaceMode(bool on);
0068 
0069     /**
0070      * Confirm the face with a face tag (name) in the database.
0071      */
0072     void confirmFaces(const QList<QModelIndex>& indexes, int tagId);
0073 
0074     /**
0075      * Removes the face from the database.
0076      * You will have to run face detection again,
0077      * to recover the face.
0078      */
0079     void removeFaces(const QList<QModelIndex>& indexes);
0080 
0081     /**
0082      * Ignored Face back to Unknown face.
0083      */
0084     void unknownFaces(const QList<QModelIndex>& indexes);
0085 
0086     /**
0087      * This slot is connected to the reject signal of
0088      * AssignNameOverlay, and handles two cases.
0089      *
0090      * If reject is done on an Unknown Face,
0091      * it will mark the face as Ignored.
0092      *
0093      * If reject is done on Unconfirmed suggestions,
0094      * the suggestion is rejected and the face is
0095      * marked as Unknown.
0096      */
0097     void rejectFaces(const QList<QModelIndex>& indexes);
0098 
0099     /**
0100      * Set Face to Ignore ID.
0101      */
0102     void ignoreFaces(const QList<QModelIndex>& indexes);
0103 
0104 
0105     void dragDropSort(const ItemInfo& pick, const QList<ItemInfo>& infos);
0106 
0107 Q_SIGNALS:
0108 
0109     void previewRequested(const ItemInfo& info);
0110     void signalSeparationModeChanged(int category);
0111     void signalShowContextMenu(QContextMenuEvent* event,
0112                                const QList<QAction*>& actions = QList<QAction*>());
0113 
0114     void signalShowContextMenuOnInfo(QContextMenuEvent* event, const ItemInfo& info,
0115                                      const QList<QAction*>& actions,
0116                                      ItemFilterModel* filterModel);
0117 
0118     void signalShowGroupContextMenu(QContextMenuEvent* event,
0119                                     const QList<ItemInfo>& selectedInfos,
0120                                     ItemFilterModel* filterModel);
0121 
0122 protected Q_SLOTS:
0123 
0124     void groupIndicatorClicked(const QModelIndex& index);
0125     void showGroupContextMenu(const QModelIndex& index, QContextMenuEvent* event);
0126 
0127 protected:
0128 
0129     void addRejectionOverlay(ItemDelegate* delegate = nullptr);
0130     void addAssignNameOverlay(ItemDelegate* delegate = nullptr);
0131 
0132     void activated(const ItemInfo& info, Qt::KeyboardModifiers modifiers)      override;
0133     void showContextMenuOnInfo(QContextMenuEvent* event, const ItemInfo& info) override;
0134     void showContextMenu(QContextMenuEvent* event)                             override;
0135     void slotSetupChanged()                                                    override;
0136 
0137     bool hasHiddenGroupedImages(const ItemInfo& info)                    const override;
0138 
0139     ItemInfoList imageInfos(const QList<QModelIndex>& indexes,
0140                             ApplicationSettings::OperationType type)     const;
0141 
0142 private Q_SLOTS:
0143 
0144     void slotRotateLeft(const QList<QModelIndex>&);
0145     void slotRotateRight(const QList<QModelIndex>&);
0146     void slotFullscreen(const QList<QModelIndex>&);
0147     void slotInitProgressIndicator();
0148     void scrollTo(const QModelIndex& index, ScrollHint hint = EnsureVisible) override;
0149 
0150 private:
0151 
0152     class Private;
0153     Private* const d;
0154 };
0155 
0156 } // namespace Digikam
0157 
0158 #endif // DIGIKAM_DIGIKAMITEM_VIEW_H