[vlc-commits] Qt: simplify media filters

Francois Cartegnie git at videolan.org
Thu Dec 8 18:13:15 CET 2011


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Thu Dec  8 17:44:04 2011 +0100| [3ce16b37046b703afe9d7f4fdaa7388c570d8e91] | committer: Francois Cartegnie

Qt: simplify media filters

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=3ce16b37046b703afe9d7f4fdaa7388c570d8e91
---

 modules/gui/qt4/dialogs_provider.cpp |   12 +++++-----
 modules/gui/qt4/dialogs_provider.hpp |   39 +++++++++------------------------
 2 files changed, 17 insertions(+), 34 deletions(-)

diff --git a/modules/gui/qt4/dialogs_provider.cpp b/modules/gui/qt4/dialogs_provider.cpp
index cc1ffd6..a18b4b6 100644
--- a/modules/gui/qt4/dialogs_provider.cpp
+++ b/modules/gui/qt4/dialogs_provider.cpp
@@ -401,21 +401,21 @@ QStringList DialogsProvider::showSimpleOpen( const QString& help,
 {
     QString fileTypes = "";
     if( filters & EXT_FILTER_MEDIA ) {
-        ADD_FILTER_MEDIA( fileTypes );
+        ADD_EXT_FILTER( fileTypes, EXTENSIONS_MEDIA );
     }
     if( filters & EXT_FILTER_VIDEO ) {
-        ADD_FILTER_VIDEO( fileTypes );
+        ADD_EXT_FILTER( fileTypes, EXTENSIONS_VIDEO );
     }
     if( filters & EXT_FILTER_AUDIO ) {
-        ADD_FILTER_AUDIO( fileTypes );
+        ADD_EXT_FILTER( fileTypes, EXTENSIONS_AUDIO );
     }
     if( filters & EXT_FILTER_PLAYLIST ) {
-        ADD_FILTER_PLAYLIST( fileTypes );
+        ADD_EXT_FILTER( fileTypes, EXTENSIONS_PLAYLIST );
     }
     if( filters & EXT_FILTER_SUBTITLE ) {
-        ADD_FILTER_SUBTITLE( fileTypes );
+        ADD_EXT_FILTER( fileTypes, EXTENSIONS_SUBTITLE );
     }
-    ADD_FILTER_ALL( fileTypes );
+    ADD_EXT_FILTER( fileTypes, EXTENSIONS_ALL );
     fileTypes.replace( ";*", " *");
 
     QStringList files = QFileDialog::getOpenFileNames( NULL,
diff --git a/modules/gui/qt4/dialogs_provider.hpp b/modules/gui/qt4/dialogs_provider.hpp
index d602977..7429057 100644
--- a/modules/gui/qt4/dialogs_provider.hpp
+++ b/modules/gui/qt4/dialogs_provider.hpp
@@ -37,34 +37,17 @@
 #include <QObject>
 #include <QStringList>
 
-#define ADD_FILTER_MEDIA( string )     \
-    string += qtr( "Media Files" );    \
-    string += " ( ";                   \
-    string += EXTENSIONS_MEDIA;        \
-    string += ");;";
-#define ADD_FILTER_VIDEO( string )     \
-    string += qtr( "Video Files" );    \
-    string += " ( ";                   \
-    string += EXTENSIONS_VIDEO;        \
-    string += ");;";
-#define ADD_FILTER_AUDIO( string )     \
-    string += qtr( "Audio Files" );    \
-    string += " ( ";                   \
-    string += EXTENSIONS_AUDIO;        \
-    string += ");;";
-#define ADD_FILTER_PLAYLIST( string )  \
-    string += qtr( "Playlist Files" ); \
-    string += " ( ";                   \
-    string += EXTENSIONS_PLAYLIST;     \
-    string += ");;";
-#define ADD_FILTER_SUBTITLE( string )  \
-    string += qtr( "Subtitles Files" );\
-    string += " ( ";                   \
-    string += EXTENSIONS_SUBTITLE;     \
-    string += ");;";
-#define ADD_FILTER_ALL( string )       \
-    string += qtr( "All Files" );      \
-    string += " (*)";
+#define TITLE_EXTENSIONS_MEDIA qtr( "Media Files" )
+#define TITLE_EXTENSIONS_VIDEO qtr( "Video Files" )
+#define TITLE_EXTENSIONS_AUDIO qtr( "Audio Files" )
+#define TITLE_EXTENSIONS_PLAYLIST qtr( "Playlist Files" )
+#define TITLE_EXTENSIONS_SUBTITLE qtr( "Subtitles Files" )
+#define TITLE_EXTENSIONS_ALL qtr( "All Files" )
+#define EXTENSIONS_ALL "*"
+#define ADD_EXT_FILTER( string, type ) \
+    string = string + QString("%1 ( %2 );;") \
+            .arg( TITLE_##type ) \
+            .arg( QString( type ) );
 
 enum {
     EXT_FILTER_MEDIA     =  0x01,



More information about the vlc-commits mailing list