reapack

Package manager for REAPER
Log | Files | Refs | Submodules | README | LICENSE

commit 6c3ed15525fc1d62390cdeed8957207cd18a9de3
parent 08e3618524c5ba25f2a6100a8bb40b71d3bf9f31
Author: cfillion <cfillion@users.noreply.github.com>
Date:   Thu,  6 Jan 2022 21:51:06 -0500

add an option to toggle the synonym matching feature

Diffstat:
Msrc/browser.cpp | 6+++++-
Msrc/config.cpp | 9+++++++--
Msrc/config.hpp | 5+++++
Msrc/filter.cpp | 6+++++-
Msrc/listview.cpp | 7++-----
Msrc/manager.cpp | 18++++++++++++++----
Msrc/manager.hpp | 5++---
7 files changed, 40 insertions(+), 16 deletions(-)

diff --git a/src/browser.cpp b/src/browser.cpp @@ -390,7 +390,10 @@ void Browser::updateFilter() { stopTimer(TIMER_FILTER); - m_list->setFilter(Win32::getWindowText(m_filter)); + { + ListView::BeginEdit edit(m_list); + m_list->setFilter(Win32::getWindowText(m_filter)); + } updateDisplayLabel(); } @@ -549,6 +552,7 @@ void Browser::fillList() m_list->clear(); m_list->reserveRows(m_entries.size()); + m_list->setFilter(Win32::getWindowText(m_filter)); // in case filter settings changed for(const Entry &entry : m_entries) { if(!match(entry)) diff --git a/src/config.cpp b/src/config.cpp @@ -41,6 +41,7 @@ static const char *MANAGER_GRP = "manager"; static const char *BROWSER_GRP = "browser"; static const char *STATE_KEY = "state"; +static const char *SYNONYMS_KEY = "synonyms"; static const char *NETWORK_GRP = "network"; static const char *PROXY_KEY = "proxy"; @@ -73,6 +74,7 @@ void Config::resetOptions() { install = {false, false, true}; network = {"", true, NetworkOpts::OneWeekThreshold}; + filter = {true}; windowState = {}; } @@ -151,6 +153,8 @@ void Config::read() network.staleThreshold = (time_t)getUInt(NETWORK_GRP, STALETHRSH_KEY, (unsigned int)network.staleThreshold); + filter.expandSynonyms = getBool(BROWSER_GRP, SYNONYMS_KEY, filter.expandSynonyms); + windowState.about = getString(ABOUT_GRP, STATE_KEY, windowState.about); windowState.browser = getString(BROWSER_GRP, STATE_KEY, windowState.browser); windowState.manager = getString(MANAGER_GRP, STATE_KEY, windowState.manager); @@ -170,13 +174,14 @@ void Config::write() setString(NETWORK_GRP, PROXY_KEY, network.proxy); setUInt(NETWORK_GRP, VERIFYPEER_KEY, network.verifyPeer); - setUInt(NETWORK_GRP, STALETHRSH_KEY, (unsigned int)network.staleThreshold); + setUInt(NETWORK_GRP, STALETHRSH_KEY, static_cast<unsigned int>(network.staleThreshold)); + + setUInt(BROWSER_GRP, SYNONYMS_KEY, filter.expandSynonyms); setString(ABOUT_GRP, STATE_KEY, windowState.about); setString(BROWSER_GRP, STATE_KEY, windowState.browser); setString(MANAGER_GRP, STATE_KEY, windowState.manager); - writeRemotes(); } diff --git a/src/config.hpp b/src/config.hpp @@ -47,6 +47,10 @@ struct NetworkOpts { time_t staleThreshold; }; +struct FilterOpts { + bool expandSynonyms; +}; + class Config { public: Config(const Path &); @@ -63,6 +67,7 @@ public: InstallOpts install; NetworkOpts network; + FilterOpts filter; WindowState windowState; RemoteList remotes; diff --git a/src/filter.cpp b/src/filter.cpp @@ -17,6 +17,9 @@ #include "filter.hpp" +#include "config.hpp" +#include "reapack.hpp" + #include <boost/algorithm/string.hpp> Filter::Filter(const std::string &input) @@ -133,7 +136,8 @@ Filter::Group *Filter::Group::push(const std::string &buf, int *flags) return this; } - else if(pushSynonyms(buf, flags)) + else if((!g_reapack || g_reapack->config()->filter.expandSynonyms) && + pushSynonyms(buf, flags)) return this; } diff --git a/src/listview.cpp b/src/listview.cpp @@ -281,11 +281,8 @@ void ListView::filter() void ListView::setFilter(const std::string &newFilter) { - if(m_filter != newFilter) { - ListView::BeginEdit edit(this); - m_filter = newFilter; - m_dirty |= NeedFilterFlag; - } + m_filter = newFilter; + m_dirty |= NeedFilterFlag; } void ListView::reindexVisible() diff --git a/src/manager.cpp b/src/manager.cpp @@ -40,7 +40,7 @@ enum { ACTION_UNINSTALL = 80, ACTION_ABOUT, ACTION_REFRESH, ACTION_COPYURL, ACTION_SELECT, ACTION_UNSELECT, ACTION_AUTOINSTALL_GLOBAL, ACTION_AUTOINSTALL_OFF, ACTION_AUTOINSTALL_ON, ACTION_AUTOINSTALL, - ACTION_BLEEDINGEDGE, ACTION_PROMPTOBSOLETE, ACTION_NETCONFIG, + ACTION_BLEEDINGEDGE, ACTION_PROMPTOBSOLETE, ACTION_SYNONYMS, ACTION_NETCONFIG, ACTION_RESETCONFIG, ACTION_IMPORT_REPO, ACTION_IMPORT_ARCHIVE, ACTION_EXPORT_ARCHIVE, }; @@ -159,6 +159,9 @@ void Manager::onCommand(const int id, int) case ACTION_PROMPTOBSOLETE: toggle(m_promptObsolete, g_reapack->config()->install.promptObsolete); break; + case ACTION_SYNONYMS: + toggle(m_expandSynonyms, g_reapack->config()->filter.expandSynonyms); + break; case ACTION_NETCONFIG: setupNetwork(); break; @@ -549,6 +552,11 @@ void Manager::options() if(m_promptObsolete.value_or(g_reapack->config()->install.promptObsolete)) menu.check(index); + index = menu.addAction( + "Search for synonyms of common words", ACTION_SYNONYMS); + if(m_expandSynonyms.value_or(g_reapack->config()->filter.expandSynonyms)) + menu.check(index); + menu.addAction("&Network settings...", ACTION_NETCONFIG); menu.addSeparator(); @@ -607,6 +615,9 @@ bool Manager::apply() if(m_promptObsolete) g_reapack->config()->install.promptObsolete = *m_promptObsolete; + if(m_expandSynonyms) + g_reapack->config()->filter.expandSynonyms = *m_expandSynonyms; + for(const auto &pair : m_mods) { Remote remote = pair.first; const RemoteMods &mods = pair.second; @@ -650,9 +661,8 @@ void Manager::reset() { m_mods.clear(); m_uninstall.clear(); - m_autoInstall = std::nullopt; - m_bleedingEdge = std::nullopt; - m_promptObsolete = std::nullopt; + m_autoInstall = m_bleedingEdge = m_promptObsolete = + m_expandSynonyms = std::nullopt; m_changes = 0; disable(m_apply); diff --git a/src/manager.hpp b/src/manager.hpp @@ -86,9 +86,8 @@ private: std::map<Remote, RemoteMods> m_mods; std::set<Remote> m_uninstall; - std::optional<bool> m_autoInstall; - std::optional<bool> m_bleedingEdge; - std::optional<bool> m_promptObsolete; + std::optional<bool> m_autoInstall, m_bleedingEdge, + m_promptObsolete, m_expandSynonyms; Serializer m_serializer; };