Baloo

pendingfilequeue.h
1 /*
2  This file is part of the KDE Baloo project.
3  SPDX-FileCopyrightText: 2011 Sebastian Trueg <[email protected]>
4  SPDX-FileCopyrightText: 2013-2014 Vishesh Handa <[email protected]>
5 
6  SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
7 */
8 
9 #ifndef PENDINGFILEQUEUE_H
10 #define PENDINGFILEQUEUE_H
11 
12 #include "pendingfile.h"
13 
14 #include <QObject>
15 #include <QString>
16 #include <QHash>
17 #include <QTimer>
18 #include <QVector>
19 
20 namespace Baloo {
21 
22 class PendingFileQueueTest;
23 
24 /**
25  *
26  */
27 class PendingFileQueue : public QObject
28 {
29  Q_OBJECT
30 
31 public:
32  explicit PendingFileQueue(QObject* parent = nullptr);
33  ~PendingFileQueue() override;
34 
35 Q_SIGNALS:
36  void indexNewFile(const QString& fileUrl);
37  void indexModifiedFile(const QString& fileUrl);
38  void indexXAttr(const QString& fileUrl);
39  void removeFileIndex(const QString& fileUrl);
40 
41 public Q_SLOTS:
42  void enqueue(const PendingFile& file);
43 
44  /**
45  * The number of seconds the file should be tracked after it has
46  * been emitted. This defaults to 2 minutes
47  */
48  void setTrackingTime(int seconds);
49 
50  /**
51  * Set the minimum amount of seconds a file should be kept in the queue
52  * on receiving successive modifications events.
53  */
54  void setMinimumTimeout(int seconds);
55  void setMaximumTimeout(int seconds);
56 
57 private Q_SLOTS:
58  void processCache(const QTime& currentTime);
59  void processPendingFiles(const QTime& currentTime);
60  void clearRecentlyEmitted(const QTime& currentTime);
61 
62 private:
63  QVector<PendingFile> m_cache;
64 
65  QTimer m_cacheTimer;
66  QTimer m_clearRecentlyEmittedTimer;
67  QTimer m_pendingFilesTimer;
68 
69  /**
70  * Holds the list of files that were recently emitted along with
71  * the time they were last emitted.
72  */
73  QHash<QString, QTime> m_recentlyEmitted;
74 
75  /**
76  * The QTime contains the time when these file events should be processed.
77  */
78  QHash<QString, QTime> m_pendingFiles;
79 
80  int m_minTimeout;
81  int m_maxTimeout;
82  int m_trackingTime;
83 
84  friend class PendingFileQueueTest;
85 };
86 
87 }
88 
89 #endif
Q_OBJECTQ_OBJECT
Q_SLOTSQ_SLOTS
Implements storage for docIds without any associated data Instantiated for:
Definition: coding.cpp:11
Q_SIGNALSQ_SIGNALS
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Wed Nov 29 2023 03:56:26 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.