Changeset View
Changeset View
Standalone View
Standalone View
src/filefetchjob.cpp
Show All 13 Lines | |||||
14 | * | 14 | * | ||
15 | * You should have received a copy of the GNU Lesser General Public | 15 | * You should have received a copy of the GNU Lesser General Public | ||
16 | * License along with this library; if not, write to the Free Software | 16 | * License along with this library; if not, write to the Free Software | ||
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
18 | * | 18 | * | ||
19 | */ | 19 | */ | ||
20 | 20 | | |||
21 | #include "filefetchjob.h" | 21 | #include "filefetchjob.h" | ||
22 | #include "propertymaputil_p.h" | ||||
22 | 23 | | |||
23 | #include <QTimer> | 24 | #include <QTimer> | ||
24 | #include <Baloo/File> | 25 | #include <Baloo/File> | ||
25 | 26 | | |||
26 | #include <KFileMetaData/UserMetaData> | 27 | #include <KFileMetaData/UserMetaData> | ||
27 | #include <KFileMetaData/PropertyInfo> | 28 | #include <KFileMetaData/PropertyInfo> | ||
28 | 29 | | |||
29 | using namespace Baloo; | 30 | using namespace Baloo; | ||
30 | 31 | | |||
31 | FileFetchJob::FileFetchJob(const QStringList& urls, QObject* parent) | 32 | FileFetchJob::FileFetchJob(const QStringList& urls, QObject* parent) | ||
32 | : KJob(parent) | 33 | : KJob(parent) | ||
33 | , m_urls(urls) | 34 | , m_urls(urls) | ||
34 | { | 35 | { | ||
35 | } | 36 | } | ||
36 | 37 | | |||
37 | void FileFetchJob::start() | 38 | void FileFetchJob::start() | ||
38 | { | 39 | { | ||
39 | QTimer::singleShot(0, this, SLOT(doStart())); | 40 | QTimer::singleShot(0, this, SLOT(doStart())); | ||
40 | } | 41 | } | ||
41 | 42 | | |||
42 | static QVariantMap convertPropertyMap(const KFileMetaData::PropertyMap& propMap) | | |||
43 | { | | |||
44 | QVariantMap map; | | |||
45 | KFileMetaData::PropertyMap::const_iterator it = propMap.constBegin(); | | |||
46 | for (; it != propMap.constEnd(); it++) { | | |||
47 | KFileMetaData::PropertyInfo pi(it.key()); | | |||
48 | map.insertMulti(pi.name(), it.value()); | | |||
49 | } | | |||
50 | | ||||
51 | return map; | | |||
52 | } | | |||
53 | | ||||
54 | void FileFetchJob::doStart() | 43 | void FileFetchJob::doStart() | ||
55 | { | 44 | { | ||
56 | for (const QString& filePath : m_urls) { | 45 | for (const QString& filePath : m_urls) { | ||
57 | Baloo::File file(filePath); | 46 | Baloo::File file(filePath); | ||
58 | file.load(); | 47 | file.load(); | ||
59 | 48 | | |||
60 | QVariantMap prop = convertPropertyMap(file.properties()); | 49 | QVariantMap prop = toNamedVariantMap(file.properties()); | ||
61 | 50 | | |||
62 | KFileMetaData::UserMetaData md(filePath); | 51 | KFileMetaData::UserMetaData md(filePath); | ||
63 | QStringList tags = md.tags(); | 52 | QStringList tags = md.tags(); | ||
64 | if (!tags.isEmpty()) { | 53 | if (!tags.isEmpty()) { | ||
65 | prop.insert("tags", tags); | 54 | prop.insert("tags", tags); | ||
66 | } | 55 | } | ||
67 | 56 | | |||
68 | int rating = md.rating(); | 57 | int rating = md.rating(); | ||
Show All 24 Lines |