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

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2010-03-21
0007  * Description : A model to hold GPS information about items.
0008  *
0009  * SPDX-FileCopyrightText: 2010-2024 by Gilles Caulier <caulier dot gilles at gmail dot com>
0010  * SPDX-FileCopyrightText: 2010      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_GPS_ITEM_MODEL_H
0017 #define DIGIKAM_GPS_ITEM_MODEL_H
0018 
0019 // Qt includes
0020 
0021 #include <QAbstractItemModel>
0022 #include <QPixmap>
0023 
0024 // Local includes
0025 
0026 #include "gpsitemcontainer.h"
0027 #include "thumbnailloadthread.h"
0028 #include "digikam_export.h"
0029 
0030 namespace Digikam
0031 {
0032 
0033 class DIGIKAM_EXPORT GPSItemModel : public QAbstractItemModel
0034 {
0035     Q_OBJECT
0036 
0037 public:
0038 
0039     explicit GPSItemModel(QObject* const parent = nullptr);
0040     ~GPSItemModel()                                                                                       override;
0041 
0042     // own functions:
0043 
0044     void addItem(GPSItemContainer* const newItem);
0045     void setColumnCount(const int nColumns);
0046     GPSItemContainer* itemFromIndex(const QModelIndex& index)                                       const;
0047     GPSItemContainer* itemFromUrl(const QUrl& url)                                                  const;
0048     QModelIndex indexFromUrl(const QUrl& url)                                                       const;
0049 
0050     QPixmap getPixmapForIndex(const QPersistentModelIndex& itemIndex, const int size);
0051 
0052     // QAbstractItemModel customizations:
0053 
0054     int columnCount(const QModelIndex& parent = QModelIndex())                                      const override;
0055     bool setData(const QModelIndex& index, const QVariant& value, int role)                               override;
0056     QVariant data(const QModelIndex& index, int role = Qt::DisplayRole)                             const override;
0057     QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex())               const override;
0058     QModelIndex parent(const QModelIndex& index)                                                    const override;
0059     int rowCount(const QModelIndex& parent = QModelIndex())                                         const override;
0060     bool setHeaderData(int section, Qt::Orientation orientation, const QVariant& value, int role)         override;
0061     QVariant headerData(int section, Qt::Orientation orientation, int role)                         const override;
0062     Qt::ItemFlags flags(const QModelIndex& index)                                                   const override;
0063     Qt::DropActions supportedDragActions()                                                          const override;
0064 
0065 protected:
0066 
0067     void itemChanged(GPSItemContainer* const changedItem);
0068 
0069 Q_SIGNALS:
0070 
0071     void signalThumbnailForIndexAvailable(const QPersistentModelIndex& index, const QPixmap& pixmap);
0072 
0073 protected Q_SLOTS:
0074 
0075     void slotThumbnailLoaded(const LoadingDescription&, const QPixmap&);
0076 
0077 private:
0078 
0079     class Private;
0080     Private* const d;
0081 
0082     friend class GPSItemContainer;
0083 };
0084 
0085 } // namespace Digikam
0086 
0087 #endif // DIGIKAM_GPS_ITEM_MODEL_H