File indexing completed on 2025-03-09 03:52:55

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2007-09-19
0007  * Description : Scanning a single item - private containers.
0008  *
0009  * SPDX-FileCopyrightText: 2007-2013 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
0010  * SPDX-FileCopyrightText: 2013-2024 by Gilles Caulier <caulier dot gilles at gmail dot com>
0011  *
0012  * SPDX-License-Identifier: GPL-2.0-or-later
0013  *
0014  * ============================================================ */
0015 
0016 #include "itemscanner_p.h"
0017 
0018 namespace Digikam
0019 {
0020 
0021 ItemScannerCommit::ItemScannerCommit()
0022     : operation(NoOp),
0023       copyImageAttributesId(-1),
0024       commitItemInformation(false),
0025       commitImageMetadata  (false),
0026       commitVideoMetadata  (false),
0027       commitItemPosition   (false),
0028       commitItemComments   (false),
0029       commitItemCopyright  (false),
0030       commitFaces          (false),
0031       commitIPTCCore       (false),
0032       hasColorTag          (false),
0033       hasPickTag           (false)
0034 {
0035 }
0036 
0037 // ---------------------------------------------------------------------------------------
0038 
0039 LessThanByProximityToSubject::LessThanByProximityToSubject(const ItemInfo& subject)
0040     : subject(subject)
0041 {
0042 }
0043 
0044 bool LessThanByProximityToSubject::operator()(const ItemInfo& a, const ItemInfo& b)
0045 {
0046     if (a.isNull() || b.isNull())
0047     {
0048         // both null: false
0049         // only a null: a greater than b (null infos at end of list)
0050         //  (a && b) || (a && !b) = a
0051         // only b null: a less than b
0052 
0053         if (a.isNull())
0054         {
0055             return false;
0056         }
0057 
0058         return true;
0059     }
0060 
0061     if (a == b)
0062     {
0063         return false;
0064     }
0065 
0066     // same collection
0067 
0068     if (a.albumId() != b.albumId())
0069     {
0070         // same album
0071 
0072         if (a.albumId() == subject.albumId())
0073         {
0074             return true;
0075         }
0076 
0077         if (b.albumId() == subject.albumId())
0078         {
0079             return false;
0080         }
0081 
0082         if (a.albumRootId() != b.albumRootId())
0083         {
0084             // different collection
0085 
0086             if (a.albumRootId() == subject.albumRootId())
0087             {
0088                 return true;
0089             }
0090 
0091             if (b.albumRootId() == subject.albumRootId())
0092             {
0093                 return false;
0094             }
0095         }
0096     }
0097 
0098     if (a.modDateTime() != b.modDateTime())
0099     {
0100         return (a.modDateTime() < b.modDateTime());
0101     }
0102 
0103     if (a.name() != b.name())
0104     {
0105         return qAbs(a.name().compare(subject.name())) < qAbs(b.name().compare(subject.name()));
0106     }
0107 
0108     // last resort
0109 
0110     return (a.id() < b.id());
0111 }
0112 
0113 // ---------------------------------------------------------------------------
0114 
0115 ItemScanner::Private::Private()
0116     : hasImage            (false),
0117       hasMetadata         (false),
0118       loadedFromDisk      (false),
0119       metadata            (new DMetadata),
0120       scanMode            (ModifiedScan),
0121       hasHistoryToResolve(false)
0122 {
0123     timer.start();
0124 }
0125 
0126 ItemScanner::Private::~Private()
0127 {
0128     delete metadata;
0129 }
0130 
0131 } // namespace Digikam