libfuoten 0.8.2
Qt based library to access the Nextcloud News App API.
Loading...
Searching...
No Matches
Fuoten::AbstractStorage Class Referenceabstract

Abstract class to handle the storage of requested News App data. More...

#include <Fuoten/Storage/AbstractStorage>

Inheritance diagram for Fuoten::AbstractStorage:
QObject Fuoten::SQLiteStorage

Properties

AbstractConfigurationconfiguration
 Pointer to an AbstractConfiguration derived class.
Fuoten::Errorerror
 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::AbstractNotificatornotificator
 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 Member Functions

 AbstractStorage (QObject *parent=nullptr)
 Constructs a new abstract local storage with the given parent.
 ~AbstractStorage () override
 Deconstructs the AbstractStorage object.
virtual void clearQueue ()
 Clears the local queue. Does not revert the action itself.
virtual Q_INVOKABLE void clearStorage ()
 Removes all data from the storage.
AbstractConfigurationconfiguration () const
 Getter function for the configuration property.
virtual bool enqueueItem (FuotenEnums::QueueAction action, Article *article)
 Enqueues an action for the given article.
virtual Q_INVOKABLE bool enqueueMarkAllItemsRead ()
 Adds all local articles that are unread to the queue and marks them as read.
virtual bool enqueueMarkFeedRead (qint64 feedId, qint64 newestItemId)
 Adds all articles older than newestItemId in the feed identified by feedId as read to the local queue.
virtual bool enqueueMarkFolderRead (qint64 folderId, qint64 newestItemId)
 Adds all articles older than newestItemId in the folder identified folderId as read to the local queue.
Errorerror () const
 Retruns a pointer to an Error object, if any error occures, otherwise returns a nullptr.
virtual ArticlegetArticle (qint64 id, int bodyLimit=0)=0
 Returns the Article identified by id.
virtual Q_INVOKABLE QString getArticleBody (qint64 id)=0
 Returns the full body of an Article identified by id.
virtual QList< Article * > getArticles (const QueryArgs &args)=0
 Returns a list of Article objects from the local storage.
virtual void getArticlesAsync (const QueryArgs &args)
 Invokes a query for Article objects from the local storage, limited by args.
virtual FeedgetFeed (qint64 id)=0
 Returns the Feed identified by id.
virtual QList< Feed * > getFeeds (const QueryArgs &args)=0
 Returns a list of Feed objects from the local storage.
virtual 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)=0
 Returns a list of Folder objects from the local storage.
virtual qint64 getNewestItemId (FuotenEnums::Type type=FuotenEnums::All, qint64 id=-1)=0
 Returns the newest item/article ID for the given type.
virtual void init ()=0
 Initializes the storage handler.
bool inOperation () const
 Getter function for the inOperation property.
AbstractNotificatornotificator () 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.

Public Slots

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

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

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

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.

Detailed Description

Abstract class to handle the storage of requested News App data.

Reimplement this class to store the data requested from the News App API. You can set your derived class to the Component::storage property, that all classes use that derive from Component. Also BaseItem hast the BaseItem::storage property for derived classes, that is used to set the storage handler to API classes that perfrom API actions.

If you derive from AbstractStorage, initialize the storage in init() and set setReady() to true when your storage is ready to handle data.

Property Documentation

◆ configuration

AbstractConfiguration * Fuoten::AbstractStorage::configuration
readwrite

◆ error

Fuoten::Error * Fuoten::AbstractStorage::error
read

Returns a pointer to an Error object, if any error occures, otherwise a nullptr.

Access functions:
Error*error() const
Notifier signal:
voiderrorChanged(Error *error)
See also
setError()

◆ inOperation

bool Fuoten::AbstractStorage::inOperation
read

Returns true while the storage is in operation.

This will only be set to true by pure storage functions (like queue functions), not when processing requested data.

Access functions:
boolinOperation() const
Notifier signal:
voidinOperationChanged(bool inOperation)

◆ notificator

Fuoten::AbstractNotificator * Fuoten::AbstractStorage::notificator
readwrite

Pointer to an object derived from AbstractNotificator.

