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 - baloo helper. 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 #ifdef HAVE_KFILEMETADATA 0019 # include "baloowrap.h" 0020 #endif 0021 0022 namespace Digikam 0023 { 0024 0025 void ItemScanner::scanBalooInfo() 0026 { 0027 0028 #ifdef HAVE_KFILEMETADATA 0029 0030 BalooWrap* const baloo = BalooWrap::instance(); 0031 0032 if (!baloo->getSyncToDigikam()) 0033 { 0034 return; 0035 } 0036 0037 BalooInfo bInfo = baloo->getSemanticInfo(QUrl::fromLocalFile(d->fileInfo.absoluteFilePath())); 0038 0039 if (!bInfo.tags.isEmpty()) 0040 { 0041 // get tag ids, create if necessary 0042 0043 QList<int> tagIds = TagsCache::instance()->getOrCreateTags(bInfo.tags); 0044 d->commit.tagIds += tagIds; 0045 } 0046 0047 if (bInfo.rating != -1) 0048 { 0049 qCDebug(DIGIKAM_DATABASE_LOG) << "Baloo rating" << bInfo.rating; 0050 0051 if (!d->commit.imageInformationFields.testFlag(DatabaseFields::Rating)) 0052 { 0053 d->commit.imageInformationFields |= DatabaseFields::Rating; 0054 } 0055 else 0056 { 0057 d->commit.imageInformationInfos.removeAt(0); 0058 } 0059 0060 d->commit.imageInformationInfos.insert(0, bInfo.rating); 0061 } 0062 0063 if (!bInfo.comment.isEmpty()) 0064 { 0065 qCDebug(DIGIKAM_DATABASE_LOG) << "Baloo comment" << bInfo.comment; 0066 0067 CaptionValues val; 0068 val.caption = bInfo.comment; 0069 d->commit.commitItemComments = true; 0070 d->commit.captions.insert(QLatin1String("x-default"), val); 0071 } 0072 0073 #endif // HAVE_KFILEMETADATA 0074 0075 } 0076 0077 } // namespace Digikam