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

Abstract feed model that provides basic functionalities for Feed models. More...

#include <Fuoten/Models/AbstractFeedModel>

Inheritance diagram for Fuoten::AbstractFeedModel:
Fuoten::BaseModel QAbstractItemModel QObject Fuoten::FeedListModel

Public Member Functions

 AbstractFeedModel (QObject *parent=nullptr)
 Constructs a new empty abstract Feed model with the given parent.
 ~AbstractFeedModel () override
 Destroys the AbstractFeedModel object.
QModelIndex findByID (qint64 id) const override
 Returns the model index of the Feed identified by id.
QHash< qint64, QModelIndexfindByIDs (const IdList &ids) const override
 Returns IDs and model indices of the Feed objects in the model defined by their ID in ids.
Public Member Functions inherited from Fuoten::BaseModel
 BaseModel (QObject *parent=nullptr)
 Constructs a new BaseModel object.
 ~BaseModel () override
 Deconstructs the BaseModel object.
double doubleParentId () const
 Returns the currently set parent ID as double. This function is for use in QML, that does not support 64bit integers. It performs a static cast from the saved qint64 parent ID to double.
bool inOperation () const
 Returns true while the model is loading data.
int limit () const
 Getter function for the limit property.
bool loaded () const
 Getter function for the loaded property. *.
qint64 parentId () const
 Returns the currently set parent ID.
void setDoubleParentId (double nDoubleParentId)
 Sets the parent ID via a double. This function is for use in QML, that does not support 64bit integers. It performs a static cast from the double to a qint64 to save it.
void setLimit (int nLimit)
 Setter function for the limit property. Emits the limitChanged() signal if nLimit is not equal to the stored value.
void setParentId (qint64 nParentId)
 Set the parent ID.
void setSortingRole (FuotenEnums::SortingRole nSortingRole)
 Setter function for the sortingRole property. Emits the sortingRoleChanged() signal if nSortingRole is not equal to the stored value.
void setSortOrder (Qt::SortOrder nSortOrder)
 Setter function for the sortOrder property. Emits the sortOrderChanged() signal if nSortOrder is not equal to the stored value.
void setStorage (AbstractStorage *nStorage)
 Sets the pointer to the local storage handler.
void setUnreadOnly (bool nUnreadOnly)
 Setter function for the unreadOnly property. Emits the unreadOnlyChanged() signal if nUnreadOnly is not equal to the stored value.
FuotenEnums::SortingRole sortingRole () const
 Getter function for the sortingRole property.
Qt::SortOrder sortOrder () const
 Getter function for the sortOrder property.
AbstractStoragestorage () const
 Returns the pointer to the currently set local storage.
bool unreadOnly () const
 Getter function for the unreadOnly property.

Public Slots

void load () override
 Populates the model with data from the local storage.
Public Slots inherited from Fuoten::BaseModel
virtual void load ()=0
 Loads the model data.
virtual void reload ()
 Reloads the complete model.

Protected Slots

void feedCreated (qint64 id, qint64 folderId)
 Takes and processes data after a feed has been created.
void feedDeleted (qint64 id)
 Takes and processes data after a feed has been deleted.
void feedMarkedRead (qint64 id, qint64 newestItemId)
 Takes and processes data after a complete feed has been marked as read.
void feedMoved (qint64 id, qint64 targetFolderId)
 Takes and processes data after a feed has been moved to a different folder.
void feedRenamed (qint64 id, const QString &newName)
 Takes and processes data after a feed has been renamed.
void feedsRequested (const Fuoten::IdList &updatedFeeds, const Fuoten::IdList &newFeeds, const Fuoten::IdList &deletedFeeds)
 Takes and processes data after feeds have been requested.
void folderDeleted (qint64 folderId)
 Takes and processes data after a folder has been deleted.
void folderMarkedRead (qint64 folderId, qint64 newestItemId)
 Takes and processes data after a complete folder has been marked as read.
void itemMarked (qint64 itemId, bool unread)
 Takes and processes data after an item/article has been marked as read/unread.
void itemsMarked ()
 Should be called after a set of items has been marked as read or unread.
void itemsRquested (const Fuoten::IdList &updatedItems, const Fuoten::IdList &newItems, const Fuoten::IdList &deletedItems)
 Takes and processes data after items/articles have been requested/updated.