Set a notificator to notify users about errors and events. This is not mandatory. You have to derive your own notificator that uses the notification system of the target platform.

If no notificator has been set via setNotificator(), the one set via Component::setDefaultConfigurator() will be used - if any has been set. If you do not set a notificator either per instance or global, this property will hold a nullptr. If a notificator is set to an instance of this class via setNotificator(), this notificator will take precedence over the global default notificator object (if any set).

Access functions:
Notifier signal:
See also
notify()

◆ ready

bool Fuoten::AbstractStorage::ready
read

Returns true when the storage handler has finished its initialization.

Access functions:
boolready() const
Notifier signal:
voidreadyChanged(bool ready)
See also
setReady()

◆ starred

int Fuoten::AbstractStorage::starred
read

Amount of starred items.

Access functions:
intstarred() const
Notifier signal:
voidstarredChanged(int starred)
See also
setStarred()

◆ totalUnread

int Fuoten::AbstractStorage::totalUnread
read

Total amount of unread items in the storage.

Access functions:
inttotalUnread() const
Notifier signal:
voidtotalUnreadChanged(int totalUnread)
See also
setTotalUnread()

Constructor & Destructor Documentation

◆ AbstractStorage()

AbstractStorage::AbstractStorage ( QObject * parent = nullptr)
explicit

Constructs a new abstract local storage with the given parent.

◆ ~AbstractStorage()

AbstractStorage::~AbstractStorage ( )
override

Deconstructs the AbstractStorage object.

Member Function Documentation

◆ allItemsMarkedRead

virtual void Fuoten::AbstractStorage::allItemsMarkedRead ( qint64 newestItemId)
pure virtualslot

Receives the reply data from the MarkAllItemsRead request.

Will mark all items in the local database as read which have an ID lower or equal to newestItemId.

◆ clearQueue()

void AbstractStorage::clearQueue ( )
virtual

Clears the local queue. Does not revert the action itself.

The default implementation does nothing. When reimplementing this function, only remove the queue entry but do not revert the action already done locally. It will be called after working the queue.

Reimplemented in Fuoten::SQLiteStorage.

◆ clearStorage()

void AbstractStorage::clearStorage ( )
virtual

Removes all data from the storage.

The default implementation does nothing. When reimplementing this, emit storageCleared() after successfully clear all stored data. Do not forget to also reset last sync time with AbstractConfiguration::setLastSync().

Reimplemented in Fuoten::SQLiteStorage.

◆ configuration()

AbstractConfiguration * AbstractStorage::configuration ( ) const

◆ configurationChanged

void Fuoten::AbstractStorage::configurationChanged ( Fuoten::AbstractConfiguration * configuration)
signal

This is emitted if the value of the configuration property changes.

See also
AbstractStorage::configuration(), AbstractStorage::setConfiguration()

◆ createdFeed

void Fuoten::AbstractStorage::createdFeed ( qint64 id,
qint64 folderId )
signal

Emit this after a new feed has been created.

Best loaction to emit this signal is your implementation of feedCreated(). The signal has to contain the id of the new feed it's parent folderId.

◆ createdFolder

void Fuoten::AbstractStorage::createdFolder ( qint64 id,
const QString & name )
signal

Emit this after a new folder has been created.

Best loaction to emit this signal is your implementation of folderCreated(). The signal has to contain the id and the name of the new folder.

◆ deletedFeed

void Fuoten::AbstractStorage::deletedFeed ( qint64 id)
signal

Emit this after a feed has been deleted.

Best location to emit this signal is your implementation of feedDeleted(). The signal has to contain the id fo the deleted feed.

◆ deletedFolder

void Fuoten::AbstractStorage::deletedFolder ( qint64 id)
signal

Emit this after a folder has been deleted.

Best location to emit this signal is your implementation of folderDeleted(). The signal has to contain the id fo the deleted folder.

◆ enqueueItem()

bool AbstractStorage::enqueueItem ( FuotenEnums::QueueAction action,
Article * article )
virtual

Enqueues an action for the given article.

