File indexing completed on 2025-01-19 03:53:29
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2007-12-01 0007 * Description : Core database recording changes. 0008 * 0009 * SPDX-FileCopyrightText: 2007-2008 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de> 0010 * 0011 * SPDX-License-Identifier: GPL-2.0-or-later 0012 * 0013 * ============================================================ */ 0014 0015 #include "coredbchangesets.h" 0016 0017 namespace Digikam 0018 { 0019 0020 ImageChangeset::ImageChangeset() 0021 { 0022 } 0023 0024 ImageChangeset::ImageChangeset(const QList<qlonglong>& ids, const DatabaseFields::Set& changes) 0025 : m_ids (ids), 0026 m_changes(changes) 0027 { 0028 } 0029 0030 ImageChangeset::ImageChangeset(qlonglong id, const DatabaseFields::Set& changes) 0031 : m_changes(changes) 0032 { 0033 m_ids << id; 0034 } 0035 0036 QList<qlonglong> ImageChangeset::ids() const 0037 { 0038 return m_ids; 0039 } 0040 0041 bool ImageChangeset::containsImage(qlonglong id) const 0042 { 0043 return m_ids.contains(id); 0044 } 0045 0046 DatabaseFields::Set ImageChangeset::changes() const 0047 { 0048 return m_changes; 0049 } 0050 0051 #ifdef HAVE_DBUS 0052 0053 ImageChangeset& ImageChangeset::operator<<(const QDBusArgument& argument) 0054 { 0055 argument.beginStructure(); 0056 argument >> m_ids >> m_changes; 0057 argument.endStructure(); 0058 return *this; 0059 } 0060 0061 const ImageChangeset& ImageChangeset::operator>>(QDBusArgument& argument) const 0062 { 0063 argument.beginStructure(); 0064 argument << m_ids << m_changes; 0065 argument.endStructure(); 0066 return *this; 0067 } 0068 0069 #endif // HAVE_DBUS 0070 0071 // --------------------------------------------------------------------------------- 0072 0073 ImageTagChangeset::ImageTagChangeset() 0074 : m_operation(Unknown) 0075 { 0076 } 0077 0078 ImageTagChangeset::ImageTagChangeset(const QList<qlonglong>& ids, const QList<int>& tags, Operation op) 0079 : m_ids (ids), 0080 m_tags (tags), 0081 m_operation(op) 0082 { 0083 } 0084 0085 ImageTagChangeset::ImageTagChangeset(qlonglong id, const QList<int>& tags, Operation op) 0086 : m_tags (tags), 0087 m_operation(op) 0088 { 0089 m_ids << id; 0090 } 0091 0092 ImageTagChangeset::ImageTagChangeset(qlonglong id, int tag, Operation op) 0093 : m_operation(op) 0094 { 0095 m_ids << id; 0096 m_tags << tag; 0097 } 0098 0099 ImageTagChangeset& ImageTagChangeset::operator<<(const ImageTagChangeset& other) 0100 { 0101 if (m_operation != other.m_operation) 0102 { 0103 m_operation = Unknown; 0104 } 0105 0106 m_ids << other.m_ids; 0107 m_tags << other.m_tags; 0108 0109 return *this; 0110 } 0111 0112 #ifdef HAVE_DBUS 0113 0114 ImageTagChangeset& ImageTagChangeset::operator<<(const QDBusArgument& argument) 0115 { 0116 argument.beginStructure(); 0117 int intValue; 0118 argument >> m_ids >> m_tags >> intValue; 0119 m_operation = (Operation)intValue; 0120 argument.endStructure(); 0121 return *this; 0122 } 0123 0124 const ImageTagChangeset& ImageTagChangeset::operator>>(QDBusArgument& argument) const 0125 { 0126 argument.beginStructure(); 0127 argument << m_ids << m_tags << (int)m_operation; 0128 argument.endStructure(); 0129 return *this; 0130 } 0131 0132 #endif 0133 0134 QList<qlonglong> ImageTagChangeset::ids() const 0135 { 0136 return m_ids; 0137 } 0138 0139 bool ImageTagChangeset::containsImage(qlonglong id) const 0140 { 0141 return m_ids.contains(id); 0142 } 0143 0144 QList<int> ImageTagChangeset::tags() const 0145 { 0146 return m_tags; 0147 } 0148 0149 bool ImageTagChangeset::containsTag(int id) const 0150 { 0151 return (m_operation == RemovedAll) || m_tags.contains(id); 0152 } 0153 0154 ImageTagChangeset::Operation ImageTagChangeset::operation() const 0155 { 0156 return m_operation; 0157 } 0158 0159 // --------------------------------------------------------------------------------- 0160 0161 CollectionImageChangeset::CollectionImageChangeset() 0162 : m_operation(Unknown) 0163 { 0164 } 0165 0166 CollectionImageChangeset::CollectionImageChangeset(const QList<qlonglong>& ids, const QList<int>& albums, Operation op) 0167 : m_ids (ids), 0168 m_albums (albums), 0169 m_operation(op) 0170 { 0171 } 0172 0173 CollectionImageChangeset::CollectionImageChangeset(const QList<qlonglong>& ids, int album, Operation op) 0174 : m_ids (ids), 0175 m_operation(op) 0176 { 0177 m_albums << album; 0178 } 0179 0180 CollectionImageChangeset::CollectionImageChangeset(qlonglong id, int album, Operation op) 0181 : m_operation(op) 0182 { 0183 m_ids << id; 0184 m_albums << album; 0185 } 0186 0187 CollectionImageChangeset& CollectionImageChangeset::operator<<(const CollectionImageChangeset& other) 0188 { 0189 if (m_operation != other.m_operation) 0190 { 0191 m_operation = Unknown; 0192 } 0193 0194 m_ids << other.m_ids; 0195 m_albums << other.m_albums; 0196 0197 return *this; 0198 } 0199 0200 #ifdef HAVE_DBUS 0201 0202 CollectionImageChangeset& CollectionImageChangeset::operator<<(const QDBusArgument& argument) 0203 { 0204 argument.beginStructure(); 0205 int intValue; 0206 argument >> m_ids >> m_albums >> intValue; 0207 m_operation = (Operation)intValue; 0208 argument.endStructure(); 0209 return *this; 0210 } 0211 0212 const CollectionImageChangeset& CollectionImageChangeset::operator>>(QDBusArgument& argument) const 0213 { 0214 argument.beginStructure(); 0215 argument << m_ids << m_albums << (int)m_operation; 0216 argument.endStructure(); 0217 return *this; 0218 } 0219 0220 #endif 0221 0222 QList<qlonglong> CollectionImageChangeset::ids() const 0223 { 0224 return m_ids; 0225 } 0226 0227 bool CollectionImageChangeset::containsImage(qlonglong id) const 0228 { 0229 return (m_operation == RemovedAll) || m_ids.contains(id); 0230 } 0231 0232 QList<int> CollectionImageChangeset::albums() const 0233 { 0234 return m_albums; 0235 } 0236 0237 bool CollectionImageChangeset::containsAlbum(int id) const 0238 { 0239 return m_albums.contains(id); 0240 } 0241 0242 CollectionImageChangeset::Operation CollectionImageChangeset::operation() const 0243 { 0244 return m_operation; 0245 } 0246 0247 // --------------------------------------------------------------------------------- 0248 0249 AlbumChangeset::AlbumChangeset() 0250 : m_id(-1), 0251 m_operation(Unknown) 0252 { 0253 } 0254 0255 AlbumChangeset::AlbumChangeset(int albumId, Operation operation) 0256 : m_id(albumId), 0257 m_operation(operation) 0258 { 0259 } 0260 0261 int AlbumChangeset::albumId() const 0262 { 0263 return m_id; 0264 } 0265 0266 AlbumChangeset::Operation AlbumChangeset::operation() const 0267 { 0268 return m_operation; 0269 } 0270 0271 #ifdef HAVE_DBUS 0272 0273 AlbumChangeset& AlbumChangeset::operator<<(const QDBusArgument& argument) 0274 { 0275 argument.beginStructure(); 0276 int intValue; 0277 argument >> m_id >> intValue; 0278 m_operation = (Operation)intValue; 0279 argument.endStructure(); 0280 return *this; 0281 } 0282 0283 const AlbumChangeset& AlbumChangeset::operator>>(QDBusArgument& argument) const 0284 { 0285 argument.beginStructure(); 0286 argument << m_id << (int)m_operation; 0287 argument.endStructure(); 0288 return *this; 0289 } 0290 0291 #endif 0292 0293 // --------------------------------------------------------------------------------- 0294 0295 TagChangeset::TagChangeset() 0296 : m_id(-1), 0297 m_operation(Unknown) 0298 { 0299 } 0300 0301 TagChangeset::TagChangeset(int tagId, Operation operation) 0302 : m_id(tagId), 0303 m_operation(operation) 0304 { 0305 } 0306 0307 int TagChangeset::tagId() const 0308 { 0309 return m_id; 0310 } 0311 0312 TagChangeset::Operation TagChangeset::operation() const 0313 { 0314 return m_operation; 0315 } 0316 0317 #ifdef HAVE_DBUS 0318 0319 TagChangeset& TagChangeset::operator<<(const QDBusArgument& argument) 0320 { 0321 argument.beginStructure(); 0322 int intValue; 0323 argument >> m_id >> intValue; 0324 m_operation = (Operation)intValue; 0325 argument.endStructure(); 0326 return *this; 0327 } 0328 0329 const TagChangeset& TagChangeset::operator>>(QDBusArgument& argument) const 0330 { 0331 argument.beginStructure(); 0332 argument << m_id << (int)m_operation; 0333 argument.endStructure(); 0334 return *this; 0335 } 0336 0337 #endif 0338 0339 // --------------------------------------------------------------------------------- 0340 0341 AlbumRootChangeset::AlbumRootChangeset() 0342 : m_id(-1), 0343 m_operation(Unknown) 0344 { 0345 } 0346 0347 AlbumRootChangeset::AlbumRootChangeset(int albumId, Operation operation) 0348 : m_id(albumId), 0349 m_operation(operation) 0350 { 0351 } 0352 0353 int AlbumRootChangeset::albumRootId() const 0354 { 0355 return m_id; 0356 } 0357 0358 AlbumRootChangeset::Operation AlbumRootChangeset::operation() const 0359 { 0360 return m_operation; 0361 } 0362 0363 #ifdef HAVE_DBUS 0364 0365 AlbumRootChangeset& AlbumRootChangeset::operator<<(const QDBusArgument& argument) 0366 { 0367 argument.beginStructure(); 0368 int intValue; 0369 argument >> m_id >> intValue; 0370 m_operation = (Operation)intValue; 0371 argument.endStructure(); 0372 return *this; 0373 } 0374 0375 const AlbumRootChangeset& AlbumRootChangeset::operator>>(QDBusArgument& argument) const 0376 { 0377 argument.beginStructure(); 0378 argument << m_id << (int)m_operation; 0379 argument.endStructure(); 0380 return *this; 0381 } 0382 0383 #endif 0384 0385 // --------------------------------------------------------------------------------- 0386 0387 SearchChangeset::SearchChangeset() 0388 : m_id(-1), 0389 m_operation(Unknown) 0390 { 0391 } 0392 0393 SearchChangeset::SearchChangeset(int albumId, Operation operation) 0394 : m_id(albumId), 0395 m_operation(operation) 0396 { 0397 } 0398 0399 int SearchChangeset::searchId() const 0400 { 0401 return m_id; 0402 } 0403 0404 SearchChangeset::Operation SearchChangeset::operation() const 0405 { 0406 return m_operation; 0407 } 0408 0409 #ifdef HAVE_DBUS 0410 0411 SearchChangeset& SearchChangeset::operator<<(const QDBusArgument& argument) 0412 { 0413 argument.beginStructure(); 0414 int intValue; 0415 argument >> m_id >> intValue; 0416 m_operation = (Operation)intValue; 0417 argument.endStructure(); 0418 return *this; 0419 } 0420 0421 const SearchChangeset& SearchChangeset::operator>>(QDBusArgument& argument) const 0422 { 0423 argument.beginStructure(); 0424 argument << m_id << (int)m_operation; 0425 argument.endStructure(); 0426 return *this; 0427 } 0428 0429 #endif 0430 0431 // --------------------------------------------------------------------------------- 0432 0433 #ifdef HAVE_DBUS 0434 0435 DatabaseFields::Set& DatabaseFields::Set::operator<<(const QDBusArgument& argument) 0436 { 0437 argument.beginStructure(); 0438 0439 int imagesInt, imageInformationInt, imageMetadataInt, imageCommentsInt, imagePositionsInt, customEnumInt, videoMetadataInt; 0440 0441 argument >> imagesInt 0442 >> imageInformationInt 0443 >> imageMetadataInt 0444 >> imageCommentsInt 0445 >> imagePositionsInt 0446 >> customEnumInt 0447 >> videoMetadataInt; 0448 0449 images = (DatabaseFields::Images)imagesInt; 0450 imageInformation = (DatabaseFields::ItemInformation)imageInformationInt; 0451 imageMetadata = (DatabaseFields::ImageMetadata)imageMetadataInt; 0452 imageComments = (DatabaseFields::ItemComments)imageCommentsInt; 0453 imagePositions = (DatabaseFields::ItemPositions)imagePositionsInt; 0454 customEnum = (DatabaseFields::CustomEnum)customEnumInt; 0455 videoMetadata = (DatabaseFields::VideoMetadata)videoMetadataInt; 0456 0457 argument.endStructure(); 0458 return *this; 0459 } 0460 0461 const DatabaseFields::Set& DatabaseFields::Set::operator>>(QDBusArgument& argument) const 0462 { 0463 argument.beginStructure(); 0464 argument << (int)images 0465 << (int) imageInformation 0466 << (int) imageMetadata 0467 << (int) imageComments 0468 << (int) imagePositions 0469 << (int) customEnum 0470 << (int) videoMetadata; 0471 argument.endStructure(); 0472 return *this; 0473 } 0474 0475 #endif 0476 0477 } // namespace Digikam