Protected Member Functions

void clear () override
 Clears the complete model and will destroy all Feed object.
QList< Feed * > feeds () const
 Returns the list of Feed objects in the model.
void handleStorageChanged (AbstractStorage *old) override
 Connects the feed realted signals of AbstractStorage to the model's slots.
Protected Member Functions inherited from Fuoten::BaseModel
void setInOperation (bool nInOperation)
 Sets the inOperation property.
void setLoaded (bool loaded)
 Set this to true if the model has initially loaded its data.

Additional Inherited Members

Properties inherited from Fuoten::BaseModel
double doubleParentId
 Stores the parent ID as double to make it accesseable from QML.
bool inOperation
 Returns true while the model is loading data.
int limit
 Limits the result to the specified number of objects.
bool loaded
 This property holds true if the model has initially loaded the data.
qint64 parentId
 Sets the parent database ID to load feeds/items for.
Fuoten::FuotenEnums::SortingRole sortingRole
 The role/value used to sort the result.
Qt::SortOrder sortOrder
 The sorting order.
Fuoten::AbstractStoragestorage
 Pointer to a class derived from AbstractStorage.
bool unreadOnly
 If true, only unread articles, feeds or folders are returned.
Signals inherited from Fuoten::BaseModel
void doubleParentIdChanged (double doubleParentId)
 This signal is emitted if the parent ID changes.
void inOperationChanged (bool inOperation)
 This signal is emitted if the operational state of the model changes.
void limitChanged (int limit)
 This is emitted if the value of the limit property changes.
void loadedChanged (bool loaded)
 This is emitted if the value of the loaded property changes.
void parentIdChanged (qint64 parentId)
 This signal is emitted if the parent ID changes.
void sortingRoleChanged (FuotenEnums::SortingRole sortingRole)
 This is emitted if the value of the sortingRole property changes.
void sortOrderChanged (Qt::SortOrder sortOrder)
 This is emitted if the value of the sortOrder property changes.
void storageChanged (Fuoten::AbstractStorage *storage)
 This signal is emitted if the poiner to the local storage changes.
void unreadOnlyChanged (bool unreadOnly)
 This is emitted if the value of the unreadOnly property changes.

Detailed Description

Abstract feed model that provides basic functionalities for Feed models.

Constructor & Destructor Documentation

◆ AbstractFeedModel()

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

Constructs a new empty abstract Feed model with the given parent.

◆ ~AbstractFeedModel()

AbstractFeedModel::~AbstractFeedModel ( )
override

Destroys the AbstractFeedModel object.

Member Function Documentation

◆ clear()

void AbstractFeedModel::clear ( )
overrideprotectedvirtual

Clears the complete model and will destroy all Feed object.

Implements Fuoten::BaseModel.

◆ feedCreated

void AbstractFeedModel::feedCreated ( qint64 id,
qint64 folderId )
protectedslot

Takes and processes data after a feed has been created.

handleStorageChanged() will connect the AbstractStorage::createdFeed() signal to this slot.

Parameters
idID of the newly created feed
folderIdID of the folder the newly created feed is part of

◆ feedDeleted

void AbstractFeedModel::feedDeleted ( qint64 id)
protectedslot

Takes and processes data after a feed has been deleted.

handleStorageChanged() will connect the AbstractStorage::deletedFeed() signal to this slot.

Parameters
idID of the deleted feed

◆ feedMarkedRead

void AbstractFeedModel::feedMarkedRead ( qint64 id,
qint64 newestItemId )
protectedslot

Takes and processes data after a complete feed has been marked as read.

handleStorageChanged() will connect the AbstractStorage::markedReadFeed() and AbstractStorage::markedReadFeedInQueue() signals to this slot.

Parameters
idID of the feed that has been marked as read
newestItemIdunused

◆ feedMoved

void AbstractFeedModel::feedMoved ( qint64 id,
qint64 targetFolderId )
protectedslot

Takes and processes data after a feed has been moved to a different folder.

handleStorageChanged() will connect the AbstractStorage::movedFeed() signal to this slot.

Parameters
idID of the moved feed
targetFolderIdID of the folder the feed has been moved to