When enqueueing an article, the performed action should already be saved in the local storage together with the queue action. If the article is marked as read for example, add the action to your local queue and also mark the article as read in your local storage.

The default implementation does nothing and returns false.

Parameters
actionthe action that should be enqueued
articlepointer to the Article object that should be enqueued
Returns
true if the enqueue was successful, otherwise false

Reimplemented in Fuoten::SQLiteStorage.

◆ enqueueMarkAllItemsRead()

bool AbstractStorage::enqueueMarkAllItemsRead ( )
virtual

Adds all local articles that are unread to the queue and marks them as read.

After successfully addint the items/articles to the local queue, emit the markedAllItemsReadInQueue() signal. The default implementation does nothing and returns false.

Returns
true on success, otherwise false

Reimplemented in Fuoten::SQLiteStorage.

◆ enqueueMarkFeedRead()

bool AbstractStorage::enqueueMarkFeedRead ( qint64 feedId,
qint64 newestItemId )
virtual

Adds all articles older than newestItemId in the feed identified by feedId as read to the local queue.

After successfully adding the items/articles to the local queue, emit the markedReadFeedInQueue() signal. The default implementation does nothing and returns false.

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 in Fuoten::SQLiteStorage.

◆ enqueueMarkFolderRead()

bool AbstractStorage::enqueueMarkFolderRead ( qint64 folderId,
qint64 newestItemId )
virtual

Adds all articles older than newestItemId in the folder identified folderId as read to the local queue.

After successfully adding the items/articles to the local queue, emit the markedReadFolderInQueue() signal. The default implementation does nothing and returns false.

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 in Fuoten::SQLiteStorage.

◆ error()

Error * AbstractStorage::error ( ) const

Retruns a pointer to an Error object, if any error occures, otherwise returns a nullptr.

◆ errorChanged

void Fuoten::AbstractStorage::errorChanged ( Fuoten::Error * error)
signal

Emitted whenever the error property changes.

◆ feedCreated

virtual void Fuoten::AbstractStorage::feedCreated ( const QJsonDocument & json)
pure virtualslot

Receives the reply data of the CreateFeed request.

Implement this in a derived class to store new feed data, for example in a local SQL databse. You my want to emit createdFeed() in your implementation after you processed the data.

Example JSON response data
{
"feeds": [
{
"id": 39,
"url": "http://feeds.feedburner.com/oatmealfeed",
"title": "The Oatmeal - Comics, Quizzes, & Stories",
"faviconLink": "http://theoatmeal.com/favicon.ico",
"added": 1367063790,
"folderId": 4,
"unreadCount": 9,
"ordering": 0, // 0 means no special ordering, 1 means oldest first, 2 newest first, new in 5.1.0
"link": "http://theoatmeal.com/",
"pinned": true // if a feed should be sorted before other feeds, added in 6.0.3
}
],
"newestItemId": 23 // only sent if there are items
}

◆ feedDeleted

virtual void Fuoten::AbstractStorage::feedDeleted ( qint64 id)
pure virtualslot

Receives the reply data of the DeleteFeed request.

Will delete the feed identified by id in the local storage and emits the deletedFeed() signal.

◆ feedMarkedRead

virtual void Fuoten::AbstractStorage::feedMarkedRead ( qint64 id,
qint64 newestItem )
pure virtualslot

Receives the reply data of the MarkFeedRead request.

Will mark all items in the feed identified by id that have a lower ID than newestItem as read in the local storage. Will than emit the markedReadFeed() signal.

◆ feedMoved

virtual void Fuoten::AbstractStorage::feedMoved ( qint64 id,
qint64 targetFolder )
pure virtualslot

Receives the reply data of the MoveFeed request.

Will move the feed identified by id to the targetFolder id and emits the movedFeed() signal.

◆ feedRenamed

virtual void Fuoten::AbstractStorage::feedRenamed ( qint64 id,
const QString & newTitle )
pure virtualslot

Receives the reply data of the RenameFeed request.

Will rename the feed identified by id to the newTitle and emits the renamedFeed() signal.

◆ feedsRequested

