digiKam
geomodelhelper.h
Go to the documentation of this file.
1 /* ============================================================
2  *
3  * This file is a part of digiKam project
4  * https://www.digikam.org
5  *
6  * Date : 2009-12-01
7  * Description : Helper class to access models
8  *
9  * Copyright (C) 2010-2022 by Gilles Caulier <caulier dot gilles at gmail dot com>
10  * Copyright (C) 2009-2010 by Michael G. Hansen <mike at mghansen dot de>
11  *
12  * This program is free software; you can redistribute it
13  * and/or modify it under the terms of the GNU General
14  * Public License as published by the Free Software Foundation;
15  * either version 2, or (at your option)
16  * any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * ============================================================ */
24 
25 #ifndef DIGIKAM_GEO_MODEL_HELPER_H
26 #define DIGIKAM_GEO_MODEL_HELPER_H
27 
28 // Qt includes
29 
30 #include <QItemSelectionModel>
31 #include <QPixmap>
32 #include <QAbstractItemModel>
33 #include <QPersistentModelIndex>
34 #include <QPoint>
35 #include <QString>
36 
37 // Local includes
38 
39 #include "geoifacetypes.h"
40 #include "geocoordinates.h"
41 #include "digikam_export.h"
42 
43 namespace Digikam
44 {
45 
46 class DIGIKAM_EXPORT GeoModelHelper : public QObject
47 {
48  Q_OBJECT
49 
50 public:
51 
53  {
54  FlagNull = 0,
55  FlagVisible = 1,
56  FlagMovable = 2,
57  FlagSnaps = 4
58  };
59 
60  Q_DECLARE_FLAGS(PropertyFlags, PropertyFlag)
61 
62 public:
63 
64  explicit GeoModelHelper(QObject* const parent = nullptr);
65  ~GeoModelHelper() override;
66 
67  void snapItemsTo(const QModelIndex& targetIndex,
68  const QList<QPersistentModelIndex>& snappedIndices);
69 
71  virtual QAbstractItemModel* model() const = 0;
72  virtual QItemSelectionModel* selectionModel() const = 0;
73  virtual bool itemCoordinates(const QModelIndex& index,
74  GeoCoordinates* const coordinates) const = 0;
75  virtual PropertyFlags modelFlags() const;
76 
78  virtual bool itemIcon(const QModelIndex& index,
79  QPoint* const offset,
80  QSize* const size,
81  QPixmap* const pixmap,
82  QUrl* const url) const;
83  virtual PropertyFlags itemFlags(const QModelIndex& index) const;
84  virtual void snapItemsTo(const QModelIndex& targetIndex,
85  const QList<QModelIndex>& snappedIndices);
86 
88  virtual QPixmap pixmapFromRepresentativeIndex(const QPersistentModelIndex& index,
89  const QSize& size);
90  virtual QPersistentModelIndex bestRepresentativeIndexFromList(const QList<QPersistentModelIndex>& list,
91  const int sortKey);
92 
93  virtual void onIndicesClicked(const QList<QPersistentModelIndex>& clickedIndices);
94  virtual void onIndicesMoved(const QList<QPersistentModelIndex>& movedIndices,
95  const GeoCoordinates& targetCoordinates,
96  const QPersistentModelIndex& targetSnapIndex);
97 
98 Q_SIGNALS:
99 
101  void signalThumbnailAvailableForIndex(const QPersistentModelIndex& index,
102  const QPixmap& pixmap);
104 };
105 
106 } // namespace Digikam
107 
108 Q_DECLARE_OPERATORS_FOR_FLAGS(Digikam::GeoModelHelper::PropertyFlags)
109 
110 #endif // DIGIKAM_GEO_MODEL_HELPER_H
Definition: geocoordinates.h:49
Helper class to access data in models.
Definition: geomodelhelper.h:47
void signalThumbnailAvailableForIndex(const QPersistentModelIndex &index, const QPixmap &pixmap)
virtual QItemSelectionModel * selectionModel() const =0
virtual QAbstractItemModel * model() const =0
these are necessary for grouped and ungrouped models
PropertyFlag
Definition: geomodelhelper.h:53
virtual bool itemCoordinates(const QModelIndex &index, GeoCoordinates *const coordinates) const =0
void signalModelChangedDrastically()
Definition: datefolderview.cpp:43