summaryrefslogtreecommitdiffstats
blob: 093a3c4f3d3ca6440a02145bd2f5cd7d0b70e8f8 (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
34
35
36
37
38
39
40
41
42
43
44
45
/*
 * Copyright (c) 2011 Tobias Markmann
 * Licensed under the simplified BSD license.
 * See Documentation/Licenses/BSD-simplified.txt for more information.
 */

#include "Swift/Controllers/FileTransferListController.h"

#include <boost/bind.hpp>

#include "Swift/Controllers/UIInterfaces/FileTransferListWidgetFactory.h"
#include "Swift/Controllers/UIEvents/RequestFileTransferListUIEvent.h"

namespace Swift {

FileTransferListController::FileTransferListController(UIEventStream* uiEventStream, FileTransferListWidgetFactory* fileTransferListWidgetFactory) : fileTransferListWidgetFactory(fileTransferListWidgetFactory), fileTransferListWidget(NULL), fileTransferOverview(0) {
	uiEventStream->onUIEvent.connect(boost::bind(&FileTransferListController::handleUIEvent, this, _1));
}

FileTransferListController::~FileTransferListController() {
	delete fileTransferListWidget;
}

void FileTransferListController::setFileTransferOverview(FileTransferOverview *overview) {
	fileTransferOverview = overview;
	if (fileTransferListWidget) {
		fileTransferListWidget->setFileTransferOverview(fileTransferOverview);
	}
}

void FileTransferListController::handleUIEvent(boost::shared_ptr<UIEvent> rawEvent) {
	boost::shared_ptr<RequestFileTransferListUIEvent> event = boost::dynamic_pointer_cast<RequestFileTransferListUIEvent>(rawEvent);
	if (event != NULL) {
		if (fileTransferListWidget == NULL) {
			fileTransferListWidget = fileTransferListWidgetFactory->createFileTransferListWidget();
			if (fileTransferOverview) {
				fileTransferListWidget->setFileTransferOverview(fileTransferOverview);
			}
		}
		fileTransferListWidget->show();
		fileTransferListWidget->activate();
	}
}

}