virtual void Fuoten::AbstractStorage::feedsRequested ( const QJsonDocument & json)
pure virtualslot

Receives the reply data of the GetFeeds request.

Implement this in a derived class to store feed data, for example in a local SQL database. You may want to emit requestedFeeds() in your implementation after you processed the data.

Example JSON response data
{
"feeds": [
{
"id": 39,
"url": "http://feeds.feedburner.com/oatmealfeed",
"title": "The Oatmeal - Comics, Quizzes, & Stories",
"faviconLink": "http://theoatmeal.com/favicon.ico",
"added": 1367063790,
"folderId": 4,
"unreadCount": 9,
"ordering": 0, // 0 means no special ordering, 1 means oldest first, 2 newest first, new in 5.1.0
"link": "http://theoatmeal.com/",
"pinned": true // if a feed should be sorted before other feeds, added in 6.0.3,
"updateErrorCount": 0,
"lastUpdateError": "error message here"
}, // etc
],
"starredCount": 2,
"newestItemId": 3443 // only sent if there are items
}

◆ folderCreated

virtual void Fuoten::AbstractStorage::folderCreated ( const QJsonDocument & json)
pure virtualslot

Receives the reply data of the CreateFolder request.

Implement this in a derived class to store new folder data, for example in a local SQL databse. You my want to emit createdFolder() in your implementation after you processed the data.

Example JSON response data
{
"folders": [
{
"id": 3,
"name": "New Folder"
}
]
}

◆ folderDeleted

virtual void Fuoten::AbstractStorage::folderDeleted ( qint64 id)
pure virtualslot

Receives the reply data of the DeleteFolder request.

Will delete the folder identified by id in the local storage and emits the deletedFolder() signal.

◆ folderMarkedRead

virtual void Fuoten::AbstractStorage::folderMarkedRead ( qint64 id,
qint64 newestItem )
pure virtualslot

Receives the reply data of the MarkFolderRead request.

Will mark all items in the folder identified by id that have a lower ID than newestItem as read in the local storage. Will than emit the markedReadFolder() signal.

◆ folderRenamed

virtual void Fuoten::AbstractStorage::folderRenamed ( qint64 id,
const QString & newName )
pure virtualslot

Receives the reply data of the RenameFolder request.

Will rename the folder identified by id in the local storage to newName and emits the renamedFolder() signal.

◆ foldersRequested

virtual void Fuoten::AbstractStorage::foldersRequested ( const QJsonDocument & json)
pure virtualslot

Receives the reply data of the GetFolders request.

Implement this in a derived class to store folder data, for example in a local SQL database. You may want to emit requestedFolders() in your implementation after you processed the data.

Example JSON response data
{
"folders": [
{
"id": 1,
"name": "Interersting Folder"
},
{
"id": 2,
"name": "Other Folder"
}, // etc
]
}

◆ getArticle()

virtual Article * Fuoten::AbstractStorage::getArticle ( qint64 id,
int bodyLimit = 0 )
pure virtual

Returns the Article identified by id.

bodyLimit limits the size of the body text in number of characters. Values lower than 0 will return no body text, 0 will return the full body text, any other positive value will return a body stripped from HTML tags and limited to the amount of characters.

Returns a nullptr if the Article can not be found.

Implemented in Fuoten::SQLiteStorage.

◆ getArticleBody()

virtual Q_INVOKABLE QString Fuoten::AbstractStorage::getArticleBody ( qint64 id)
pure virtual

Returns the full body of an Article identified by id.

Implemented in Fuoten::SQLiteStorage.

◆ getArticles()

virtual QList< Article * > Fuoten::AbstractStorage::getArticles ( const QueryArgs & args)
pure virtual

Returns a list of Article objects from the local storage.

See QueryArgs for a list of possible query arguments.

Implemented in Fuoten::SQLiteStorage.

◆ getArticlesAsync()

void AbstractStorage::getArticlesAsync ( const QueryArgs & args)
virtual

Invokes a query for Article objects from the local storage, limited by args.

This should emit the gotArticlesAsync() signal containing a list of Article objects. The default implementation is not really asynchronous, it simply calls getArticles() and emits gotArticlesSync() with the return value of that function.

