66 Copyright (c) 2015 Scientific Computing and Imaging Institute,
77 University of Utah.
88
9-
9+
1010 Permission is hereby granted, free of charge, to any person obtaining a
1111 copy of this software and associated documentation files (the "Software"),
1212 to deal in the Software without restriction, including without limitation
@@ -106,7 +106,7 @@ class IEPluginLegacyAdapter : public GenericIEPluginInterface<Data>
106106
107107template <class Data >
108108class PluginMap
109- {
109+ {
110110public:
111111 PluginMap () : lock_(" IE plugin map" ), pluginTable_(nullptr ) {}
112112 Core::Thread::Mutex& getLock ();
@@ -174,7 +174,7 @@ size_t PluginMap<Data>::numPlugins() const
174174template <class Data >
175175void GenericIEPluginManager<Data>::get_importer_list(std::vector<std::string>& results) const
176176{
177- if (0 == map_.numPlugins ())
177+ if (0 == map_.numPlugins ())
178178 {
179179 return ;
180180 }
@@ -190,7 +190,7 @@ void GenericIEPluginManager<Data>::get_importer_list(std::vector<std::string>& r
190190template <class Data >
191191void GenericIEPluginManager<Data>::get_exporter_list(std::vector<std::string>& results) const
192192{
193- if (0 == map_.numPlugins ())
193+ if (0 == map_.numPlugins ())
194194 {
195195 return ;
196196 }
@@ -338,24 +338,28 @@ SCISHARE std::string defaultImportTypeForFile(const GenericIEPluginManager<NrrdD
338338
339339SCISHARE std::string fileTypeDescriptionFromDialogBoxFilter (const std::string& fileFilter);
340340
341+ template <class Data >
342+ std::string dialogBoxFilterFromFileTypeDescription (const GenericIEPluginManager<Data>& mgr, const std::string& name)
343+ {
344+ if (name.find (" *" ) != std::string::npos) // user has set state variable with full filter string
345+ return name;
346+ std::ostringstream filter;
347+ auto pl = mgr.get_plugin (name);
348+ auto ext = pl ? pl->fileExtension () : std::string ();
349+ filter << name << " (" << (!ext.empty () ? ext : " *.*" ) << " )" ;
350+ return filter.str ();
351+ }
352+
341353template <class Data >
342354std::string printPluginDescriptionsForFilter (const GenericIEPluginManager<Data>& mgr, const std::string& defaultType, const std::vector<std::string>& pluginNames)
343355{
344356 std::ostringstream types;
345357 types << defaultType;
346358
359+ // Qt dialog-specific formatting
347360 for (const auto & name : pluginNames)
348361 {
349- auto pl = mgr.get_plugin (name);
350- types << " ;;" << name;
351- if (!pl->fileExtension ().empty ())
352- {
353- types << " (" << pl->fileExtension () << " )" ;
354- }
355- else
356- {
357- types << " (*.*)" ;
358- }
362+ types << " ;;" << dialogBoxFilterFromFileTypeDescription (mgr, name);
359363 }
360364 return types.str ();
361365}
@@ -370,7 +374,7 @@ std::string makeGuiTypesListForImport(const GenericIEPluginManager<Data>& mgr)
370374}
371375
372376template <class Data >
373- std::string defaultExportTypeForFile (const GenericIEPluginManager<Data>* mgr = 0 )
377+ std::string defaultExportTypeForFile (const GenericIEPluginManager<Data>* mgr = nullptr )
374378{
375379 return " " ;
376380}
0 commit comments