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

Abstract base class for Folder, Feed and Article. More...

#include <Fuoten/BaseItem>

Inheritance diagram for Fuoten::BaseItem:
QObject Fuoten::Article Fuoten::Feed Fuoten::Folder

Properties

Fuoten::Errorerror
 Pointer to an Error object, if an error occurred, otherwise returns a nullptr.
qint64 id
 Database ID of the Article, Feed or Folder.
bool inOperation
 Returns true while there is an operation running on the item.

Public Member Functions

 BaseItem (QObject *parent=nullptr)
 Constructs an empty base item with the given parent.
 ~BaseItem () override
 Deconstructs the base item.
Q_INVOKABLE void clearError ()
 Removes the current Error object and sets a nullptr.
virtual void copy (BaseItem *other)
 Makes a deep copy of other into this object.
Errorerror () const
 Returns a pointer to an Error object, if any error occurred, otherwise a nullptr.
qint64 id () const
 Returns the ID of the item.
bool inOperation () const
 Returns true while there is some operation ongoing directly on the item.
void setId (qint64 nId)
 Sets the database ID of the item/feed/folder.

Signals

void errorChanged (Fuoten::Error *error)
 This signal will be emitted whenever the error property changes. May return a nullptr.
void idChanged (qint64 id)
 This signal will be emitted whenever the id property changes.
void inOperationChanged (bool inOperation)
 This signal will be emitted whenever the inOperation property changes.

Protected Member Functions

Componentcomponent () const
 Returns the pointer to the currently active Component.
void setComponent (Component *nComp)
 Sets the API component to perform an internal API request.
void setError (Error *nError)
 Sets the Error object of the error property.

Detailed Description

Abstract base class for Folder, Feed and Article.

Provides some basic properties used by other items. You have to derive this class and implement the pure virtual funtions.

Usage in models

If you are using a class that derives from BaseItem as the content object in a model, do not set the model as parent of the item if you intent to use item internal operations like remove, rename, etc. Setting the model as parent will delete the item when the model will be destructed.

Delete the model items manually in the model's destructor and check for items that are still inOperation(), use QObject::deleteLater() to delete these items so that they can finish the ongoing operation.

while (!folders.isEmpty()) {
Folder *f = folders.takeFirst();
if (f->inOperation()) {
} else {
delete f;
}
}
bool inOperation
Returns true while there is an operation running on the item.
Definition baseitem.h:68
Contains information about a single folder.
Definition folder.h:24
void deleteLater()

Property Documentation

◆ error

Fuoten::Error * Fuoten::BaseItem::error
read

Pointer to an Error object, if an error occurred, otherwise returns a nullptr.

Access functions:
Error*error() const
Notifier signal:
voiderrorChanged(Error *error)
See also
setError()

◆ id

qint64 Fuoten::BaseItem::id
read

Database ID of the Article, Feed or Folder.

Access functions:
qint64id() const
Notifier signal:
voididChanged(qint64 id)
See also
setId()

◆ inOperation

bool Fuoten::BaseItem::inOperation
read

Returns true while there is an operation running on the item.

This is used for operations that are directly invoked by methods from the item, not from outside classes.

Access functions:
boolinOperation() const
Notifier signal:
voidinOperationChanged(bool inOperation)

Constructor & Destructor Documentation

◆ BaseItem()

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

Constructs an empty base item with the given parent.

◆ ~BaseItem()

BaseItem::~BaseItem ( )
override

Deconstructs the base item.

Member Function Documentation

◆ clearError()

void BaseItem::clearError ( )

Removes the current Error object and sets a nullptr.

◆ component()

Component * BaseItem::component ( ) const
protected

Returns the pointer to the currently active Component.

If no component is active, a nullptr will be returned.

See also
setComponent()

◆ copy()

void BaseItem::copy ( BaseItem * other)
virtual

Makes a deep copy of other into this object.

The default implementation does nothing. When reimplementing, do a qobject_cast to the derived type.

Reimplemented in Fuoten::Article, Fuoten::Feed, and Fuoten::Folder.

◆ error()

Error * BaseItem::error ( ) const

Returns a pointer to an Error object, if any error occurred, otherwise a nullptr.

See also
BaseItem::error

◆ errorChanged

void Fuoten::BaseItem::errorChanged ( Fuoten::Error * error)
signal

This signal will be emitted whenever the error property changes. May return a nullptr.

See also
BaseItem::error

◆ id()

qint64 BaseItem::id ( ) const

Returns the ID of the item.

See also
BaseItem::id

◆ idChanged

void Fuoten::BaseItem::idChanged ( qint64 id)
signal

This signal will be emitted whenever the id property changes.

See also
BaseItem::id

◆ inOperation()

bool BaseItem::inOperation ( ) const

Returns true while there is some operation ongoing directly on the item.

See also
BaseItem::inOperation

◆ inOperationChanged

void Fuoten::BaseItem::inOperationChanged ( bool inOperation)
signal

This signal will be emitted whenever the inOperation property changes.

See also
BaseItem::inOperation

◆ setComponent()

void BaseItem::setComponent ( Component * nComp)
protected

Sets the API component to perform an internal API request.

This has to be a subclass of Component. Failed requests are handled automatically by connecting to the Component::failed() signal. It will set the BaseItem::error property and will delete the component as well setting the internal pointer to a nullptr.

Handling of succeeded API requests should be handled in the implementation.

Example
{
if (!config) {
qWarning("Can not delete the folder. No AbstractConfiguration available.");
return;
}
DeleteFolder *df = new DeleteFolder(this);
df->setConfiguration(config);
df->setStorage(storage);
df->setFolderId(id());
}
Server and authentication settings abstract base class.
Definition abstractconfiguration.h:34
Abstract class to handle the storage of requested News App data.
Definition abstractstorage.h:59
Component * component() const
Returns the pointer to the currently active Component.
Definition baseitem.cpp:101
void inOperationChanged(bool inOperation)
This signal will be emitted whenever the inOperation property changes.
Definition moc_baseitem.cpp:206
void setComponent(Component *nComp)
Sets the API component to perform an internal API request.
Definition baseitem.cpp:103
void setConfiguration(AbstractConfiguration *nAbstractConfiguration)
Sets a pointer to a AbstractConfiguration to use for the API request.
Definition component.cpp:634
void setStorage(AbstractStorage *localStorage)
Setter function for the storage property.
Definition component.cpp:660
virtual Q_INVOKABLE void execute()=0
Executes the API request.
Deletes a folder on the News App server.
Definition deletefolder.h:39
void setFolderId(qint64 nFolderId)
Sets the ID of the folder to delete.
Definition deletefolder.cpp:114
void succeeded(qint64 id)
Will be emitted in the success callback function and contains the ID of the deleted folder.
Definition moc_deletefolder.cpp:200
Q_INVOKABLE void remove()
Removes this folder from the remote server. This is an overloaded member function,...
Definition folder.cpp:172
Q_EMITQ_EMIT
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
See also
component()

◆ setError()

void BaseItem::setError ( Error * nError)
protected

Sets the Error object of the error property.

See also
error

◆ setId()

void BaseItem::setId ( qint64 nId)

Sets the database ID of the item/feed/folder.

See also
id

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