libfuoten  0.8.1
Qt based library to access the ownCloud/Nextcloud News App API
Properties | Public Member Functions | Signals | Protected Member Functions | List of all members
MarkMultipleItems Class Reference

#include <Fuoten/API/MarkMultipleItems>

Inheritance diagram for MarkMultipleItems:
Component

Properties

IdList itemIds
 
bool unread
 
- Properties inherited from Component
Fuoten::AbstractConfiguration configuration
 
Fuoten::Error error
 
bool inOperation
 
Fuoten::AbstractNotificator notificator
 
quint16 requestTimeout
 
Fuoten::AbstractStorage storage
 
bool useStorage
 
Fuoten::WipeManager wipeManager
 

Public Member Functions

 MarkMultipleItems (QObject *parent=nullptr)
 
 MarkMultipleItems (const IdList &itemIds, bool unread, QObject *parent=nullptr)
 
 ~MarkMultipleItems () override
 
Q_INVOKABLE void execute () override
 
IdList itemIds () const
 
void setItemIds (const IdList &nItemIds)
 
void setUnread (bool nUnread)
 
bool unread () const
 
- Public Member Functions inherited from Component
 Component (QObject *parent=nullptr)
 
 ~Component () override
 
AbstractConfigurationconfiguration () const
 
Errorerror () const
 
bool inOperation () const
 
bool isUseStorageEnabled () const
 
AbstractNotificatornotificator () const
 
quint16 requestTimeout () const
 
void setConfiguration (AbstractConfiguration *nAbstractConfiguration)
 
void setNotificator (AbstractNotificator *notificator)
 
void setRequestTimeout (quint16 seconds)
 
void setStorage (AbstractStorage *localStorage)
 
void setUseStorage (bool useStorage)
 
void setWipeManager (WipeManager *wipeManager)
 
AbstractStoragestorage () const
 
WipeManagerwipeManager () const
 

Signals

void itemIdsChanged (const Fuoten::IdList &itemIds)
 
void succeeded (const Fuoten::IdList &itemIds, bool unread)
 
void unreadChanged (bool unread)
 
- Signals inherited from Component
void configurationChanged (Fuoten::AbstractConfiguration *configuration)
 
void errorChanged (Fuoten::Error *error)
 
void failed (Fuoten::Error *error)
 
void inOperationChanged (bool inOperation)
 
void notificatorChanged (Fuoten::AbstractNotificator *notificator)
 
void requestTimeoutChanged (quint16 requestTimeout)
 
void sslErrors (QNetworkReply *reply, const QList< QSslError > &errors)
 
void storageChanged (Fuoten::AbstractStorage *storage)
 
void succeeded (const QJsonDocument &result)
 
void useStorageChanged (bool useStorage)
 
void wipeManagerChanged (Fuoten::WipeManager *wipeManager)
 

Protected Member Functions

bool checkInput () override
 
void successCallback () override
 
- Protected Member Functions inherited from Component
void addRequestHeader (const QByteArray &headerName, const QByteArray &headerValue)
 
void addRequestHeaders (const QHash< QByteArray, QByteArray > &headers)
 
virtual bool checkOutput ()
 
virtual void extractError (QNetworkReply *reply)
 
QJsonDocument jsonResult () const
 
void notify (const Error *e) const
 
void notify (AbstractNotificator::Type type, QtMsgType severity, const QVariant &data) const
 
QHash< QByteArray, QByteArray > requestHeaders () const
 
void sendRequest ()
 
void setApiRoute (const QString &route)
 
void setApiRoute (const QStringList &routeParts)
 
void setError (Error *nError)
 
void setExpectedJSONType (ExpectedJSONType type)
 
void setInOperation (bool nInOperation)
 
void setNetworkOperation (QNetworkAccessManager::Operation operation)
 
void setPayload (const QByteArray &payload)
 
void setPayload (const QJsonObject &payload)
 
void setRequestHeaders (const QHash< QByteArray, QByteArray > &headers)
 
void setRequiresAuth (bool reqAuth)
 
void setUrlQuery (const QUrlQuery &query)
 

Additional Inherited Members

- Public Types inherited from Component
enum  ExpectedJSONType : quint8 { Empty = 0, Array = 1, Object = 2 }
 
- Static Public Member Functions inherited from Component
static AbstractConfigurationdefaultConfiguration ()
 
static AbstractNotificatordefaultNotificator ()
 
static AbstractStoragedefaultStorage ()
 
static WipeManagerdefaultWipeManager ()
 
