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

Abstract article model that provides basic functionalities for Article models. More...

#include <Fuoten/Models/AbstractArticleModel>

Inheritance diagram for Fuoten::AbstractArticleModel:
Fuoten::BaseModel QAbstractItemModel QObject Fuoten::ArticleListModel

Properties

int bodyLimit
 Limits the size of the body text in number of characters.
Fuoten::FuotenEnums::Type parentIdType
 Defines the type of the parentId. Can be Feed, Folder or All.
bool starredOnly
 If true, only starred articles will be returned.
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.

Public Member Functions

 AbstractArticleModel (QObject *parent=nullptr)
 Constructs a new empty abstract Article model with the given parent.
 ~AbstractArticleModel () override
 Destroys the AbstractArticleModel object.
int bodyLimit () const
 Getter function for the bodyLimit property.
QModelIndex findByID (qint64 id) const override
 Returns the model index of the Article identified by id. Returns an invalid index if the ID could not be found in the mode.
QHash< qint64, QModelIndexfindByIDs (const IdList &ids) const override
 Returns IDs and model indices of the Article objects in the model identified by their ID in ids.
FuotenEnums::Type parentIdType () const
 Getter function for the parentIdType property.
void setBodyLimit (int nBodyLimit)
 Setter function for the bodyLimit property. Emits the bodyLimitChanged() signal if nBodyLimit is not equal to the stored value.
void setParentIdType (FuotenEnums::Type nParentIdType)
 Setter function for the parentIdType property. Emits the parentIdTypeChanged() signal if nParentIdType is not equal to the stored value.
void setStarredOnly (bool nStarredOnly)
 Setter function for the starredOnly property. Emits the starredOnlyChanged() signal if nStarredOnly is not equal to the stored value.
bool starredOnly () const
 Getter function for the starredOnly property.
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.

Signals

void bodyLimitChanged (int bodyLimit)
 This is emitted if the value of the bodyLimit property changes.
void parentIdTypeChanged (FuotenEnums::Type parentIdType)
 This is emitted if the value of the parentIdType property changes.
void starredOnlyChanged (bool starredOnly)
 This is emitted if the value of the starredOnly property changes.
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.

Protected Slots

void allItemsMarkedRead (qint64 newestItemId)
 Takes and processes data after all items/articles have been marked as read.
void allItemsMarkedReadInQueue ()
 Takes and processes data after all items/articles have been marked as read in local queue.
void feedDeleted (qint64 feedId)
 Takes and processes data after a feed has been deleted.
void feedMarkedRead (qint64 feedId, qint64 newestItemId)
 Takes and processes data after a feed has been marked as read.
void feedMarkedReadInQueue (qint64 feedId, qint64 newestItemId)
 Takes and processes data after a feeds has been marked as read in local queue.
void folderDeleted (qint64 folderId)
 Takes and processes data after a folder has been deleted.
void folderMarkedRead (qint64 folderId, qint64 newestItemId)
 Takes and processses data after a folder has been marked as read.
void folderMarkedReadInQueue (qint64 folderId, qint64 newestItemId)
 Takes and processses data after a folder has been marked as read in the queue.
void itemMarked (qint64 itemId, bool unread)
 Takes and processes data after an item/article has been marked as read/unread.
void itemsMarked (const Fuoten::IdList &itemIds, bool unread)
 Takes and processes data after a list of items/articles has been marked as read/unread.
void itemsRequested (const Fuoten::IdList &updatedItems, const Fuoten::IdList &newItems, const Fuoten::IdList &deletedItems)
 Takes and processes data after items/articles have been requested.
void itemsStarred (const QList< QPair< qint64, QString > > &articles, bool starred)
 Takes and processes data after a list of items/articles has been starred/unstarred.
void itemStarred (qint64 feedId, const QString &guidHash, bool starred)
 Takes and processes data after an item/article has been starred/unstarred.
void queueCleared ()
 Updates the model after the local queue has been cleared.

Protected Member Functions

QList< Article * > articles () const
 Returns the list of Article objects in the model.
void clear () override
 Clears the model and destroy all Article objects.
void handleStorageChanged (AbstractStorage *old) override
 Connets the article related 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.

Detailed Description

Abstract article model that provides basic functionalities for Article models.

Property Documentation

◆ bodyLimit

int Fuoten::AbstractArticleModel::bodyLimit
readwrite

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. Defaults to -1.

