- QString aXMLFormat = QString::fromStdString(theData->getProperty("formats"));
- aXMLFormat = aXMLFormat.toUpper();
- const QChar kSep = ',';
- return aXMLFormat.split(kSep, QString::SkipEmptyParts);
+ if (theFormat.isEmpty() && !theFormat.contains(":"))
+ return QString();
+
+ QStringList aExtesionList = theFormat.section(':', 0, 0).split("|");
+ QString aFormat = theFormat.section(':', 1, 1);
+ return QString("%1 files (%2)").arg(aFormat)
+ .arg(QStringList(aExtesionList).replaceInStrings(QRegExp("^(.*)$"), "*.\\1").join(" "));
+}
+
+QString ModuleBase_WidgetFileSelector::filterToShortFormat(const QString & theFilter)
+{
+ // Simplified implementation.
+ // It relies on theFilter was made by formatToFilter() function.
+ return theFilter.section(' ', 0, 0);
+}
+
+QStringList ModuleBase_WidgetFileSelector::filterToExtensions(const QString & theFilter)
+{
+ // Simplified implementation.
+ // It relies on theFilter was made by formatToFilter() function.
+ QStringList anExtensions = theFilter.section("(", 1, 1).section(")", 0, 0).split(" ");
+ return anExtensions;
+}
+
+QStringList ModuleBase_WidgetFileSelector::getValidatorFormats() const
+{
+ SessionPtr aMgr = ModelAPI_Session::get();
+ ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
+
+ ModelAPI_ValidatorsFactory::Validators allValidators;
+ aFactory->validators(myFeature->getKind(), myAttributeID, allValidators);
+
+ QStringList aResult;
+ std::list<std::string> anArgumentList = allValidators.front().second;
+ std::list<std::string>::const_iterator it = anArgumentList.begin();
+ for (; it != anArgumentList.end(); ++it) {
+ QString aFormat = QString::fromStdString(*it);
+ if (!aFormat.isEmpty())
+ aResult << aFormat;
+ }
+ return aResult;