reapack

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

commit 8620cda08d5c7a2173e4496254720f131be0e6bd
parent f7e8bbc8022aa4bd75e9918a284e974eb4fa0b93
Author: cfillion <cfillion@users.noreply.github.com>
Date:   Thu, 17 Mar 2016 22:55:32 -0400

remove rows in the queued list when actions are cancelled

Diffstat:
Msrc/browser.cpp | 28+++++++++++++++++++++-------
Msrc/browser.hpp | 11+++++++++++
2 files changed, 32 insertions(+), 7 deletions(-)

diff --git a/src/browser.cpp b/src/browser.cpp @@ -52,9 +52,12 @@ Browser::Browser(const vector<IndexPtr> &indexes, ReaPack *reapack) void Browser::onInit() { m_action = getControl(IDC_ACTION); + m_apply = getControl(IDAPPLY); m_filterHandle = getControl(IDC_FILTER); m_display = getControl(IDC_DISPLAY); + disable(m_apply); + SendMessage(m_display, CB_ADDSTRING, 0, (LPARAM)AUTO_STR("All")); SendMessage(m_display, CB_ADDSTRING, 0, (LPARAM)AUTO_STR("Queued")); SendMessage(m_display, CB_ADDSTRING, 0, (LPARAM)AUTO_STR("Installed")); @@ -436,10 +439,7 @@ bool Browser::match(const Entry &entry) const { using namespace boost; - enum Display { All, Queued, Installed, OutOfDate, Obsolete, Uninstalled }; - Display display = (Display)SendMessage(m_display, CB_GETCURSEL, 0, 0); - - switch(display) { + switch(getDisplay()) { case All: break; case Queued: @@ -548,10 +548,18 @@ void Browser::resetAction(const int index) const Entry *entry = getEntry(index); const auto it = m_actions.find(entry); - if(it != m_actions.end()) { - m_actions.erase(it); + if(it == m_actions.end()) + return; + + m_actions.erase(it); + + if(getDisplay() == Queued) + m_list->removeRow(index); + else m_list->replaceRow(index, makeRow(*entry)); - } + + if(m_actions.empty()) + disable(m_apply); } bool Browser::isTarget(const Entry *entry, const Version *target) const @@ -573,6 +581,7 @@ void Browser::setAction(const int index, const Version *target) else if(entry) { m_actions[entry] = target; m_list->replaceRow(index, makeRow(*entry)); + enable(m_apply); } } @@ -582,6 +591,11 @@ void Browser::selectionDo(const std::function<void (int)> &func) func(index); } +auto Browser::getDisplay() const -> Display +{ + return (Display)SendMessage(m_display, CB_GETCURSEL, 0, 0); +} + void Browser::apply() { } diff --git a/src/browser.hpp b/src/browser.hpp @@ -75,6 +75,15 @@ private: RemoteColumn, }; + enum Display { + All, + Queued, + Installed, + OutOfDate, + Obsolete, + Uninstalled, + }; + static Entry makeEntry(const Package *, const Registry::Entry &); bool match(const Entry &) const; @@ -88,6 +97,7 @@ private: bool isTarget(const Entry *, const Version *) const; void setAction(const int index, const Version *); void selectionDo(const std::function<void (int)> &); + Display getDisplay() const; void apply(); void installLatest(int index); @@ -114,6 +124,7 @@ private: std::map<int, HWND> m_types; ListView *m_list; HWND m_action; + HWND m_apply; }; #endif