Skip to content

Commit

Permalink
itemtags: Remove unnecessary commands
Browse files Browse the repository at this point in the history
  • Loading branch information
hluk committed Apr 14, 2024
1 parent 12f8356 commit a8ec7f4
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions plugins/itemtags/itemtags.cpp
Expand Up @@ -168,16 +168,10 @@ void addTagCommands(const QString &tagName, const QString &match, QVector<Comman

c = dummyTagCommand();
c.internalId = QStringLiteral("copyq_tags_tag:") + name;
c.name = ItemTagsLoader::tr("Tag as %1").arg(quotedTag);
c.matchCmd = "copyq: plugins.itemtags.hasTag(" + tagString + ") && fail()";
c.cmd = "copyq: plugins.itemtags.tag(" + tagString + ")";
commands->append(c);

c = dummyTagCommand();
c.internalId = QStringLiteral("copyq_tags_untag:") + name;
c.name = ItemTagsLoader::tr("Remove tag %1").arg(quotedTag);
c.matchCmd = "copyq: plugins.itemtags.hasTag(" + tagString + ") || fail()";
c.cmd = "copyq: plugins.itemtags.untag(" + tagString + ")";
c.name = ItemTagsLoader::tr("Toggle Tag %1").arg(quotedTag);
c.cmd = QStringLiteral(
"copyq: (plugins.itemtags.hasTag(%1) ? plugins.itemtags.untag : plugins.itemtags.tag)(%1)"
).arg(tagString);
commands->append(c);
}

Expand Down Expand Up @@ -747,8 +741,14 @@ QVector<Command> ItemTagsLoader::commands() const
if (m_tags.isEmpty()) {
addTagCommands(tr("Important", "Tag name for example command"), QString(), &commands);
} else {
for (const auto &tag : m_tags)
const QRegularExpression reCapture(R"(\(.*\))");
const QRegularExpression reGroup(R"(\\\d)");
for (const auto &tag : m_tags) {
if ( reCapture.match(tag.match).hasMatch() && reGroup.match(tag.name).hasMatch() )
continue;

addTagCommands(tag.name, tag.match, &commands);
}
}

Command c;
Expand Down

0 comments on commit a8ec7f4

Please sign in to comment.