libfuoten  0.8.1
Qt based library to access the ownCloud/Nextcloud News App API
Public Member Functions | List of all members
SQLiteStorage Class Referencefinal

#include <Fuoten/Storage/SQLiteStorage>

Inheritance diagram for SQLiteStorage:
AbstractStorage

Public Member Functions

 SQLiteStorage (const QString &dbpath, QObject *parent=nullptr)
 
 ~SQLiteStorage () override
 
void clearQueue () override
 
Q_INVOKABLE void clearStorage () override
 
bool enqueueItem (FuotenEnums::QueueAction action, Article *article) override
 
Q_INVOKABLE bool enqueueMarkAllItemsRead () override
 
bool enqueueMarkFeedRead (qint64 feedId, qint64 newestItemId) override
 
bool enqueueMarkFolderRead (qint64 folderId, qint64 newestItemId) override
 
ArticlegetArticle (qint64 id, int bodyLimit=0) override
 
Q_INVOKABLE QString getArticleBody (qint64 id) override
 
QList< Article * > getArticles (const QueryArgs &args) override
 
void getArticlesAsync (const QueryArgs &args) override
 
FeedgetFeed (qint64 id) override
 
QList< Feed * > getFeeds (const QueryArgs &args) override
 
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
 
qint64 getNewestItemId (FuotenEnums::Type type=FuotenEnums::All, qint64 id=-1) override
 
void init () override
 
- Public Member Functions inherited from AbstractStorage
 AbstractStorage (QObject *parent=nullptr)
 
 ~AbstractStorage () override
 
AbstractConfigurationconfiguration () const
 
Errorerror () const
 
bool inOperation () const
 
AbstractNotificatornotificator () const
 
bool ready () const
 
void setConfiguration (AbstractConfiguration *nConfiguration)
 
void setNotificator (AbstractNotificator *notificator)
 
virtual int starred () const
 
virtual int totalUnread () const
 

Additional Inherited Members

- Properties inherited from AbstractStorage
AbstractConfiguration configuration
 
Fuoten::Error error
 
bool inOperation
 
Fuoten::AbstractNotificator notificator
 
bool ready
 
int starred
 
int totalUnread
 
- Public Slots inherited from AbstractStorage
virtual void allItemsMarkedRead (qint64 newestItemId)=0
 
virtual void feedCreated (const QJsonDocument &json)=0
 
virtual void feedDeleted (qint64 id)=0
 
virtual void feedMarkedRead (qint64 id, qint64 newestItem)=0
 
virtual void feedMoved (qint64 id, qint64 targetFolder)=0
 
virtual void feedRenamed (qint64 id, const QString &newTitle)=0
 
virtual void feedsRequested (const QJsonDocument &json)=0
 
virtual void folderCreated (const QJsonDocument &json)=0
 
virtual void folderDeleted (qint64 id)=0
 
virtual void folderMarkedRead (qint64 id, qint64 newestItem)=0
 
virtual void folderRenamed (qint64 id, const QString &newName)=0
 
virtual void foldersRequested (const QJsonDocument &json)=0
 
virtual void itemMarked (qint64 itemId, bool unread)=0
 
virtual void itemsMarked (const Fuoten::IdList &itemIds, bool unread)=0
 
virtual void itemsRequested (const QJsonDocument &json)=0
 
virtual void itemsStarred (const QList< QPair< qint64, QString >> &articles, bool star)=0
 
virtual void itemStarred (qint64 feedId, const QString &guidHash, bool star)=0
 
- Signals inherited from AbstractStorage
void configurationChanged (Fuoten::AbstractConfiguration *configuration)
 
void createdFeed (qint64 id, qint64 folderId)
 
void createdFolder (qint64 id, const QString &name)
 
void deletedFeed (qint64 id)
 
void deletedFolder (qint64 id)
 
void errorChanged (Fuoten::Error *error)
 
void gotArticlesAsync (const Fuoten::ArticleList &articles)
 
void inOperationChanged (bool inOperation)
 
void markedAllItemsRead (qint64 newestItemId)
 
void markedAllItemsReadInQueue ()
 
void markedItem (qint64 itemId, bool unread)
 
void markedItems (const Fuoten::IdList &itemIds, bool unread)
 
void markedReadFeed (qint64 id, qint64 newestItem)
 
void markedReadFeedInQueue (qint64 feedId, qint64 newestItemId)
 
void markedReadFolder (qint64 id, qint64 newestItem)
 
void markedReadFolderInQueue (qint64 folderId, qint64 newestItemId)
 
void movedFeed (qint64 id, qint64 targetFolder)
 
void notificatorChanged (Fuoten::AbstractNotificator *notificator)
 