When reimplementing this and connecting to the gotArticlesSync() signal, be aware that the Article objects in the list might have been created in a different thread.

Reimplemented in Fuoten::SQLiteStorage.

◆ getFeed()

virtual Feed * Fuoten::AbstractStorage::getFeed ( qint64 id)
pure virtual

Returns the Feed identified by id.

Returns a nullptr if the Feed can not be found.

Implemented in Fuoten::SQLiteStorage.

◆ getFeeds()

virtual QList< Feed * > Fuoten::AbstractStorage::getFeeds ( const QueryArgs & args)
pure virtual

Returns a list of Feed objects from the local storage.

See QueryArgs for a list of possible query arguments.

Implemented in Fuoten::SQLiteStorage.

◆ getFolders()

virtual QList< Folder * > Fuoten::AbstractStorage::getFolders ( FuotenEnums::SortingRole sortingRole = FuotenEnums::Name,
Qt::SortOrder sortOrder = Qt::AscendingOrder,
const IdList & ids = IdList(),
FuotenEnums::Type idType = FuotenEnums::Folder,
int limit = 0 )
pure virtual

Returns a list of Folder objects from the local storage.

The returned list will be sorted by sortingRole and sortOrder. If ids is not empty, only folders with IDs of idType from the list will be returned. The idType specifies the id the folder is compared with. If the idType is not one of out of the table below, it will be treated as FuotenEnums::Folder.

FuotenEnums::FolderOnly folders with an ID in ids will be returned
FuotenEnums::FeedOnly folders will be returned that contain feeds with an ID in ids
FuotenEnums::ItemOnly folders will be returned that contain items with an ID in ids

Setting limit > 0 returns only the amount of items up to that limit.

The Folder objects in the returned list will have their parent set to nullptr.

Examples

Implemented in Fuoten::SQLiteStorage.

◆ getIdFromJson

qint64 AbstractStorage::getIdFromJson ( const QJsonValue & value)
staticslot

Convert a JSON value into an integer id.

Based on the News App API version, IDs are either returned as numbers or as strings. This will check the JSON value type and convert it into an appropriate id value.

Since
0.8.2

◆ getNewestItemId()

virtual qint64 Fuoten::AbstractStorage::getNewestItemId ( FuotenEnums::Type type = FuotenEnums::All,
qint64 id = -1 )
pure virtual

Returns the newest item/article ID for the given type.

Supported Types: FuotenEnums::Feed, FuotenEnums::Folder, FuotenEnums::All. For folder and feed type a valid id has to 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.

Implemented in Fuoten::SQLiteStorage.

◆ gotArticlesAsync

void Fuoten::AbstractStorage::gotArticlesAsync ( const Fuoten::ArticleList & articles)
signal

Emit this after getArticlesAsync() has been called and articles have been queried.

Be aware that the objects in the list might have been created in a different thread when you connect to this signal.

Parameters
articleslist of Article objects

◆ init()

virtual void Fuoten::AbstractStorage::init ( )
pure virtual

Initializes the storage handler.

For example, create your database layout. When finished set setReady() to true.

Implemented in Fuoten::SQLiteStorage.

◆ inOperation()

bool AbstractStorage::inOperation ( ) const

◆ inOperationChanged

void Fuoten::AbstractStorage::inOperationChanged ( bool inOperation)
signal

This is emitted if the value of the inOperation property changes.

See also
AbstractStorage::inOperation(), AbstractStorage::setInOperation()

◆ itemMarked

virtual void Fuoten::AbstractStorage::itemMarked ( qint64 itemId,
bool unread )
pure virtualslot

Receives the reply data for the MarkItem request.

Will mark the item identified by itemId in the local storage as read or unread.

Parameters
itemIdID of the item/article that has been marked
unreadtrue if the item has been marked as unread, false if marked as read

◆ itemsMarked

virtual void Fuoten::AbstractStorage::itemsMarked ( const Fuoten::IdList & itemIds,
bool unread )
pure virtualslot

