Move "All supported types" to top

Like usual browse menu. Migrated "as-is" (just for the model browser for
now)
This commit is contained in:
Christophe Mateos 2017-05-24 21:23:47 +02:00
parent 5940b1adbc
commit 45dd743f81
2 changed files with 20 additions and 18 deletions

View file

@ -1330,17 +1330,6 @@ const char* file_dialog( void *parent, gboolean open, const char* title, const c
CFileType typelist;
if ( pattern != NULL ) {
GetFileTypeRegistry()->getTypeList( pattern, &typelist );
// kaz - viewing all file types at once is really convenient for model selection
if ( !strcmp( "Open Model", title ) ) {
CString allTypesFilter;
for( int i = 0; i < typelist.GetNumTypes(); i++ ) {
allTypesFilter += typelist.GetTypeForIndex(i).pattern;
if ( i < typelist.GetNumTypes() - 1 )
allTypesFilter += ";";
}
typelist.addType(filetype_t("All supported types", allTypesFilter.GetBuffer()));
}
}
#ifdef _WIN32
@ -1360,12 +1349,6 @@ const char* file_dialog( void *parent, gboolean open, const char* title, const c
// "select the first filter as default".
if ( pattern ) {
ofn.lpstrFilter = typelist.m_strWin32Filters;
// kaz - the "all supported types" will be at bottom of list
// ...idiomatically uncouth but not worth fixing
if ( !strcmp( "Open Model", title ) ) {
ofn.nFilterIndex = typelist.GetNumTypes();
}
}
else
{

View file

@ -91,8 +91,27 @@ virtual void addType( const char* key, filetype_t type ){
}
virtual void getTypeList( const char* key, IFileTypeList* typelist ){
filetype_list_t& list_ref = m_typelists[key];
for ( unsigned int i = 0; i < list_ref.size(); ++i )
if (key == "model") {
// Get the list of all supported types (adapted from kaz)
CString allTypesFilter;
for (unsigned int i = 0; i < list_ref.size(); ++i) {
allTypesFilter += list_ref[i].getType().pattern;
if (i < list_ref.size() - 1) {
allTypesFilter += ";";
}
}
// Add the item on top
// TODO: Make is translatable
typelist->addType(filetype_t("All supported types", allTypesFilter.GetBuffer()));
}
// Then add the supported types one by one
// TODO: Sort them alphabetically (have them sorted in m_typelists[key])
for ( unsigned int i = 0; i < list_ref.size(); ++i ) {
typelist->addType( list_ref[i].getType() );
}
}
private:
struct filetype_copy_t