commit c5d3ee003940b8965a8e8d3a76822bcda4994b14
parent 2cd2a7e6f007ed312508e4694d2831bb48fe9638
Author: cfillion <cfillion@users.noreply.github.com>
Date: Tue, 24 Oct 2017 05:08:52 -0400
browser: fix 0e172bc73d5f071f6f8d55d40727dbf600e0f734 when in the Queued tab
Diffstat:
2 files changed, 18 insertions(+), 7 deletions(-)
diff --git a/src/browser.cpp b/src/browser.cpp
@@ -29,6 +29,8 @@
#include "transaction.hpp"
#include "win32.hpp"
+#include <numeric>
+
using namespace std;
enum Timers { TIMER_FILTER = 1, TIMER_ABOUT };
@@ -756,16 +758,22 @@ void Browser::updateAction(const int index)
void Browser::selectionDo(const function<void (int)> &func)
{
+ listDo(func, m_list->selection());
+}
+
+void Browser::listDo(const function<void (int)> &func, const vector<int> &indexes)
+{
ListView::BeginEdit edit(m_list);
int lastSize = m_list->rowCount();
int offset = 0;
- for(const int index : m_list->selection()) {
+ // assumes the index vector is sorted
+ for(const int index : indexes) {
func(index - offset);
// handle row removal
- int newSize = m_list->rowCount();
+ const int newSize = m_list->rowCount();
if(newSize < lastSize)
offset++;
lastSize = newSize;
@@ -837,11 +845,13 @@ bool Browser::apply()
}
if(!tx->runTasks()) {
- // this is an asynchronous transaction
- // update the state column right away to give visual feedback
- ListView::BeginEdit edit(m_list);
- for(int i = 0, count = m_list->rowCount(); i < count; ++i)
- updateAction(i);
+ // This is an asynchronous transaction.
+ // Updating the state column of all rows (not just visible ones since the
+ // hidden rows can be filtered into view again by user at any time) right away
+ // to give visual feedback.
+ vector<int> fullList(m_list->rowCount());
+ iota(fullList.begin(), fullList.end(), 0);
+ listDo(bind(&Browser::updateAction, this, _1), fullList);
}
return true;
diff --git a/src/browser.hpp b/src/browser.hpp
@@ -107,6 +107,7 @@ private:
void resetActions(int index);
void updateAction(const int index);
void selectionDo(const std::function<void (int)> &);
+ void listDo(const std::function<void (int)> &, const std::vector<int> &);
View currentView() const;
void copy();
bool confirm() const;