File indexing completed on 2025-01-05 03:54:04
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2010-10-23 0007 * Description : Graph data class for item history 0008 * 0009 * SPDX-FileCopyrightText: 2010-2011 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de> 0010 * 0011 * SPDX-License-Identifier: GPL-2.0-or-later 0012 * 0013 * ============================================================ */ 0014 0015 #ifndef DIGIKAM_ITEM_HISTORY_GRAPH_DATA_H 0016 #define DIGIKAM_ITEM_HISTORY_GRAPH_DATA_H 0017 0018 // Qt includes 0019 0020 #include <QSharedData> 0021 0022 // Local includes 0023 0024 #include "filteraction.h" 0025 #include "historyimageid.h" 0026 #include "itemhistorygraph_boost.h" 0027 0028 namespace Digikam 0029 { 0030 0031 class ItemInfo; 0032 0033 /** 0034 * Every vertex has one associated object of this class 0035 * 0036 * All entries in a vertex refer to _identical_ images. 0037 * There can be multiple referred images in a history entry. 0038 * Each single HistoryImageId can resolve into none, one, 0039 * or multiple ItemInfos. 0040 * So there is no mapping between the two fields here. 0041 * 0042 * If an image is created from multiple source images (panorama etc.), 0043 * there will be one vertex per source image! 0044 */ 0045 class DIGIKAM_DATABASE_EXPORT HistoryVertexProperties 0046 { 0047 public: 0048 0049 ItemInfo firstItemInfo() const; 0050 0051 bool markedAs(HistoryImageId::Type) const; 0052 bool alwaysMarkedAs(HistoryImageId::Type) const; 0053 0054 bool operator==(const QString& uuid) const; 0055 bool operator==(const ItemInfo& info) const; 0056 bool operator==(qlonglong id) const; 0057 bool operator==(const HistoryImageId& info) const; 0058 0059 HistoryVertexProperties& operator+=(const QString& uuid); 0060 HistoryVertexProperties& operator+=(const ItemInfo& info); 0061 HistoryVertexProperties& operator+=(const HistoryImageId& info); 0062 0063 public: 0064 0065 QString uuid; 0066 QList<HistoryImageId> referredImages; 0067 QList<ItemInfo> infos; 0068 }; 0069 0070 QDebug operator<<(QDebug dbg, const HistoryVertexProperties& props); 0071 QDebug operator<<(QDebug dbg, const HistoryImageId& id); 0072 0073 // ------------------------------------------------------------------------------ 0074 0075 /** 0076 * Every edge has one associated object of this class. 0077 * 0078 * For two vertices v1, v2 with and edge e, v1 -> v2, 0079 * describes the actions necessary to create v2 from v2: 0080 * v1 -> actions[0] -> ... -> actions[n] = v2. 0081 */ 0082 class DIGIKAM_DATABASE_EXPORT HistoryEdgeProperties 0083 { 0084 public: 0085 0086 QList<FilterAction> actions; 0087 0088 HistoryEdgeProperties& operator+=(const FilterAction& action); 0089 }; 0090 0091 typedef Graph<HistoryVertexProperties, HistoryEdgeProperties> HistoryGraph; 0092 0093 // ------------------------------------------------------------------------------ 0094 0095 class DIGIKAM_DATABASE_EXPORT ItemHistoryGraphData : public HistoryGraph, // clazy:exclude=copyable-polymorphic 0096 public QSharedData 0097 { 0098 public: 0099 0100 ItemHistoryGraphData() 0101 : HistoryGraph(ChildToParent) 0102 { 0103 } 0104 0105 explicit ItemHistoryGraphData(const HistoryGraph& g) 0106 : HistoryGraph(g) 0107 { 0108 } 0109 0110 ItemHistoryGraphData& operator=(const HistoryGraph& g) 0111 { 0112 HistoryGraph::operator=(g); 0113 0114 return *this; 0115 } 0116 0117 Vertex addVertex(const HistoryImageId& id); 0118 Vertex addVertex(const QList<HistoryImageId>& imageIds); 0119 Vertex addVertex(qlonglong id); 0120 Vertex addVertexScanned(qlonglong id); 0121 Vertex addVertex(const ItemInfo& info); 0122 0123 void addHistory(const DImageHistory& givenHistory, qlonglong extraCurrent = 0); 0124 0125 int removeNextUnresolvedVertex(int begin); 0126 0127 inline QList<ItemInfo> toInfoList(const QList<Vertex>& vertices) const 0128 { 0129 QList<ItemInfo> infos; 0130 0131 Q_FOREACH (const HistoryGraph::Vertex& v, vertices) 0132 { 0133 infos << properties(v).infos; 0134 } 0135 0136 return infos; 0137 } 0138 0139 QHash<Vertex, HistoryImageId::Types> categorize() const; 0140 0141 protected: 0142 0143 void applyProperties(Vertex& v, const QList<ItemInfo>& infos, const QList<HistoryImageId>& ids); 0144 }; 0145 0146 } // namespace Digikam 0147 0148 #endif // DIGIKAM_ITEM_HISTORY_GRAPH_DATA_H