#include <Config_Keywords.h>
#include <Config_WidgetAPI.h>
+#include <Config_Translator.h>
#include <Events_Loop.h>
#include <QEvent>
#include <QLabel>
#include <QFocusEvent>
+#include <QTextCodec>
//#define DEBUG_VALUE_STATE
+//#define DEBUG_WIDGET_INSTANCE
+
ModuleBase_ModelWidget::ModuleBase_ModelWidget(QWidget* theParent,
const Config_WidgetAPI* theData)
: QWidget(theParent),
myFlushUpdateBlocked(false),
myWidgetValidator(0)
{
+#ifdef DEBUG_WIDGET_INSTANCE
+ qDebug("ModuleBase_ModelWidget::ModuleBase_ModelWidget");
+#endif
+
myIsInternal = theData->getBooleanAttribute(ATTR_INTERNAL, false);
myDefaultValue = theData->getProperty(ATTR_DEFAULT);
connect(this, SIGNAL(valuesModified()), this, SLOT(onWidgetValuesModified()));
}
+ModuleBase_ModelWidget::~ModuleBase_ModelWidget()
+{
+#ifdef DEBUG_WIDGET_INSTANCE
+ qDebug("ModuleBase_ModelWidget::~ModuleBase_ModelWidget");
+#endif
+}
+
bool ModuleBase_ModelWidget::reset()
{
bool aResult = resetCustom();
if (anError.isEmpty() && theValueStateChecked)
anError = getValueStateError();
+ anError = translateString(anError);
return anError;
}
+
+QString ModuleBase_ModelWidget::translateString(const QString& theMsg) const
+{
+ if (!theMsg.isEmpty()) {
+ std::string aContext = feature()->getKind();
+ std::string aStr = Config_Translator::translate(aContext, theMsg.toStdString().c_str());
+ std::string aCodec = Config_Translator::codec(aContext);
+ return QTextCodec::codecForName(aCodec.c_str())->toUnicode(aStr.c_str());
+ }
+ return theMsg;
+}
+
+
void ModuleBase_ModelWidget::enableFocusProcessing()
{
QList<QWidget*> aMyControls = getControls();
bool ModuleBase_ModelWidget::focusTo()
{
+#ifdef DEBUG_WIDGET_INSTANCE
+ qDebug("ModuleBase_ModelWidget::focusTo");
+#endif
QList<QWidget*> aControls = getControls();
QList<QWidget*>::const_iterator anIt = aControls.begin(), aLast = aControls.end();
bool isFocusAccepted = false;
void ModuleBase_ModelWidget::activate()
{
+#ifdef DEBUG_WIDGET_INSTANCE
+ qDebug("ModuleBase_ModelWidget::activate");
+#endif
// the control value is stored to the mode by the focus in on the widget
// we need the value is initialized in order to enable the apply button in the property panel.
// It should happens in the creation mode only because all fields are filled in the edition mode
void ModuleBase_ModelWidget::deactivate()
{
+#ifdef DEBUG_WIDGET_INSTANCE
+ qDebug("ModuleBase_ModelWidget::deactivate");
+#endif
myIsValueStateBlocked = false;
myState = Stored;
if (myWidgetValidator)
void ModuleBase_ModelWidget::updateObject(ObjectPtr theObject)
{
if (!myFlushUpdateBlocked) {
+#ifdef DEBUG_WIDGET_INSTANCE
+ qDebug("ModuleBase_ModelWidget::updateObject");
+#endif
ModuleBase_Tools::flushUpdated(theObject);
emit objectUpdated();
}
void ModuleBase_ModelWidget::moveObject(ObjectPtr theObj)
{
//blockUpdateViewer(true);
+#ifdef DEBUG_WIDGET_INSTANCE
+ qDebug("ModuleBase_ModelWidget::moveObject");
+#endif
static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_MOVED);
ModelAPI_EventCreator::get()->sendUpdated(theObj, anEvent);