#ifndef VISITHISTORYMANAGER_H #define VISITHISTORYMANAGER_H #include #include #include #include struct VisitRecord { QString filename; qint64 timestamp; }; using PVisitRecord = std::shared_ptr; struct VisitHistory{ qint64 timestamp; QList files; QList projects; }; using PVisitHistory = std::shared_ptr; class VisitHistoryManager { public: VisitHistoryManager(const QString& filename); const QList &files() const; const QList &projects() const; void clearFiles(); void clearProjects(); bool addFile(const QString& filename); void removeFile(const QString& filename); bool addProject(const QString& filename); void removeProject(const QString& filename); void save(); void load(); private: PVisitHistory doLoad(const QString& filename, qint64 criteriaTime); QList fromJson(const QJsonArray &array, qint64 criteriaTime); void mergeRead(QList& target, const QList& readed); QJsonArray toJson(const QList& list); bool doAdd(QList &list, const QString& filename, int maxCount); void doRemove(QList &list, const QString& filename); private: QList mFiles; QList mProjects; qint64 mLastLoadtime; QString mSaveFilename; int mMaxFileCount; int mMaxProjectCount; }; #endif // VISITHISTORYMANAGER_H