digiKam
tableview_selection_model_syncer.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 : 2013-02-18
7  * Description : Sync QItemSelectionModel of ItemFilterModel and TableViewModel
8  *
9  * Copyright (C) 2017-2022 by Gilles Caulier <caulier dot gilles at gmail dot com>
10  * Copyright (C) 2013 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) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * ============================================================ */
23 
24 #ifndef DIGIKAM_TABLE_VIEW_SELECTION_MODEL_SYNCER_H
25 #define DIGIKAM_TABLE_VIEW_SELECTION_MODEL_SYNCER_H
26 
27 // Qt includes
28 
29 #include <QItemSelectionModel>
30 #include <QObject>
31 
32 namespace Digikam
33 {
34 
35 class TableViewShared;
36 
37 class TableViewSelectionModelSyncer : public QObject
38 {
39  Q_OBJECT
40 
41 public:
42 
43  explicit TableViewSelectionModelSyncer(TableViewShared* const sharedObject, QObject* const parent = nullptr);
45 
46  QModelIndex toSource(const QModelIndex& targetIndex) const;
47  QModelIndex toTarget(const QModelIndex& sourceIndex) const;
48  QItemSelection itemSelectionToSource(const QItemSelection& selection) const;
49  QItemSelection itemSelectionToTarget(const QItemSelection& selection) const;
50  int targetModelColumnCount() const;
51  QItemSelection targetIndexToRowItemSelection(const QModelIndex& targetIndex) const;
52 
53 private Q_SLOTS:
54 
55  void slotSourceModelReset();
56  void slotSourceCurrentChanged(const QModelIndex& current, const QModelIndex& previous);
57 /*
58  void slotSourceCurrentColumnChanged(const QModelIndex& current, const QModelIndex& previous);
59  void slotSourceCurrentRowChanged(const QModelIndex& current, const QModelIndex& previous);
60 */
61  void slotSourceSelectionChanged(const QItemSelection& selected, const QItemSelection& deselected);
62  void slotTargetCurrentChanged(const QModelIndex& current, const QModelIndex& previous);
63 /*
64  void slotTargetCurrentColumnChanged(const QModelIndex& current, const QModelIndex& previous);
65  void slotTargetCurrentRowChanged(const QModelIndex& current, const QModelIndex& previous);
66 */
67  void slotTargetSelectionChanged(const QItemSelection& selected, const QItemSelection& deselected);
68  void slotTargetColumnsInserted(const QModelIndex& parent, int start, int end);
69  void slotTargetModelRowsInserted(const QModelIndex& parent, int start, int end);
70  void slotTargetModelReset();
71  void slotDoInitialSync();
72 
73 public Q_SLOTS:
74 
75  void slotSetActive(const bool isActive);
76 
77 private:
78 
79  class Private;
80 
81  const QScopedPointer<Private> d;
82  TableViewShared* const s;
83 };
84 
85 } // namespace Digikam
86 
87 #endif // DIGIKAM_TABLE_VIEW_SELECTION_MODEL_SYNCER_H
Definition: tableview_selection_model_syncer.h:38
~TableViewSelectionModelSyncer() override
Definition: tableview_selection_model_syncer.cpp:90
void slotSetActive(const bool isActive)
Definition: tableview_selection_model_syncer.cpp:313
TableViewSelectionModelSyncer(TableViewShared *const sharedObject, QObject *const parent=nullptr)
Definition: tableview_selection_model_syncer.cpp:52
QModelIndex toSource(const QModelIndex &targetIndex) const
Definition: tableview_selection_model_syncer.cpp:94
int targetModelColumnCount() const
Definition: tableview_selection_model_syncer.cpp:104
QItemSelection itemSelectionToTarget(const QItemSelection &selection) const
Definition: tableview_selection_model_syncer.cpp:189
QItemSelection itemSelectionToSource(const QItemSelection &selection) const
Definition: tableview_selection_model_syncer.cpp:165
QModelIndex toTarget(const QModelIndex &sourceIndex) const
Definition: tableview_selection_model_syncer.cpp:99
QItemSelection targetIndexToRowItemSelection(const QModelIndex &targetIndex) const
Definition: tableview_selection_model_syncer.cpp:109
Definition: tableview_shared.h:44
Definition: datefolderview.cpp:43