MauiKit File Browsing
tagging.cpp
75const QVariantList Tagging::get(const QString &queryTxt, std::function<bool(QVariantMap &item)> modifier)
113 return !strict ? this->db()->checkExistance(TAG::TABLEMAP[TAG::TABLE::TAGS], FMH::MODEL_NAME[FMH::MODEL_KEY::TAG], tag)
114 : this->db()->checkExistance(QString(QStringLiteral("select t.tag from APP_TAGS where t.org = '%1' and t.tag = '%2'"))
120 return this->db()->checkExistance(QString(QStringLiteral("select * from TAGS_URLS where url = '%1' and tag = '%2'")).arg(url, tag));
127 this->appOrg = qApp->organizationDomain().isEmpty() ? QString(QStringLiteral("org.maui.%1")).arg(this->appName) : qApp->organizationDomain();
144 {FMH::MODEL_NAME[FMH::MODEL_KEY::ADDDATE], QDateTime::currentDateTime().toString(Qt::TextDate)},
153 {FMH::MODEL_NAME[FMH::MODEL_KEY::ADDDATE], QDateTime::currentDateTime().toString(Qt::TextDate)}};
207 return this->db()->update(TAG::TABLEMAP[TAG::TABLE::TAGS_URLS], {{FMH::MODEL_KEY::URL, newUrl}}, {{FMH::MODEL_NAME[FMH::MODEL_KEY::URL], url}});
210QVariantList Tagging::getUrlsTags(const bool &strict) //all used tags, meaning, all tags that are used with an url in tags_url table
212 const auto query = !strict ? QString(QStringLiteral("select distinct t.* from TAGS t inner join TAGS_URLS turl where t.tag = turl.tag order by t.tag asc")) :
220 item.insert(QStringLiteral("icon"), item.value(QStringLiteral("tag")).toString() == QStringLiteral("fav") ? QStringLiteral("love") : QStringLiteral("tag"));
231QVariantList Tagging::getUrls(const QString &tag, const bool &strict, const int &limit, const QString &mimeType, std::function<bool(QVariantMap &item)> modifier)
233 return !strict ? this->get(QString(QStringLiteral("select distinct * from TAGS_URLS where tag = '%1' and mime like '%2%' limit %3")).arg(tag, mimeType, QString::number(limit)), modifier)
245 return !strict ? this->get(QString(QStringLiteral("select distinct turl.*, t.color, t.comment as tagComment from tags t inner join TAGS_URLS turl on turl.tag = t.tag where turl.url = '%1'")).arg(url))
251bool Tagging::removeUrlTags(const QString &url, const bool &strict) // same as removing the url from the tags_urls
330 const auto filtersAccumulate = std::accumulate(filters.constBegin(), filters.constEnd(), QVector<QRegularExpression> {}, [](QVector<QRegularExpression> &res, const QString &filter) -> QVector<QRegularExpression> {
331 QString wildcardExp = QRegularExpression::wildcardToRegularExpression(filter).replace(QStringLiteral("[^/]"), QStringLiteral("."));
348QList<QUrl> Tagging::getTagUrls(const QString &tag, const QStringList &filters, const bool &strict, const int &limit, const QString &mime)
384 data << FMH::MODEL {{FMH::MODEL_KEY::PATH, FMStatic::PATHTYPE_URI[FMStatic::PATHTYPE_KEY::TAGS_PATH] + label},
385 {FMH::MODEL_KEY::ICON, item.value(FMH::MODEL_NAME[FMH::MODEL_KEY::ICON], QStringLiteral("tag")).toString()},
386 {FMH::MODEL_KEY::MODIFIED, QDateTime::fromString(item.value(FMH::MODEL_NAME[FMH::MODEL_KEY::ADDDATE]).toString(), Qt::TextDate).toString()},
static const QHash< PATHTYPE_KEY, QString > PATHTYPE_URI
Similar to PATHTYPE_SCHEME, but mapped with the complete scheme.
Definition fmstatic.h:369
static QString PathTypeLabel(const FMStatic::PATHTYPE_KEY &key)
Given a PATHTYPE_KEY return a user friendly string.
Definition fmstatic.cpp:31
The TAGDB class exposes methods to add, remove and modify tags in the MauiKit FileBrowsing Tagging sy...
Definition tagdb.h:56
bool update(const QString &tableName, const FMH::MODEL &updateData, const QVariantMap &where) const
Update data in the database.
Definition tagdb.cpp:182
bool checkExistance(const QString &tableName, const QString &searchId, const QString &search) const
Check for the existence of an entry.
Definition tagdb.cpp:120
bool insert(const QString &tableName, const QVariantMap &insertData) const
Insert data into the given table.
Definition tagdb.cpp:152
QSqlQuery getQuery(const QString &queryTxt) const
Retrieve the database query object of a performed a query.
Definition tagdb.cpp:140
The Tagging class provides quick methods to access and modify the tags associated to the files.
Definition tagging.h:43
void urlTagged(QString url, QString tag)
Emitted when a tag has been assigened to a file URL.
bool tag(const QString &tag, const QString &color=QString(), const QString &comment=QString())
Adds a new tag, the newly created tag gets associated to the app making the call.
Definition tagging.cpp:131
const QVariantList get(const QString &query, std::function< bool(QVariantMap &item)> modifier=nullptr)
Retrieve the information into a model, optionally you can pass a modifier callback function to manipu...
Definition tagging.cpp:75
QList< QUrl > getTagUrls(const QString &tag, const QStringList &filters, const bool &strict=false, const int &limit=9999, const QString &mime=QStringLiteral(""))
Shortcut for getting a list of file URLs associated to a tag, the resulting list of URLs can be filte...
Definition tagging.cpp:348
QVariantList getUrlsTags(const bool &strict=false)
Give a list of all tags associated to files.
Definition tagging.cpp:210
bool tagUrl(const QString &url, const QString &tag, const QString &color=QString(), const QString &comment=QString())
Adds a tag to a given file URL, if the given tag doesn't exists then it gets created.
Definition tagging.cpp:164
bool tagExists(const QString &tag, const bool &strict=false)
Checks if a given tag exists, it can be strictly enforced, meaning it is checked if the tag was creat...
Definition tagging.cpp:111
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)
Returns a model of all the file URLs associated to a tag, the result can be strictly enforced to only...
Definition tagging.cpp:231
bool isFav(const QUrl &url, const bool &strict=false)
Checks if a file URL has been marked as favorite.
Definition tagging.cpp:428
FMH::MODEL_LIST getTags(const int &limit=5)
Get all the tags available with detailed information packaged as a FMH::MODEL_LIST.
Definition tagging.cpp:374
bool updateUrlTags(const QString &url, const QStringList &tags, const bool &strict=false)
Updates the tags associated to a file URL.
Definition tagging.cpp:193
QVariantList getAllTags(const bool &strict=false)
Returns a list model of all the tags.
Definition tagging.cpp:224
bool removeTagToUrl(const QString tag, const QUrl &url)
Removes a tag from a file URL if the tags exists.
Definition tagging.cpp:405
bool unFav(const QUrl &url)
If the given file has been marked as favorite then the tag is removed.
Definition tagging.cpp:423
bool removeUrlTag(const QString &url, const QString &tag)
Removes a given tag associated to a given file URL.
Definition tagging.cpp:257
QVariantList getUrlTags(const QString &url, const bool &strict=false)
Returns a model list of all the tags associated to a file URL.
Definition tagging.cpp:243
bool urlTagExists(const QString &url, const QString &tag)
Checks if a given tag is associated to a give file URL.
Definition tagging.cpp:118
void urlTagRemoved(QString tag, QString url)
Emitted when a tag has been dissociated from a file URL.
bool updateUrl(const QString &url, const QString &newUrl)
Updates a file URL to a new URL, preserving all associated tags.
Definition tagging.cpp:205
bool toggleFav(const QUrl &url)
Toggle the fav tag of a given file, meaning, if a file is marked as fav then the tag gets removed and...
Definition tagging.cpp:410
void urlRemoved(QString url)
Emitted when a file has been removed a thus all associations to any tag.
bool removeUrlTags(const QString &url, const bool &strict=false)
Given a file URL remove all the tags associated to it.
Definition tagging.cpp:251
bool addTagToUrl(const QString tag, const QUrl &url)
Adds a tag to a given file URL.
Definition tagging.cpp:400
const QString mapValue(const QVariantMap &map, const MODEL_KEY &key)
const FMH::MODEL_LIST toModelList(const QVariantList &list)
bool fileExists(const QUrl &path)
static const QHash< MODEL_KEY, QString > MODEL_NAME
void aboutToQuit()
QDateTime currentDateTime()
QDateTime fromString(QStringView string, QStringView format, QCalendar cal)
QString toString(QStringView format, QCalendar cal) const const
QString baseName() const const
bool contains(const Key &key) const const
iterator insert(const Key &key, const T &value)
const_iterator constBegin() const const
const_iterator constEnd() const const
qsizetype indexOf(const AT &value, qsizetype from) const const
bool isEmpty() const const
T value(qsizetype i) const const
QMimeType mimeTypeForFile(const QFileInfo &fileInfo, MatchMode mode) const const
name
Q_EMITQ_EMIT
QString arg(Args &&... args) const const
bool isEmpty() const const
QString number(double n, char format, int precision)
TextDate
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
QThread * currentThread()
QString toString(FormattingOptions options) const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 29 2024 11:49:46 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 29 2024 11:49:46 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.