◆ feedRenamed

void AbstractFeedModel::feedRenamed ( qint64 id,
const QString & newName )
protectedslot

Takes and processes data after a feed has been renamed.

handleStorageChanged() will connect the AbstractStorage::renamedFeed() signal to this slot.

Parameters
idID of the renamed feed
newNamenew name for the feed

◆ feeds()

QList< Feed * > AbstractFeedModel::feeds ( ) const
protected

Returns the list of Feed objects in the model.

◆ feedsRequested

void AbstractFeedModel::feedsRequested ( const Fuoten::IdList & updatedFeeds,
const Fuoten::IdList & newFeeds,
const Fuoten::IdList & deletedFeeds )
protectedslot

Takes and processes data after feeds have been requested.

handleStorageChanged() will connect the AbstractStorage::requestedFeeds() signal to this slot.

Parameters
updatedFeedslist of IDs of feeds that have been updated
newFeedslist of IDs of feeds that are new to the local storage
deletedFeedslist of IDs of feeds that have been deleted in the local storage (and remotely before)

◆ findByID()

QModelIndex AbstractFeedModel::findByID ( qint64 id) const
overridevirtual

Returns the model index of the Feed identified by id.

Parameters
idID of the feed to find in the model

Reimplemented from Fuoten::BaseModel.

◆ findByIDs()

QHash< qint64, QModelIndex > AbstractFeedModel::findByIDs ( const IdList & ids) const
overridevirtual

Returns IDs and model indices of the Feed objects in the model defined by their ID in ids.

The key of the hash table contains the ID of the Feed, the value will contain the feed's model index. Only feeds will be returned of that the ID is part of the model.

Parameters
idslist of feed IDs to find in the model

Reimplemented from Fuoten::BaseModel.

◆ folderDeleted

void AbstractFeedModel::folderDeleted ( qint64 folderId)
protectedslot

Takes and processes data after a folder has been deleted.

handleStorageChanged() will connect the AbstractStorage::deletedFolder() signal to this slot.

Parameters
folderIdID of the folder that has been deleted

◆ folderMarkedRead

void AbstractFeedModel::folderMarkedRead ( qint64 folderId,
qint64 newestItemId )
protectedslot

Takes and processes data after a complete folder has been marked as read.

handleStorageChanged() will connect the AbstractStorage::markedReadFolder() and AbstractStorage::markedReadFolderInQueue() signals to this slot.

Parameters
folderIdID of the folder that has been marked as read
newestItemIdunused

◆ handleStorageChanged()

void AbstractFeedModel::handleStorageChanged ( Fuoten::AbstractStorage * old)
overrideprotectedvirtual

Connects the feed realted signals of AbstractStorage to the model's slots.

Reimplemented from Fuoten::BaseModel.

◆ itemMarked

void AbstractFeedModel::itemMarked ( qint64 itemId,
bool unread )
protectedslot

Takes and processes data after an item/article has been marked as read/unread.

handleStorageChanged() will connect the AbstractStorage::markedItem() signal to this slot.

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

◆ itemsMarked

void AbstractFeedModel::itemsMarked ( )
protectedslot

Should be called after a set of items has been marked as read or unread.

Will update the unreadCount property of all Feed objects in the model.

handleStorageChanged() will connect the following signals to this slot:

◆ itemsRquested

void AbstractFeedModel::itemsRquested ( const Fuoten::IdList & updatedItems,
const Fuoten::IdList & newItems,
const Fuoten::IdList & deletedItems )
protectedslot

Takes and processes data after items/articles have been requested/updated.

handleStorageChanged() will connect the AbstractStorage::requestedItems() signal to this slot. The model will reload all feeds in it and will update the unreadCount properties, it will not use the arguments of the slot

◆ load

void AbstractFeedModel::load ( )
overrideslot

Populates the model with data from the local storage.

Uses AbstractStorage::getFeeds() to get Feed objects from the local storage that will be added to the model. If the BaseModel::parentId property is set to a value greater than -1, only feeds will be loaded that are part of the folder indentified by the parentId property.


The documentation for this class was generated from the following files:
  • Fuoten/Models/abstractfeedmodel.h
  • Fuoten/Models/abstractfeedmodel.cpp