Baloo

mainhub.cpp
1 /*
2  SPDX-FileCopyrightText: 2015 Vishesh Handa <[email protected]>
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 
14 using namespace Baloo;
15 
16 MainHub::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 
51 void MainHub::quit() const
52 {
54 }
55 
56 void MainHub::updateConfig()
57 {
58  m_config->forceConfigUpdate();
59  m_fileWatcher.updateIndexedFoldersWatches();
60  m_fileIndexScheduler.updateConfig();
61 }
62 
63 #include "moc_mainhub.cpp"
bool registerObject(const QString &path, QObject *object, QDBusConnection::RegisterOptions options)
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QDBusConnection sessionBus()
Implements storage for docIds without any associated data Instantiated for:
Definition: coding.cpp:11
QCoreApplication * instance()
Active config class which emits signals if the config was changed, for example if the KCM saved the c...
KSharedConfigPtr config()
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Dec 11 2023 03:53:57 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.