1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-10-13 14:13:32 +02:00

Rewrite FileDialogWrapper using FileNames::FileTypes...

... also removing some repeated code and using the config keys /DefaultOpenType
and /LastOpenType only in Import.cpp
This commit is contained in:
Paul Licameli
2019-12-20 13:02:31 -05:00
parent fc668f09b0
commit c64b3cb31f
13 changed files with 93 additions and 216 deletions

View File

@@ -137,15 +137,6 @@ bool Importer::Terminate()
return true;
}
void Importer::GetSupportedImportFormats(FormatList *formatList)
{
for(const auto &importPlugin : sImportPluginList())
{
formatList->emplace_back(importPlugin->GetPluginFormatDescription(),
importPlugin->GetSupportedExtensions());
}
}
FileNames::FileTypes
Importer::GetFileTypes( const FileNames::FileType &extraType )
{
@@ -159,8 +150,12 @@ Importer::GetFileTypes( const FileNames::FileType &extraType )
if ( !extraType.extensions.empty() )
fileTypes.push_back( extraType );
FormatList l;
GetSupportedImportFormats(&l);
FileNames::FileTypes l;
for(const auto &importPlugin : sImportPluginList())
{
l.emplace_back(importPlugin->GetPluginFormatDescription(),
importPlugin->GetSupportedExtensions());
}
using ExtensionSet = std::unordered_set< FileExtension >;
FileExtensions allList = extraType.extensions, newList;
@@ -168,13 +163,13 @@ Importer::GetFileTypes( const FileNames::FileType &extraType )
for ( const auto &format : l ) {
newList.clear();
newSet.clear();
for ( const auto &extension : format.formatExtensions ) {
for ( const auto &extension : format.extensions ) {
if ( newSet.insert( extension ).second )
newList.push_back( extension );
if ( allSet.insert( extension ).second )
allList.push_back( extension );
}
fileTypes.push_back( { format.formatName, newList } );
fileTypes.push_back( { format.description, newList } );
}
fileTypes[1].extensions = allList;

View File

@@ -30,22 +30,8 @@ class ImportFileHandle;
class UnusableImportPlugin;
typedef bool (*progress_callback_t)( void *userData, float percent );
class Format {
public:
TranslatableString formatName;
FileExtensions formatExtensions;
Format(const TranslatableString &_formatName,
FileExtensions _formatExtensions):
formatName(_formatName),
formatExtensions( std::move( _formatExtensions ) )
{
}
};
class ExtImportItem;
using FormatList = std::vector<Format> ;
using ExtImportItems = std::vector< std::unique_ptr<ExtImportItem> >;
class ExtImportItem
@@ -116,11 +102,6 @@ public:
bool Initialize();
bool Terminate();
/**
* Fills @formatList with a list of supported import formats
*/
void GetSupportedImportFormats(FormatList *formatList);
/**
* Constructs a list of types, for use by file opening dialogs, that includes
* all supported file types