- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/UIElements/Qt4/Query/FileQtQuery.cpp
rf8bccc rf130d4 45 45 #include "UIElements/Qt4/Query/QtQuery.hpp" 46 46 47 #include <algorithm>48 #include <boost/filesystem.hpp>49 50 #include "Parameters/Validators/getFlatListFromHierarchyOfValidators.hpp"51 #include "Parameters/Validators/Validator.hpp"52 #include "Parameters/Validators/Specific/FilePresentValidator.hpp"53 #include "Parameters/Validators/Specific/FileSuffixValidator.hpp"54 #include "Parameters/Validators/Specific/ParserFileValidator.hpp"55 47 #include "Parser/ParserTypes.hpp" 56 48 #include "Parser/FormatParserStorage.hpp" … … 59 51 QtQuery<boost::filesystem::path>(_param, _title, _description), 60 52 parent(_parent), 61 dialog(_dialog), 62 mustBePresent(false) 53 dialog(_dialog) 63 54 { 64 55 filenameLineEdit = new QLineEdit(); … … 66 57 filenameLineEdit->setReadOnly(true); 67 58 68 filenameLabel = new QLabel(QString( _title.c_str()));59 filenameLabel = new QLabel(QString("Input file:")); 69 60 filenameLabel->setBuddy(filenameLineEdit); 70 61 filenameLabel->setToolTip(QString(getDescription().c_str())); … … 80 71 81 72 QObject::connect(filedialogButton,SIGNAL(clicked()),this,SLOT(showFileDialog())); 82 83 // fill list of suffixes84 const Validator<boost::filesystem::path> &validator =85 _param.getValidator();86 typedef std::vector<std::pair<const Validator<boost::filesystem::path> *, bool> > validators_t;87 const validators_t validators =88 getFlatListFromHierarchyOfValidators<boost::filesystem::path>(validator);89 for (validators_t::const_iterator iter = validators.begin();90 iter != validators.end(); ++iter) {91 const Validator< boost::filesystem::path > ¤tvalidator = *iter->first;92 if (dynamic_cast<const FileSuffixValidator * const>(¤tvalidator) != NULL)93 suffixes.push_back(dynamic_cast<const FileSuffixValidator &>(currentvalidator).getSuffix());94 if (dynamic_cast<const ParserFileValidator * const>(¤tvalidator) != NULL) {95 const std::vector<std::string> moresuffixes =96 dynamic_cast<const ParserFileValidator &>(currentvalidator).getSuffixes();97 suffixes.insert(suffixes.end(), moresuffixes.begin(), moresuffixes.end());98 }99 if (dynamic_cast<const FilePresentValidator * const>(¤tvalidator) != NULL)100 mustBePresent = iter->second;101 }102 std::sort(suffixes.begin(), suffixes.end());103 73 } 104 74 … … 123 93 // gather all possible suffixes 124 94 QStringList filters; 125 std::stringstream filter_string; 126 if (!suffixes.empty()) { 127 filter_string << "Valid files ("; 128 for (std::vector<std::string>::const_iterator iter = suffixes.begin(); 129 iter != suffixes.end(); ++iter) 130 filter_string << (iter == suffixes.begin() ? "*." : " *.") << *iter << " "; 131 filter_string << ")"; 132 filters << tr(filter_string.str().c_str()); 95 std::stringstream parsersuffixes; 96 parsersuffixes << std::string("Config files ("); 97 for (ParserTypes t = ParserTypes_begin; t < ParserTypes_end; ++t){ 98 if (t != ParserTypes_begin) 99 parsersuffixes << std::string(" "); 100 parsersuffixes << std::string("*.") << 101 FormatParserStorage::getInstance().getSuffixFromType(t); 133 102 } 103 parsersuffixes << std::string(")"); 104 filters << tr(parsersuffixes.str().c_str()); 105 filters << tr("Data files (*.dat)"); 134 106 filters << tr("Any files (*)"); 135 107 theFileDialog->setNameFilters(filters);
Note:
See TracChangeset
for help on using the changeset viewer.