1 /*****************************************************************************
2 * vlc_model.cpp : base for playlist and ml model
3 ****************************************************************************
4 * Copyright (C) 2010 the VideoLAN team and AUTHORS
7 * Authors: Srikanth Raju <srikiraju#gmail#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 *****************************************************************************/
24 #include "vlc_model.hpp"
26 VLCModel::VLCModel( intf_thread_t
*_p_intf
, QObject
*parent
)
27 : QAbstractItemModel( parent
), p_intf(_p_intf
)
35 QString
VLCModel::getMeta( const QModelIndex
& index
, int meta
)
37 return index
.model()->index( index
.row(), columnFromMeta( meta
), index
.parent() ).
41 QPixmap
VLCModel::getArtPixmap( const QModelIndex
& index
, const QSize
& size
)
44 artUrl
= index
.model()->index( index
.row(),
45 columnFromMeta( COLUMN_COVER
),
50 QString key
= artUrl
+ QString("%1%2").arg(size
.width()).arg(size
.height());
52 if( !QPixmapCache::find( key
, artPix
))
54 if( artUrl
.isEmpty() || !artPix
.load( artUrl
) )
56 key
= QString("noart%1%2").arg(size
.width()).arg(size
.height());
57 if( !QPixmapCache::find( key
, artPix
) )
59 artPix
= QPixmap( ":/noart" ).scaled( size
,
61 Qt::SmoothTransformation
);
62 QPixmapCache::insert( key
, artPix
);
67 artPix
= artPix
.scaled( size
, Qt::KeepAspectRatio
, Qt::SmoothTransformation
);
68 QPixmapCache::insert( key
, artPix
);