Skip to content

Commit

Permalink
feat: add new "grabber:monitored" flag
Browse files Browse the repository at this point in the history
  • Loading branch information
Bionus committed Feb 8, 2023
1 parent 94fab58 commit b46ea6d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/_docs/search.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ A special token is generated by Grabber for images to be used by post-filters. I
* `grabber:inMd5List` if an image's MD5 is already present in the global MD5 list
* `grabber:downloaded` if either `grabber:alreadyExists` or `grabber:inMd5List` is true
* `grabber:favorited` if the image's tags contain a favorited tag
* `grabber:monitored` if the image's tags contain a monitored tag


# Blacklist
Expand Down
10 changes: 10 additions & 0 deletions src/lib/src/loader/downloadable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "functions.h"
#include "loader/token.h"
#include "models/profile.h"
#include "monitoring/monitor-manager.h"
#include "tags/tag.h"


Expand Down Expand Up @@ -90,6 +91,15 @@ const QMap<QString, Token> &Downloadable::tokens(Profile *profile) const
if (isFavorited) {
metas.append("favorited");
}

// Monitored
const auto &monitors = profile->monitorManager()->monitors();
bool isMonitored = std::any_of(monitors.constBegin(), monitors.constEnd(), [&tags](const Monitor &monitor) {
return tags.contains(monitor.query().toString());
});
if (isMonitored) {
metas.append("monitored");
}
}

return metas;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/src/models/profile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ Profile::Profile(QString path)
m_urlDownloaderManager = new UrlDownloaderManager(ReadWritePath(defaultPath, customPath), this);

// Complete auto-complete
static QStringList specialCompletes = { "grabber:alreadyExists", "grabber:inMd5List", "grabber:downloaded", "grabber:favorited" };
static QStringList specialCompletes = { "grabber:alreadyExists", "grabber:inMd5List", "grabber:downloaded", "grabber:favorited", "grabber:monitored" };
m_autoComplete.reserve(m_autoComplete.count() + m_customAutoComplete.count() + m_favorites.count() + specialCompletes.count());
m_autoComplete.append(m_customAutoComplete);
for (const Favorite &fav : qAsConst(m_favorites)) {
Expand Down

0 comments on commit b46ea6d

Please sign in to comment.