Tagging

Search for usage in LXR

#include <tagging.h>

Inheritance diagram for Tagging:

Signals

void tagged (QVariantMap tag)
 
void tagRemoved (QString tag)
 
void urlRemoved (QString url)
 
void urlTagged (QString url, QString tag)
 
void urlTagRemoved (QString tag, QString url)
 

Public Slots

bool addTagToUrl (const QString tag, const QUrl &url)
 
bool fav (const QUrl &url)
 
const QVariantList get (const QString &query, std::function< bool(QVariantMap &item)> modifier=nullptr)
 
QVariantList getAllTags (const bool &strict=false)
 
FMH::MODEL_LIST getTags (const int &limit=5)
 
QList< QUrlgetTagUrls (const QString &tag, const QStringList &filters, const bool &strict=false, const int &limit=9999, const QString &mime=QStringLiteral(""))
 
QVariantList getUrls (const QString &tag, const bool &strict=false, const int &limit=MAX_LIMIT, const QString &mimeType=QStringLiteral(""), std::function< bool(QVariantMap &item)> modifier=nullptr)
 
QVariantList getUrlsTags (const bool &strict=false)
 
QVariantList getUrlTags (const QString &url, const bool &strict=false)
 
FMH::MODEL_LIST getUrlTags (const QUrl &url)
 
bool isFav (const QUrl &url, const bool &strict=false)
 
bool removeTag (const QString &tag, const bool &strict=false)
 
bool removeTagToUrl (const QString tag, const QUrl &url)
 
bool removeUrl (const QString &url)
 
bool removeUrlTag (const QString &url, const QString &tag)
 
bool removeUrlTags (const QString &url, const bool &strict=false)
 
bool tag (const QString &tag, const QString &color=QString(), const QString &comment=QString())
 
bool tagExists (const QString &tag, const bool &strict=false)
 
bool tagUrl (const QString &url, const QString &tag, const QString &color=QString(), const QString &comment=QString())
 
bool toggleFav (const QUrl &url)
 
bool unFav (const QUrl &url)
 
bool updateUrl (const QString &url, const QString &newUrl)
 
bool updateUrlTags (const QString &url, const QStringList &tags, const bool &strict=false)
 
bool urlTagExists (const QString &url, const QString &tag)
 

Static Public Member Functions

static TagginggetInstance ()
 
static QObjectqmlInstance (QQmlEngine *engine, QJSEngine *scriptEngine)
 
- 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)
 

Static Protected Member Functions

static bool setTagIconName (QVariantMap &item)
 

Additional Inherited Members

- Properties inherited from QObject
 objectName
 
- Public Member Functions inherited from QObject
 QObject (QObject *parent)
 
QBindable< QStringbindableObjectName ()
 
bool blockSignals (bool block)
 
const QObjectListchildren () 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< QByteArraydynamicPropertyNames () const const
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
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 QMetaObjectmetaObject () const const
 
void moveToThread (QThread *targetThread)
 
QString objectName () const const
 
void objectNameChanged (const QString &objectName)
 
QObjectparent () 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
 
qobject_cast (const QObject *object)
 
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)
 
QThreadthread () const const
 
- Public Attributes inherited from QObject
typedef QObjectList
 
- 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
 
QObjectsender () const const
 
int senderSignalIndex () const const
 
virtual void timerEvent (QTimerEvent *event)
 

Detailed Description

The Tagging class provides quick methods to access and modify the tags associated to the files.

Note
This class follows a singleton pattern and it is thread safe, by creating a new instance for each new thread that request access to the singleton. All of the internal instances are self-handled and destroyed when the application quits.

Graphical interfaces are provided which implement most of this class functionality and can be quickly used:

Definition at line 46 of file tagging.h.

Member Function Documentation

◆ addTagToUrl

bool Tagging::addTagToUrl ( const QString tag,
const QUrl & url )
slot

Adds a tag to a given file URL.

Parameters
tagthe wanted tag, if the tag doesn't exists it is created
urlthe file URL
Returns
whether the operation has been successful

Definition at line 400 of file tagging.cpp.

◆ fav

bool Tagging::fav ( const QUrl & url)
slot

Marks a file URL as favorite.

This works if the tagging component has been enabled, otherwise returns false as default.

Parameters
urlthe file URL
Returns
whether the operation has been successful

Definition at line 418 of file tagging.cpp.

◆ get

const QVariantList Tagging::get ( const QString & query,
std::function< bool(QVariantMap &item)> modifier = nullptr )
slot

