| 1 | /* |
| 2 | This file is part of the KDE Baloo Project |
| 3 | SPDX-FileCopyrightText: 2014 Vishesh Handa <me@vhanda.in> |
| 4 | |
| 5 | SPDX-License-Identifier: LGPL-2.1-or-later |
| 6 | */ |
| 7 | |
| 8 | #ifndef BALOO_PENDINGFILE_H |
| 9 | #define BALOO_PENDINGFILE_H |
| 10 | |
| 11 | #include <QString> |
| 12 | #include <QObject> |
| 13 | |
| 14 | namespace Baloo { |
| 15 | |
| 16 | /** |
| 17 | * Represents a file which needs to be indexed. |
| 18 | */ |
| 19 | class PendingFile |
| 20 | { |
| 21 | public: |
| 22 | explicit PendingFile(const QString& path); |
| 23 | |
| 24 | QString path() const; |
| 25 | |
| 26 | void setAttributeChanged() { m_attributesChanged = true; } |
| 27 | void setClosedOnWrite() { m_closedOnWrite = true; } |
| 28 | void setModified() { m_modified = true; } |
| 29 | void setCreated() { m_created = true; } |
| 30 | void setDeleted() { m_deleted = true; } |
| 31 | |
| 32 | bool isNewFile() const; |
| 33 | bool shouldIndexContents() const; |
| 34 | bool shouldIndexXAttrOnly() const; |
| 35 | bool shouldRemoveIndex() const; |
| 36 | |
| 37 | bool operator == (const PendingFile& rhs) const { |
| 38 | return m_path == rhs.m_path; |
| 39 | } |
| 40 | |
| 41 | /** |
| 42 | * Takes a PendingFile \p file and merges its flags into |
| 43 | * the current PendingFile |
| 44 | */ |
| 45 | void merge(const PendingFile& file); |
| 46 | |
| 47 | private: |
| 48 | QString m_path; |
| 49 | |
| 50 | bool m_created : 1; |
| 51 | bool m_closedOnWrite : 1; |
| 52 | bool m_attributesChanged : 1; |
| 53 | bool m_deleted : 1; |
| 54 | bool m_modified : 1; |
| 55 | |
| 56 | void printFlags() const; |
| 57 | }; |
| 58 | |
| 59 | } |
| 60 | |
| 61 | Q_DECLARE_TYPEINFO(Baloo::PendingFile, Q_RELOCATABLE_TYPE); |
| 62 | |
| 63 | #endif // BALOO_PENDINGFILE_H |
| 64 | |