From b5ad1ec998ec01501866c2ae5ea66c650b79c5cf Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Remko=20Tron=C3=A7on?= <git@el-tramo.be>
Date: Fri, 17 Dec 2010 16:47:07 +0100
Subject: Collapsed all UI factories into UIFactory.


diff --git a/Swift/Controllers/Chat/UnitTest/ChatsManagerTest.cpp b/Swift/Controllers/Chat/UnitTest/ChatsManagerTest.cpp
index c180062..9c1cc36 100644
--- a/Swift/Controllers/Chat/UnitTest/ChatsManagerTest.cpp
+++ b/Swift/Controllers/Chat/UnitTest/ChatsManagerTest.cpp
@@ -79,7 +79,7 @@ public:
 		uiEventStream_ = new UIEventStream();
 		entityCapsManager_ = new EntityCapsManager(capsProvider_, stanzaChannel_);
 		chatListWindowFactory_ = mocks_->InterfaceMock<ChatListWindowFactory>();
-		mocks_->ExpectCall(chatListWindowFactory_, ChatListWindowFactory::createWindow).With(uiEventStream_).Return(NULL);
+		mocks_->ExpectCall(chatListWindowFactory_, ChatListWindowFactory::createChatListWindow).With(uiEventStream_).Return(NULL);
 		manager_ = new ChatsManager(jid_, stanzaChannel_, iqRouter_, eventController_, chatWindowFactory_, nickResolver_, presenceOracle_, directedPresenceSender_, uiEventStream_, chatListWindowFactory_, true, NULL, mucRegistry_, entityCapsManager_, mucManager_);
 
 		avatarManager_ = new NullAvatarManager();
