digiKam
gpsitemsortproxymodel.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 : 2010-03-21
7  * Description : A model to hold GPS information about items.
8  *
9  * Copyright (C) 2010-2022 by Gilles Caulier <caulier dot gilles at gmail dot com>
10  * Copyright (C) 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_GPS_ITEM_SORT_PROXY_MODEL_H
26 #define DIGIKAM_GPS_ITEM_SORT_PROXY_MODEL_H
27 
28 // Qt includes
29 
30 #include <QItemSelectionModel>
31 #include <QSortFilterProxyModel>
32 #include <QAbstractItemModel>
33 #include <QModelIndex>
34 #include <QItemSelection>
35 
36 // Local includes
37 
38 #include "gpsitemmodel.h"
39 
40 namespace Digikam
41 {
42 
43 class GPSItemSortProxyModel : public QSortFilterProxyModel
44 {
45  Q_OBJECT
46 
47 public:
48 
49  explicit GPSItemSortProxyModel(GPSItemModel* const imageModel,
50  QItemSelectionModel* const sourceSelectionModel);
51  ~GPSItemSortProxyModel() override;
52 
53  QItemSelectionModel* mappedSelectionModel() const;
54 
55 protected:
56 
57  bool lessThan(const QModelIndex& left,
58  const QModelIndex& right) const override;
59 
60 private:
61 
62  class Private;
63  Private* const d;
64 };
65 
66 // ----------------------------------------------------------------------------------------------------------
67 
68 class GPSLinkItemSelectionModelPrivate;
69 
79 class GPSLinkItemSelectionModel : public QItemSelectionModel
80 {
81  Q_OBJECT
82  Q_PROPERTY(QItemSelectionModel* linkedItemSelectionModel
86 
87 public:
88 
89  GPSLinkItemSelectionModel(QAbstractItemModel* const targetModel,
90  QItemSelectionModel* const linkedItemSelectionModel,
91  QObject* const parent = nullptr);
92  explicit GPSLinkItemSelectionModel(QObject* const parent = nullptr);
93  ~GPSLinkItemSelectionModel() override;
94 
95  QItemSelectionModel* linkedItemSelectionModel() const;
96  void setLinkedItemSelectionModel(QItemSelectionModel* const selectionModel);
97 
98  void select(const QModelIndex& index, QItemSelectionModel::SelectionFlags command) override;
99  void select(const QItemSelection& selection, QItemSelectionModel::SelectionFlags command) override;
100 
101 Q_SIGNALS:
102 
104 
105 protected:
106 
107  GPSLinkItemSelectionModelPrivate* const d_ptr;
108 
109 private:
110 
111  Q_DECLARE_PRIVATE(GPSLinkItemSelectionModel)
112  Q_PRIVATE_SLOT(d_func(), void sourceSelectionChanged(const QItemSelection& selected,
113  const QItemSelection& deselected))
114  Q_PRIVATE_SLOT(d_func(), void sourceCurrentChanged(const QModelIndex& current))
115  Q_PRIVATE_SLOT(d_func(), void slotCurrentChanged(const QModelIndex& current))
116 };
117 
118 // ----------------------------------------------------------------------------------------------------------
119 
120 class GPSModelIndexProxyMapperPrivate;
121 
139 class GPSModelIndexProxyMapper : public QObject
140 {
141  Q_OBJECT
142 
148  Q_PROPERTY(bool isConnected
149  READ isConnected
150  NOTIFY isConnectedChanged)
151 
152 public:
153 
154  explicit GPSModelIndexProxyMapper(const QAbstractItemModel* const leftModel,
155  const QAbstractItemModel* const rightModel,
156  QObject* const parent = nullptr);
157  ~GPSModelIndexProxyMapper() override;
158 
162  QModelIndex mapLeftToRight(const QModelIndex& index) const;
163 
167  QModelIndex mapRightToLeft(const QModelIndex& index) const;
168 
172  QItemSelection mapSelectionLeftToRight(const QItemSelection& selection) const;
173 
177  QItemSelection mapSelectionRightToLeft(const QItemSelection& selection) const;
178 
179  bool isConnected() const;
180 
181 Q_SIGNALS:
182 
184 
185 private:
186 
187  Q_DECLARE_PRIVATE(GPSModelIndexProxyMapper)
188  GPSModelIndexProxyMapperPrivate* const d_ptr;
189 };
190 
191 } // namespace Digikam
192 
193 #endif // DIGIKAM_GPS_ITEM_SORT_PROXY_MODEL_H
Definition: gpsitemmodel.h:43
Definition: gpsitemsortproxymodel.h:44
~GPSItemSortProxyModel() override
Definition: gpsitemsortproxymodel.cpp:65
QItemSelectionModel * mappedSelectionModel() const
Definition: gpsitemsortproxymodel.cpp:87
GPSItemSortProxyModel(GPSItemModel *const imageModel, QItemSelectionModel *const sourceSelectionModel)
Definition: gpsitemsortproxymodel.cpp:54
bool lessThan(const QModelIndex &left, const QModelIndex &right) const override
Definition: gpsitemsortproxymodel.cpp:70
Definition: gpsitemsortproxymodel.h:80
~GPSLinkItemSelectionModel() override
Definition: gpsitemsortproxymodel.cpp:174
void select(const QModelIndex &index, QItemSelectionModel::SelectionFlags command) override
Definition: gpsitemsortproxymodel.cpp:216
GPSLinkItemSelectionModelPrivate *const d_ptr
Definition: gpsitemsortproxymodel.h:107
QItemSelectionModel * linkedItemSelectionModel
Definition: gpsitemsortproxymodel.h:85
void setLinkedItemSelectionModel(QItemSelectionModel *const selectionModel)
Definition: gpsitemsortproxymodel.cpp:186
GPSLinkItemSelectionModel(QAbstractItemModel *const targetModel, QItemSelectionModel *const linkedItemSelectionModel, QObject *const parent=nullptr)
Definition: gpsitemsortproxymodel.cpp:159
Definition: gpsitemsortproxymodel.h:140
Definition: datefolderview.cpp:43