Receives the reply data for the MarkItems request.

Will mark the items identified by their ID in the itemIds as read if unread is set to false, otherwise it will mark them as unread. You should emit markedItems() in your implementation after you processed the data to update connected models.

Parameters
itemIdsIDs of articles that have been marked as read or unread
unreadtrue if the articles have been marked as unread, false if marked as read

◆ itemsRequested

virtual void Fuoten::AbstractStorage::itemsRequested ( const QJsonDocument & json)
pure virtualslot

Receives the reply data of the GetItems request.

Implement this in a derived class to store item data, for example in a local SQL database. You may want to emit requestedItems() in your implementation after you processed the data.

Example JSON response data
{
"items": [
{
"id": 3443,
"guid": "http://grulja.wordpress.com/?p=76",
+ "guidHash": "3059047a572cd9cd5d0bf645faffd077",
"url": "http://grulja.wordpress.com/2013/04/29/plasma-nm-after-the-solid-sprint/",
"title": "Plasma-nm after the solid sprint",
"author": "Jan Grulich (grulja)",
"pubDate": 1367270544,
"body": "<p>At first I have to say...</p>",
"enclosureMime": null,
"enclosureLink": null,
"feedId": 67,
"unread": true,
"starred": false,
"lastModified": 1367273003,
"fingerprint": "aeaae2123"
}, // etc
]
}

◆ itemsStarred

virtual void Fuoten::AbstractStorage::itemsStarred ( const QList< QPair< qint64, QString > > & articles,
bool star )
pure virtualslot

Receives the reply data for the StarItems request.

The lists contains the item/article IDs and the guid hash of the items/articles that have been either starred or unstarred. You should emit starredItems() in your implementation after you processed the data to update connected models.

Parameters
articleslist of pairs of feed ID and guid hash of starred/unstarred articles
startrue if the articles have been starred, false if they have been unstarred

◆ itemStarred

virtual void Fuoten::AbstractStorage::itemStarred ( qint64 feedId,
const QString & guidHash,
bool star )
pure virtualslot

Receives the reply data from the StarItem request.

Will star or unstar the item/article identified by itemId and guidHash in the local storage.

Parameters
feedIdID of the feed the item/article that has been starred or unstarred belongs to
guidHashglobal unique ID hash of the item/article that has been starred or unstarred
startrue if the article has been starred, false if it has been unstarred

◆ markedAllItemsRead

void Fuoten::AbstractStorage::markedAllItemsRead ( qint64 newestItemId)
signal

Emit this signal after all items/articles have been marked as read.

Best location to emit this signal is your implementation of allItemsMarkedRead().

Parameters
newestItemIdhighest/newest ID of the local available items/articles

◆ markedAllItemsReadInQueue

void Fuoten::AbstractStorage::markedAllItemsReadInQueue ( )
signal

Emit this signal after all items/articles have been marked as read in the local queue.

Best location to emit this signal is your implemetation of enqueueMarkAllItemsRead().

◆ markedItem

void Fuoten::AbstractStorage::markedItem ( qint64 itemId,
bool unread )
signal

Emit this after an item/article has been marked read or unread.

Best location to emit this signal is your implementation of itemMarked().

Parameters
itemIdthe ID of the item/article that has been marked as read or unread
unreadtrue if the article has been marked as unread, false if marked as read

◆ markedItems

void Fuoten::AbstractStorage::markedItems ( const Fuoten::IdList & itemIds,
bool unread )
signal

Emit this after items/articles have been marked as read or unread.

Best location to emit this signal is your implementation of itemsMarked().

The lists have to conatin the item/article IDs that haven been marked as read or unread.

Parameters
itemIdsIDs of articles that have been marked as read or unread
unreadtrue if the articles have been marked as unread, false if marked as read

◆ markedReadFeed

void Fuoten::AbstractStorage::markedReadFeed ( qint64 id,
qint64 newestItem )
signal

Emit this after a feed has been marked as read.

Best location to emit this signal is your implementation of feedMarkedRead(). The signal has to contain the id of the feed that has been marked as read as well as the ID of the newestItem that has been marked as read.

