digiKam
itemhistorygraphmodel.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-10-27
7  * Description : Model to an ItemHistoryGraph
8  *
9  * Copyright (C) 2010-2011 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
10  *
11  * This program is free software; you can redistribute it
12  * and/or modify it under the terms of the GNU General
13  * Public License as published by the Free Software Foundation;
14  * either version 2, or (at your option)
15  * 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_ITEM_HISTORY_GRAPH_MODEL_H
25 #define DIGIKAM_ITEM_HISTORY_GRAPH_MODEL_H
26 
27 // Qt includes
28 
29 #include <QAbstractItemModel>
30 
31 // Local includes
32 
34 #include "itemhistorygraph.h"
35 #include "digikam_export.h"
36 
37 namespace Digikam
38 {
39 
40 class ItemHistoryGraph;
41 class ItemInfo;
42 class ItemListModel;
43 class FilterAction;
44 
45 class DIGIKAM_DATABASE_EXPORT ItemHistoryGraphModel : public QAbstractItemModel,
47 {
48  Q_OBJECT
49 
50 public:
51 
52  enum Mode
53  {
56  CombinedTreeMode
57  };
58 
60  {
61  IsImageItemRole = Qt::UserRole + 1000,
62  IsFilterActionItemRole = Qt::UserRole + 1001,
63  IsHeaderItemRole = Qt::UserRole + 1002,
64  IsCategoryItemRole = Qt::UserRole + 1003,
65  IsSeparatorItemRole = Qt::UserRole + 1004,
66 
67  IsSubjectImageRole = Qt::UserRole + 1010,
68 
69  FilterActionRole = Qt::UserRole + 1020
70  };
71 
72 public:
73 
74  explicit ItemHistoryGraphModel(QObject* const parent = nullptr);
75  ~ItemHistoryGraphModel() override;
76 
77  void setMode(Mode mode);
78  Mode mode() const;
79 
84  void setHistory(const ItemInfo& subject,
85  const ItemHistoryGraph& graph = ItemHistoryGraph());
86 
87  ItemInfo subject() const;
88 
89  bool isImage(const QModelIndex& index) const;
90  bool hasImage(const ItemInfo& info);
91  ItemInfo imageInfo(const QModelIndex& index) const;
92 
94  QModelIndex indexForInfo(const ItemInfo& info) const;
95 
96  bool isFilterAction(const QModelIndex& index) const;
97  FilterAction filterAction(const QModelIndex& index) const;
98 
101  QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
102  int rowCount(const QModelIndex& parent = QModelIndex()) const override;
103  int columnCount(const QModelIndex& parent = QModelIndex()) const override;
104  Qt::ItemFlags flags(const QModelIndex& index) const override;
105  bool hasChildren(const QModelIndex& parent = QModelIndex()) const override;
106  QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const override;
107  QModelIndex parent(const QModelIndex& index) const override;
108  QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
109  bool setData(const QModelIndex& index, const QVariant& value, int role) override;
111 
113 
118  ItemListModel* imageModel() const;
119 
125  QModelIndex imageModelIndex(const QModelIndex& index) const;
126 
127 private:
128 
129  // Disable
131  ItemHistoryGraphModel& operator=(const ItemHistoryGraphModel&) = delete;
132 
133  class Private;
134  Private* const d;
135 };
136 
137 } // namespace Digikam
138 
139 #endif // DIGIKAM_ITEM_HISTORY_GRAPH_MODEL_H
Definition: dragdropimplementations.h:40
Definition: filteraction.h:43
Definition: itemhistorygraphmodel.h:47
ExtraRoles
Definition: itemhistorygraphmodel.h:60
Mode
Definition: itemhistorygraphmodel.h:53
@ ImagesTreeMode
Definition: itemhistorygraphmodel.h:55
@ ImagesListMode
Definition: itemhistorygraphmodel.h:54
Definition: itemhistorygraph.h:46
Definition: iteminfo.h:78
Definition: itemlistmodel.h:39
#define DECLARE_MODEL_DRAG_DROP_METHODS
Definition: dragdropimplementations.h:90
qulonglong value
Definition: itemviewutilities.cpp:592
@ Orientation
Definition: coredbfields.h:86
Definition: datefolderview.cpp:43