Access functions:
intbodyLimit() const
voidsetBodyLimit(int nBodyLimit)
Notifier signal:
voidbodyLimitChanged(int bodyLimit)

◆ parentIdType

Fuoten::FuotenEnums::Type Fuoten::AbstractArticleModel::parentIdType
readwrite

Defines the type of the parentId. Can be Feed, Folder or All.

Default: FuotenEnums::All

Access functions:
FuotenEnums::TypeparentIdType() const
voidsetParentIdType(FuotenEnums::Type nParentIdType)
Notifier signal:
voidparentIdTypeChanged(FuotenEnums::Type parentIdType)

◆ starredOnly

bool Fuoten::AbstractArticleModel::starredOnly
readwrite

If true, only starred articles will be returned.

Access functions:
boolstarredOnly() const
voidsetStarredOnly(bool nStarredOnly)
Notifier signal:
voidstarredOnlyChanged(bool starredOnly)

Constructor & Destructor Documentation

◆ AbstractArticleModel()

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

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

◆ ~AbstractArticleModel()

AbstractArticleModel::~AbstractArticleModel ( )
override

Destroys the AbstractArticleModel object.

Member Function Documentation

◆ allItemsMarkedRead

void AbstractArticleModel::allItemsMarkedRead ( qint64 newestItemId)
protectedslot

Takes and processes data after all items/articles have been marked as read.

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

Parameters
newestItemIdhighest/newest ID of local available items/articles

◆ allItemsMarkedReadInQueue

void AbstractArticleModel::allItemsMarkedReadInQueue ( )
protectedslot

Takes and processes data after all items/articles have been marked as read in local queue.

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

◆ articles()

QList< Article * > AbstractArticleModel::articles ( ) const
protected

Returns the list of Article objects in the model.

◆ bodyLimit()

int AbstractArticleModel::bodyLimit ( ) const

◆ bodyLimitChanged

void Fuoten::AbstractArticleModel::bodyLimitChanged ( int bodyLimit)
signal

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

See also
AbstractArticleModel::bodyLimit(), AbstractArticleModel::setBodyLimit()

◆ clear()

void AbstractArticleModel::clear ( )
overrideprotectedvirtual

Clears the model and destroy all Article objects.

Implements Fuoten::BaseModel.

◆ feedDeleted

void AbstractArticleModel::feedDeleted ( qint64 feedId)
protectedslot

Takes and processes data after a feed has been deleted.

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

Parameters
feedIdID of the feed that has been deleted.

◆ feedMarkedRead

void AbstractArticleModel::feedMarkedRead ( qint64 feedId,
qint64 newestItemId )
protectedslot

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

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

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

◆ feedMarkedReadInQueue

void AbstractArticleModel::feedMarkedReadInQueue ( qint64 feedId,
qint64 newestItemId )
protectedslot

Takes and processes data after a feeds has been marked as read in local queue.

Will do the same as feedMarkedRead() but will also update the queue property of the article objects.

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

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

◆ findByID()

QModelIndex AbstractArticleModel::findByID ( qint64 id) const
overridevirtual

Returns the model index of the Article identified by id. Returns an invalid index if the ID could not be found in the mode.

Parameters
idID of the Article to find in the model

Reimplemented from Fuoten::BaseModel.

◆ findByIDs()

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

Returns IDs and model indices of the Article objects in the model identified by their ID in ids.

The key of the returned hash table will contain the ID of the Article, the value will contain the article's model index. Only articles will be returned of that the ID is part of the model.

Parameters
idslist of article IDs to find in the model

Reimplemented from Fuoten::BaseModel.

◆ folderDeleted

void AbstractArticleModel::folderDeleted ( qint64 folderId)
protectedslot

Takes and processes data after a folder has been deleted.

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

Parameters
folderIdID of the folder that has been deleted.

◆ folderMarkedRead

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

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

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

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

◆ folderMarkedReadInQueue

void AbstractArticleModel::folderMarkedReadInQueue ( qint64 folderId,
qint64 newestItemId )
protectedslot

Takes and processses data after a folder has been marked as read in the queue.

handleStorageChanged() will connect the AbstractStorage::markedReadFolderInQueue() signal to this slots.

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

◆ handleStorageChanged()

void AbstractArticleModel::handleStorageChanged ( AbstractStorage * old)
overrideprotectedvirtual

