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

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2010-07-15
0007  * Description : central Map view
0008  *
0009  * SPDX-FileCopyrightText: 2010      by Gabriel Voicu <ping dot gabi at gmail dot com>
0010  * SPDX-FileCopyrightText: 2010      by Michael G. Hansen <mike at mghansen dot de>
0011  * SPDX-FileCopyrightText: 2014-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_MAP_WIDGET_VIEW_H
0018 #define DIGIKAM_MAP_WIDGET_VIEW_H
0019 
0020 // Qt includes
0021 
0022 #include <QWidget>
0023 
0024 // Local includes
0025 
0026 #include "geomodelhelper.h"
0027 #include "digikam_export.h"
0028 #include "dcategorizedsortfilterproxymodel.h"
0029 #include "statesavingobject.h"
0030 #include "itemalbummodel.h"
0031 #include "thumbnailloadthread.h"
0032 #include "itemfiltermodel.h"
0033 #include "camiteminfo.h"
0034 
0035 namespace Digikam
0036 {
0037 
0038 class AlbumWidgetStack;
0039 class ImageChangeset;
0040 
0041 class DIGIKAM_GUI_EXPORT MapWidgetView : public QWidget,
0042                                          public StateSavingObject
0043 {
0044     Q_OBJECT
0045 
0046 public:
0047 
0048     enum Application
0049     {
0050         ApplicationDigikam  = 1,
0051         ApplicationImportUI = 2
0052     };
0053 
0054 public:
0055 
0056     explicit MapWidgetView(QItemSelectionModel* const selectionModel,
0057                            DCategorizedSortFilterProxyModel* const imageFilterModel,
0058                            QWidget* const parent,
0059                            const Application application);
0060     ~MapWidgetView()                        override;
0061 
0062     void setActive(const bool state);
0063     bool getActiveState()            const;
0064 
0065     ItemInfo   currentItemInfo()     const;
0066     CamItemInfo currentCamItemInfo() const;
0067 
0068 private Q_SLOTS:
0069 
0070     void slotModelChanged();
0071     void slotAllTrackFilesReady();
0072     void slotLoadTracksFromAlbums();
0073 
0074 protected:
0075 
0076     void doLoadState()                      override;
0077     void doSaveState()                      override;
0078 
0079 private:
0080 
0081     class Private;
0082     const QScopedPointer<Private> d;
0083 };
0084 
0085 // ----------------------------------------------------------------------------------------------
0086 
0087 class MapViewModelHelper : public GeoModelHelper
0088 {
0089     Q_OBJECT
0090 
0091 public:
0092 
0093     explicit MapViewModelHelper(QItemSelectionModel* const selection,
0094                                 DCategorizedSortFilterProxyModel* const filterModel,
0095                                 QObject* const parent,
0096                                 const MapWidgetView::Application application);
0097     ~MapViewModelHelper()                                                     override;
0098 
0099     QAbstractItemModel* model()                                         const override;
0100     QItemSelectionModel* selectionModel()                               const override;
0101     bool itemCoordinates(const QModelIndex& index,
0102                          GeoCoordinates* const coordinates)             const override;
0103 
0104     QPixmap pixmapFromRepresentativeIndex(const QPersistentModelIndex& index,
0105                                           const QSize& size)                  override;
0106     QPersistentModelIndex bestRepresentativeIndexFromList(const QList<QPersistentModelIndex>& list,
0107                                                           const int sortKey)  override;
0108 
0109     void onIndicesClicked(const QList<QPersistentModelIndex>& clickedIndices) override;
0110 
0111 Q_SIGNALS:
0112 
0113     void signalFilteredImages(const QList<qlonglong>& idList);
0114 
0115 private Q_SLOTS:
0116 
0117     void slotThumbnailLoaded(const LoadingDescription&, const QPixmap&);
0118     void slotThumbnailLoaded(const CamItemInfo& info);
0119     void slotImageChange(const ImageChangeset& changeset);
0120 
0121 private:
0122 
0123     class Private;
0124     const QScopedPointer<Private> d;
0125 };
0126 
0127 } // namespace Digikam
0128 
0129 #endif // DIGIKAM_MAP_WIDGET_VIEW_H