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

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2013-03-02
0007  * Description : Table view: Tree view subelement
0008  *
0009  * SPDX-FileCopyrightText: 2017-2024 by Gilles Caulier <caulier dot gilles at gmail dot com>
0010  * SPDX-FileCopyrightText: 2013      by Michael G. Hansen <mike at mghansen dot de>
0011  *
0012  * SPDX-License-Identifier: GPL-2.0-or-later
0013  *
0014  * ============================================================ */
0015 
0016 #ifndef DIGIKAM_TABLE_VIEW_TREEVIEW_H
0017 #define DIGIKAM_TABLE_VIEW_TREEVIEW_H
0018 
0019 // Qt includes
0020 
0021 #include <QTreeView>
0022 #include <QWidget>
0023 
0024 // Local includes
0025 
0026 #include "digikam_export.h"
0027 #include "dragdropimplementations.h"
0028 #include "itemalbummodel.h"
0029 #include "itemfiltermodel.h"
0030 #include "statesavingobject.h"
0031 #include "tableview_columnfactory.h"
0032 #include "tableview_shared.h"
0033 #include "thumbnailloadthread.h"
0034 #include "groupingviewimplementation.h"
0035 
0036 class QMenu;
0037 class QContextMenuEvent;
0038 
0039 namespace Digikam
0040 {
0041 
0042 /**
0043  * @todo For proper drag-and-drop support, we probably have to implement more
0044  *        of DragDropModelImplementation's functions in the TableViewModel or
0045  *        in the sort model. Subclassing DragDropModelImplementation would not
0046  *        work there, because we want to re-use ItemDragDropHandler.
0047  */
0048 class TableViewTreeView : public QTreeView,
0049                           public DragDropViewImplementation,
0050                           public GroupingViewImplementation
0051 {
0052     Q_OBJECT
0053 
0054 public:
0055 
0056     explicit TableViewTreeView(TableViewShared* const tableViewShared, QWidget* const parent = nullptr);
0057     ~TableViewTreeView()                                               override;
0058 
0059     Album* albumAt(const QPoint& pos) const;
0060 
0061 protected:
0062 
0063     bool eventFilter(QObject* watched, QEvent* event)                  override;
0064 
0065     DECLARE_VIEW_DRAG_DROP_METHODS(QTreeView)
0066 
0067     AbstractItemDragDropHandler* dragDropHandler()               const override;
0068     QModelIndex mapIndexForDragDrop(const QModelIndex& index)    const override;
0069     QPixmap     pixmapForDrag(const QList<QModelIndex>& indexes) const override;
0070     void wheelEvent(QWheelEvent* event)                                override;
0071 
0072     bool hasHiddenGroupedImages(const ItemInfo& info)            const override;
0073 
0074 private:
0075 
0076     void addColumnDescriptionsToMenu(const QList<TableViewColumnDescription>& columnDescriptions, QMenu* const menu);
0077     void showHeaderContextMenu(QEvent* const event);
0078 
0079 private Q_SLOTS:
0080 
0081     void slotHeaderContextMenuAddColumn();
0082     void slotHeaderContextMenuConfigureColumn();
0083     void slotHeaderContextMenuActionRemoveColumnTriggered();
0084     void slotModelGroupingModeChanged();
0085 
0086 Q_SIGNALS:
0087 
0088     void signalZoomInStep();
0089     void signalZoomOutStep();
0090 
0091 private:
0092 
0093     class Private;
0094 
0095     const QScopedPointer<Private> d;
0096     TableViewShared* const        s;
0097 };
0098 
0099 } // namespace Digikam
0100 
0101 #endif // DIGIKAM_TABLE_VIEW_TREEVIEW_H