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

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2010-07-20
0007  * Description : GPS search marker tiler
0008  *
0009  * SPDX-FileCopyrightText: 2010      by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
0010  * SPDX-FileCopyrightText: 2010      by Gabriel Voicu <ping dot gabi at gmail dot com>
0011  * SPDX-FileCopyrightText: 2010-2011 by Michael G. Hansen <mike at mghansen dot de>
0012  * SPDX-FileCopyrightText: 2015      by Mohamed_Anwer <m_dot_anwer at gmx dot com>
0013  *
0014  * SPDX-License-Identifier: GPL-2.0-or-later
0015  *
0016  * ============================================================ */
0017 
0018 #ifndef DIGIKAM_GPS_MARKER_TILER_H
0019 #define DIGIKAM_GPS_MARKER_TILER_H
0020 
0021 // Qt includes
0022 
0023 #include <QByteArray>
0024 #include <QMetaType>
0025 #include <QItemSelectionModel>
0026 
0027 // Local includes
0028 
0029 #include "abstractmarkertiler.h"
0030 #include "mapwidget.h"
0031 #include "digikam_export.h"
0032 #include "itemposition.h"
0033 #include "coredbchangesets.h"
0034 #include "itemlister.h"
0035 #include "coredbaccess.h"
0036 #include "coredb.h"
0037 #include "iteminfo.h"
0038 #include "thumbnailloadthread.h"
0039 #include "thumbsdbaccess.h"
0040 #include "thumbsdb.h"
0041 #include "coredbwatch.h"
0042 #include "coredbfields.h"
0043 #include "itemalbummodel.h"
0044 #include "itemfiltermodel.h"
0045 
0046 namespace Digikam
0047 {
0048 
0049 class GPSItemInfo;
0050 
0051 class GPSMarkerTiler : public AbstractMarkerTiler
0052 {
0053     Q_OBJECT
0054 
0055 public:
0056 
0057     class MyTile;
0058 
0059     explicit GPSMarkerTiler(QObject* const parent,
0060                             ItemFilterModel* const imageFilterModel,
0061                             QItemSelectionModel* const selectionModel);
0062     ~GPSMarkerTiler()                                                                               override;
0063 
0064     Tile* tileNew()                                                                                 override;
0065     void prepareTiles(const GeoCoordinates& upperLeft, const GeoCoordinates& lowerRight, int level) override;
0066     void regenerateTiles()                                                                          override;
0067     AbstractMarkerTiler::Tile* getTile(const TileIndex& tileIndex, const bool stopIfEmpty)          override;
0068     int getTileMarkerCount(const TileIndex& tileIndex)                                              override;
0069     int getTileSelectedCount(const TileIndex& tileIndex)                                            override;
0070 
0071     QVariant getTileRepresentativeMarker(const TileIndex& tileIndex, const int sortKey)             override;
0072     QVariant bestRepresentativeIndexFromList(const QList<QVariant>& indices, const int sortKey)     override;
0073     QPixmap pixmapFromRepresentativeIndex(const QVariant& index, const QSize& size)                 override;
0074     bool indicesEqual(const QVariant& a, const QVariant& b) const                                   override;
0075     GeoGroupState getTileGroupState(const TileIndex& tileIndex)                                     override;
0076     GeoGroupState getGlobalGroupState()                                                             override;
0077 
0078     void onIndicesClicked(const ClickInfo& clickInfo)                                               override;
0079 
0080     void setActive(const bool state)                                                                override;
0081 
0082     void setRegionSelection(const GeoCoordinates::Pair& sel);
0083     void removeCurrentRegionSelection();
0084     void setPositiveFilterIsActive(const bool state);
0085 
0086 Q_SIGNALS:
0087 
0088     void signalModelFilteredImages(const QList<qlonglong>& imagesId);
0089 
0090 public Q_SLOTS:
0091 
0092     void slotNewModelData(const QList<ItemInfo>& infoList);
0093 
0094 private Q_SLOTS:
0095 
0096     /// @todo Do we monitor all signals of the source models?
0097     void slotMapImagesJobResult();
0098     void slotMapImagesJobData(const QList<ItemListerRecord>& records);
0099     void slotThumbnailLoaded(const LoadingDescription&, const QPixmap&);
0100     void slotImageChange(const ImageChangeset& changeset);
0101     void slotSelectionChanged(const QItemSelection& selected, const QItemSelection& deselected);
0102 
0103 private:
0104 
0105     QList<qlonglong> getTileMarkerIds(const TileIndex& tileIndex);
0106     GeoGroupState getImageState(const qlonglong imageId);
0107     void removeMarkerFromTileAndChildren(const qlonglong imageId,
0108                                          const TileIndex& markerTileIndex);
0109     void addMarkerToTileAndChildren(const qlonglong imageId,
0110                                     const TileIndex& markerTileIndex);
0111 
0112 private:
0113 
0114     class Private;
0115     Private* const d;
0116 };
0117 
0118 } // namespace Digikam
0119 
0120 #endif // DIGIKAM_GPS_MARKER_TILER_H