digiKam
itemhistorygraph.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-23
7  * Description : Graph data class for item history
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_H
25 #define DIGIKAM_ITEM_HISTORY_GRAPH_H
26 
27 // Qt includes
28 
29 #include <QFlags>
30 #include <QSharedDataPointer>
31 #include <QDebug>
32 
33 // Local includes
34 
35 #include "iteminfo.h"
36 #include "historyimageid.h"
37 #include "digikam_export.h"
38 
39 namespace Digikam
40 {
41 
42 class ItemHistoryGraphData;
43 class DImageHistory;
44 
45 class DIGIKAM_DATABASE_EXPORT ItemHistoryGraph
46 {
47 public:
48 
50  {
52  LoadRelationCloud = 1 << 0,
53 
55  LoadSubjectHistory = 1 << 1,
56 
58  LoadLeavesHistory = 1 << 2,
59 
60  LoadAll = LoadRelationCloud | LoadSubjectHistory | LoadLeavesHistory
61  };
62  Q_DECLARE_FLAGS(HistoryLoadingMode, HistoryLoadingFlag)
63 
65  {
67  PrepareForDisplay
68  };
69 
70 public:
71 
73  ItemHistoryGraph(const ItemHistoryGraph& other);
75 
76  ItemHistoryGraph& operator=(const ItemHistoryGraph& other);
77 
78  bool isNull() const;
79  bool isEmpty() const;
80  bool isSingleVertex() const;
81 
86  bool hasEdges() const;
87 
88  ItemHistoryGraphData& data();
89  const ItemHistoryGraphData& data() const;
90 
97  static ItemHistoryGraph fromInfo(const ItemInfo& info,
98  HistoryLoadingMode loadingMode = LoadAll,
99  ProcessingMode processingMode = PrepareForDisplay);
100 
107  void addHistory(const DImageHistory& history, const ItemInfo& historySubject = ItemInfo());
108  void addHistory(const DImageHistory& history, const HistoryImageId& historySubject = HistoryImageId());
109 
115  void addScannedHistory(const DImageHistory& history, qlonglong historySubjectId);
116 
121  void addRelations(const QList<QPair<qlonglong, qlonglong> >& pairs);
122 
126  void clear();
127 
133  void reduceEdges();
134 
138  bool hasUnresolvedEntries() const;
139 
144  void dropUnresolvedEntries();
145 
149  void sortForInfo(const ItemInfo& subject);
150 
154  void prepareForDisplay(const ItemInfo& subject);
155 
161  QList<QPair<qlonglong, qlonglong> > relationCloud() const;
162  QPair<QList<qlonglong>, QList<qlonglong> > relationCloudParallel() const;
163 
167  QList<ItemInfo> allImages() const;
168  QList<qlonglong> allImageIds() const;
169 
174  QList<ItemInfo> rootImages() const;
175 
180  QList<ItemInfo> leafImages() const;
181 
187  QHash<ItemInfo, HistoryImageId::Types> categorize() const;
188 
189 private:
190 
191  QSharedDataPointer<ItemHistoryGraphData> d;
192 };
193 
194 QDebug DIGIKAM_DATABASE_EXPORT operator<<(QDebug dbg, const ItemHistoryGraph& g);
195 
196 } // namespace Digikam
197 
198 Q_DECLARE_OPERATORS_FOR_FLAGS(Digikam::ItemHistoryGraph::HistoryLoadingMode)
199 
200 #endif // DIGIKAM_ITEM_HISTORY_GRAPH_H
Definition: dimagehistory.h:49
Definition: historyimageid.h:42
Definition: itemhistorygraphdata.h:106
Definition: itemhistorygraph.h:46
HistoryLoadingFlag
Definition: itemhistorygraph.h:50
ProcessingMode
Definition: itemhistorygraph.h:65
@ NoProcessing
Definition: itemhistorygraph.h:66
Definition: iteminfo.h:78
Definition: piwigotalker.h:48
Definition: datefolderview.cpp:43
QDebug operator<<(QDebug dbg, const DbEngineParameters &p)
Definition: dbengineparameters.cpp:863