#include "recents.hpp"
+#include "dialogs_provider.hpp"
+#include "menus.hpp"
#include <QList>
#include <QString>
{
stack = new QList<QString>;
signalMapper = new QSignalMapper(this);
+ CONNECT( signalMapper,
+ mapped(const QString & ),
+ DialogsProvider::getInstance( p_intf ),
+ playMRL( const QString & ) );
isActive = config_GetInt( p_intf, "qt-recentplay" );
- filter = new QRegExp(
- qfu( config_GetPsz( p_intf, "qt-recentplay-filter" ) ),
- Qt::CaseInsensitive );
+ char* psz_tmp = config_GetPsz( p_intf, "qt-recentplay-filter" );
+ 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()
{
+ delete filter;
delete stack;
}
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 ) );
- if( stack->contains( mrl ) )
+ int i_index = stack->indexOf( mrl );
+ if( 0 <= i_index )
{
- stack->removeOne( mrl );
- stack->prepend( mrl );
+ /* move to the front */
+ stack->move( i_index, 0 );
}
else
{
if( stack->size() > RECENTS_LIST_SIZE )
stack->takeLast();
}
- emit updated();
+ QVLCMenu::updateRecents( p_intf );
save();
}
if ( stack->isEmpty() )
return;
stack->clear();
- emit updated();
+ if( isActive ) QVLCMenu::updateRecents( p_intf );
save();
}
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) );
}
}