Skip to content

Commit

Permalink
feat: add new "remove" option to tag context menu (fix #3100)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bionus committed Feb 20, 2024
1 parent 28cf266 commit af539a9
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/gui/src/tag-context-menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,19 @@ TagContextMenu::TagContextMenu(QString tag, QList<Tag> allTags, QUrl browserUrl,
addAction(QIcon(":/images/icons/eye-minus.png"), tr("Blacklist"), this, SLOT(blacklist()));
}

// Ignore
// Ignored tags
if (profile->getIgnored().contains(m_tag, Qt::CaseInsensitive)) {
addAction(QIcon(":/images/icons/eye-plus.png"), tr("Don't ignore"), this, SLOT(unignore()));
} else {
addAction(QIcon(":/images/icons/eye-minus.png"), tr("Ignore"), this, SLOT(ignore()));
}

// Removed tags
if (profile->getRemovedTags().contains(m_tag)) {
addAction(QIcon(":/images/icons/eye-plus.png"), tr("Don't remove"), this, &TagContextMenu::unremove);
} else {
addAction(QIcon(":/images/icons/eye-minus.png"), tr("Remove"), this, &TagContextMenu::remove);
}
addSeparator();

// Copy
Expand Down Expand Up @@ -92,6 +99,15 @@ void TagContextMenu::unignore()
m_profile->removeIgnored(m_tag);
}

void TagContextMenu::remove()
{
m_profile->getRemovedTags().add(m_tag);
}
void TagContextMenu::unremove()
{
m_profile->getRemovedTags().remove(m_tag);
}

void TagContextMenu::blacklist()
{
m_profile->addBlacklistedTag(m_tag);
Expand Down
2 changes: 2 additions & 0 deletions src/gui/src/tag-context-menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ class TagContextMenu : public QMenu
void unviewitlater();
void ignore();
void unignore();
void remove();
void unremove();
void blacklist();
void unblacklist();
void openInNewTab();
Expand Down
14 changes: 14 additions & 0 deletions src/lib/src/models/filtering/tag-filter-list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ void TagFilterList::add(const QStringList &words)
}
}

void TagFilterList::remove(const QString &word)
{
if (word.contains('*')) {
m_starTags.removeAll(QRegularExpression::fromWildcard(word, Qt::CaseInsensitive));
} else {
m_rawTags.removeAll(word);
}
}

void TagFilterList::clear()
{
m_rawTags.clear();
Expand Down Expand Up @@ -48,3 +57,8 @@ QList<Tag> TagFilterList::filterTags(const QList<Tag> &tags) const

return ret;
}

bool TagFilterList::contains(const QString &word) const
{
return m_rawTags.contains(word, Qt::CaseInsensitive);
}
2 changes: 2 additions & 0 deletions src/lib/src/models/filtering/tag-filter-list.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ class TagFilterList
public:
void add(const QString &word);
void add(const QStringList &words);
void remove(const QString &word);
void clear();

QList<Tag> filterTags(const QList<Tag> &tags) const;
bool contains(const QString &word) const;

private:
QStringList m_rawTags;
Expand Down

0 comments on commit af539a9

Please # to comment.