2 * ModuleBase_PagedContainer.cpp
4 * Created on: Mar 13, 2015
8 #include <ModuleBase_PagedContainer.h>
9 #include <ModuleBase_PageBase.h>
10 #include <ModuleBase_ModelWidget.h>
11 #include <ModuleBase_Tools.h>
13 #include <ModelAPI_AttributeString.h>
17 #include <QVBoxLayout>
20 ModuleBase_PagedContainer::ModuleBase_PagedContainer(QWidget* theParent, const Config_WidgetAPI* theData,
21 const std::string& theParentId)
22 : ModuleBase_ModelWidget(theParent, theData, theParentId),
23 myIsFocusOnCurrentPage(false)
27 ModuleBase_PagedContainer::~ModuleBase_PagedContainer()
31 int ModuleBase_PagedContainer::addPage(ModuleBase_PageBase* thePage,
32 const QString& theName, const QString& theCaseId)
34 myCaseIds << theCaseId;
36 return myPages.count();
39 QList<QWidget*> ModuleBase_PagedContainer::getControls() const
41 QList<QWidget*> aResult;
42 int anIndex = currentPageIndex();
43 QList<ModuleBase_ModelWidget*> aModelWidgets = myPages[anIndex]->modelWidgets();
44 foreach(ModuleBase_ModelWidget* eachModelWidget, aModelWidgets) {
45 aResult << eachModelWidget->getControls();
50 bool ModuleBase_PagedContainer::focusTo()
52 int anIndex = currentPageIndex();
53 if (anIndex > myPages.count())
55 return myPages[anIndex]->takeFocus();
58 void ModuleBase_PagedContainer::setHighlighted(bool)
60 //page containers should not be highlighted, do nothing
63 void ModuleBase_PagedContainer::enableFocusProcessing()
65 myIsFocusOnCurrentPage = true;
68 bool ModuleBase_PagedContainer::restoreValue()
70 // A rare case when plugin was not loaded.
73 DataPtr aData = myFeature->data();
74 AttributeStringPtr aStringAttr = aData->string(attributeID());
75 QString aCaseId = QString::fromStdString(aStringAttr->value());
76 int idx = myCaseIds.indexOf(aCaseId);
79 setCurrentPageIndex(idx);
83 void ModuleBase_PagedContainer::activateCustom()
85 // activate current page
89 bool ModuleBase_PagedContainer::storeValueCustom() const
91 // A rare case when plugin was not loaded.
94 DataPtr aData = myFeature->data();
95 AttributeStringPtr aStringAttr = aData->string(attributeID());
96 QString aWidgetValue = myCaseIds.at(currentPageIndex());
97 aStringAttr->setValue(aWidgetValue.toStdString());
102 void ModuleBase_PagedContainer::onPageChanged()
105 if (myIsFocusOnCurrentPage) focusTo();