static AbstractNamFactorynetworkAccessManagerFactory ()
 
static void setDefaultConfiguration (AbstractConfiguration *config)
 
static void setDefaultNotificator (AbstractNotificator *notificator)
 
static void setDefaultStorage (AbstractStorage *storage)
 
static void setDefaultWipeManager (WipeManager *wipeManager)
 
static void setNetworkAccessManagerFactory (AbstractNamFactory *factory)
 

Detailed Description

Marks a list of articles read or unread on the News App server.

To mark a list of articles as read or unread, you have to set a list of article IDs to MarkMultipleItems::itemIds and a valid object to Component::configuration. Use MarkMultipleItems::unread to define if you want to mark the articles as read or unread. After setting the mandatory properties, call execute() to perform the API request.

If a valid AbstractStorage object is set to the Component::storage property, AbstractStorage::itemsMarked() will be called in the successCallback() to update the local storage. If the request succeeded, the MarkMultipleItemsPrivate::succeeded() signal will be emitted, containing the feedIds and the unread state. If something failed, the Component::failed() signal will be emitted and Component::error will contain a valid pointer to an Error object.

Mandatory properties
MarkMultipleItems::feedIds,Component::configuration
API route
/folders/{read|unread}/multiple
Method
PUT

Property Documentation

◆ itemIds

IdList itemIds
readwrite

List of IDs of items that should be marked as read or unread.

This property can not be changed while Component::inOperation() returns true.

Access functions:
IdListitemIds() const
voidsetItemIds(const IdList &nItemIds)
Notifier signal:
voiditemIdsChanged(const IdList &itemIds)

◆ unread

bool unread
readwrite

True if items should be marked as unread, otherwise false.

This property can not be changed while Component::inOperation() returns true.

Access functions:
boolunread() const
voidsetUnread(bool nUnread)
Notifier signal:
voidunreadChanged(bool unread)

Constructor & Destructor Documentation

◆ MarkMultipleItems() [1/2]

MarkMultipleItems ( QObject *  parent = nullptr)
explicit

Constructs a new MarkMultipleItems object with default values and the given parent.

◆ MarkMultipleItems() [2/2]

MarkMultipleItems ( const IdList &  itemIds,
bool  unread,
QObject *  parent = nullptr 
)

Constructs a new MarkMultipleItems object with the given arguments and parent.

◆ ~MarkMultipleItems()

~MarkMultipleItems ( )
override

Destroys the MarkMultipleItems object.

Member Function Documentation

◆ checkInput()

bool checkInput ( )
overrideprotectedvirtual

Will check if the itemIds property is not empty.

Will at first perform the checks of Component::checkInput(). Will than simply check for the existence of the itemIds list.

Reimplemented from Component.

◆ execute()

void execute ( )
overridevirtual

Executes the API request.

To perform a successful API request to mark a folder as read, MarkFolderRead::folderId and MarkFolderRead::newestItemId have to be valid IDs and there has to be a AbstractConfiguration object set to Component::configuration.

Execution will not run while Component::inOperation returns true and will itself set that property to true when the request starts.

Implements Component.

◆ itemIds()

IdList itemIds ( ) const

◆ itemIdsChanged

void itemIdsChanged ( const Fuoten::IdList &  itemIds)
signal

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

See also
MarkMultipleItems::itemIds(), MarkMultipleItems::setItemIds()

◆ setItemIds()

void setItemIds ( const IdList &  nItemIds)

Setter function for the itemIds property. Emits the itemIdsChanged() signal if nItemIds is not equal to the stored value.

See also
MarkMultipleItems::itemIds(), MarkMultipleItems::itemIdsChanged()

◆ setUnread()

void setUnread ( bool  nUnread)

Setter function for the unread property. Emits the unreadChanged() signal if nUnread is not equal to the stored value.

See also
MarkMultipleItems::unread(), MarkMultipleItems::unreadChanged()

◆ succeeded

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

This signal is emitted if the request to mark multiple items as read or unread was successful.

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

◆ successCallback()

void successCallback ( )
overrideprotectedvirtual

Finishes the marking if the request was successful.

If Component::storage contains a valid pointer, the AbstractStorage::itemsMarked() function will be called to update the local storage. After that the Component::inOperation property will be set to false and the succeeded() signal will be emitted.

Implements Component.

◆ unread()

bool unread ( ) const

◆ unreadChanged

void unreadChanged ( bool  unread)
signal

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

See also
MarkMultipleItems::unread(), MarkMultipleItems::setUnread()