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        : 2013-02-11
0007  * Description : Table view
0008  *
0009  * SPDX-FileCopyrightText: 2013      by Michael G. Hansen <mike at mghansen dot de>
0010  * SPDX-FileCopyrightText: 2017      by Simon Frei <freisim93 at gmail dot com>
0011  * SPDX-FileCopyrightText: 2017-2024 by Gilles Caulier <caulier dot gilles at gmail dot com>
0012  *
0013  * SPDX-License-Identifier: GPL-2.0-or-later
0014  *
0015  * ============================================================ */
0016 
0017 #ifndef DIGIKAM_TABLE_VIEW_H
0018 #define DIGIKAM_TABLE_VIEW_H
0019 
0020 // Qt includes
0021 
0022 #include <QWidget>
0023 
0024 // Local includes
0025 
0026 #include "applicationsettings.h"
0027 #include "dcategorizedsortfilterproxymodel.h"
0028 #include "digikam_export.h"
0029 #include "itemviewutilities.h"
0030 #include "iteminfo.h"
0031 #include "statesavingobject.h"
0032 
0033 class QMenu;
0034 class QContextMenuEvent;
0035 class QItemDelegate;
0036 class QItemSelectionModel;
0037 class QTreeView;
0038 
0039 namespace Digikam
0040 {
0041 
0042 class Album;
0043 class ItemFilterModel;
0044 class ThumbnailSize;
0045 class TableViewShared;
0046 
0047 class TableView : public QWidget, public StateSavingObject
0048 {
0049     Q_OBJECT
0050 
0051 public:
0052 
0053     explicit TableView(QItemSelectionModel* const selectionModel,
0054                        DCategorizedSortFilterProxyModel* const imageFilterModel,
0055                        QWidget* const parent);
0056 
0057     ~TableView()                                                                                  override;
0058 
0059     void setThumbnailSize(const ThumbnailSize& size);
0060     ThumbnailSize getThumbnailSize()                                                        const;
0061     ItemInfo currentInfo()                                                                  const;
0062     Album* currentAlbum()                                                                   const;
0063     int numberOfSelectedItems()                                                             const;
0064     ItemInfo nextInfo()                                                                     const;
0065     ItemInfo previousInfo()                                                                 const;
0066     ItemInfo deepRowItemInfo(const int rowNumber, const bool relative)                      const;
0067 
0068     void selectAll();
0069     void clearSelection();
0070     void invertSelection();
0071 
0072     ItemInfoList allItemInfos(bool grouping = false)                                        const;
0073     ItemInfoList selectedItemInfos(bool grouping = false)                                   const;
0074     ItemInfoList selectedItemInfosCurrentFirst(bool grouping = false)                       const;
0075     bool          allNeedGroupResolving(const ApplicationSettings::OperationType type)      const;
0076     bool          selectedNeedGroupResolving(const ApplicationSettings::OperationType type) const;
0077 
0078 protected:
0079 
0080     void doLoadState() override;
0081     void doSaveState() override;
0082 
0083     bool eventFilter(QObject* watched, QEvent* event) override;
0084     QList<QAction*> getExtraGroupingActions();
0085 
0086 public Q_SLOTS:
0087 
0088     void slotGoToRow(const int rowNumber, const bool relativeMove);
0089     void slotSetCurrentUrlWhenAvailable(const QUrl& url);
0090     void slotSetCurrentWhenAvailable(const qlonglong id);
0091     void slotAwayFromSelection();
0092     void slotDeleteSelected(const ItemViewUtilities::DeleteMode deleteMode = ItemViewUtilities::DeleteUseTrash);
0093     void slotDeleteSelectedWithoutConfirmation(const ItemViewUtilities::DeleteMode deleteMode = ItemViewUtilities::DeleteUseTrash);
0094     void slotSetActive(const bool isActive);
0095     void slotPaste();
0096     void rename();
0097 
0098 protected Q_SLOTS:
0099 
0100     void slotItemActivated(const QModelIndex& tableViewIndex);
0101     void slotGroupingModeActionTriggered();
0102 
0103 Q_SIGNALS:
0104 
0105     void signalPreviewRequested(const ItemInfo& info);
0106     void signalZoomInStep();
0107     void signalZoomOutStep();
0108     void signalPopupTagsView();
0109     void signalItemsChanged();
0110     void signalInsertSelectedToExistingQueue(int queue);
0111     void signalShowContextMenu(QContextMenuEvent* event,
0112                                const QList<QAction*>& actions);
0113     void signalShowContextMenuOnInfo(QContextMenuEvent* event, const ItemInfo& info,
0114                                      const QList<QAction*>& actions,
0115                                      ItemFilterModel* filterModel = nullptr);
0116 
0117 private:
0118 
0119     class Private;
0120 
0121     const QScopedPointer<Private>         d;
0122     const QScopedPointer<TableViewShared> s;
0123 };
0124 
0125 } // namespace Digikam
0126 
0127 #endif // DIGIKAM_TABLE_VIEW_H