1 /* This file is part of the KDE project
3 Copyright (C) 2008 Lukas Appelhans <l.appelhans@gmx.de>
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
10 #include "nepomukhandler.h"
14 #include <Soprano/Vocabulary/Xesam>
15 #include <Soprano/Vocabulary/NAO>
16 #include <nepomuk/variant.h>
17 #include <nepomuk/tag.h>
19 NepomukHandler::NepomukHandler(Transfer
*transfer
, QObject
*parent
)
21 m_resource(Nepomuk::Resource(transfer
->dest(), Soprano::Vocabulary::Xesam::File())),
26 NepomukHandler::~NepomukHandler()
30 void NepomukHandler::setRating(int rating
)
32 m_resource
.setProperty(Soprano::Vocabulary::NAO::rating(), Nepomuk::Variant(rating
));
35 int NepomukHandler::rating() const
37 return m_resource
.rating();
40 void NepomukHandler::addTag(const QString
&newTag
)
42 m_resource
.addTag(Nepomuk::Tag(newTag
));
45 void NepomukHandler::removeTag(const QString
&oldTag
)
47 QList
<Nepomuk::Tag
> list
= m_resource
.tags();
48 list
.removeAll(Nepomuk::Tag(oldTag
));
49 m_resource
.setTags(list
);
52 QStringList
NepomukHandler::tags() const
55 foreach (const Nepomuk::Tag
&tag
, m_resource
.tags())
56 list
.append(tag
.genericLabel());
60 void NepomukHandler::saveFileProperties()
62 if (!m_resource
.isValid())
64 saveFileProperties(m_resource
);
67 void NepomukHandler::saveFileProperties(const Nepomuk::Resource
&res
)
69 Nepomuk::Resource m_res
= res
;
70 m_res
.setProperty(Soprano::Vocabulary::Xesam::originURL(), Nepomuk::Variant(m_transfer
->source()));
71 m_res
.setProperty(Soprano::Vocabulary::Xesam::size(), Nepomuk::Variant(m_transfer
->totalSize()));
72 m_res
.addTag(Nepomuk::Tag("Downloads"));