Skip to content

Commit

Permalink
refresh save list after unpublishing a group of them, fixes #238
Browse files Browse the repository at this point in the history
  • Loading branch information
jacob1 committed Jan 10, 2015
1 parent 4a3a6de commit c325543
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/gui/search/SearchController.cpp
Expand Up @@ -119,6 +119,12 @@ void SearchController::DoSearch(std::string query, bool now)
//searchModel->UpdateSaveList(1, query);
}

void SearchController::Refresh()
{
ClearSelection();
searchModel->UpdateSaveList(searchModel->GetPageNum(), searchModel->GetLastQuery());
}

void SearchController::PrevPage()
{
if (searchModel->GetPageNum()>1)
Expand Down Expand Up @@ -240,9 +246,10 @@ void SearchController::removeSelectedC()
{
class RemoveSavesTask : public Task
{
SearchController *c;
std::vector<int> saves;
public:
RemoveSavesTask(std::vector<int> saves_) { saves = saves_; }
RemoveSavesTask(std::vector<int> saves_, SearchController *c_) { saves = saves_; c = c_; }
virtual bool doWork()
{
for(int i = 0; i < saves.size(); i++)
Expand All @@ -258,12 +265,13 @@ void SearchController::removeSelectedC()
}
notifyProgress((float(i+1)/float(saves.size())*100));
}
c->Refresh();
return true;
}
};

std::vector<int> selected = searchModel->GetSelected();
new TaskWindow("Removing saves", new RemoveSavesTask(selected));
new TaskWindow("Removing saves", new RemoveSavesTask(selected, this));
ClearSelection();
searchModel->UpdateSaveList(searchModel->GetPageNum(), searchModel->GetLastQuery());
}
Expand Down Expand Up @@ -294,8 +302,9 @@ void SearchController::unpublishSelectedC()
class UnpublishSavesTask : public Task
{
std::vector<int> saves;
SearchController *c;
public:
UnpublishSavesTask(std::vector<int> saves_) { saves = saves_; }
UnpublishSavesTask(std::vector<int> saves_, SearchController *c_) { saves = saves_; c = c_; }
virtual bool doWork()
{
for(int i = 0; i < saves.size(); i++)
Expand All @@ -312,14 +321,13 @@ void SearchController::unpublishSelectedC()
}
notifyProgress((float(i+1)/float(saves.size())*100));
}
c->Refresh();
return true;
}
};

std::vector<int> selected = searchModel->GetSelected();
new TaskWindow("Unpublishing saves", new UnpublishSavesTask(selected));
ClearSelection();
searchModel->UpdateSaveList(searchModel->GetPageNum(), searchModel->GetLastQuery());
new TaskWindow("Unpublishing saves", new UnpublishSavesTask(selected, this));
}

void SearchController::FavouriteSelected()
Expand Down
1 change: 1 addition & 0 deletions src/gui/search/SearchController.h
Expand Up @@ -32,6 +32,7 @@ class SearchController
SearchView * GetView() { return searchView; }
void Exit();
void DoSearch(std::string query, bool now = false);
void Refresh();
void NextPage();
void PrevPage();
void SetPage(int page);
Expand Down
1 change: 1 addition & 0 deletions src/tasks/Task.h
Expand Up @@ -5,6 +5,7 @@
#include <pthread.h>
#undef GetUserName //God dammit microsoft!
#include "TaskListener.h"
#include "Config.h"

class TaskListener;
class Task {
Expand Down

0 comments on commit c325543

Please sign in to comment.