// SPDX-FileCopyrightText: 2020 Jonah BrĂ¼chert // SPDX-FileCopyrightText: 2020 Rinigus // // SPDX-License-Identifier: GPL-2.0-or-later #ifndef DBMANAGER_H #define DBMANAGER_H #include #include #include #include #include class QQmlEngine; /** * @class DBManager * @short Class for database initialization and applying changes in its records */ class DBManager : public QObject { Q_OBJECT public: explicit DBManager(QObject *parent = nullptr); Q_SIGNALS: // emitted with the name of the table that has been changed void databaseTableChanged(QString table); public: QCoro::Task<> addBookmark(const QVariantMap bookmarkdata); QCoro::Task<> removeBookmark(const QString url); QCoro::Task isBookmarked(const QString url) const; QCoro::Task<> addToHistory(const QVariantMap pagedata); QCoro::Task<> removeFromHistory(const QString url); QCoro::Task<> clearHistory(); QCoro::Task<> updateIcon(QQmlEngine *engine, const QString url, const QString iconSource); QCoro::Task<> updateLastVisited(const QString url); inline std::shared_ptr database() { return m_database; } private: // limit the size of history table QCoro::Task<> trimHistory(); // drop unused icons QCoro::Task<> trimIcons(); // execute SQL statement QCoro::Task<> execute(const QString command); // methods for manipulation of bookmarks or history tables QCoro::Task<> addRecord(const QString table, const QVariantMap pagedata); QCoro::Task<> removeRecord(const QString table, const QString url); QCoro::Task<> removeAllRecords(const QString table); QCoro::Task<> updateIconRecord(const QString table, const QString url, const QString iconSource); QCoro::Task<> setLastVisitedRecord(const QString table, const QString url); QCoro::Task hasRecord(const QString table, const QString url) const; std::shared_ptr m_database; }; #endif // DBMANAGER_H