27 #include "../../../common/StringUtils.h" 28 #include "../../../core/translator/Translator.h" 29 #include "../../../dataaccess/datasource/DataSource.h" 30 #include "../../../dataaccess/datasource/DataSourceCapabilities.h" 31 #include "../../../dataaccess/datasource/DataSourceFactory.h" 44 #include <boost/filesystem.hpp> 45 #include <boost/regex.hpp> 56 QString extensions =
"";
57 std::map<QString, QString> mappedExtensions;
66 QString filteredExtention;
70 QString filePath = fileDialog.getSaveFileName(
m_parent,
71 QString(
TE_TR(
"Save as...")),
75 QFileDialog::DontConfirmOverwrite);
77 if (filePath.isEmpty())
81 boost::filesystem::path path(filePath.toUtf8().data());
82 std::string filename = path.stem().string();
83 QString fileExtension = path.extension().string().c_str();
85 if(!path.extension().empty())
86 if(mappedExtensions[filteredExtention].compare(fileExtension.toLower().toUtf8().data()))
93 QFileInfo fileInfo( filePath );
94 if(fileInfo.suffix().isEmpty())
95 filePath.append(mappedExtensions[filteredExtention]);
98 setPath(filePath.toUtf8().data());
120 boost::filesystem::path path(filePath);
131 boost::filesystem::path path(filePath);
137 std::map<QString, QString> mappedExtensions;
139 std::vector< std::string > tokens;
141 for(
auto extension : tokens)
143 boost::regex expression(
"[.]+[a-z0-9]+");
144 boost::smatch extMatched;
145 if(boost::regex_search(extension, extMatched, expression))
147 mappedExtensions[QString::fromStdString(extension)] = QString::fromStdString(extMatched[0]);
151 return mappedExtensions;
156 boost::regex expression{
"\\W+"};
158 if (boost::regex_search(filename, expression))
An instance of QFileDialog that includes file extention if necessary.
#define TE_TR(message)
It marks a string in order to get translated.
void Tokenize(const std::string &str, std::vector< std::string > &tokens, const std::string &delimiters=" ")
It tokenizes a given string with a delimiter of your own choice.
This class is designed to declare objects to be thrown as exceptions by TerraLib. ...