1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156 | /* ============================================================
*
* This file is a part of digiKam project
* https://www.digikam.org
*
* Date : 2005-04-21
* Description : Handling access to one item and associated data - History
*
* SPDX-FileCopyrightText: 2005 by Renchi Raju <renchi dot raju at gmail dot com>
* SPDX-FileCopyrightText: 2007-2013 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
* SPDX-FileCopyrightText: 2009-2025 by Gilles Caulier <caulier dot gilles at gmail dot com>
* SPDX-FileCopyrightText: 2013 by Michael G. Hansen <mike at mghansen dot de>
*
* SPDX-License-Identifier: GPL-2.0-or-later
*
* ============================================================ */
#include "iteminfo_p.h"
namespace Digikam
{
DImageHistory ItemInfo::imageHistory() const
{
if (!m_data)
{
return DImageHistory();
}
ImageHistoryEntry entry = CoreDbAccess().db()->getItemHistory(m_data->id);
return DImageHistory::fromXml(entry.history);
}
void ItemInfo::setItemHistory(const DImageHistory& history)
{
if (!m_data)
{
return;
}
CoreDbAccess().db()->setItemHistory(m_data->id, history.toXml());
}
bool ItemInfo::hasImageHistory() const
{
if (!m_data)
{
return false;
}
return CoreDbAccess().db()->hasImageHistory(m_data->id);
}
QString ItemInfo::uuid() const
{
if (!m_data)
{
return QString();
}
return CoreDbAccess().db()->getImageUuid(m_data->id);
}
void ItemInfo::setUuid(const QString& uuid)
{
if (!m_data)
{
return;
}
CoreDbAccess().db()->setImageUuid(m_data->id, uuid);
}
HistoryImageId ItemInfo::historyImageId() const
{
if (!m_data)
{
return HistoryImageId();
}
HistoryImageId id(uuid());<--- Shadow variable
id.setCreationDate(dateTime());
id.setFileName(name());
id.setPathOnDisk(filePath());
if (CoreDbAccess().db()->getUniqueHashVersion() > 1)
{
ItemScanInfo info = CoreDbAccess().db()->getItemScanInfo(m_data->id);
id.setUniqueHash(info.uniqueHash, info.fileSize);
}
return id;
}
bool ItemInfo::hasDerivedImages() const
{
if (!m_data)
{
return false;
}
return CoreDbAccess().db()->hasImagesRelatingTo(m_data->id, DatabaseRelation::DerivedFrom);
}
bool ItemInfo::hasAncestorImages() const
{
if (!m_data)
{
return false;
}
return CoreDbAccess().db()->hasImagesRelatedFrom(m_data->id, DatabaseRelation::DerivedFrom);
}
QList<ItemInfo> ItemInfo::derivedImages() const
{
if (!m_data)
{
return QList<ItemInfo>();
}
return ItemInfoList(CoreDbAccess().db()->getImagesRelatingTo(m_data->id, DatabaseRelation::DerivedFrom));
}
QList<ItemInfo> ItemInfo::ancestorImages() const
{
if (!m_data)
{
return QList<ItemInfo>();
}
return ItemInfoList(CoreDbAccess().db()->getImagesRelatedFrom(m_data->id, DatabaseRelation::DerivedFrom));
}
QList<QPair<qlonglong, qlonglong> > ItemInfo::relationCloud() const
{
if (!m_data)
{
return QList<QPair<qlonglong, qlonglong> >();
}
return CoreDbAccess().db()->getRelationCloud(m_data->id, DatabaseRelation::DerivedFrom);
}
void ItemInfo::markDerivedFrom(const ItemInfo& ancestor)
{
if (!m_data || ancestor.isNull())
{
return;
}
CoreDbAccess().db()->addImageRelation(m_data->id, ancestor.id(), DatabaseRelation::DerivedFrom);
}
} // namespace Digikam
|