]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/recents.cpp
Qt4: get 10 recents items (was 8)
[vlc] / modules / gui / qt4 / recents.cpp
index ea3fcd4fce9f3a19b62e9de0b940d5ae6f15db66..82a20e137cb78b74a9a339af9438130f44765403 100644 (file)
@@ -24,6 +24,7 @@
 
 #include "recents.hpp"
 #include "dialogs_provider.hpp"
+#include "menus.hpp"
 
 #include <QList>
 #include <QString>
@@ -45,11 +46,14 @@ RecentsMRL::RecentsMRL( intf_thread_t *_p_intf ) : p_intf( _p_intf )
 
     isActive = config_GetInt( p_intf, "qt-recentplay" );
     char* psz_tmp = config_GetPsz( p_intf, "qt-recentplay-filter" );
-    filter = new QRegExp( psz_tmp, Qt::CaseInsensitive );
+    if( psz_tmp && *psz_tmp )
+        filter = new QRegExp( psz_tmp, Qt::CaseInsensitive );
+    else
+        filter = NULL;
     free( psz_tmp );
 
     load();
-    if ( !isActive ) clear();
+    if( !isActive ) clear();
 }
 
 RecentsMRL::~RecentsMRL()
@@ -60,7 +64,7 @@ RecentsMRL::~RecentsMRL()
 
 void RecentsMRL::addRecent( const QString &mrl )
 {
-    if ( !isActive || filter->indexIn( mrl ) >= 0 )
+    if ( !isActive || ( filter && filter->indexIn( mrl ) >= 0 ) )
         return;
 
     msg_Dbg( p_intf, "Adding a new MRL to recent ones: %s", qtu( mrl ) );
@@ -76,7 +80,7 @@ void RecentsMRL::addRecent( const QString &mrl )
         if( stack->size() > RECENTS_LIST_SIZE )
             stack->takeLast();
     }
-    emit updated();
+    QVLCMenu::updateRecents( p_intf );
     save();
 }
 
@@ -85,7 +89,7 @@ void RecentsMRL::clear()
     if ( stack->isEmpty() )
         return;
     stack->clear();
-    emit updated();
+    if( isActive ) QVLCMenu::updateRecents( p_intf );
     save();
 }
 
@@ -100,7 +104,7 @@ void RecentsMRL::load()
 
     for( int i = 0; i < list.size(); ++i )
     {
-        if (filter->indexIn( list.at(i) ) == -1)
+        if ( !filter || filter->indexIn( list.at(i) ) == -1 )
             stack->append( list.at(i) );
     }
 }