// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-FileCopyrightText: 2024 Alexander Kavon #include "kueapplication.h" #include #include #include #include #include #include #include #include #include #include #include using namespace Qt::StringLiterals; KueApplication::KueApplication(QObject *parent) : AbstractKirigamiApplication(parent) , m_loading(true) { m_session = new Akonadi::Session(QByteArrayLiteral("Kue Kernel"), this); auto monitor = new Akonadi::Monitor(this); auto treeModel = new Akonadi::EntityTreeModel(monitor, this); treeModel->setItemPopulationStrategy(Akonadi::EntityTreeModel::LazyPopulation); auto entityTreeModel = new Akonadi::CollectionFilterProxyModel(this); entityTreeModel->setSourceModel(treeModel); entityTreeModel->addMimeTypeFilter(KMime::Message::mimeType()); m_descendantsProxyModel = new KDescendantsProxyModel(this); m_descendantsProxyModel->setSourceModel(entityTreeModel); qDebug() << m_descendantsProxyModel->rowCount(); if (Akonadi::ServerManager::isRunning()) { m_loading = false; } else { connect(Akonadi::ServerManager::self(), &Akonadi::ServerManager::stateChanged, this, [this](Akonadi::ServerManager::State state) { if (state == Akonadi::ServerManager::Broken) { qDebug() << "ServerManager Broken"; qApp->exit(-1); return; } bool loading = state != Akonadi::ServerManager::State::Running; if (loading == m_loading) { return; } m_loading = loading; Q_EMIT loadingChanged(); disconnect(Akonadi::ServerManager::self(), &Akonadi::ServerManager::stateChanged, this, nullptr); }); } } bool KueApplication::loading() const { return m_loading; } KDescendantsProxyModel *KueApplication::descendantsProxyModel() const { return m_descendantsProxyModel; } Akonadi::Session *KueApplication::session() const { return m_session; } #include "moc_kueapplication.cpp"