defuze.me
Client
|
00001 /************************************************************************** 00002 ** defuze.me Epitech Innovative Project 00003 ** 00004 ** Copyright 2010-2011 00005 ** Athena Calmettes - Jocelyn De La Rosa - Francois Gaillard 00006 ** Adrien Jarthon - Alexandre Moore - Luc Peres - Arnaud Sellier 00007 ** 00008 ** All rights reserved. 00009 **************************************************************************/ 00010 00011 #include "module.hpp" 00012 #include "guicore.hpp" 00013 #include "exception.hpp" 00014 #include "parametersmodule.hpp" 00015 00016 using namespace Gui; 00017 00018 Module::Module(GuiCore *guiCore) : guiCore(guiCore) 00019 { 00020 widget = 0; 00021 position.setX(-1); 00022 position.setY(0); 00023 tabIndex = 0; 00024 sizePolicy = QSizePolicy::Preferred; 00025 colSizePolicy = QSizePolicy::Expanding; 00026 } 00027 00028 void Module::setPosition(QPoint position) 00029 { 00030 this->position = position; 00031 if (position.x() < -1) 00032 position.setX(-1); 00033 if (position.y() < 0) 00034 position.setY(0); 00035 } 00036 00037 void Module::setTitle(const QString &title) 00038 { 00039 this->title = title; 00040 } 00041 00042 void Module::setWidget(ModuleWidget *widget) 00043 { 00044 this->widget = widget; 00045 this->title = widget->windowTitle(); 00046 } 00047 00048 void Module::setTabIndex(int tabIndex) 00049 { 00050 this->tabIndex = tabIndex; 00051 } 00052 00053 void Module::setUniqId(const QString &uniqId) 00054 { 00055 if (ModuleFactory::modules.contains(uniqId)) 00056 throw_exception(0x01, tr("Can't create two modules with the same ID.")); 00057 this->uniqId = uniqId; 00058 } 00059 00060 void Module::setSizePolicy(const QSizePolicy::Policy &sizePolicy, const QSizePolicy::Policy &colSizePolicy) 00061 { 00062 this->sizePolicy = sizePolicy; 00063 this->colSizePolicy = colSizePolicy; 00064 } 00065 00066 void Module::submitForDisplay(ModuleWidget* widget) 00067 { 00068 this->widget = widget; 00069 submitForDisplay(); 00070 } 00071 00072 void Module::submitForDisplay() 00073 { 00074 if (!widget) 00075 throw_exception(0x02, tr("No widget for module.")); 00076 // if (hasParameters()) 00077 // { 00078 // foreach (ParametersPage *page, parametersPages) 00079 // { 00080 // ParametersCategory *category; 00081 // if (guiCore->getParametersModule()->getCategories().keys().contains(page->getPath())) 00082 // category = guiCore->getParametersModule()->getCategories()[page->getPath()]; 00083 // else 00084 // { 00085 // category = new ParametersCategory(page->getCategory()); 00086 // guiCore->getParametersModule()->registerCategory(category); 00087 // } 00088 // category->addPage(page); 00089 // } 00090 00091 // } 00092 guiCore->addModule(this); 00093 } 00094 00095 void Module::addParametersPage(ParametersPage *parameterPage) 00096 { 00097 parametersPages[parameterPage->getPath()] = parameterPage; 00098 } 00099 00100 bool Module::hasParameters() const 00101 { 00102 return !parametersPages.isEmpty(); 00103 } 00104 00105 const QString& Module::getUniqId() const 00106 { 00107 return uniqId; 00108 } 00109 00110 int Module::getTabIndex() const 00111 { 00112 return tabIndex; 00113 } 00114 00115 const QPoint& Module::getPosition() const 00116 { 00117 return position; 00118 } 00119 00120 int Module::getRow() const 00121 { 00122 return position.y(); 00123 } 00124 00125 int Module::getColumn() const 00126 { 00127 return position.x(); 00128 } 00129 00130 ModuleWidget *Module::getWidget() const 00131 { 00132 return widget; 00133 }