File indexing completed on 2024-04-28 08:31:13

0001 /*
0002     SPDX-FileCopyrightText: 2019 Stefan BrĂ¼ns <stefan.bruens@rwth-aachen.de>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include <KFileMetaData/Properties>
0008 #include <KFileMetaData/UserMetaData>
0009 #include <QString>
0010 #include <QStringList>
0011 #include <QVariantMap>
0012 
0013 namespace Baloo
0014 {
0015 namespace Private
0016 {
0017 /**
0018  * Converts the UserMetaData attributes into a variant map
0019  *
0020  * /sa: KFileMetaData::UserMetaData
0021  */
0022 QVariantMap convertUserMetaData(const QMap<KFileMetaData::UserMetaData::Attribute, QVariant>& metaData);
0023 
0024 /**
0025  * Fetches the data for the file assiciated with /p metadata
0026  *
0027  * /p wantedAttributes Set of attributes which should be fetched
0028  *
0029  * This may block
0030  * /sa: KFileMetaData::UserMetaData
0031  */
0032 QMap<KFileMetaData::UserMetaData::Attribute, QVariant>
0033 fetchUserMetaData(const KFileMetaData::UserMetaData &metaData, KFileMetaData::UserMetaData::Attributes wantedAttributes);
0034 
0035 /**
0036  * Fetches and converts the data for the file assiciated with /p metadata
0037  *
0038  * This is an amalgation of fetchUserMetaData and convertUserMetaData,
0039  * and thus may block.
0040  */
0041 QVariantMap convertUserMetaData(const KFileMetaData::UserMetaData &metaData);
0042 
0043 /**
0044  * Converts the property map into a variant map using the
0045  * property name as key. In case a key has multiple values,
0046  * all its values are collected in a QVariantList that is
0047  * stored as a single entry.
0048  */
0049 QVariantMap toNamedVariantMap(const KFileMetaData::PropertyMultiMap &propMap);
0050 
0051 /**
0052  * Merges common data for \p files into \p target
0053  *
0054  * Properties where a total makes sense are summed up (e.g. duration or
0055  * wordcount). All other properties are only kept if the values match,
0056  * e.g. when all files have the same "width". Properties which are
0057  * only present for some files are removed.
0058  */
0059 void mergeCommonData(QVariantMap& target, const QList<QVariantMap> &files);
0060 
0061 /*
0062  * Sort tags ie. {"c", "200", "B", "3", "a"} to {"3", "200", "a", "B", "c"}
0063  * It respects locale and will sort numbers correctly.
0064  */
0065 QStringList sortTags(const QStringList &tags);
0066 
0067 } // namespace Private
0068 } // namespace Baloo