diff options
| author | Simon Robertshaw <simon@hardwired.org.uk> | 2012-01-26 01:13:33 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2012-01-26 01:13:33 (GMT) |
| commit | 9e1be78bc21d1fb76a19ce12ef36193aea6e2b93 (patch) | |
| tree | 081b67d551bb44fecbf6deb99b6c44ea9789614c /src/search/SearchController.cpp | |
| parent | b2d3257ae944a3ea3b57dc8ee4171b1b2f85483e (diff) | |
| download | powder-9e1be78bc21d1fb76a19ce12ef36193aea6e2b93.zip powder-9e1be78bc21d1fb76a19ce12ef36193aea6e2b93.tar.gz | |
I've got to a point where I can no longer be bothered to think of a proper commit comment
Diffstat (limited to 'src/search/SearchController.cpp')
| -rw-r--r-- | src/search/SearchController.cpp | 53 |
1 files changed, 46 insertions, 7 deletions
diff --git a/src/search/SearchController.cpp b/src/search/SearchController.cpp index 46a353c..96f759e 100644 --- a/src/search/SearchController.cpp +++ b/src/search/SearchController.cpp @@ -5,8 +5,24 @@ #include "interface/Panel.h" #include "preview/PreviewController.h" -SearchController::SearchController(): - activePreview(NULL) +class SearchController::OpenCallback: public ControllerCallback +{ + SearchController * cc; +public: + OpenCallback(SearchController * cc_) { cc = cc_; } + virtual void ControllerExit() + { + if(cc->activePreview->GetDoOpen()) + { + cc->searchModel->SetLoadedSave(new Save(*(cc->activePreview->GetSave()))); + cc->Exit(); + } + } +}; + +SearchController::SearchController(ControllerCallback * callback): + activePreview(NULL), + HasExited(false) { searchModel = new SearchModel(); searchView = new SearchView(); @@ -15,19 +31,42 @@ SearchController::SearchController(): searchModel->UpdateSaveList(1, ""); + this->callback = callback; + //Set up interface //windowPanel.AddChild(); } -SearchController::~SearchController() +Save * SearchController::GetLoadedSave() { - if(activePreview) + return searchModel->GetLoadedSave(); +} + +void SearchController::Update() +{ + if(activePreview && activePreview->HasExited) { - ui::Engine::Ref().CloseWindow(); delete activePreview; + activePreview = NULL; } +} + +void SearchController::Exit() +{ + if(ui::Engine::Ref().GetWindow() == searchView) + { + ui::Engine::Ref().CloseWindow(); + } + if(callback) + callback->ControllerExit(); + HasExited = true; +} + +SearchController::~SearchController() +{ delete searchModel; - delete searchView; + if(searchView) + delete searchView; } void SearchController::DoSearch(std::string query) @@ -66,6 +105,6 @@ void SearchController::ShowOwn(bool show) void SearchController::OpenSave(int saveID) { - activePreview = new PreviewController(saveID); + activePreview = new PreviewController(saveID, new OpenCallback(this)); ui::Engine::Ref().ShowWindow(activePreview->GetView()); } |
