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 | providerAdded (KNSCore::ProviderCore *provider) |
void | providersChanged () |
void | signalCategoriesMetadataLoaded (const QList< KNSCore::CategoryMetadata > &categories) |
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< KNSCore::SearchPreset > &presets) |
void | signalSearchPresetsLoaded (const QList< Provider::SearchPreset > &presets) |
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 55 of file enginebase.h.
Member Enumeration Documentation
◆ ContentWarningType
|
strong |
The ContentWarningType enum.
- Since
- 6.1
Definition at line 387 of file enginebase.h.
Property Documentation
◆ contentWarningType
|
read |
Definition at line 81 of file enginebase.h.
◆ providerIDs
|
read |
- Since
- 5.85
Definition at line 76 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 71 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 63 of file enginebase.h.
Constructor & Destructor Documentation
◆ EngineBase()
EngineBase::EngineBase | ( | QObject * | parent = nullptr | ) |
Definition at line 93 of file enginebase.cpp.
◆ ~EngineBase()
|
override |
Definition at line 112 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 459 of file enginebase.cpp.
◆ addProvider()
|
protectedvirtual |
Add a provider and connect it to the right slots.
- Deprecated
- since 6.9 Use providerAdded signal
Definition at line 337 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 438 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 467 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 102 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 498 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
- Deprecated
- since 6.9 Do not use the cache directly
Definition at line 419 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 284 of file enginebase.cpp.
◆ categoriesMetadata()
QList< Provider::CategoryMetadata > EngineBase::categoriesMetadata | ( | ) |
- Deprecated
- since 6.9 use categoriesMetadata2
Definition at line 290 of file enginebase.cpp.
◆ categoriesMetadata2()
QList< CategoryMetadata > EngineBase::categoriesMetadata2 | ( | ) |
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 300 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 547 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
- Deprecated
- since 6.9 Do not write provider-specific code
Definition at line 512 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 454 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 526 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 121 of file enginebase.cpp.
◆ installation()
|
protected |
Definition at line 535 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 279 of file enginebase.cpp.
◆ provider()
QSharedPointer< Provider > EngineBase::provider | ( | const QString & | providerId | ) | const |
The Provider instance with the passed ID.
- Parameters
-
providerId The ID of the Provider to fetch
- Since
- 5.63
- Deprecated
- since 6.9 Do not write provider-specific code
Definition at line 505 of file enginebase.cpp.
◆ 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 521 of file enginebase.cpp.
◆ providers()
|
protected |
- Deprecated
- since 6.9 Do not write provider-specific code
Definition at line 553 of file enginebase.cpp.
◆ providersChanged
|
signal |
Fired whenever the list of providers changes.
- Since
- 5.85
- Deprecated
- since 6.9 Use providerAdded signal
◆ search() [1/2]
ResultsStream * EngineBase::search | ( | const KNSCore::Provider::SearchRequest & | request | ) |
Returns a stream object that will fulfill the request
.
- Since
- 6.0
- Deprecated
- since 6.9 Use the new search function
Definition at line 541 of file enginebase.cpp.
◆ search() [2/2]
KNSCore::ResultsStream * KNSCore::EngineBase::search | ( | const KNSCore::SearchRequest & | request | ) |
Returns a stream object that will fulfill the request
.
- Since
- 6.9
Definition at line 559 of file enginebase.cpp.
◆ searchPresets()
QList< Provider::SearchPreset > EngineBase::searchPresets | ( | ) |
- Deprecated
- since 6.9 use searchPresets2
Definition at line 306 of file enginebase.cpp.
◆ searchPresets2()
QList< SearchPreset > EngineBase::searchPresets2 | ( | ) |
- Since
- 6.9
Definition at line 321 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 446 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 425 of file enginebase.cpp.
◆ signalCategoriesMetadataLoded
|
signal |
- Deprecated
- since 6.9 Use variant with new argument type
◆ 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 helpful 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 [1/2]
|
signal |
Fires when the engine has loaded search presets.
These represent interesting searches for the user, such as recommendations.
- Since
- 6.9
◆ signalSearchPresetsLoaded [2/2]
|
signal |
Fires when the engine has loaded search presets.
These represent interesting searches for the user, such as recommendations.
- Since
- 5.83
- Deprecated
- since 6.9 Use variant with new argument type
◆ tagFilter()
QStringList EngineBase::tagFilter | ( | ) | const |
Gets the current tag filter list.
- See also
- setTagFilter(QStringList)
- Since
- 5.51
Definition at line 433 of file enginebase.cpp.
◆ updateStatus()
|
protectedvirtual |
Definition at line 531 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 331 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 326 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 492 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 480 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 486 of file enginebase.cpp.
Member Data Documentation
◆ d
|
protected |
Definition at line 511 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 Dec 20 2024 11:50:57 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.