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_db(db)
18 , m_config(config)
19 , m_fileWatcher(db, config, this)
20 , m_fileIndexScheduler(db, config, firstRun, this)
21{
22 Q_ASSERT(db);
23 Q_ASSERT(config);
24
25 connect(&m_fileWatcher, &FileWatch::indexNewFile, &m_fileIndexScheduler, &FileIndexScheduler::indexNewFile);
26 connect(&m_fileWatcher, &FileWatch::indexModifiedFile, &m_fileIndexScheduler, &FileIndexScheduler::indexModifiedFile);
27 connect(&m_fileWatcher, &FileWatch::indexXAttr, &m_fileIndexScheduler, &FileIndexScheduler::indexXAttrFile);
28 connect(&m_fileWatcher, &FileWatch::fileRemoved, &m_fileIndexScheduler, &FileIndexScheduler::handleFileRemoved);
29
30 connect(&m_fileWatcher, &FileWatch::installedWatches, &m_fileIndexScheduler, &FileIndexScheduler::scheduleIndexing);
31
33 bus.registerObject(QStringLiteral("/"), this, QDBusConnection::ExportAllSlots |
35
36 if (firstRun) {
37 QTimer::singleShot(5000, this, [this] {
38 m_fileIndexScheduler.startupFinished();
39 });
40 } else {
41 // Delay these checks so we don't end up consuming excessive resources on login
42 QTimer::singleShot(5000, this, [this] {
43 m_fileIndexScheduler.checkUnindexedFiles();
44 m_fileIndexScheduler.checkStaleIndexEntries();
45 m_fileIndexScheduler.startupFinished();
46 });
47 }
48 QTimer::singleShot(0, &m_fileWatcher, &FileWatch::updateIndexedFoldersWatches);
49}
50
51void MainHub::quit() const
52{
54}
55
56void MainHub::updateConfig()
57{
58 m_config->forceConfigUpdate();
59 m_fileWatcher.updateIndexedFoldersWatches();
60 m_fileIndexScheduler.updateConfig();
61}
62
63#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 Tue Mar 26 2024 11:20:16 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.