Baloo

monitor.h
1/*
2 This file is part of the KDE Baloo Project
3 SPDX-FileCopyrightText: 2015 Pinak Ahuja <pinak.ahuja@gmail.com>
4
5 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
6*/
7
8#ifndef BALOOMONITOR_MONITOR_H
9#define BALOOMONITOR_MONITOR_H
10
11#include <QDeadlineTimer>
12#include <QObject>
13#include <QString>
14#include <qqmlregistration.h>
15
16#include "indexerstate.h"
17#include "schedulerinterface.h"
18#include "fileindexerinterface.h"
19
20struct BalooForeign {
21 Q_GADGET
22 QML_NAMED_ELEMENT(Global)
23 QML_FOREIGN_NAMESPACE(Baloo)
24};
25
26namespace Baloo {
27class Monitor : public QObject
28{
30 QML_ELEMENT
31
32 Q_PROPERTY(QString filePath READ filePath NOTIFY newFileIndexed)
33 Q_PROPERTY(QString suspendState READ suspendState NOTIFY indexerStateChanged)
34 Q_PROPERTY(bool balooRunning MEMBER m_balooRunning NOTIFY balooStateChanged)
35 Q_PROPERTY(uint totalFiles MEMBER m_totalFiles NOTIFY totalFilesChanged)
36 Q_PROPERTY(uint filesIndexed MEMBER m_filesIndexed NOTIFY newFileIndexed)
37 Q_PROPERTY(QString remainingTime READ remainingTime NOTIFY remainingTimeChanged)
38 Q_PROPERTY(QString stateString READ stateString NOTIFY indexerStateChanged)
39 Q_PROPERTY(Baloo::IndexerState state READ state NOTIFY indexerStateChanged)
40public:
41 explicit Monitor(QObject* parent = nullptr);
42
43 // Property readers
44 QString filePath() const { return m_filePath; }
45 QString suspendState() const;
46 QString remainingTime() const { return m_remainingTime; }
47 QString stateString() const { return Baloo::stateString(m_indexerState); }
48 Baloo::IndexerState state() const { return m_indexerState; }
49
50 // Invokable methods
51 Q_INVOKABLE void toggleSuspendState();
52 Q_INVOKABLE void startBaloo();
53
55 void newFileIndexed();
56 void balooStateChanged();
57 void totalFilesChanged();
58 void remainingTimeChanged();
59 void indexerStateChanged();
60
61private Q_SLOTS:
62 void newFile(const QString& filePath);
63 void balooStarted();
64 void slotIndexerStateChanged(int state);
65
66private:
67 void fetchTotalFiles();
68 void updateRemainingTime();
69
70 QDBusConnection m_bus;
71
72 QString m_filePath;
73 bool m_balooRunning = false;
74 Baloo::IndexerState m_indexerState = Baloo::Unavailable;
75 QDeadlineTimer m_remainingTimeTimer = QDeadlineTimer(0);
76
77 org::kde::baloo::scheduler* m_scheduler;
78 org::kde::baloo::fileindexer* m_fileindexer;
79
80 uint m_totalFiles = 0;
81 uint m_filesIndexed = 0;
82 QString m_remainingTime;
83 uint m_remainingTimeSeconds = 0;
84};
85}
86#endif //BALOOMONITOR_MONITOR_H
Implements storage for docIds without any associated data Instantiated for:
Definition coding.cpp:11
Q_INVOKABLEQ_INVOKABLE
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
Q_SIGNALSQ_SIGNALS
Q_SLOTSQ_SLOTS
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:56:58 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.