blob: 4f970062c78cea7a632e457e5cd71bc57f33af43 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
/*
* Copyright (c) 2012 Catalin Badea
* Licensed under the simplified BSD license.
* See Documentation/Licenses/BSD-simplified.txt for more information.
*/
#include <Swift/Controllers/HistoryController.h>
#include <Swift/Controllers/UIInterfaces/HistoryWindowFactory.h>
#include <Swift/Controllers/UIEvents/RequestHistoryUIEvent.h>
namespace Swift {
HistoryController::HistoryController(UIEventStream* uiEventStream, HistoryWindowFactory* historyWindowFactory) : uiEventStream_(uiEventStream), historyWindowFactory_(historyWindowFactory), historyWindow_(NULL) {
uiEventStream_->onUIEvent.connect(boost::bind(&HistoryController::handleUIEvent, this, _1));
}
HistoryController::~HistoryController() {
uiEventStream_->onUIEvent.disconnect(boost::bind(&HistoryController::handleUIEvent, this, _1));
delete historyWindow_;
}
void HistoryController::handleUIEvent(boost::shared_ptr<UIEvent> rawEvent) {
boost::shared_ptr<RequestHistoryUIEvent> event = boost::dynamic_pointer_cast<RequestHistoryUIEvent>(rawEvent);
if (event != NULL) {
if (historyWindow_ == NULL) {
historyWindow_ = historyWindowFactory_->createHistoryWindow();
}
historyWindow_->activate();
}
}
}
|