Retrieve the information into a model, optionally you can pass a modifier callback function to manipulate or discard items in the model.

Parameters
querythe query to be retrieved
modifiera callback function that sends as an argument a reference to the current item being retrieved, which can be modified in-place, and expects a boolean value to be returned to decide if such item should de added to the model or not
Returns
the resulting model

Definition at line 75 of file tagging.cpp.

◆ getAllTags

QVariantList Tagging::getAllTags ( const bool & strict = false)
slot

Returns a list model of all the tags.

The model can be strictly enforced to only tags that were created by the application making the call

Parameters
strictif true returns only tags created by the application making the request
Returns
the model with the info of all the requested tags

Definition at line 224 of file tagging.cpp.

◆ getInstance()

Tagging * Tagging::getInstance ( )
static

Returns an instance to the tagging object.

Returns

Definition at line 70 of file tagging.cpp.

◆ getTags

FMH::MODEL_LIST Tagging::getTags ( const int & limit = 5)
slot

Get all the tags available with detailed information packaged as a FMH::MODEL_LIST.

Parameters
limitthe maximum numbers of tags
Returns
the model of tags

Definition at line 374 of file tagging.cpp.

◆ getTagUrls

QList< QUrl > Tagging::getTagUrls ( const QString & tag,
const QStringList & filters,
const bool & strict = false,
const int & limit = 9999,
const QString & mime = QStringLiteral("") )
slot

Shortcut for getting a list of file URLs associated to a tag, the resulting list of URLs can be filtered by regular expression or by mime-type and limited.

Parameters
tagthe tag to look up
filtersthe regular expressions list
strictif strict then the URLs returned are only associated to the application making the call, meaning, that such tag was added by such application only.
limitthe maximum limit number of URLs to be returned
mimethe mime-type filtering, for example, "image/\*" or "image/png", "audio/mp4"
Returns
the list of file URLs

Definition at line 348 of file tagging.cpp.

◆ getUrls

QVariantList Tagging::getUrls ( const QString & tag,
const bool & strict = false,
const int & limit = MAX_LIMIT,
const QString & mimeType = QStringLiteral(""),
std::function< bool(QVariantMap &item)> modifier = nullptr )
slot

Returns a model of all the file URLs associated to a tag, the result can be strictly enforced to only file URLs associated to a tag created by the application making the request, restrict it to a maximum limit, filter by the mime-type or just add a modifier function.

Parameters
tagthe tag name to perform the search
strictstrictly enforced to only file URLs associated to the given tag created by the application making the request
limitmaximum limit of results
mimeTypefilter by mime-type, for example: "image/\*" or "image/png"
modifiera callback function that sends as an argument a reference to the current item being retrieved, which can be modified, and expects a boolean value to be returned to decide if such item should be added to the model or not
Returns
the result model

Definition at line 231 of file tagging.cpp.

◆ getUrlsTags

QVariantList Tagging::getUrlsTags ( const bool & strict = false)
slot

Give a list of all tags associated to files.

Deprecated
Parameters
strict
Returns
whether the operation was successful

Definition at line 210 of file tagging.cpp.

◆ getUrlTags [1/2]

QVariantList Tagging::getUrlTags ( const QString & url,
const bool & strict = false )
slot

Returns a model list of all the tags associated to a file URL.

The result can be strictly enforced to only tags created by the application making the call

Parameters
urlthe file URL
strictstrictly enforced to only tags created by the application making the request
Returns
the result model

Definition at line 243 of file tagging.cpp.

◆ getUrlTags [2/2]

FMH::MODEL_LIST Tagging::getUrlTags ( const QUrl & url)
slot

Returns a model of tags associated to a file URL.

Parameters
urlthe file URL
Returns
model of the tags

Definition at line 395 of file tagging.cpp.

◆ isFav

bool Tagging::isFav ( const QUrl & url,
const bool & strict = false )
slot

Checks if a file URL has been marked as favorite.

This works if the tagging component has been enabled, otherwise returns false as default.

Parameters
urlthe file URL to be checked
strictstrictly check if the file has been marked as favorite by the app making the request or not
Returns

Definition at line 428 of file tagging.cpp.

◆ qmlInstance()

static QObject * Tagging::qmlInstance ( QQmlEngine * engine,
QJSEngine * scriptEngine )
inlinestatic

Definition at line 59 of file tagging.h.

◆ removeTag

bool Tagging::removeTag ( const QString & tag,
const bool & strict = false )
slot

Remove a tag.

Definition at line 293 of file tagging.cpp.

◆ removeTagToUrl

