1 /*****************************************************************************
2 * recents.cpp : Recents MRL (menu)
3 *****************************************************************************
4 * Copyright © 2006-2008 the VideoLAN team
7 * Authors: Ludovic Fauvet <etix@l0cal.com>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * ( at your option ) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
25 #include "recents.hpp"
32 #include <QSignalMapper>
34 RecentsMRL* RecentsMRL::instance = NULL;
36 RecentsMRL::RecentsMRL( intf_thread_t *_p_intf ) : p_intf( _p_intf )
38 stack = new QList<QString>;
39 signalMapper = new QSignalMapper(this);
41 isActive = config_GetInt( p_intf, "qt-recentplay" );
43 qfu( config_GetPsz( p_intf, "qt-recentplay-filter" ) ),
44 Qt::CaseInsensitive );
47 if ( !isActive ) clear();
50 RecentsMRL::~RecentsMRL()
56 void RecentsMRL::addRecent( const QString &mrl )
58 if ( !isActive || filter->indexIn( mrl ) >= 0 )
61 if( stack->contains( mrl ) )
63 stack->removeOne( mrl );
64 stack->prepend( mrl );
68 stack->prepend( mrl );
69 if( stack->size() > RECENTS_LIST_SIZE )
76 void RecentsMRL::clear()
78 if ( stack->isEmpty() )
85 QList<QString> RecentsMRL::recents()
87 return QList<QString>(*stack);
90 void RecentsMRL::load()
94 getSettings()->beginGroup( "RecentsMRL" );
95 list = getSettings()->value( "list" ).toStringList();
96 getSettings()->endGroup();
98 for( int i = 0; i < list.size(); ++i )
100 if (filter->indexIn( list.at(i) ) == -1)
101 stack->append( list.at(i) );
105 void RecentsMRL::save()
109 for( int i = 0; i < stack->size(); ++i )
110 list << stack->at(i);
112 getSettings()->beginGroup( "RecentsMRL" );
113 getSettings()->setValue( "list", list );
114 getSettings()->endGroup();