reapack

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

commit e318b3fab18eca80844bf53f8a1289d712c90776
parent 7bf796be44985d263e42c8c8755dfdea80031166
Author: cfillion <cfillion@users.noreply.github.com>
Date:   Sun, 29 Oct 2017 09:18:42 -0400

manager: refactor repository enable status display update

Diffstat:
Msrc/manager.cpp | 25++++++++++++-------------
Msrc/manager.hpp | 4++--
2 files changed, 14 insertions(+), 15 deletions(-)

diff --git a/src/manager.cpp b/src/manager.cpp @@ -314,7 +314,7 @@ void Manager::refresh() } } -void Manager::setMods(const ModsCallback &cb, const bool updateRow) +void Manager::setMods(const ModsCallback &cb) { ListView::BeginEdit edit(m_list); @@ -325,7 +325,7 @@ void Manager::setMods(const ModsCallback &cb, const bool updateRow) if(it == m_mods.end()) { RemoteMods mods; - cb(remote, &mods); + cb(remote, index, &mods); if(!mods) continue; @@ -335,29 +335,28 @@ void Manager::setMods(const ModsCallback &cb, const bool updateRow) } else { RemoteMods *mods = &it->second; - cb(remote, mods); + cb(remote, index, mods); if(!*mods) { m_mods.erase(it); setChange(-1); } } - - if(updateRow) - m_list->row(index)->setChecked(isRemoteEnabled(remote)); // TODO: move into cb } } void Manager::toggleEnabled() { - setMods([=](const Remote &remote, RemoteMods *mods) { - const bool enabled = !mods->enable.value_or(remote.isEnabled()); + setMods([=](const Remote &remote, const int index, RemoteMods *mods) { + const bool enable = !mods->enable.value_or(remote.isEnabled()); - if(remote.isEnabled() == enabled) + if(remote.isEnabled() == enable) mods->enable = boost::none; else - mods->enable = enabled; - }, true); + mods->enable = enable; + + m_list->row(index)->setChecked(enable); + }); } bool Manager::isRemoteEnabled(const Remote &remote) const @@ -372,7 +371,7 @@ bool Manager::isRemoteEnabled(const Remote &remote) const void Manager::setRemoteAutoInstall(const tribool &enabled) { - setMods([=](const Remote &remote, RemoteMods *mods) { + setMods([=](const Remote &remote, int, RemoteMods *mods) { const bool same = remote.autoInstall() == enabled || (indeterminate(remote.autoInstall()) && indeterminate(enabled)); @@ -380,7 +379,7 @@ void Manager::setRemoteAutoInstall(const tribool &enabled) mods->autoInstall = boost::none; else mods->autoInstall = enabled; - }, false); + }); } tribool Manager::remoteAutoInstall(const Remote &remote) const diff --git a/src/manager.hpp b/src/manager.hpp @@ -52,11 +52,11 @@ private: operator bool() const { return enable || autoInstall; } }; - typedef std::function<void (const Remote &, RemoteMods *)> ModsCallback; + typedef std::function<void (const Remote &, int index, RemoteMods *)> ModsCallback; Remote getRemote(int index) const; bool fillContextMenu(Menu &, int index) const; - void setMods(const ModsCallback &, bool updateRow); + void setMods(const ModsCallback &); void toggleEnabled(); bool isRemoteEnabled(const Remote &) const; void setRemoteAutoInstall(const tribool &);