Baloo

mainhub.cpp
1/*
2 SPDX-FileCopyrightText: 2015 Vishesh Handa <vhanda@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.1-or-later
5*/
6
7#include "mainhub.h"
8#include "fileindexerconfig.h"
9
10#include <QDBusConnection>
11#include <QCoreApplication>
12#include <QTimer>
13
14using namespace Baloo;
15
16MainHub::MainHub(Database *db, FileIndexerConfig *config, bool firstRun)
17 : m_config(config)
18 , m_fileWatcher(db, config, this)
19 , m_fileIndexScheduler(db, config, firstRun, this)
20{
21 Q_ASSERT(db);
22 Q_ASSERT(config);
23
24 connect(&m_fileWatcher, &FileWatch::indexNewFile, &m_fileIndexScheduler, &FileIndexScheduler::indexNewFile);
25 connect(&m_fileWatcher, &FileWatch::indexModifiedFile, &m_fileIndexScheduler, &FileIndexScheduler::indexModifiedFile);
26 connect(&m_fileWatcher, &FileWatch::indexXAttr, &m_fileIndexScheduler, &FileIndexScheduler::indexXAttrFile);
27 connect(&m_fileWatcher, &FileWatch::fileRemoved, &m_fileIndexScheduler, &FileIndexScheduler::handleFileRemoved);
28
29 connect(&m_fileWatcher, &FileWatch::installedWatches, &m_fileIndexScheduler, &FileIndexScheduler::scheduleIndexing);
30
32 bus.registerObject(QStringLiteral("/"), this, QDBusConnection::ExportAllSlots |
34
35 if (firstRun) {
36 QTimer::singleShot(5000, this, [this] {
37 m_fileIndexScheduler.startupFinished();
38 });
39 } else {
40 // Delay these checks so we don't end up consuming excessive resources on login
41 QTimer::singleShot(5000, this, [this] {
42 m_fileIndexScheduler.checkUnindexedFiles();
43 m_fileIndexScheduler.checkStaleIndexEntries();
44 m_fileIndexScheduler.startupFinished();
45 });
46 }
47 QTimer::singleShot(0, &m_fileWatcher, &FileWatch::updateIndexedFoldersWatches);
48}
49
50void MainHub::quit() const
51{
53}
54
55void MainHub::updateConfig()
56{
57 m_config->forceConfigUpdate();
58 m_fileWatcher.updateIndexedFoldersWatches();
59 m_fileIndexScheduler.updateConfig();
60}
61
62#include "moc_mainhub.cpp"
Active config class which emits signals if the config was changed, for example if the KCM saved the c...
void forceConfigUpdate()
Reread the config from disk and update the configuration cache.
Implements storage for docIds without any associated data Instantiated for:
Definition coding.cpp:11
QCoreApplication * instance()
bool registerObject(const QString &path, QObject *object, RegisterOptions options)
QDBusConnection sessionBus()
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
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.