diff --git a/Swift/Controllers/UIInterfaces/UIFactory.h b/Swift/Controllers/UIInterfaces/UIFactory.h
new file mode 100644
index 0000000..4e15b27
--- /dev/null
+++ b/Swift/Controllers/UIInterfaces/UIFactory.h
@@ -0,0 +1,22 @@
+/*
+ * Copyright (c) 2010 Remko Tronçon
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+#pragma once
+
+#include <Swift/Controllers/UIInterfaces/ChatListWindowFactory.h>
+#include <Swift/Controllers/UIInterfaces/ChatWindowFactory.h>
+#include <Swift/Controllers/UIInterfaces/EventWindowFactory.h>
+#include <Swift/Controllers/UIInterfaces/LoginWindowFactory.h>
+#include <Swift/Controllers/UIInterfaces/MainWindowFactory.h>
+#include <Swift/Controllers/UIInterfaces/MUCSearchWindowFactory.h>
+#include <Swift/Controllers/UIInterfaces/XMLConsoleWidgetFactory.h>
+
+namespace Swift {
+	class UIFactory : public ChatListWindowFactory, public ChatWindowFactory, public EventWindowFactory, public LoginWindowFactory, public MainWindowFactory, public MUCSearchWindowFactory, public XMLConsoleWidgetFactory {
+		public:
+			virtual ~UIFactory() {}
+	};
+}
diff --git a/Swift/QtUI/QtUIFactory.cpp b/Swift/QtUI/QtUIFactory.cpp
new file mode 100644
index 0000000..60a7a6a
--- /dev/null
+++ b/Swift/QtUI/QtUIFactory.cpp
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2010 Remko Tronçon
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+#include "QtUIFactory.h"
+
+#include <QSplitter>
+
+#include "QtXMLConsoleWidget.h"
+#include "QtChatTabs.h"
+#include "QtMainWindow.h"
+#include "QtLoginWindow.h"
+#include "QtSystemTray.h"
+#include "QtSettingsProvider.h"
+#include "QtMainWindow.h"
+#include "QtChatWindow.h"
+#include "QtChatWindowFactory.h"
+#include "QtSwiftUtil.h"
+#include "MUCSearch/QtMUCSearchWindow.h"
+
+namespace Swift {
+
+QtUIFactory::QtUIFactory(QtSettingsProvider* settings, QtChatTabs* tabs, QSplitter* netbookSplitter, QtSystemTray* systemTray, QtChatWindowFactory* chatWindowFactory) : settings(settings), tabs(tabs), netbookSplitter(netbookSplitter), systemTray(systemTray), chatWindowFactory(chatWindowFactory), lastMainWindow(NULL), loginWindow(NULL)  {
+}
+
+XMLConsoleWidget* QtUIFactory::createXMLConsoleWidget() {
+	QtXMLConsoleWidget* widget = new QtXMLConsoleWidget();
+	tabs->addTab(widget);
+	if (!tabs->isVisible()) {
+		tabs->show();
+	}
+	widget->show();
+	return widget;
+}
+
+
+MainWindow* QtUIFactory::createMainWindow(UIEventStream* eventStream) {
+	lastMainWindow  = new QtMainWindow(settings, eventStream);
+	return lastMainWindow;
+}
+
+LoginWindow* QtUIFactory::createLoginWindow(UIEventStream* eventStream) {
+	loginWindow = new QtLoginWindow(eventStream);
+	if (netbookSplitter) {
+		netbookSplitter->insertWidget(0, loginWindow);
+	}
+	connect(systemTray, SIGNAL(clicked()), loginWindow, SLOT(bringToFront()));
+
+	QVariant loginWindowGeometryVariant = settings->getQSettings()->value("loginWindowGeometry");
+	if (loginWindowGeometryVariant.isValid()) {
+		loginWindow->restoreGeometry(loginWindowGeometryVariant.toByteArray());
+	}
+	connect(loginWindow, SIGNAL(geometryChanged()), this, SLOT(handleLoginWindowGeometryChanged()));
+	return loginWindow;
+}
+
+void QtUIFactory::handleLoginWindowGeometryChanged() {
+	settings->getQSettings()->setValue("loginWindowGeometry", loginWindow->saveGeometry());
+}
+
+EventWindow* QtUIFactory::createEventWindow() {
+	return lastMainWindow->getEventWindow();
+}
+
+ChatListWindow* QtUIFactory::createChatListWindow(UIEventStream*) {
+	return lastMainWindow->getChatListWindow();
+}
+
+MUCSearchWindow* QtUIFactory::createMUCSearchWindow(UIEventStream* eventStream) {
+		return new QtMUCSearchWindow(eventStream);
+}
+
+ChatWindow* QtUIFactory::createChatWindow(const JID& contact, UIEventStream* eventStream) {
+	return chatWindowFactory->createChatWindow(contact, eventStream);
+}
+
+}
diff --git a/Swift/QtUI/QtUIFactory.h b/Swift/QtUI/QtUIFactory.h
new file mode 100644
index 0000000..e06b411
--- /dev/null
+++ b/Swift/QtUI/QtUIFactory.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2010 Remko Tronçon
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+#pragma once
+
+#include <QObject>
+
+#include <Swift/Controllers/UIInterfaces/UIFactory.h>
+
+class QSplitter;
+
+namespace Swift {
+	class QtSettingsProvider;
+	class QtChatTabs;
+	class QtSystemTray;
+	class QtLoginWindow;
+	class QtMainWindow;
+	class QtChatTheme;
+	class QtChatWindowFactory;
+
+	class QtUIFactory : public QObject, public UIFactory {
+			Q_OBJECT
+		public:
+			QtUIFactory(QtSettingsProvider* settings, QtChatTabs* tabs, QSplitter* netbookSplitter, QtSystemTray* systemTray, QtChatWindowFactory* chatWindowFactory);
+
+			virtual XMLConsoleWidget* createXMLConsoleWidget();
+			virtual MainWindow* createMainWindow(UIEventStream* eventStream);
+			virtual LoginWindow* createLoginWindow(UIEventStream* eventStream);
+			virtual EventWindow* createEventWindow();
+			virtual ChatListWindow* createChatListWindow(UIEventStream*);
+			virtual MUCSearchWindow* createMUCSearchWindow(UIEventStream* eventStream);
+			virtual ChatWindow* createChatWindow(const JID &contact, UIEventStream* eventStream);
+
+		private slots:
+			void handleLoginWindowGeometryChanged();
+
+		private:
+			QtSettingsProvider* settings;
+			QtChatTabs* tabs;
+			QSplitter* netbookSplitter;
+			QtSystemTray* systemTray;
+			QtChatWindowFactory* chatWindowFactory;
+			QtMainWindow* lastMainWindow;
+			QtLoginWindow* loginWindow;
+	};
+}
-- 
cgit v0.10.2-6-g49f6