bool Tagging::removeTagToUrl ( const QString tag,
const QUrl & url )
slot

Removes a tag from a file URL if the tags exists.

Parameters
tagthe lookup tag
urlthe file URL
Returns
whether the operation has been successful

Definition at line 405 of file tagging.cpp.

◆ removeUrl

bool Tagging::removeUrl ( const QString & url)
slot

Removes a URL with its associated tags.

Parameters
urlthe file URL
Returns
whether the operation was successful

Definition at line 270 of file tagging.cpp.

◆ removeUrlTag

bool Tagging::removeUrlTag ( const QString & url,
const QString & tag )
slot

Removes a given tag associated to a given file URL.

Parameters
urlfile URL
tagtag associated to file URL to be removed
Returns
whether the operation was successful

Definition at line 257 of file tagging.cpp.

◆ removeUrlTags

bool Tagging::removeUrlTags ( const QString & url,
const bool & strict = false )
slot

Given a file URL remove all the tags associated to it.

Parameters
urlthe file URL
Returns
whether the operation was successful

Definition at line 251 of file tagging.cpp.

◆ setTagIconName()

bool Tagging::setTagIconName ( QVariantMap & item)
staticprotected

Definition at line 218 of file tagging.cpp.

◆ tag

bool Tagging::tag ( const QString & tag,
const QString & color = QString(),
const QString & comment = QString() )
slot

Adds a new tag, the newly created tag gets associated to the app making the call.

If the tag already exists nothing is changed. If the tag exists the app making the request will get associated to the tag too

Parameters
tagthe name of the tag
coloroptional color for the tag
commentoptional comment for the tag
Deprecated
Returns
whether the operation was successful, meaning the tag was created

Definition at line 131 of file tagging.cpp.

◆ tagExists

bool Tagging::tagExists ( const QString & tag,
const bool & strict = false )
slot

Checks if a given tag exists, it can be strictly enforced, meaning it is checked if the tag was created by the application making the request.

Parameters
tagthe tag to search
strictwhether the search should be strictly enforced. If strict is true then the tag should have been created by the app making the request, otherwise checks if the tag exists and could have been created by any other application.
Returns

Definition at line 111 of file tagging.cpp.

◆ tagUrl

bool Tagging::tagUrl ( const QString & url,
const QString & tag,
const QString & color = QString(),
const QString & comment = QString() )
slot

Adds a tag to a given file URL, if the given tag doesn't exists then it gets created.

Parameters
urlthe file URL to be tagged
tagthe tag to be added to the file URL
color
Deprecated
Optional color
Parameters
commentoptional comment
Returns
whether the operation was successful

Definition at line 164 of file tagging.cpp.

◆ toggleFav

bool Tagging::toggleFav ( const QUrl & url)
slot

Toggle the fav tag of a given file, meaning, if a file is marked as fav then the tag gets removed and if it is not marked then the fav tag gets added.

Parameters
urlthe file URL
Returns
whether the operation has been successful

Definition at line 410 of file tagging.cpp.

◆ unFav

bool Tagging::unFav ( const QUrl & url)
slot

If the given file has been marked as favorite then the tag is removed.

This works if the tagging component has been enabled, otherwise returns false as default.

Parameters
urlthe file URL
Returns
whether the operation has been successful

Definition at line 423 of file tagging.cpp.

◆ updateUrl

bool Tagging::updateUrl ( const QString & url,
const QString & newUrl )
slot

Updates a file URL to a new URL, preserving all associated tags.

This is useful if a file is rename or moved to a new location

Parameters
urlprevious file URL
newUrlnew file URL
Returns
whether the operation was successful

Definition at line 205 of file tagging.cpp.

◆ updateUrlTags

bool Tagging::updateUrlTags ( const QString & url,
const QStringList & tags,
const bool & strict = false )
slot

Updates the tags associated to a file URL.

If any of the given tags doesn't exists then they get created, if a tag associated to the current file URL is missing in the new passed tags then those get removed

Parameters
urlthe file URL
tagsthe new set of tags to be associated to the file URL
Returns
whether the operation was successful

Definition at line 193 of file tagging.cpp.

◆ urlTagExists

bool Tagging::urlTagExists ( const QString & url,
const QString & tag )
slot

Checks if a given tag is associated to a give file URL.

The check can be strictly enforced, meaning the given URL was tagged by the application making the request

Parameters
urlthe file URL
tagthe tag to perform the check
strictstrictly enforced check
Returns

Definition at line 118 of file tagging.cpp.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 17 2024 11:51:27 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.