#include "tagmanager.h" TagManager::TagManager(SqliteDbService &dbService) { this->dbService = &dbService; } bool TagManager::addTagsToPath(QString path, const QSet &tags) { QVector currentTags = this->dbService->getTagsForPath(path); for(const QString &tag : tags) { currentTags.append(tag.toLower()); } QSet newTags{currentTags.begin(), currentTags.end()}; return this->dbService->setTags(path, newTags); } bool TagManager::removeTagsForPath(QString path, const QSet &tags) { QVector currentTags = this->dbService->getTagsForPath(path); for(const QString &tag : tags) { currentTags.removeAll(tag); } QSet newTags{currentTags.begin(), currentTags.end()}; return this->dbService->setTags(path, newTags); } bool TagManager::removePathsForTag(QString tag, const QVector &paths) { return this->dbService->removePathsForTag(tag, paths); } bool TagManager::deleteTag(QString tag) { return this->dbService->deleteTag(tag); } QVector TagManager::getTags(QString path) { return this->dbService->getTagsForPath(path); } QVector TagManager::getTags() { return this->dbService->getTags(); } QVector TagManager::getPaths(QString tag) { return this->dbService->getPathsForTag(tag); } bool TagManager::addTagsToPath(QString path, QString tagstring, QChar delim) { auto splitted = tagstring.split(delim); return addTagsToPath(path, QSet{splitted.begin(), splitted.end()}); } bool TagManager::addPathsToTag(QString tag, const QVector &paths) { return this->dbService->addTag(tag, paths); }