- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/UIElements/Qt4/Query/FileQtQuery.cpp
rf130d4 rf8bccc 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" 47 55 #include "Parser/ParserTypes.hpp" 48 56 #include "Parser/FormatParserStorage.hpp" … … 51 59 QtQuery<boost::filesystem::path>(_param, _title, _description), 52 60 parent(_parent), 53 dialog(_dialog) 61 dialog(_dialog), 62 mustBePresent(false) 54 63 { 55 64 filenameLineEdit = new QLineEdit(); … … 57 66 filenameLineEdit->setReadOnly(true); 58 67 59 filenameLabel = new QLabel(QString( "Input file:"));68 filenameLabel = new QLabel(QString(_title.c_str())); 60 69 filenameLabel->setBuddy(filenameLineEdit); 61 70 filenameLabel->setToolTip(QString(getDescription().c_str())); … … 71 80 72 81 QObject::connect(filedialogButton,SIGNAL(clicked()),this,SLOT(showFileDialog())); 82 83 // fill list of suffixes 84 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()); 73 103 } 74 104 … … 93 123 // gather all possible suffixes 94 124 QStringList filters; 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); 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()); 102 133 } 103 parsersuffixes << std::string(")");104 filters << tr(parsersuffixes.str().c_str());105 filters << tr("Data files (*.dat)");106 134 filters << tr("Any files (*)"); 107 135 theFileDialog->setNameFilters(filters);
Note:
See TracChangeset
for help on using the changeset viewer.