app/core/FolderPredictionSession.h
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #pragma once | ||
| 2 | |||
| 3 | #include "service/PredictorTrainingService.h" | ||
| 4 | #include "data/Models.h" | ||
| 5 | #include <QObject> | ||
| 6 | #include <QPointer> | ||
| 7 | |||
| 8 | class MailSessionCore; | ||
| 9 | |||
| 10 | // Owns derived classifier training independently of a visible frontend. | ||
| 11 | // Synchronous classifier instances in legacy dialogs remain borrowers of the | ||
| 12 | // same file; no second bootstrap or train-on-visit owner is installed there. | ||
| 13 | class FolderPredictionSession final : public QObject { | ||
| 14 | Q_OBJECT | ||
| 15 | public: | ||
| 16 | explicit FolderPredictionSession(MailSessionCore &session, QObject *parent = nullptr); | ||
| 17 | ~FolderPredictionSession() override; | ||
| 18 | 430 | QString databasePath() const { return m_databasePath; } | |
| 19 | 177149 | bool ready() const { return m_ready; } | |
| 20 | bool busy() const; | ||
| 21 | 2 | quint64 revision() const { return m_revision; } | |
| 22 | QString error() const { return m_error; } | ||
| 23 | static bool excludedFolder(const QString &path); | ||
| 24 | signals: | ||
| 25 | void changed(); | ||
| 26 | void trainingStarted(); | ||
| 27 | void trainingFinished(bool completed, int documents, const QString &error); | ||
| 28 | private: | ||
| 29 | void reset(); | ||
| 30 | void bootstrap(quint64 generation); | ||
| 31 | void trainHeaders(const QString &folder, qint64 folderId, | ||
| 32 | quint32 uidValidity, const QList<MailHeader> &headers); | ||
| 33 | void finishMeasurement(bool completed, int documents); | ||
| 34 | // S105.3.6: new inbox mail is classified (and its suggestion stored) | ||
| 35 | // right after the header insert, before its row is first looked at. | ||
| 36 | void classifyArrivals(const QString &folder, qint64 folderId, quint32 uidValidity, const QList<MailHeader> &headers); | ||
| 37 | MailSessionCore &m_session; | ||
| 38 | QPointer<PredictorTrainingService> m_training; | ||
| 39 | QString m_databasePath, m_error; | ||
| 40 | bool m_ready = false; | ||
| 41 | quint64 m_generation = 0, m_revision = 0; | ||
| 42 | qint64 m_startedNs = 0; | ||
| 43 | }; | ||
| 44 |