File indexing completed on 2025-01-05 03:57:58

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2021-09-27
0007  * Description : List-view for the Showfoto stack view.
0008  *
0009  * SPDX-FileCopyrightText: 2021-2024 by Gilles Caulier <caulier dot gilles at gmail dot com>
0010  *
0011  * SPDX-License-Identifier: GPL-2.0-or-later
0012  *
0013  * ============================================================ */
0014 
0015 #ifndef SHOWFOTO_STACK_VIEW_LIST_H
0016 #define SHOWFOTO_STACK_VIEW_LIST_H
0017 
0018 // QT includes
0019 
0020 #include <QList>
0021 #include <QPixmap>
0022 #include <QTreeWidget>
0023 #include <QMouseEvent>
0024 #include <QContextMenuEvent>
0025 #include <QModelIndex>
0026 
0027 // Local includes
0028 
0029 #include "showfotostackviewsidebar.h"
0030 
0031 namespace ShowFoto
0032 {
0033 
0034 class ShowfotoThumbnailBar;
0035 
0036 class ShowfotoStackViewList : public QTreeWidget
0037 {
0038     Q_OBJECT
0039 
0040 public:
0041 
0042     enum StackViewRole
0043     {
0044         FileName = 0,
0045         FileSize,
0046         FileType,
0047         FileDate            ///< Metadata date if exists, else Modifier date
0048     };
0049 
0050     enum ThumbnailSize
0051     {
0052         SizeSmall  = 32,
0053         SizeMedium = 48,
0054         SizeLarge  = 64,
0055         SizeHuge   = 96
0056     };
0057 
0058 public:
0059 
0060     explicit ShowfotoStackViewList(ShowfotoStackViewSideBar* const view);
0061     ~ShowfotoStackViewList()                                            override;
0062 
0063     void setThumbbar(ShowfotoThumbnailBar* const thumbbar);
0064 
0065     ShowfotoItemInfo infoFromIndex(const QModelIndex& index)      const;
0066     QList<QUrl> urls();
0067     QUrl        currentUrl()                                      const;
0068 
0069     int sortOrder()                                               const;
0070     int sortRole()                                                const;
0071 
0072 public Q_SLOTS:
0073 
0074     void slotIconSizeChanged(int);
0075 
0076 Q_SIGNALS:
0077 
0078     void signalItemListChanged(int nbitems);
0079     void signalAddFavorite();
0080     void signalClearItemsList();
0081     void signalRemoveItemInfos(const QList<ShowfotoItemInfo>& infos);
0082     void signalShowfotoItemInfoActivated(const ShowfotoItemInfo& info);
0083 
0084 private:
0085 
0086     void contextMenuEvent(QContextMenuEvent*)                           override;
0087     void mouseMoveEvent(QMouseEvent*)                                   override;
0088     void wheelEvent(QWheelEvent*)                                       override;
0089     void keyPressEvent(QKeyEvent*)                                      override;
0090     void focusOutEvent(QFocusEvent*)                                    override;
0091     void leaveEvent(QEvent*)                                            override;
0092 
0093     void hideToolTip();
0094     bool acceptToolTip(const QModelIndex& index)                  const;
0095 
0096     void drawRow(QPainter* p,
0097                  const QStyleOptionViewItem& opt,
0098                  const QModelIndex& index)                        const override;
0099 
0100 private Q_SLOTS:
0101 
0102     void slotToolTip();
0103     void slotOpenInFileManager();
0104     void slotItemsAdded(const QList<ShowfotoItemInfo>& items);
0105     void slotItemsRemoved(const QList<ShowfotoItemInfo>& items);
0106     void slotItemThumbnail(const ShowfotoItemInfo& info, const QPixmap& pix);
0107     void slotItemsSelected(const QList<ShowfotoItemInfo>& items);
0108     void slotItemsDeselected(const QList<ShowfotoItemInfo>& items);
0109     void slotSelectionChanged(QTreeWidgetItem*);
0110     void slotItemDoubleClicked(QTreeWidgetItem*);
0111     void slotItemsListChanged();
0112     void slotRemoveItems();
0113 
0114 private:
0115 
0116     class Private;
0117     Private* const d;
0118 };
0119 
0120 } // namespace ShowFoto
0121 
0122 #endif // SHOWFOTO_STACK_VIEW_LIST_H