libfuoten 0.8.1
Qt based library to access the ownCloud/Nextcloud News App API
Loading...
Searching...
No Matches
AbstractArticleModel Class Reference

#include <Fuoten/Models/AbstractArticleModel>

Inheritance diagram for AbstractArticleModel:
BaseModel ArticleListModel

Properties

int bodyLimit
Fuoten::FuotenEnums::Type parentIdType
bool starredOnly
Properties inherited from BaseModel
double doubleParentId
bool inOperation
int limit
bool loaded
qint64 parentId
Fuoten::FuotenEnums::SortingRole sortingRole
Qt::SortOrder sortOrder
Fuoten::AbstractStoragestorage
bool unreadOnly

Public Member Functions

 AbstractArticleModel (QObject *parent=nullptr)
 ~AbstractArticleModel () override
int bodyLimit () const
QModelIndex findByID (qint64 id) const override
QHash< qint64, QModelIndex > findByIDs (const IdList &ids) const override
FuotenEnums::Type parentIdType () const
void setBodyLimit (int nBodyLimit)
void setParentIdType (FuotenEnums::Type nParentIdType)
void setStarredOnly (bool nStarredOnly)
bool starredOnly () const
Public Member Functions inherited from BaseModel
 BaseModel (QObject *parent=nullptr)
 ~BaseModel () override
double doubleParentId () const
bool inOperation () const
int limit () const
bool loaded () const
qint64 parentId () const
void setDoubleParentId (double nDoubleParentId)
void setLimit (int nLimit)
void setParentId (qint64 nParentId)
void setSortingRole (FuotenEnums::SortingRole nSortingRole)
void setSortOrder (Qt::SortOrder nSortOrder)
void setStorage (AbstractStorage *nStorage)
void setUnreadOnly (bool nUnreadOnly)
FuotenEnums::SortingRole sortingRole () const
Qt::SortOrder sortOrder () const
AbstractStoragestorage () const
bool unreadOnly () const

Public Slots

void load () override
Public Slots inherited from BaseModel
virtual void load ()=0
virtual void reload ()

Signals

void bodyLimitChanged (int bodyLimit)
void parentIdTypeChanged (FuotenEnums::Type parentIdType)
void starredOnlyChanged (bool starredOnly)
Signals inherited from BaseModel
void doubleParentIdChanged (double doubleParentId)
void inOperationChanged (bool inOperation)
void limitChanged (int limit)
void loadedChanged (bool loaded)
void parentIdChanged (qint64 parentId)
void sortingRoleChanged (FuotenEnums::SortingRole sortingRole)
void sortOrderChanged (Qt::SortOrder sortOrder)
void storageChanged (Fuoten::AbstractStorage *storage)
void unreadOnlyChanged (bool unreadOnly)

Protected Slots

void allItemsMarkedRead (qint64 newestItemId)
void allItemsMarkedReadInQueue ()
void feedDeleted (qint64 feedId)
void feedMarkedRead (qint64 feedId, qint64 newestItemId)
void feedMarkedReadInQueue (qint64 feedId, qint64 newestItemId)
void folderDeleted (qint64 folderId)
void folderMarkedRead (qint64 folderId, qint64 newestItemId)
void folderMarkedReadInQueue (qint64 folderId, qint64 newestItemId)
void itemMarked (qint64 itemId, bool unread)
void itemsMarked (const Fuoten::IdList &itemIds, bool unread)
void itemsRequested (const Fuoten::IdList &updatedItems, const Fuoten::IdList &newItems, const Fuoten::IdList &deletedItems)
void itemsStarred (const QList< QPair< qint64, QString > > &articles, bool starred)
void itemStarred (qint64 feedId, const QString &guidHash, bool starred)
void queueCleared ()

Protected Member Functions

QList< Article * > articles () const
void clear () override
void handleStorageChanged (AbstractStorage *old) override
Protected Member Functions inherited from BaseModel
void setInOperation (bool nInOperation)
void setLoaded (bool loaded)

Detailed Description

Abstract article model that provides basic functionalities for Article models.

Property Documentation

◆ bodyLimit

int 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 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 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 ( QObject * parent = nullptr)
explicit

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

◆ ~AbstractArticleModel()

~AbstractArticleModel ( )
override

Destroys the AbstractArticleModel object.

Member Function Documentation

◆ allItemsMarkedRead

void 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 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 * > articles ( ) const
protected

Returns the list of Article objects in the model.

◆ bodyLimit()

int bodyLimit ( ) const

◆ bodyLimitChanged

void bodyLimitChanged ( int bodyLimit)
signal

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

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

◆ clear()

void clear ( )
overrideprotectedvirtual

Clears the model and destroy all Article objects.

Implements BaseModel.

◆ feedDeleted

void 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 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 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 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 BaseModel.

◆ findByIDs()

QHash< qint64, QModelIndex > 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 BaseModel.

◆ folderDeleted

void 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 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 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 handleStorageChanged ( AbstractStorage * old)
overrideprotectedvirtual

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

Reimplemented from BaseModel.

◆ itemMarked

void 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 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 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 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 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 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()

◆ parentIdTypeChanged

void parentIdTypeChanged ( FuotenEnums::Type parentIdType)
signal

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

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

◆ queueCleared

void 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 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 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 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 starredOnly ( ) const

◆ starredOnlyChanged

void starredOnlyChanged ( bool starredOnly)
signal

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

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