File indexing completed on 2025-01-19 03:58:09

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2010-07-17
0007  * Description : A marker tiler operating on item models
0008  *
0009  * SPDX-FileCopyrightText: 2010-2024 by Gilles Caulier <caulier dot gilles at gmail dot com>
0010  * SPDX-FileCopyrightText: 2010-2011 by Michael G. Hansen <mike at mghansen dot de>
0011  *
0012  * SPDX-License-Identifier: GPL-2.0-or-later
0013  *
0014  * ============================================================ */
0015 
0016 #ifndef ITEM_MARKER_TILER_H
0017 #define ITEM_MARKER_TILER_H
0018 
0019 // Qt includes
0020 
0021 #include <QItemSelection>
0022 
0023 // Local includes
0024 
0025 #include "digikam_export.h"
0026 #include "abstractmarkertiler.h"
0027 
0028 namespace Digikam
0029 {
0030 class GeoModelHelper;
0031 
0032 class DIGIKAM_EXPORT ItemMarkerTiler : public AbstractMarkerTiler
0033 {
0034     Q_OBJECT
0035 
0036 private:
0037 
0038     class MyTile;
0039 
0040 public:
0041 
0042     explicit ItemMarkerTiler(GeoModelHelper* const modelHelper, QObject* const parent = nullptr);
0043     ~ItemMarkerTiler()                                                                                    override;
0044 
0045     TilerFlags tilerFlags()                                                                         const override;
0046     Tile* tileNew()                                                                                       override;
0047     void prepareTiles(const GeoCoordinates& upperLeft, const GeoCoordinates& lowerRight, int level)       override;
0048     void regenerateTiles()                                                                                override;
0049     Tile* getTile(const TileIndex& tileIndex, const bool stopIfEmpty)                                     override;
0050     int getTileMarkerCount(const TileIndex& tileIndex)                                                    override;
0051     int getTileSelectedCount(const TileIndex& tileIndex)                                                  override;
0052 
0053     QVariant getTileRepresentativeMarker(const TileIndex& tileIndex, const int sortKey)                   override;
0054     QVariant bestRepresentativeIndexFromList(const QList<QVariant>& indices, const int sortKey)           override;
0055     QPixmap pixmapFromRepresentativeIndex(const QVariant& index, const QSize& size)                       override;
0056     bool indicesEqual(const QVariant& a, const QVariant& b)                                         const override;
0057     GeoGroupState getTileGroupState(const TileIndex& tileIndex)                                           override;
0058     GeoGroupState getGlobalGroupState()                                                                   override;
0059 
0060     void onIndicesClicked(const ClickInfo& clickInfo)                                                     override;
0061     void onIndicesMoved(const TileIndex::List& tileIndicesList,
0062                                 const GeoCoordinates& targetCoordinates,
0063                                 const QPersistentModelIndex& targetSnapIndex)                             override;
0064 
0065     void setMarkerGeoModelHelper(GeoModelHelper* const modelHelper);
0066     void removeMarkerIndexFromGrid(const QModelIndex& markerIndex, const bool ignoreSelection = false);
0067     void addMarkerIndexToGrid(const QPersistentModelIndex& markerIndex);
0068 
0069     void setActive(const bool state)                                                                      override;
0070 
0071 private Q_SLOTS:
0072 
0073     void slotSourceModelRowsInserted(const QModelIndex& parentIndex, int start, int end);
0074     void slotSourceModelRowsAboutToBeRemoved(const QModelIndex& parentIndex, int start, int end);
0075     void slotSourceModelDataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight);
0076     void slotSourceModelReset();
0077     void slotSelectionChanged(const QItemSelection& selected, const QItemSelection& deselected);
0078     void slotThumbnailAvailableForIndex(const QPersistentModelIndex& index, const QPixmap& pixmap);
0079     void slotSourceModelLayoutChanged();
0080 
0081 private:
0082 
0083     QList<QPersistentModelIndex> getTileMarkerIndices(const TileIndex& tileIndex);
0084 
0085 private:
0086 
0087     class Private;
0088     Private* const d;
0089 };
0090 
0091 } // namespace Digikam
0092 
0093 #endif // ITEM_MARKER_TILER_H