File indexing completed on 2024-05-12 04:37:32

0001 /*
0002     SPDX-FileCopyrightText: 2020 Friedrich W. H. Kossebau <kossebau@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #ifndef KDEVELOPSESSIONSWATCH_SESSIONFILESTRACKER_H
0008 #define KDEVELOPSESSIONSWATCH_SESSIONFILESTRACKER_H
0009 
0010 // lib
0011 #include "kdevelopsessiondata.h"
0012 // Qt
0013 #include <QObject>
0014 #include <QVector>
0015 #include <QMutex>
0016 
0017 class KDirWatch;
0018 
0019 class SessionFilesTracker : public QObject
0020 {
0021     Q_OBJECT
0022 
0023 public:
0024     static SessionFilesTracker *instance();
0025 
0026 public:
0027     SessionFilesTracker();
0028     ~SessionFilesTracker() override;
0029 
0030 public:
0031     void registerObserver(QObject* observer);
0032     void unregisterObserver(QObject* observer);
0033 
0034     void cleanup();
0035 
0036 Q_SIGNALS:
0037     void sessionDataListChanged(const QVector<KDevelopSessionData>& sessionDataList);
0038 
0039 private Q_SLOTS:
0040     void sessionSourceChanged(const QString& path);
0041 
0042 private:
0043     void updateSessions();
0044     QVector<KDevelopSessionData> readSessionDataList() const;
0045 
0046 private:
0047     QVector<KDevelopSessionData> m_sessionDataList;
0048 
0049     QMutex m_mutex;
0050     QVector<QObject*> m_observers;
0051 
0052     QString m_sessionDir;
0053     KDirWatch* m_dirWatch;
0054 };
0055 
0056 #endif