◆ markedReadFeedInQueue

void Fuoten::AbstractStorage::markedReadFeedInQueue ( qint64 feedId,
qint64 newestItemId )
signal

Emit this after a feed has been marked as read in the local queue.

Parameters
feedIdID of the feed that has been marked as read
newestItemIdID of the newest item in the feed

◆ markedReadFolder

void Fuoten::AbstractStorage::markedReadFolder ( qint64 id,
qint64 newestItem )
signal

Emit this after a folder has been marked as read.

Best location to emit this signal is your implementation of folderMarkedRead(). The signal has to contain the id of the folder that has been marked as read as well as the ID of the newestItem that has been marked as read.

◆ markedReadFolderInQueue

void Fuoten::AbstractStorage::markedReadFolderInQueue ( qint64 folderId,
qint64 newestItemId )
signal

Emit this after a folder has been marked as read in the local queue.

Best location to emit this signal is your implementation of enqueueMarkFolderRead().

Parameters
folderIdID of the folder that has been marked as read in the local queue
newestItemIdID of the newest item in folder that has been marked as read in the local queue

◆ movedFeed

void Fuoten::AbstractStorage::movedFeed ( qint64 id,
qint64 targetFolder )
signal

Emit this signal after a feed has been moved to another folder.

Best location to emit this signal is your implementation of feedMoved(). The signal has to contain the id of the moved feed and the targetFolder id.

◆ notificator()

AbstractNotificator * AbstractStorage::notificator ( ) const

Getter function for the notificator property.

See also
setNotificator(), notificatorChanged()

◆ notificatorChanged

void Fuoten::AbstractStorage::notificatorChanged ( Fuoten::AbstractNotificator * notificator)
signal

Notifier signal for the notificator property.

See also
setNotificator(), notificator()

◆ notify() [1/2]

void AbstractStorage::notify ( AbstractNotificator::Type type,
QtMsgType severity,
const QVariant & data ) const
protected

Checks if a notificator has been set and will use it to notify the user.

See also
AbstractNotificator::notify(AbstractNotificator::Type type, QtMsgType severity, const QVariant &data)

◆ notify() [2/2]

void AbstractStorage::notify ( const Error * e) const
protected

Checks if a notificator has been set and will use it to notify about an occured error.

See also
AbstractNotificator::notify(const Error *e)

◆ queueCleared

void Fuoten::AbstractStorage::queueCleared ( )
signal

This is emitted after the local queue has been cleared.

Emit this in your implementation of clearQueue().

◆ ready()

bool AbstractStorage::ready ( ) const

Returns true when the storage is ready to handle data, otherwise false.

◆ readyChanged

void Fuoten::AbstractStorage::readyChanged ( bool ready)
signal

Emitted whenever the ready property changes.

◆ renamedFeed

void Fuoten::AbstractStorage::renamedFeed ( qint64 id,
const QString & newName )
signal

Emit this signal after a feed has been renamed.

Best location to emit this signal is your implementation of feedRename(). The signal has to contain the id of the renamed feed and the newName.

◆ renamedFolder

void Fuoten::AbstractStorage::renamedFolder ( qint64 id,
const QString & newName )
signal

Emit this after a folder has been renamed.

Best location to emit this signal is your implementation of folderRenamed(). The signal has to contain the id and the newName of the folder.

◆ requestedFeeds

void Fuoten::AbstractStorage::requestedFeeds ( const Fuoten::IdList & updatedFeeds,
const Fuoten::IdList & newFeeds,
const Fuoten::IdList & deletedFeeds )
signal

Emit this after feeds have been received and processed.

Best location to emit this signal is your implementation of feedsRequested().

Every argument of the signal should contain a list of feed IDs that are either updated, new or deleted.

◆ requestedFolders

void Fuoten::AbstractStorage::requestedFolders ( const QList< QPair< qint64, QString > > & updatedFolders,
const QList< QPair< qint64, QString > > & newFolders,
const Fuoten::IdList & deletedFolders )
signal

Emit this after folders have been received and processed.

