1/*
2 * This file is part of the KDE Baloo Project
3 * Copyright (C) 2013 Vishesh Handa <me@vhanda.in>
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) version 3, or any
9 * later version accepted by the membership of KDE e.V. (or its
10 * successor approved by the membership of KDE e.V.), which shall
11 * act as a proxy defined in Section 6 of version 3 of the license.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
20 *
21 */
22
23#ifndef _BALOO_FILE_H
24#define _BALOO_FILE_H
25
26#include "filefetchjob.h"
27#include <kfilemetadata/properties.h>
28
29namespace Baloo {
30
31class FilePrivate;
32
33/**
34 * @short Provides acess to all File Metadata
35 *
36 * The File class acts as a temporary container for all the file metadata.
37 * It needs to be filled via the FileFetchJob, and any modifications made
38 * are not saved until the FileModifyJob is called.
39 */
40class BALOO_FILE_EXPORT File
41{
42public:
43 File();
44 File(const File& f);
45
46 /**
47 * Constructor
48 *
49 * \p url the local url of the file
50 */
51 File(const QString& url);
52 ~File();
53
54 const File& operator =(const File& f);
55
56 static File fromId(const QByteArray& id);
57
58 /**
59 * The local url of the file
60 */
61 QString url() const;
62 void setUrl(const QString& url);
63
64 /**
65 * Represents a unique identifier for this file. This identifier
66 * is unique and will never change unlike the url of the file
67 */
68 QByteArray id() const;
69 void setId(const QByteArray& id);
70
71 /**
72 * Gives a variant map of the properties that have been extracted
73 * from the file by the indexer
74 */
75 KFileMetaData::PropertyMap properties() const;
76 QVariant property(KFileMetaData::Property::Property property) const;
77
78 /**
79 * Set the rating for the file. This will not be saved until
80 * a FileModifyJob is called
81 */
82 void setRating(int rating);
83 int rating() const;
84
85 /**
86 * Add a tag to the list of tags. This will not be saved until
87 * a FileModifyJob is called.
88 */
89 void addTag(const QString& tag);
90 void setTags(const QStringList& tags);
91 QStringList tags() const;
92
93 QString userComment() const;
94 void setUserComment(const QString& comment);
95
96private:
97 FilePrivate* d;
98 friend class FileFetchJob;
99};
100
101}
102
103#endif // _BALOO_FILE_H
104