File indexing completed on 2024-05-19 04:48:38
0001 /**************************************************************************************** 0002 * Copyright (c) 2010 Casey Link <unnamedrambler@gmail.com> * 0003 * * 0004 * This program is free software; you can redistribute it and/or modify it under * 0005 * the terms of the GNU General Public License as published by the Free Software * 0006 * Foundation; either version 2 of the License, or (at your option) any later * 0007 * version. * 0008 * * 0009 * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 0010 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 0011 * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 0012 * * 0013 * You should have received a copy of the GNU General Public License along with * 0014 * this program. If not, see <http://www.gnu.org/licenses/>. * 0015 ****************************************************************************************/ 0016 0017 #include "DirPlaylistTrackFilterProxyModel.h" 0018 0019 #include "core/playlists/PlaylistFormat.h" 0020 #include "core-impl/meta/file/File.h" 0021 0022 #include <KDirModel> 0023 #include <KFileItem> 0024 0025 DirPlaylistTrackFilterProxyModel::DirPlaylistTrackFilterProxyModel( QObject *parent ) 0026 : KDirSortFilterProxyModel( parent ) 0027 { 0028 } 0029 0030 bool 0031 DirPlaylistTrackFilterProxyModel::filterAcceptsRow( int source_row, 0032 const QModelIndex& source_parent ) const 0033 { 0034 QModelIndex index = sourceModel()->index( source_row, 0, source_parent ); 0035 0036 QVariant qvar = index.data( KDirModel::FileItemRole ); 0037 if( !qvar.canConvert<KFileItem>() ) 0038 return false; 0039 0040 KFileItem item = qvar.value<KFileItem>(); 0041 0042 if( item.name() == "." ) 0043 return false; 0044 0045 if( item.isDir() || 0046 Playlists::isPlaylist( item.url() ) || 0047 MetaFile::Track::isTrack( item.url() ) ) 0048 { 0049 return QSortFilterProxyModel::filterAcceptsRow( source_row, source_parent ); 0050 } 0051 0052 return false; 0053 }