refresh save list after unpublishing a group of them, fixes #238

This commit is contained in:
jacob1 2015-01-10 12:39:19 -05:00
parent 4a3a6dee30
commit c325543402
3 changed files with 16 additions and 6 deletions

View File

@ -119,6 +119,12 @@ void SearchController::DoSearch(std::string query, bool now)
//searchModel->UpdateSaveList(1, query); //searchModel->UpdateSaveList(1, query);
} }
void SearchController::Refresh()
{
ClearSelection();
searchModel->UpdateSaveList(searchModel->GetPageNum(), searchModel->GetLastQuery());
}
void SearchController::PrevPage() void SearchController::PrevPage()
{ {
if (searchModel->GetPageNum()>1) if (searchModel->GetPageNum()>1)
@ -240,9 +246,10 @@ void SearchController::removeSelectedC()
{ {
class RemoveSavesTask : public Task class RemoveSavesTask : public Task
{ {
SearchController *c;
std::vector<int> saves; std::vector<int> saves;
public: public:
RemoveSavesTask(std::vector<int> saves_) { saves = saves_; } RemoveSavesTask(std::vector<int> saves_, SearchController *c_) { saves = saves_; c = c_; }
virtual bool doWork() virtual bool doWork()
{ {
for(int i = 0; i < saves.size(); i++) for(int i = 0; i < saves.size(); i++)
@ -258,12 +265,13 @@ void SearchController::removeSelectedC()
} }
notifyProgress((float(i+1)/float(saves.size())*100)); notifyProgress((float(i+1)/float(saves.size())*100));
} }
c->Refresh();
return true; return true;
} }
}; };
std::vector<int> selected = searchModel->GetSelected(); std::vector<int> selected = searchModel->GetSelected();
new TaskWindow("Removing saves", new RemoveSavesTask(selected)); new TaskWindow("Removing saves", new RemoveSavesTask(selected, this));
ClearSelection(); ClearSelection();
searchModel->UpdateSaveList(searchModel->GetPageNum(), searchModel->GetLastQuery()); searchModel->UpdateSaveList(searchModel->GetPageNum(), searchModel->GetLastQuery());
} }
@ -294,8 +302,9 @@ void SearchController::unpublishSelectedC()
class UnpublishSavesTask : public Task class UnpublishSavesTask : public Task
{ {
std::vector<int> saves; std::vector<int> saves;
SearchController *c;
public: public:
UnpublishSavesTask(std::vector<int> saves_) { saves = saves_; } UnpublishSavesTask(std::vector<int> saves_, SearchController *c_) { saves = saves_; c = c_; }
virtual bool doWork() virtual bool doWork()
{ {
for(int i = 0; i < saves.size(); i++) for(int i = 0; i < saves.size(); i++)
@ -312,14 +321,13 @@ void SearchController::unpublishSelectedC()
} }
notifyProgress((float(i+1)/float(saves.size())*100)); notifyProgress((float(i+1)/float(saves.size())*100));
} }
c->Refresh();
return true; return true;
} }
}; };
std::vector<int> selected = searchModel->GetSelected(); std::vector<int> selected = searchModel->GetSelected();
new TaskWindow("Unpublishing saves", new UnpublishSavesTask(selected)); new TaskWindow("Unpublishing saves", new UnpublishSavesTask(selected, this));
ClearSelection();
searchModel->UpdateSaveList(searchModel->GetPageNum(), searchModel->GetLastQuery());
} }
void SearchController::FavouriteSelected() void SearchController::FavouriteSelected()

View File

@ -32,6 +32,7 @@ public:
SearchView * GetView() { return searchView; } SearchView * GetView() { return searchView; }
void Exit(); void Exit();
void DoSearch(std::string query, bool now = false); void DoSearch(std::string query, bool now = false);
void Refresh();
void NextPage(); void NextPage();
void PrevPage(); void PrevPage();
void SetPage(int page); void SetPage(int page);

View File

@ -5,6 +5,7 @@
#include <pthread.h> #include <pthread.h>
#undef GetUserName //God dammit microsoft! #undef GetUserName //God dammit microsoft!
#include "TaskListener.h" #include "TaskListener.h"
#include "Config.h"
class TaskListener; class TaskListener;
class Task { class Task {