void queueCleared ()
 
void readyChanged (bool ready)
 
void renamedFeed (qint64 id, const QString &newName)
 
void renamedFolder (qint64 id, const QString &newName)
 
void requestedFeeds (const Fuoten::IdList &updatedFeeds, const Fuoten::IdList &newFeeds, const Fuoten::IdList &deletedFeeds)
 
void requestedFolders (const QList< QPair< qint64, QString > > &updatedFolders, const QList< QPair< qint64, QString > > &newFolders, const Fuoten::IdList &deletedFolders)
 
void requestedItems (const Fuoten::IdList &updatedItems, const Fuoten::IdList &newItems, const Fuoten::IdList &deletedItems)
 
void starredChanged (int starred)
 
void starredItem (qint64 feedId, const QString &guidHash, bool starred)
 
void starredItems (const QList< QPair< qint64, QString >> &articles, bool star)
 
void storageCleared ()
 
void totalUnreadChanged (int totalUnread)
 
- Protected Slots inherited from AbstractStorage
virtual void setStarred (int nStarred)
 
virtual void setTotalUnread (int nTotalUnread)
 
- Protected Member Functions inherited from AbstractStorage
void notify (const Error *e) const
 
void notify (AbstractNotificator::Type type, QtMsgType severity, const QVariant &data) const
 
void setError (Error *nError)
 
void setInOperation (bool nInOperation)
 
void setReady (bool nReady)
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ SQLiteStorage()

SQLiteStorage ( const QString &  dbpath,
QObject *  parent = nullptr 
)

Constructs a new SQLiteStorage object with given dbpath and parent.

◆ ~SQLiteStorage()

~SQLiteStorage ( )
override

Deconstructs the SQLiteStorage object.

Member Function Documentation

◆ clearQueue()

void clearQueue ( )
overridevirtual

Resets the queue column after the queue has been worked.

Reimplemented from AbstractStorage.

◆ clearStorage()

void clearStorage ( )
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 AbstractStorage.

◆ enqueueItem()

bool enqueueItem ( FuotenEnums::QueueAction  action,
Article article 
)
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.

Parameters
actionthe action to be performed on the Article object
articlethe Article object the action should be performed on
Returns
true if the enqueue was successful, otherwise false

Reimplemented from AbstractStorage.

◆ enqueueMarkAllItemsRead()

bool enqueueMarkAllItemsRead ( )
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.

Returns
true on success, otherwise false

Reimplemented from AbstractStorage.

◆ enqueueMarkFeedRead()

bool enqueueMarkFeedRead ( qint64  feedId,
qint64  newestItemId 
)
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.

Parameters
feedIdID of the feed to be marked as read
newestItemIdID of the newest item in the feed
Returns
true on success, otherwise false

Reimplemented from AbstractStorage.

◆ enqueueMarkFolderRead()

bool enqueueMarkFolderRead ( qint64  folderId,
qint64  newestItemId 
)
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.

Parameters
folderIdID of the folder to be marked as read
newestItemIdID of the newest item in the folder
Returns
true on success, otherwise false

Reimplemented from AbstractStorage.

◆ getArticle()

Article * getArticle ( qint64  id,
int  bodyLimit = 0 
)
overridevirtual

Returns the Article identified by id.

Returns a nullptr if the Article can not be found.

Implements AbstractStorage.

◆ getArticleBody()

QString getArticleBody ( qint64  id)
overridevirtual

Returns the full body of an Article identified by id.

Implements AbstractStorage.

◆ getArticles()

QList< Article * > getArticles ( const QueryArgs args)
overridevirtual

Returns a list of Article objects from the items table.

Implements AbstractStorage.

◆ getArticlesAsync()

void getArticlesAsync ( const QueryArgs args)
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.

Parameters
argsquery arguments

Reimplemented from AbstractStorage.

◆ getFeed()

Feed * getFeed ( qint64  id)
overridevirtual

Returns the Feed identified by id.

Returns a nullptr if the Feed can not be found.

Implements AbstractStorage.

◆ getFeeds()

QList< Feed * > getFeeds ( const QueryArgs args)
overridevirtual

Returns a list of Feed objects from the feeds table.

Implements AbstractStorage.

◆ getFolders()

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 
)
overridevirtual

Returns a list of Folder objects from the folders table.

Implements AbstractStorage.

◆ getNewestItemId()

qint64 getNewestItemId ( FuotenEnums::Type  type = FuotenEnums::All,
qint64  id = -1 
)
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 AbstractStorage.

◆ init()

void init ( )
overridevirtual

Initializes the SQLite database.

This will create/check the table layout.

Implements AbstractStorage.