|
libfuoten 0.8.2
Qt based library to access the Nextcloud News App API.
|
Storage using a local SQLite database. More...
#include <Fuoten/Storage/SQLiteStorage>
Public Member Functions | |
| SQLiteStorage (const QString &dbpath, QObject *parent=nullptr) | |
| Constructs a new SQLiteStorage object with given dbpath and parent. | |
| ~SQLiteStorage () override | |
| Deconstructs the SQLiteStorage object. | |
| void | clearQueue () override |
| Resets the queue column after the queue has been worked. | |
| Q_INVOKABLE void | clearStorage () override |
| Deletes all local data from the database. | |
| bool | enqueueItem (FuotenEnums::QueueAction action, Article *article) override |
| Enqueues the action for the given article in the local SQLite database. | |
| Q_INVOKABLE bool | enqueueMarkAllItemsRead () override |
| Adds all local articles that are unread to the queue and marks them as read. | |
| bool | enqueueMarkFeedRead (qint64 feedId, qint64 newestItemId) override |
| Adds all articles older than newestItemId in the feed identified by feedId as read to the local queue. | |
| bool | enqueueMarkFolderRead (qint64 folderId, qint64 newestItemId) override |
| Adds all articles older than newestItemId in the folder identified by folderId as read to the local queue. | |
| Article * | getArticle (qint64 id, int bodyLimit=0) override |
| Returns the Article identified by id. | |
| Q_INVOKABLE QString | getArticleBody (qint64 id) override |
| Returns the full body of an Article identified by id. | |
| QList< Article * > | getArticles (const QueryArgs &args) override |
| Returns a list of Article objects from the items table. | |
| void | getArticlesAsync (const QueryArgs &args) override |
| Invokes an asynchronous query for articles in a different thread. | |
| Feed * | getFeed (qint64 id) override |
| Returns the Feed identified by id. | |
| QList< Feed * > | getFeeds (const QueryArgs &args) override |
| Returns a list of Feed objects from the feeds table. | |
| QList< Folder * > | getFolders (FuotenEnums::SortingRole sortingRole=FuotenEnums::Name, Qt::SortOrder sortOrder=Qt::AscendingOrder, const IdList &ids=IdList(), FuotenEnums::Type idType=FuotenEnums::Folder, int limit=0) override |
| Returns a list of Folder objects from the folders table. | |
| qint64 | getNewestItemId (FuotenEnums::Type type=FuotenEnums::All, qint64 id=-1) override |
| Returns the newest/highest item/article ID fo the given type. | |
| void | init () override |
| Initializes the SQLite database. | |
| Public Member Functions inherited from Fuoten::AbstractStorage | |
| AbstractStorage (QObject *parent=nullptr) | |
| Constructs a new abstract local storage with the given parent. | |
| ~AbstractStorage () override | |
| Deconstructs the AbstractStorage object. | |
| AbstractConfiguration * | configuration () const |
| Getter function for the configuration property. | |
| Error * | error () const |
| Retruns a pointer to an Error object, if any error occures, otherwise returns a nullptr. | |
| bool | inOperation () const |
| Getter function for the inOperation property. | |
| AbstractNotificator * | notificator () const |
| Getter function for the notificator property. | |
| bool | ready () const |
| Returns true when the storage is ready to handle data, otherwise false. | |
| void | setConfiguration (AbstractConfiguration *nConfiguration) |
| Setter function for the configuration property. Emits the configurationChanged() signal if nConfiguration is not equal to the stored value. | |
| void | setNotificator (AbstractNotificator *notificator) |
| Setter function for the notificator property. | |
| virtual int | starred () const |
| Returns the total number of starred articles. | |
| virtual int | totalUnread () const |
| Returns the total number of unread articles. | |
Additional Inherited Members | |
| Properties inherited from Fuoten::AbstractStorage | |
| AbstractConfiguration * | configuration |
| Pointer to an AbstractConfiguration derived class. | |
| Fuoten::Error * | error |
| Returns a pointer to an Error object, if any error occures, otherwise a nullptr. | |
| bool | inOperation |
| Returns true while the storage is in operation. | |
| Fuoten::AbstractNotificator * | notificator |
| Pointer to an object derived from AbstractNotificator. | |
| bool | ready |
| Returns true when the storage handler has finished its initialization. | |
| int | starred |
| Amount of starred items. | |
| int | totalUnread |
| Total amount of unread items in the storage. | |
| Public Slots inherited from Fuoten::AbstractStorage | |
| virtual void | allItemsMarkedRead (qint64 newestItemId)=0 |
| Receives the reply data from the MarkAllItemsRead request. | |
| virtual void | feedCreated (const QJsonDocument &json)=0 |
| Receives the reply data of the CreateFeed request. | |
| virtual void | feedDeleted (qint64 id)=0 |
| Receives the reply data of the DeleteFeed request. | |
| virtual void | feedMarkedRead (qint64 id, qint64 newestItem)=0 |
| Receives the reply data of the MarkFeedRead request. | |
| virtual void | feedMoved (qint64 id, qint64 targetFolder)=0 |
| Receives the reply data of the MoveFeed request. | |
| virtual void | feedRenamed (qint64 id, const QString &newTitle)=0 |
| Receives the reply data of the RenameFeed request. | |
| virtual void | feedsRequested (const QJsonDocument &json)=0 |
| Receives the reply data of the GetFeeds request. | |
| virtual void | folderCreated (const QJsonDocument &json)=0 |
| Receives the reply data of the CreateFolder request. | |
| virtual void | folderDeleted (qint64 id)=0 |
| Receives the reply data of the DeleteFolder request. | |
| virtual void | folderMarkedRead (qint64 id, qint64 newestItem)=0 |
| Receives the reply data of the MarkFolderRead request. | |
| virtual void | folderRenamed (qint64 id, const QString &newName)=0 |
| Receives the reply data of the RenameFolder request. | |
| virtual void | foldersRequested (const QJsonDocument &json)=0 |
| Receives the reply data of the GetFolders request. | |
| static qint64 | getIdFromJson (const QJsonValue &value) |
| Convert a JSON value into an integer id. | |
| virtual void | itemMarked (qint64 itemId, bool unread)=0 |
| Receives the reply data for the MarkItem request. | |
| virtual void | itemsMarked (const Fuoten::IdList &itemIds, bool unread)=0 |
| Receives the reply data for the MarkItems request. | |
| virtual void | itemsRequested (const QJsonDocument &json)=0 |
| Receives the reply data of the GetItems request. | |
| virtual void | itemsStarred (const QList< QPair< qint64, QString > > &articles, bool star)=0 |
| Receives the reply data for the StarItems request. | |
| virtual void | itemStarred (qint64 feedId, const QString &guidHash, bool star)=0 |
| Receives the reply data from the StarItem request. | |
| Signals inherited from Fuoten::AbstractStorage | |
| void | configurationChanged (Fuoten::AbstractConfiguration *configuration) |
| This is emitted if the value of the configuration property changes. | |
| void | createdFeed (qint64 id, qint64 folderId) |
| Emit this after a new feed has been created. | |
| void | createdFolder (qint64 id, const QString &name) |
| Emit this after a new folder has been created. | |
| void | deletedFeed (qint64 id) |
| Emit this after a feed has been deleted. | |
| void | deletedFolder (qint64 id) |
| Emit this after a folder has been deleted. | |
| void | errorChanged (Fuoten::Error *error) |
| Emitted whenever the error property changes. | |
| void | gotArticlesAsync (const Fuoten::ArticleList &articles) |
| Emit this after getArticlesAsync() has been called and articles have been queried. | |
| void | inOperationChanged (bool inOperation) |
| This is emitted if the value of the inOperation property changes. | |
| void | markedAllItemsRead (qint64 newestItemId) |
| Emit this signal after all items/articles have been marked as read. | |
| void | markedAllItemsReadInQueue () |
| Emit this signal after all items/articles have been marked as read in the local queue. | |
| void | markedItem (qint64 itemId, bool unread) |
| Emit this after an item/article has been marked read or unread. | |
| void | markedItems (const Fuoten::IdList &itemIds, bool unread) |
| Emit this after items/articles have been marked as read or unread. | |
| void | markedReadFeed (qint64 id, qint64 newestItem) |
| Emit this after a feed has been marked as read. | |
| void | markedReadFeedInQueue (qint64 feedId, qint64 newestItemId) |
| Emit this after a feed has been marked as read in the local queue. | |
| void | markedReadFolder (qint64 id, qint64 newestItem) |
| Emit this after a folder has been marked as read. | |
| void | markedReadFolderInQueue (qint64 folderId, qint64 newestItemId) |
| Emit this after a folder has been marked as read in the local queue. | |
| void | movedFeed (qint64 id, qint64 targetFolder) |
| Emit this signal after a feed has been moved to another folder. | |
| void | notificatorChanged (Fuoten::AbstractNotificator *notificator) |
| Notifier signal for the notificator property. | |
| void | queueCleared () |
| This is emitted after the local queue has been cleared. | |
| void | readyChanged (bool ready) |
| Emitted whenever the ready property changes. | |
| void | renamedFeed (qint64 id, const QString &newName) |
| Emit this signal after a feed has been renamed. | |
| void | renamedFolder (qint64 id, const QString &newName) |
| Emit this after a folder has been renamed. | |
| void | requestedFeeds (const Fuoten::IdList &updatedFeeds, const Fuoten::IdList &newFeeds, const Fuoten::IdList &deletedFeeds) |
| Emit this after feeds have been received and processed. | |
| void | requestedFolders (const QList< QPair< qint64, QString > > &updatedFolders, const QList< QPair< qint64, QString > > &newFolders, const Fuoten::IdList &deletedFolders) |
| Emit this after folders have been received and processed. | |
| void | requestedItems (const Fuoten::IdList &updatedItems, const Fuoten::IdList &newItems, const Fuoten::IdList &deletedItems) |
| Emit this after items/articles have been received and processed. | |
| void | starredChanged (int starred) |
| This signal is emitted if the amount of total starred articles changes. | |
| void | starredItem (qint64 feedId, const QString &guidHash, bool starred) |
| Emit this after an item/article has been starred or unstarred. | |
| void | starredItems (const QList< QPair< qint64, QString > > &articles, bool star) |
| Emit this after items/articles have been starred or unstarred. | |
| void | storageCleared () |
| This is emitted after the local storage has been cleared. | |
| void | totalUnreadChanged (int totalUnread) |
| This signal is emitted if the amount of total unread articles changes. | |
| Protected Slots inherited from Fuoten::AbstractStorage | |
| virtual void | setStarred (int nStarred) |
| Sets the total number of starred articles. | |
| virtual void | setTotalUnread (int nTotalUnread) |
| Sets the total number of unread articles. | |
| Protected Member Functions inherited from Fuoten::AbstractStorage | |
| void | notify (AbstractNotificator::Type type, QtMsgType severity, const QVariant &data) const |
| Checks if a notificator has been set and will use it to notify the user. | |
| void | notify (const Error *e) const |
| Checks if a notificator has been set and will use it to notify about an occured error. | |
| void | setError (Error *nError) |
| Sets the Error object. | |
| void | setInOperation (bool nInOperation) |
| Setter function for the inOperation property. Emits the inOperationChanged() signal if nInOperation is not equal to the stored value. | |
| void | setReady (bool nReady) |
| Set this to true when the storage has finished it's initialization. | |
Storage using a local SQLite database.
To use this storage, simply set the path to the SQLite database file in the constructor and call init(). The path to the database file will not be created automatically. It has to be created before calling init().
If you want to have a custom storage class, derive from AbstractStorage.
Constructs a new SQLiteStorage object with given dbpath and parent.
|
override |
Deconstructs the SQLiteStorage object.
|
overridevirtual |
Resets the queue column after the queue has been worked.
Reimplemented from Fuoten::AbstractStorage.
|
overridevirtual |
Deletes all local data from the database.
This will clear the local storage and will emit AbstractStorage::storageCleared(). Will also set AbstractConfiguration::setLastSync() to an invalid QDateTime.
Reimplemented from Fuoten::AbstractStorage.
|
overridevirtual |
Enqueues the action for the given article in the local SQLite database.
Will update the queue column in the items table and also will perform the action locally.
| action | the action to be performed on the Article object |
| article | the Article object the action should be performed on |
true if the enqueue was successful, otherwise false Reimplemented from Fuoten::AbstractStorage.
|
overridevirtual |
Adds all local articles that are unread to the queue and marks them as read.
Will update the queue column for every item in the database and will also perform the cation locally. Will emit the AbstractStorage::markedAllItemsReadInQueue() signal on success The action will be performed in a separate thread, so the return value only indicates if the threaded action has been started successfully.
true on success, otherwise false Reimplemented from Fuoten::AbstractStorage.
|
overridevirtual |
Adds all articles older than newestItemId in the feed identified by feedId as read to the local queue.
Will update the queue column for every item in the feed and will also perform the action locally. Will emit the AbstractStorage::markedReadFeedInQueue() signal on success. The action will be performed in a separate thread, so the return value only indicates if the threaded action has been started successfully.
| feedId | ID of the feed to be marked as read |
| newestItemId | ID of the newest item in the feed |
true on success, otherwise false Reimplemented from Fuoten::AbstractStorage.
|
overridevirtual |
Adds all articles older than newestItemId in the folder identified by folderId as read to the local queue.
Will update the queue column for every item in the folder and will also perform the action locally. Will emit the AbstractStorage::markedReadFolderInQueue() signal on success. The action will be performed in a separate thread, so the return value only indicates if the threaded action has been started successfully.
| folderId | ID of the folder to be marked as read |
| newestItemId | ID of the newest item in the folder |
true on success, otherwise false Reimplemented from Fuoten::AbstractStorage.
|
overridevirtual |
Returns the Article identified by id.
Returns a nullptr if the Article can not be found.
Implements Fuoten::AbstractStorage.
|
overridevirtual |
Returns the full body of an Article identified by id.
Implements Fuoten::AbstractStorage.
Returns a list of Article objects from the items table.
Implements Fuoten::AbstractStorage.
|
overridevirtual |
Invokes an asynchronous query for articles in a different thread.
Will emit the AbstractStorage::gotArticlesAsync() signal after the query finished. The signal will contain a list of Article objects. When connecting to this signal, be aware that the objects in the list have been created in a different thread.
| args | query arguments |
Reimplemented from Fuoten::AbstractStorage.
|
overridevirtual |
Returns the Feed identified by id.
Returns a nullptr if the Feed can not be found.
Implements Fuoten::AbstractStorage.
Returns a list of Feed objects from the feeds table.
Implements Fuoten::AbstractStorage.
|
overridevirtual |
Returns a list of Folder objects from the folders table.
Implements Fuoten::AbstractStorage.
|
overridevirtual |
Returns the newest/highest item/article ID fo the given type.
Supported Types: FuotenEnums::Feed, FuotenEnums::Folder, FuotenEnums::All. For folder and feed type a valid id has be provided that identifieds the folder or feed.
If the type does not match one of the supported or if there are not items, -1 is returned.
Implements Fuoten::AbstractStorage.
|
overridevirtual |
Initializes the SQLite database.
This will create/check the table layout.
Implements Fuoten::AbstractStorage.