|
libfuoten 0.8.1
Qt based library to access the ownCloud/Nextcloud News App API
|
#include <Fuoten/Models/BaseModel>
Properties | |
| double | doubleParentId |
| bool | inOperation |
| int | limit |
| bool | loaded |
| qint64 | parentId |
| Fuoten::FuotenEnums::SortingRole | sortingRole |
| Qt::SortOrder | sortOrder |
| Fuoten::AbstractStorage * | storage |
| bool | unreadOnly |
Public Member Functions | |
| BaseModel (QObject *parent=nullptr) | |
| ~BaseModel () override | |
| double | doubleParentId () const |
| virtual QModelIndex | findByID (qint64 id) const |
| virtual QHash< qint64, QModelIndex > | findByIDs (const IdList &ids) 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 |
| AbstractStorage * | storage () const |
| bool | unreadOnly () const |
Public Slots | |
| virtual void | load ()=0 |
| virtual void | reload () |
Signals | |
| 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 Member Functions | |
| virtual void | clear ()=0 |
| virtual void | handleStorageChanged (AbstractStorage *old) |
| void | setInOperation (bool nInOperation) |
| void | setLoaded (bool loaded) |
Abstract base class for all data models.
|
readwrite |
Stores the parent ID as double to make it accesseable from QML.
This uses the same data as parentId, but converts it between double and qint64. This is a convenience property for use in QML that does not support 64bit integers. As JavaScript and JSON are storing number values according to IEEE 754, there might happen an overflow, if setting values greater than the limit of qint64. Under normal circumstances we simply assume, that there will hardly be greater database IDs than what fits in qint64.
| double | doubleParentId() const |
| void | setDoubleParentId(double nDoubleParentId) |
| void | doubleParentIdChanged(double doubleParentId) |
|
readwrite |
Returns true while the model is loading data.
| bool | inOperation() const |
| void | inOperationChanged(bool inOperation) |
|
readwrite |
Limits the result to the specified number of objects.
| int | limit() const |
| void | setLimit(int nLimit) |
| void | limitChanged(int limit) |
|
read |
This property holds true if the model has initially loaded the data.
While it is true, load() will return immediately without loading data. Use reload() instead. When creating a derived class, you should use setLoaded() after your model has initially loaded the data.
|
readwrite |
Sets the parent database ID to load feeds/items for.
If used on a model presenting feeds, this defines the folder, the feed belongs to. If used on a model presenting items, this defines the feed the items belong to.
| qint64 | parentId() const |
| void | setParentId(qint64 nParentId) |
| void | parentIdChanged(qint64 parentId) |
|
readwrite |
The role/value used to sort the result.
| FuotenEnums::SortingRole | sortingRole() const |
| void | setSortingRole(FuotenEnums::SortingRole nSortingRole) |
| void | sortingRoleChanged(FuotenEnums::SortingRole sortingRole) |
|
readwrite |
The sorting order.
| Qt::SortOrder | sortOrder() const |
| void | setSortOrder(Qt::SortOrder nSortOrder) |
| void | sortOrderChanged(Qt::SortOrder sortOrder) |
|
readwrite |
Pointer to a class derived from AbstractStorage.
| AbstractStorage* | storage() const |
| void | setStorage(AbstractStorage *nStorage) |
| void | storageChanged(AbstractStorage *storage) |
|
readwrite |
If true, only unread articles, feeds or folders are returned.
| bool | unreadOnly() const |
| void | setUnreadOnly(bool nUnreadOnly) |
| void | unreadOnlyChanged(bool unreadOnly) |
|
explicit |
Constructs a new BaseModel object.
|
override |
Deconstructs the BaseModel object.
|
protectedpure virtual |
Clears the model and removes all model data.
Implemented in AbstractArticleModel, AbstractFeedModel, and AbstractFolderModel.
| 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.
|
signal |
This signal is emitted if the parent ID changes.
|
virtual |
Returns the model index of the item identified by database ID.
The default implementation returns an invalid QModelIndex. Reimplement this function in a subclass.
Reimplemented in AbstractArticleModel, AbstractFeedModel, and AbstractFolderModel.
|
virtual |
Returns a hash-table containing IDs and their model index fount in the model.
The default implementation return an empty QHash<qint64, QModelIndex>. Reimplement this function in a subclass.
Reimplemented in AbstractArticleModel, and AbstractFeedModel.
|
protectedvirtual |
Will be called by setStorage() whenever the storage changes.
The default implementation does nothing. You should use this to connect signals from the AbstractStorage to slots in the model implementation that updates the model data after the local data has been changed.
Reimplemented in AbstractArticleModel, AbstractFeedModel, and AbstractFolderModel.
| bool inOperation | ( | ) | const |
Returns true while the model is loading data.
|
signal |
This signal is emitted if the operational state of the model changes.
| int limit | ( | ) | const |
Getter function for the limit property.
|
signal |
This is emitted if the value of the limit property changes.
|
pure virtualslot |
Loads the model data.
Reimplement this in a subclass. Do only load the data, if loaded() returns false and set setLoaded() to true after the data has been loaded. All later changes, after the model has loaded the initial data, should be done by signals and slots without reloading the full model.
Additionally you could use the inOperation property in this function to indicate, that the model is loading its data.
| bool loaded | ( | ) | const |
Getter function for the loaded property. *.
|
signal |
This is emitted if the value of the loaded property changes.
| qint64 parentId | ( | ) | const |
Returns the currently set parent ID.
|
signal |
This signal is emitted if the parent ID changes.
|
virtualslot |
| 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.
|
protected |
Sets the inOperation property.
| void setLimit | ( | int | nLimit | ) |
Setter function for the limit property. Emits the limitChanged() signal if nLimit is not equal to the stored value.
|
protected |
Set this to true if the model has initially loaded its data.
In the reimplementation of a BaseModel this should be set in the implementation of the load() function, after the initial data has been loaded.
| 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.
|
signal |
This is emitted if the value of the sortingRole property changes.
| Qt::SortOrder sortOrder | ( | ) | const |
Getter function for the sortOrder property.
|
signal |
This is emitted if the value of the sortOrder property changes.
| AbstractStorage * storage | ( | ) | const |
Returns the pointer to the currently set local storage.
|
signal |
This signal is emitted if the poiner to the local storage changes.
| bool unreadOnly | ( | ) | const |
Getter function for the unreadOnly property.
|
signal |
This is emitted if the value of the unreadOnly property changes.