Best location to emit this signal is your implementation of foldersRequested().

updatedFolders should contain a list of the database IDs and names of updated folders, newFolders should contain a list of databaes IDs and names of new folders, and deletedFolders should contain a list of database IDs of deleted folders.

◆ requestedItems

void Fuoten::AbstractStorage::requestedItems ( const Fuoten::IdList & updatedItems,
const Fuoten::IdList & newItems,
const Fuoten::IdList & deletedItems )
signal

Emit this after items/articles have been received and processed.

Best location to emit this signal is your implementation of itemsRequested().

Every argument of the signal should contain a list of item IDs that are either updated, new or deleted.

Parameters
updatedItemslist of IDs from items that have been updated
newItemslist of IDs from items that are new in the local storage
deletedItemslist of IDs from items that have been remove from the local storage

◆ setConfiguration()

void AbstractStorage::setConfiguration ( AbstractConfiguration * nConfiguration)

Setter function for the configuration property. Emits the configurationChanged() signal if nConfiguration is not equal to the stored value.

See also
AbstractStorage::configuration(), AbstractStorage::configurationChanged()

◆ setError()

void AbstractStorage::setError ( Error * nError)
protected

Sets the Error object.

See also
error

◆ setInOperation()

void AbstractStorage::setInOperation ( bool nInOperation)
protected

Setter function for the inOperation property. Emits the inOperationChanged() signal if nInOperation is not equal to the stored value.

See also
AbstractStorage::inOperation(), AbstractStorage::inOperationChanged()

◆ setNotificator()

void AbstractStorage::setNotificator ( AbstractNotificator * notificator)

Setter function for the notificator property.

See also
notificator(), notificatorChanged()

◆ setReady()

void AbstractStorage::setReady ( bool nReady)
protected

Set this to true when the storage has finished it's initialization.

See also
ready

◆ setStarred

void AbstractStorage::setStarred ( int nStarred)
protectedvirtualslot

Sets the total number of starred articles.

See also
starred

◆ setTotalUnread

void AbstractStorage::setTotalUnread ( int nTotalUnread)
protectedvirtualslot

Sets the total number of unread articles.

See also
totalUnread

◆ starred()

int AbstractStorage::starred ( ) const
virtual

Returns the total number of starred articles.

See also
starred

◆ starredChanged

void Fuoten::AbstractStorage::starredChanged ( int starred)
signal

This signal is emitted if the amount of total starred articles changes.

See also
starred

◆ starredItem

void Fuoten::AbstractStorage::starredItem ( qint64 feedId,
const QString & guidHash,
bool starred )
signal

Emit this after an item/article has been starred or unstarred.

Best location to emit this signal is your implementation of itemStarred().

Parameters
feedIdthe ID of the feed the item/article that has been starred or unstarred belongs to
guidHashthe global unique ID hash of the article that has been starred or unstarred
starredtrue if the article has been starred, false if it has been unstarred

◆ starredItems

void Fuoten::AbstractStorage::starredItems ( const QList< QPair< qint64, QString > > & articles,
bool star )
signal

Emit this after items/articles have been starred or unstarred.

Best location to emit this signal is your implementation of itemsStarred().

Parameters
articleslist of pairs of feed ID and guid hash of starred/unstarred articles
startrue if the articles have been starred, false if they have been unstarred

◆ storageCleared

void Fuoten::AbstractStorage::storageCleared ( )
signal

This is emitted after the local storage has been cleared.

Emit this in your implementation of clearStorage() after all local data has been deleted successfully.

◆ totalUnread()

int AbstractStorage::totalUnread ( ) const
virtual

Returns the total number of unread articles.

See also
totalUnread

◆ totalUnreadChanged

void Fuoten::AbstractStorage::totalUnreadChanged ( int totalUnread)
signal

This signal is emitted if the amount of total unread articles changes.

See also
totalUnread

The documentation for this class was generated from the following files:
  • Fuoten/Storage/abstractstorage.h
  • build/Fuoten/FuotenQt5_autogen/include/moc_abstractstorage.cpp
  • Fuoten/Storage/abstractstorage.cpp