X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModuleBase%2FModuleBase_WidgetCreatorFactory.cpp;h=cdf53e151274393d684b6bb353323817fae669a3;hb=31c4ff77330b870d466fbd6b38e1fa566600f79a;hp=ff3ee01f9c5dbf6e89158a1c92c547c4de0230b7;hpb=eaedfec1bd44832c5c1b75265a034d5b79340420;p=modules%2Fshaper.git diff --git a/src/ModuleBase/ModuleBase_WidgetCreatorFactory.cpp b/src/ModuleBase/ModuleBase_WidgetCreatorFactory.cpp index ff3ee01f9..cdf53e151 100755 --- a/src/ModuleBase/ModuleBase_WidgetCreatorFactory.cpp +++ b/src/ModuleBase/ModuleBase_WidgetCreatorFactory.cpp @@ -7,6 +7,8 @@ #include #include +#include + #include #include @@ -36,23 +38,57 @@ void ModuleBase_WidgetCreatorFactory::registerCreator(const WidgetCreatorPtr& th std::set::const_iterator anIt = aTypes.begin(), aLast = aTypes.end(); for (; anIt != aLast; anIt++) { std::string aKey = *anIt; - if (!myModelWidgets.contains(aKey)) - myModelWidgets[aKey] = theCreator; + if (!myCreators.contains(aKey)) + myCreators[aKey] = theCreator; + else { + Events_Error::send("The" + aKey + " widget XML definition has been already \ +used by another widget creator"); + } + } + + const std::set& aPTypes = theCreator->pageTypes(); + for (anIt = aPTypes.begin(), aLast = aPTypes.end(); anIt != aLast; anIt++) { + std::string aKey = *anIt; + if (!myPageToCreator.contains(aKey)) + myPageToCreator[aKey] = theCreator; else { - Events_Error::send("The" + aKey + " widget XML definition has been already\ - used by another widget creator"); + Events_Error::send("The" + aKey + " page XML definition has been already \ +used by another widget creator"); } } } +bool ModuleBase_WidgetCreatorFactory::hasPageWidget(const std::string& theType) +{ + return myPageToCreator.contains(theType); +} + +ModuleBase_PageBase* ModuleBase_WidgetCreatorFactory::createPageByType( + const std::string& theType, QWidget* theParent, + Config_WidgetAPI* theWidgetApi, std::string theParentId) +{ + ModuleBase_PageBase* aPage = 0; + + if (myPageToCreator.contains(theType)) { + WidgetCreatorPtr aCreator = myPageToCreator[theType]; + aPage = aCreator->createPageByType(theType, theParent, theWidgetApi, theParentId); + } + + return aPage; +} + + ModuleBase_ModelWidget* ModuleBase_WidgetCreatorFactory::createWidgetByType( - const std::string& theType, QWidget* theParent) + const std::string& theType, QWidget* theParent, + Config_WidgetAPI* theWidgetApi, std::string theParentId, + ModuleBase_IWorkshop* theWorkshop) { ModuleBase_ModelWidget* aWidget = 0; - if (myModelWidgets.contains(theType)) { - WidgetCreatorPtr aCreator = myModelWidgets[theType]; - aWidget = aCreator->createWidgetByType(theType, theParent); + if (myCreators.contains(theType)) { + WidgetCreatorPtr aCreator = myCreators[theType]; + aWidget = aCreator->createWidgetByType(theType, theParent, theWidgetApi, theParentId, + theWorkshop); } return aWidget;