Connets the article related signals of AbstractStorage to the model's slots.

Reimplemented from Fuoten::BaseModel.

◆ itemMarked

void AbstractArticleModel::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 article that has been marked as read or unread
unreadtrue if the article has been marked as unread, false if it has been marked as read

◆ itemsMarked

void AbstractArticleModel::itemsMarked ( const Fuoten::IdList & itemIds,
bool unread )
protectedslot

Takes and processes data after a list of items/articles has been marked as read/unread.

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

Parameters
itemIdslist of IDs of items/articles that have been marked as read/unread
unreadtrue if the items/articles in the list have been marked as unread, false if they have been marked as read

◆ itemsRequested

void AbstractArticleModel::itemsRequested ( const Fuoten::IdList & updatedItems,
const Fuoten::IdList & newItems,
const Fuoten::IdList & deletedItems )
protectedslot

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

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

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

◆ itemsStarred

void AbstractArticleModel::itemsStarred ( const QList< QPair< qint64, QString > > & articles,
bool starred )
protectedslot

Takes and processes data after a list of items/articles has been starred/unstarred.

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

Parameters
articleslist of pairs of feed ID and article/item guid hash of articles that have been starred/unstarred
starredtrue if the articles in the list have been starred, false if the have been unstarred

◆ itemStarred

void AbstractArticleModel::itemStarred ( qint64 feedId,
const QString & guidHash,
bool starred )
protectedslot

Takes and processes data after an item/article has been starred/unstarred.

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

Parameters
feedIdID of the feed the article/item that has been starred/unstarred belongs to
guidHashGUID hash of the article/item that has been starred/unstarred
starredtrue if the article/item has been starred, false if it has been unstarred

◆ load

void AbstractArticleModel::load ( )
overrideslot

Populates the model with data from the local storage.

Use AbstractStorage::getArticles() to ge Article objects from the local storage that will be added to the model. If the BaseModel::parentId property is set to a value gerater than -1, only Articles will be loaded that are part of the type defined in AbstractArticleMode::parentIdType.

◆ parentIdType()

FuotenEnums::Type AbstractArticleModel::parentIdType ( ) const

◆ parentIdTypeChanged

void Fuoten::AbstractArticleModel::parentIdTypeChanged ( FuotenEnums::Type parentIdType)
signal

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

See also
AbstractArticleModel::parentIdType(), AbstractArticleModel::setParentIdType()

◆ queueCleared

void AbstractArticleModel::queueCleared ( )
protectedslot

Updates the model after the local queue has been cleared.

Will set the Article::queue property of every article in the model to FuotenEnums::NoQueueAction. handleStorageChanged() will connect the AbstractStorage::queueCleared() signal to this slot.

◆ setBodyLimit()

void AbstractArticleModel::setBodyLimit ( int nBodyLimit)

Setter function for the bodyLimit property. Emits the bodyLimitChanged() signal if nBodyLimit is not equal to the stored value.

See also
AbstractArticleModel::bodyLimit(), AbstractArticleModel::bodyLimitChanged()

◆ setParentIdType()

void AbstractArticleModel::setParentIdType ( FuotenEnums::Type nParentIdType)

Setter function for the parentIdType property. Emits the parentIdTypeChanged() signal if nParentIdType is not equal to the stored value.

See also
AbstractArticleModel::parentIdType(), AbstractArticleModel::parentIdTypeChanged()

◆ setStarredOnly()

void AbstractArticleModel::setStarredOnly ( bool nStarredOnly)

Setter function for the starredOnly property. Emits the starredOnlyChanged() signal if nStarredOnly is not equal to the stored value.

See also
AbstractArticleModel::starredOnly(), AbstractArticleModel::starredOnlyChanged()

◆ starredOnly()

bool AbstractArticleModel::starredOnly ( ) const

◆ starredOnlyChanged

void Fuoten::AbstractArticleModel::starredOnlyChanged ( bool starredOnly)
signal

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

See also
AbstractArticleModel::starredOnly(), AbstractArticleModel::setStarredOnly()

The documentation for this class was generated from the following files:
  • Fuoten/Models/abstractarticlemodel.h
  • build/Fuoten/FuotenQt5_autogen/include/moc_abstractarticlemodel.cpp
  • Fuoten/Models/abstractarticlemodel.cpp