Commit 15f8f945 authored by Jan Möbius's avatar Jan Möbius
Browse files

Fixed load and save bug, where extensions where considered equal if prefix matched

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@11990 383ad7c9-94d9-4d36-a494-682f7c89f535
parent b8a6cf48
...@@ -206,15 +206,37 @@ int Core::loadObject ( QString _filename ) { ...@@ -206,15 +206,37 @@ int Core::loadObject ( QString _filename ) {
for (int i=0; i < (int)supportedTypes().size(); i++){ for (int i=0; i < (int)supportedTypes().size(); i++){
QString filters = supportedTypes()[i].plugin->getLoadFilters(); QString filters = supportedTypes()[i].plugin->getLoadFilters();
//check extension
if ( ! filters.contains( "*." + fi.completeSuffix() , Qt::CaseInsensitive) ) { // Only take the parts inside the brackets
if ( ! filters.contains( "*." + fi.suffix() , Qt::CaseInsensitive) ) { filters = filters.section("(",1).section(")",0,0);
continue;
} else { // Split into blocks
emit log(LOGWARN,"Found supported datatype but only the suffix is matched not the complete suffix!"); QStringList separateFilters = filters.split(" ");
bool found = false;
// for all filters associated with this plugin
for ( int filterId = 0 ; filterId < separateFilters.size(); ++filterId ) {
separateFilters[filterId] = separateFilters[filterId].trimmed();
//check extension
if ( separateFilters[filterId].endsWith( "*." + fi.completeSuffix() , Qt::CaseInsensitive) ) {
found = true;
break;
} }
if ( separateFilters[filterId].endsWith( "*." + fi.suffix() , Qt::CaseInsensitive) ) {
found = true;
emit log(LOGWARN,"Found supported datatype but only the suffix is matched not the complete suffix!");
break;
}
} }
// continue processing only if found
if ( ! found )
continue;
if ( OpenFlipper::Options::gui() ) { if ( OpenFlipper::Options::gui() ) {
coreWidget_->statusMessage( tr("Loading %1 ... ").arg(_filename)); coreWidget_->statusMessage( tr("Loading %1 ... ").arg(_filename));
if ( !OpenFlipper::Options::loadingSettings() ) if ( !OpenFlipper::Options::loadingSettings() )
...@@ -267,10 +289,36 @@ int Core::loadObject( DataType _type, QString _filename) { ...@@ -267,10 +289,36 @@ int Core::loadObject( DataType _type, QString _filename) {
if (supportedTypes()[i].type & _type || supportedTypes()[i].type == _type) { if (supportedTypes()[i].type & _type || supportedTypes()[i].type == _type) {
QString filters = supportedTypes()[i].plugin->getLoadFilters(); QString filters = supportedTypes()[i].plugin->getLoadFilters();
//check extension
if ( ! filters.contains( "*." + fi.suffix() ,Qt::CaseInsensitive ) ) // Only take the parts inside the brackets
filters = filters.section("(",1).section(")",0,0);
// Split into blocks
QStringList separateFilters = filters.split(" ");
bool found = false;
// for all filters associated with this plugin
for ( int filterId = 0 ; filterId < separateFilters.size(); ++filterId ) {
separateFilters[filterId] = separateFilters[filterId].trimmed();
//check extension
if ( separateFilters[filterId].endsWith( "*." + fi.completeSuffix() , Qt::CaseInsensitive) ) {
found = true;
break;
}
if ( separateFilters[filterId].endsWith( "*." + fi.suffix() , Qt::CaseInsensitive) ) {
found = true;
emit log(LOGWARN,"Found supported datatype but only the suffix is matched not the complete suffix!");
break;
}
}
// continue processing only if found
if ( ! found )
continue; continue;
if ( OpenFlipper::Options::gui() ) { if ( OpenFlipper::Options::gui() ) {
coreWidget_->statusMessage( tr("Loading %1 ... ").arg(_filename)); coreWidget_->statusMessage( tr("Loading %1 ... ").arg(_filename));
......
...@@ -74,11 +74,24 @@ FileOptionsDialog::FileOptionsDialog(std::vector<fileTypes>& _supportedTypes, QS ...@@ -74,11 +74,24 @@ FileOptionsDialog::FileOptionsDialog(std::vector<fileTypes>& _supportedTypes, QS
else else
filters = supportedTypes_[t].saveFilters; filters = supportedTypes_[t].saveFilters;
if (filters.contains("." + ext_[i],Qt::CaseInsensitive)){ // Only take the parts inside the brackets
count++; filters = filters.section("(",1).section(")",0,0);
names.push_back( supportedTypes_[t].name );
usefulPlugins.push_back( t ); // Split into blocks
QStringList separateFilters = filters.split(" ");
for ( int filterId = 0 ; filterId < separateFilters.size(); ++filterId ) {
separateFilters[filterId] = separateFilters[filterId].trimmed();
if (separateFilters[filterId].endsWith("." + ext_[i],Qt::CaseInsensitive)){
count++;
names.push_back( supportedTypes_[t].name );
usefulPlugins.push_back( t );
continue;
}
} }
} }
//more than one plugin can handle the extension //more than one plugin can handle the extension
......
...@@ -215,10 +215,25 @@ void LoadWidget::loadFile(){ ...@@ -215,10 +215,25 @@ void LoadWidget::loadFile(){
QString filters = supportedTypes_[t].loadFilters; QString filters = supportedTypes_[t].loadFilters;
if (filters.contains(ext[i],Qt::CaseInsensitive)){ // Take only part inside brackets
pluginForExtension_[ ext[i] ] = t; filters = filters.section("(",1).section(")",0,0);
break;
QStringList separateFilters = filters.split(" ");
bool found = false;
for ( int filterId = 0 ; filterId < separateFilters.size(); ++filterId ) {
if (separateFilters[filterId].endsWith(ext[i],Qt::CaseInsensitive)){
pluginForExtension_[ ext[i] ] = t;
found = true;
}
} }
if ( found )
break;
} }
} }
...@@ -288,10 +303,25 @@ void LoadWidget::saveFile(){ ...@@ -288,10 +303,25 @@ void LoadWidget::saveFile(){
QString filters = supportedTypes_[t].saveFilters; QString filters = supportedTypes_[t].saveFilters;
if (filters.contains( fi.suffix(),Qt::CaseInsensitive )){ // Take only part inside brackets
pluginForExtension_[ fi.suffix() ] = t; filters = filters.section("(",1).section(")",0,0);
break;
QStringList separateFilters = filters.split(" ");
bool found = false;
for ( int filterId = 0 ; filterId < separateFilters.size(); ++filterId ) {
if (separateFilters[filterId].endsWith(fi.suffix(),Qt::CaseInsensitive)){
pluginForExtension_[ fi.suffix() ] = t;
found = true;
}
} }
if ( found )
break;
} }
// display options for all dataTypes // display options for all dataTypes
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment