]> SALOME platform Git repositories - modules/shaper.git/blob - src/PartSet/PartSet_WidgetFileSelector.cpp
Salome HOME
A correction to check modified value in extrusion cut/sketch/etc operations.
[modules/shaper.git] / src / PartSet / PartSet_WidgetFileSelector.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 /*
4  * PartSet_WidgetFileSelector.cpp
5  *
6  *  Created on: May 18, 2015
7  *      Author: spo
8  */
9
10 #include "PartSet_WidgetFileSelector.h"
11
12 #include <ModelAPI_AttributeString.h>
13
14 #include <ExchangePlugin_ExportFeature.h>
15
16 PartSet_WidgetFileSelector::PartSet_WidgetFileSelector(QWidget* theParent,
17                                                        ModuleBase_IWorkshop* theWorkshop,
18                                                        const Config_WidgetAPI* theData,
19                                                        const std::string& theParentId)
20 : ModuleBase_WidgetFileSelector(theParent, theData, theParentId)
21 , myWorkshop(theWorkshop)
22 {
23 }
24
25 bool PartSet_WidgetFileSelector::restoreValueCustom()
26 {
27   // A rare case when plugin was not loaded.
28   if (!myFeature)
29     return false;
30
31   DataPtr aData = myFeature->data();
32   AttributeStringPtr aStringAttr = aData->string(ExchangePlugin_ExportFeature::FILE_PATH_ID());
33   mySelectedFilter = formatToFilter(shortFormatToFullFormat(QString::fromStdString(aStringAttr->value())));
34
35   return ModuleBase_WidgetFileSelector::restoreValueCustom();
36 }
37
38 bool PartSet_WidgetFileSelector::storeValueCustom() const
39 {
40   // A rare case when plugin was not loaded.
41   if (!myFeature)
42     return false;
43
44   DataPtr aData = myFeature->data();
45   AttributeStringPtr aStringAttr = aData->string(ExchangePlugin_ExportFeature::FILE_FORMAT_ID());
46   aStringAttr->setValue(filterToShortFormat(mySelectedFilter).toStdString());
47
48   return ModuleBase_WidgetFileSelector::storeValueCustom();
49 }
50
51 QString PartSet_WidgetFileSelector::shortFormatToFullFormat( const QString & theFormat ) const
52 {
53   foreach(const QString & eachFormat, getValidatorFormats())
54     if (filterToShortFormat(formatToFilter(eachFormat)) == theFormat)
55       return eachFormat;
56   return QString();
57 }