KNSCore::EngineBase
#include <enginebase.h>
Public Types | |
enum class | ContentWarningType { Static , Executables } |
Public Types inherited from QObject | |
typedef | QObjectList |
Properties | |
ContentWarningType | contentWarningType |
QStringList | providerIDs |
bool | uploadEnabled |
QString | useLabel |
Properties inherited from QObject | |
objectName | |
Signals | |
void | loadingProvider () |
void | providersChanged () |
void | signalCategoriesMetadataLoded (const QList< Provider::CategoryMetadata > &categories) |
void | signalErrorCode (KNSCore::ErrorCode::ErrorCode errorCode, const QString &message, const QVariant &metadata) |
void | signalMessage (const QString &message) |
void | signalProvidersLoaded () |
void | signalSearchPresetsLoaded (const QList< Provider::SearchPreset > &presets) |
Public Member Functions | |
EngineBase (QObject *parent=nullptr) | |
void | addDownloadTagFilter (const QString &filter) |
void | addTagFilter (const QString &filter) |
QList< Attica::Provider * > | atticaProviders () const |
void | becomeFan (const Entry &entry) |
QSharedPointer< Cache > | cache () const |
QStringList | categories () const |
QList< Provider::CategoryMetadata > | categoriesMetadata () |
ContentWarningType | contentWarningType () const |
Q_SIGNAL void | contentWarningTypeChanged () |
QSharedPointer< Provider > | defaultProvider () const |
QStringList | downloadTagFilter () const |
bool | hasAdoptionCommand () const |
virtual bool | init (const QString &configfile) |
QString | name () const |
QSharedPointer< Provider > | provider (const QString &providerId) const |
QStringList | providerIDs () const |
ResultsStream * | search (const KNSCore::Provider::SearchRequest &request) |
QList< Provider::SearchPreset > | searchPresets () |
void | setDownloadTagFilter (const QStringList &filter) |
void | setTagFilter (const QStringList &filter) |
QStringList | tagFilter () const |
bool | uploadEnabled () const |
Q_SIGNAL void | uploadEnabledChanged () |
QString | useLabel () const |
Q_SIGNAL void | useLabelChanged () |
bool | userCanBecomeFan (const Entry &entry) |
bool | userCanVote (const Entry &entry) |
void | vote (const Entry &entry, uint rating) |
Public Member Functions inherited from QObject | |
QObject (QObject *parent) | |
QBindable< QString > | bindableObjectName () |
bool | blockSignals (bool block) |
const QObjectList & | children () const const |
QMetaObject::Connection | connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const |
void | deleteLater () |
void | destroyed (QObject *obj) |
bool | disconnect (const char *signal, const QObject *receiver, const char *method) const const |
bool | disconnect (const QObject *receiver, const char *method) const const |
void | dumpObjectInfo () const const |
void | dumpObjectTree () const const |
QList< QByteArray > | dynamicPropertyNames () const const |
virtual bool | event (QEvent *e) |
virtual bool | eventFilter (QObject *watched, QEvent *event) |
T | findChild (const QString &name, Qt::FindChildOptions options) const const |
QList< T > | findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const |
QList< T > | findChildren (const QString &name, Qt::FindChildOptions options) const const |
QList< T > | findChildren (Qt::FindChildOptions options) const const |
bool | inherits (const char *className) const const |
void | installEventFilter (QObject *filterObj) |
bool | isQuickItemType () const const |
bool | isWidgetType () const const |
bool | isWindowType () const const |
void | killTimer (int id) |
virtual const QMetaObject * | metaObject () const const |
void | moveToThread (QThread *targetThread) |
QString | objectName () const const |
void | objectNameChanged (const QString &objectName) |
QObject * | parent () const const |
QVariant | property (const char *name) const const |
Q_CLASSINFO (Name, Value) | |
Q_EMIT Q_EMIT | |
Q_ENUM (...) | |
Q_ENUM_NS (...) | |
Q_ENUMS (...) | |
Q_FLAG (...) | |
Q_FLAG_NS (...) | |
Q_FLAGS (...) | |
Q_GADGET Q_GADGET | |
Q_GADGET_EXPORT (EXPORT_MACRO) | |
Q_INTERFACES (...) | |
Q_INVOKABLE Q_INVOKABLE | |
Q_MOC_INCLUDE Q_MOC_INCLUDE | |
Q_NAMESPACE Q_NAMESPACE | |
Q_NAMESPACE_EXPORT (EXPORT_MACRO) | |
Q_OBJECT Q_OBJECT | |
Q_PROPERTY (...) | |
Q_REVISION Q_REVISION | |
Q_SET_OBJECT_NAME (Object) | |
Q_SIGNAL Q_SIGNAL | |
Q_SIGNALS Q_SIGNALS | |
Q_SLOT Q_SLOT | |
Q_SLOTS Q_SLOTS | |
T | qobject_cast (const QObject *object) |
T | qobject_cast (QObject *object) |
QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT | |
void | removeEventFilter (QObject *obj) |
void | setObjectName (const QString &name) |
void | setObjectName (QAnyStringView name) |
void | setParent (QObject *parent) |
bool | setProperty (const char *name, const QVariant &value) |
bool | setProperty (const char *name, QVariant &&value) |
bool | signalsBlocked () const const |
int | startTimer (int interval, Qt::TimerType timerType) |
int | startTimer (std::chrono::milliseconds interval, Qt::TimerType timerType) |
QThread * | thread () const const |
Static Public Member Functions | |
static QStringList | availableConfigFiles () |
Static Public Member Functions inherited from QObject | |
QMetaObject::Connection | connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, Functor functor) |
bool | disconnect (const QMetaObject::Connection &connection) |
bool | disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method) |
bool | disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method) |
bool | disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method) |
QString | tr (const char *sourceText, const char *disambiguation, int n) |
Protected Member Functions | |
virtual void | addProvider (QSharedPointer< KNSCore::Provider > provider) |
Installation * | installation () const |
QList< QSharedPointer< Provider > > | providers () const |
virtual void | updateStatus () |
Protected Member Functions inherited from QObject | |
virtual void | childEvent (QChildEvent *event) |
virtual void | connectNotify (const QMetaMethod &signal) |
virtual void | customEvent (QEvent *event) |
virtual void | disconnectNotify (const QMetaMethod &signal) |
bool | isSignalConnected (const QMetaMethod &signal) const const |
int | receivers (const char *signal) const const |
QObject * | sender () const const |
int | senderSignalIndex () const const |
virtual void | timerEvent (QTimerEvent *event) |
Protected Attributes | |
std::unique_ptr< EngineBasePrivate > | d |
Detailed Description
KNewStuff engine.
An engine keeps track of data which is available locally and remote and offers high-level synchronization calls as well as upload and download primitives using an underlying GHNS protocol.
This is a base class for different engine implementations
Definition at line 51 of file enginebase.h.
Member Enumeration Documentation
◆ ContentWarningType
|
strong |
The ContentWarningType enum.
- Since
- 6.1
Definition at line 348 of file enginebase.h.
Property Documentation
◆ contentWarningType
|
read |
Definition at line 77 of file enginebase.h.
◆ providerIDs
|
read |
- Since
- 5.85
Definition at line 72 of file enginebase.h.
◆ uploadEnabled
|
read |
Whether or not the configuration says that the providers are expected to support uploading.
As it stands, this is used to determine whether or not to show the Upload... action where that is displayed (primarily NewStuff.Page).
- Since
- 5.85
Definition at line 67 of file enginebase.h.
◆ useLabel
|
read |
Text that should be displayed for the adoption button, this defaults to "Use".
- Since
- 5.77
Definition at line 59 of file enginebase.h.
Constructor & Destructor Documentation
◆ EngineBase()
EngineBase::EngineBase | ( | QObject * | parent = nullptr | ) |
Definition at line 38 of file enginebase.cpp.
◆ ~EngineBase()
EngineBase::~EngineBase | ( | ) |
Definition at line 57 of file enginebase.cpp.
Member Function Documentation
◆ addDownloadTagFilter()
void EngineBase::addDownloadTagFilter | ( | const QString & | filter | ) |
Add a single filter entry to the download tag filter.
The filter should be in the same form as the filter lines in the list used by setDownloadsTagFilter(QStringList)
- Parameters
-
filter The filter in the form of a string
- See also
- setTagFilter(QStringList)
- setDownloadTagFilter(QStringList)
- Since
- 5.51
Definition at line 394 of file enginebase.cpp.
◆ addProvider()
|
protectedvirtual |
Add a provider and connect it to the right slots.
Reimplemented in Engine.
Definition at line 251 of file enginebase.cpp.
◆ addTagFilter()
void KNSCore::EngineBase::addTagFilter | ( | const QString & | filter | ) |
Add a single filter entry to the entry tag filter.
The filter should be in the same form as the filter lines in the list used by setTagFilter(QStringList)
- Parameters
-
filter The filter in the form of a string
- See also
- setTagFilter(QStringList)
- Since
- 5.51
Definition at line 373 of file enginebase.cpp.
◆ atticaProviders()
QList< Attica::Provider * > EngineBase::atticaProviders | ( | ) | const |
- Returns
- the list of attica (OCS) providers this engine is connected to
- Since
- 5.92
Definition at line 402 of file enginebase.cpp.
◆ availableConfigFiles()
|
static |
List of all available config files.
This list will contain no duplicated filenames. The returned file paths are absolute.
- Since
- 5.83
Definition at line 47 of file enginebase.cpp.
◆ becomeFan()
void EngineBase::becomeFan | ( | const Entry & | entry | ) |
This will mark the user who is currently authenticated as a fan of the entry passed to the function.
- Parameters
-
entry The entry the user wants to be a fan of
Definition at line 433 of file enginebase.cpp.
◆ cache()
QSharedPointer< Cache > EngineBase::cache | ( | ) | const |
Get the entries cache for this engine (note that it may be null if the engine is not yet initialized).
- Returns
- The cache for this engine (or null if the engine is not initialized)
- Since
- 5.74
Definition at line 355 of file enginebase.cpp.
◆ categories()
QStringList EngineBase::categories | ( | ) | const |
The list of the server-side names of the categories handled by this engine instance.
This corresponds directly to the list of categories in your knsrc file. This is not supposed to be used as user-facing strings -
- See also
- categoriesMetadata() for that.
- Returns
- The categories which this instance of Engine handles
Definition at line 226 of file enginebase.cpp.
◆ categoriesMetadata()
QList< Provider::CategoryMetadata > EngineBase::categoriesMetadata | ( | ) |
The list of metadata for the categories handled by this engine instance.
If you wish to show the categories to the user, this is the data to use. The category name is the string used to set categories for the filter, and also what is returned by both categories() and categoriesFilter(). The human-readable name is displayName, and the only thing which should be shown to the user.
- Returns
- The metadata for all categories handled by this engine
Definition at line 231 of file enginebase.cpp.
◆ contentWarningType()
EngineBase::ContentWarningType EngineBase::contentWarningType | ( | ) | const |
The level of warning that should be presented to the user.
- Since
- 6.1
- See also
- ContentWarningType
Definition at line 476 of file enginebase.cpp.
◆ contentWarningTypeChanged()
Q_SIGNAL void KNSCore::EngineBase::contentWarningTypeChanged | ( | ) |
Emitted after the initial config load.
- Since
- 6.1
◆ defaultProvider()
QSharedPointer< Provider > EngineBase::defaultProvider | ( | ) | const |
Return the first provider in the providers list (usually the default provider)
- Returns
- The first Provider (or null if the engine is not initialized)
- Since
- 5.63
Definition at line 444 of file enginebase.cpp.
◆ downloadTagFilter()
QStringList EngineBase::downloadTagFilter | ( | ) | const |
Gets the current downloadlink tag filter list.
- See also
- setDownloadTagFilter(QStringList)
- Since
- 5.51
Definition at line 389 of file enginebase.cpp.
◆ hasAdoptionCommand()
bool EngineBase::hasAdoptionCommand | ( | ) | const |
Whether or not an adoption command exists for this engine.
- See also
- adoptionCommand(KNSCore::Entry)
- Returns
- True if an adoption command exists
Definition at line 457 of file enginebase.cpp.
◆ init()
|
virtual |
Initializes the engine.
This step is application-specific and relies on an external configuration file, which determines all the details about the initialization.
- Parameters
-
configfile KNewStuff2 configuration file (*.knsrc)
- Returns
- true if any valid configuration was found, false otherwise
- See also
- KNS3::DownloadDialog
Definition at line 66 of file enginebase.cpp.
◆ installation()
|
protected |
Definition at line 466 of file enginebase.cpp.
◆ name()
QString KNSCore::EngineBase::name | ( | ) | const |
The name as defined by the knsrc file.
- Returns
- The name associated with the engine's configuration file
- Since
- 5.63
Definition at line 221 of file enginebase.cpp.
◆ provider()
QSharedPointer< Provider > EngineBase::provider | ( | const QString & | providerId | ) | const |
◆ providerIDs()
QStringList EngineBase::providerIDs | ( | ) | const |
The IDs of all providers known by this engine.
Use this in combination with provider(const QString&) to iterate over all providers.
- Returns
- The string IDs of all known providers
- Since
- 5.85
Definition at line 452 of file enginebase.cpp.
◆ providers()
|
protected |
Definition at line 481 of file enginebase.cpp.
◆ providersChanged
|
signal |
Fired whenever the list of providers changes.
- Since
- 5.85
◆ search()
ResultsStream * EngineBase::search | ( | const KNSCore::Provider::SearchRequest & | request | ) |
Returns a stream object that will fulfill the request
.
- Since
- 6.0
Definition at line 471 of file enginebase.cpp.
◆ searchPresets()
QList< Provider::SearchPreset > EngineBase::searchPresets | ( | ) |
Definition at line 236 of file enginebase.cpp.
◆ setDownloadTagFilter()
void EngineBase::setDownloadTagFilter | ( | const QStringList & | filter | ) |
Sets a filter to be applied to the downloads for an entry.
The logic is the same as used in setTagFilter(QStringList), but vitally, only one downloadlink is required to match the filter for the list to be valid. If you do not wish to show the others in your client, you must hide them yourself.
For an entry to be accepted when a download tag filter is set, it must also be accepted by the entry filter (so, for example, while a list of downloads might be accepted, if the entry has ghns_excluded set, and the default entry filter is set, the entry will still be filtered out).
In your knsrc file, set DownloadTagFilter to the filter you wish to apply, using the same logic as described for the entry tagfilter.
- Parameters
-
filter The filter in the form of a list of strings
- See also
- setTagFilter(QStringList)
- Since
- 5.51
Definition at line 381 of file enginebase.cpp.
◆ setTagFilter()
void EngineBase::setTagFilter | ( | const QStringList & | filter | ) |
Set a filter for results, which filters out all entries which do not match the filter, as applied to the tags for the entry.
This filters only on the tags specified for the entry itself. To filter the downloadlinks, use setDownloadTagFilter(QStringList).
- Note
- The default filter if one is not set from your knsrc file will filter out entries marked as ghns_excluded=1. To retain this when setting a custom filter, add "ghns_excluded!=1" as one of the filters.
- Some tags provided by OCS do not supply a value (and are simply passed as a key). These will be interpreted as having the value 1 for filtering purposes. An example of this might be ghns_excluded, which in reality will generally be passed through ocs as "ghns_excluded" rather than "ghns_excluded=1"
- As tags are metadata, they are provided in the form of adjectives. They are never supplied as action verbs or instructions (as an example, a good tag to suggest that for example a wallpaper is painted would be "painted" as opposed to "paint", and another example might be that an item should be "excluded" as opposed to "exclude").
== Examples of use == Value for tag "tagname" must be exactly "tagdata": tagname==tagdata
Value for tag "tagname" must be different from "tagdata": tagname!=tagdata
== KNSRC entry == A tag filter line in a .knsrc file, which is a comma separated list of tag/value pairs, might look like:
TagFilter=ghns_excluded!=1,data##mimetype==application/cbr+zip,data##mimetype==application/cbr+rar which would honour the exclusion and filter out anything that does not include a comic book archive in either zip or rar format in one or more of the download items. Notice in particular that there are two data##mimetype entries. Use this for when a tag may have multiple values.
TagFilter=application##architecture==x86_64 which would not honour the exclusion, and would filter out all entries which do not mark themselves as having a 64bit application binary in at least one download item.
The value does not current support wildcards. The list should be considered a binary AND operation (that is, all filter entries must match for the data entry to be included in the return data)
- Parameters
-
filter The filter in the form of a list of strings
- See also
- setDownloadTagFilter(QStringList)
- Since
- 5.51
Definition at line 360 of file enginebase.cpp.
◆ signalErrorCode
|
signal |
Fires in the case of any critical or serious errors, such as network or API problems.
- Parameters
-
errorCode Represents the specific type of error which has occurred message A human-readable message which can be shown to the end user metadata Any additional data which might be hepful to further work out the details of the error (see KNSCore::Entry::ErrorCode for the metadata details)
- See also
- KNSCore::Entry::ErrorCode
- Since
- 5.53
◆ signalMessage
|
signal |
Indicates a message to be added to the ui's log, or sent to a messagebox.
◆ signalSearchPresetsLoaded
|
signal |
Fires when the engine has loaded search presets.
These represent interesting searches for the user, such as recommendations.
- Since
- 5.83
◆ tagFilter()
QStringList EngineBase::tagFilter | ( | ) | const |
Gets the current tag filter list.
- See also
- setTagFilter(QStringList)
- Since
- 5.51
Definition at line 368 of file enginebase.cpp.
◆ updateStatus()
|
protectedvirtual |
Definition at line 462 of file enginebase.cpp.
◆ uploadEnabled()
bool EngineBase::uploadEnabled | ( | ) | const |
Whether or not the configuration says that the providers are expected to support uploading.
- Returns
- True if the providers are expected to support uploading
- Since
- 5.85
Definition at line 246 of file enginebase.cpp.
◆ uploadEnabledChanged()
Q_SIGNAL void KNSCore::EngineBase::uploadEnabledChanged | ( | ) |
Fired when the uploadEnabled property changes.
- Since
- 5.85
◆ useLabel()
QString EngineBase::useLabel | ( | ) | const |
Text that should be displayed for the adoption button, this defaults to i18n("Use")
- Since
- 5.77
Definition at line 241 of file enginebase.cpp.
◆ useLabelChanged()
Q_SIGNAL void KNSCore::EngineBase::useLabelChanged | ( | ) |
Signal gets emitted when the useLabel property changes.
- Since
- 5.77
◆ userCanBecomeFan()
bool EngineBase::userCanBecomeFan | ( | const Entry & | entry | ) |
Whether or not the user is allowed to become a fan of a particular entry.
Not all providers (and consequently entries) support the fan functionality and you can use this function to determine this ability.
- Parameters
-
entry The entry the user might wish to be a fan of
- Returns
- Whether or not it is possible for the user to become a fan of that entry
Definition at line 427 of file enginebase.cpp.
◆ userCanVote()
bool EngineBase::userCanVote | ( | const Entry & | entry | ) |
Whether or not a user is able to vote on the passed entry.
- Parameters
-
entry The entry to check votability on
- Returns
- True if the user is able to vote on the entry
Definition at line 415 of file enginebase.cpp.
◆ vote()
void EngineBase::vote | ( | const Entry & | entry, |
uint | rating ) |
Cast a vote on the passed entry.
- Parameters
-
entry The entry to vote on rating A number from 0 to 100, 50 being neutral, 0 being most negative and 100 being most positive.
Definition at line 421 of file enginebase.cpp.
Member Data Documentation
◆ d
|
protected |
Definition at line 439 of file enginebase.h.
The documentation for this class was generated from the following files:
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Oct 11 2024 12:12:42 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.