* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
-#define PLI_NAME( p ) p ? p->p_input->psz_name : "null"
#include <assert.h>
#include <QIcon>
#include <vlc_intf_strings.h>
#include "pixmaps/type_unknown.xpm"
-#include "pixmaps/type_afile.xpm"
-#include "pixmaps/type_vfile.xpm"
+#include "pixmaps/type_file.xpm"
#include "pixmaps/type_net.xpm"
#include "pixmaps/type_card.xpm"
#include "pixmaps/type_disc.xpm"
i_id = _i_id; i_input_id = _i_input_id;
model = m;
-
if( parentItem == NULL )
{
i_showflags = config_GetInt( model->p_intf , "qt-pl-showflags" );
updateview();
+ } else {
+ i_showflags = parentItem->i_showflags;
+ //Add empty string and update() handles data appending
+ strings.append( "" );
}
}
{
strings.clear();
- for( int i_index=1; i_index <= VLC_META_ENGINE_MB_TRM_ID; i_index = i_index*2 )
+ if( model->i_depth == 1 ) //left window for playlist etc.
+ {
+ strings.append( "" );
+ return;
+ }
+
+ for( int i_index=1; i_index <= VLC_META_ENGINE_ART_URL; i_index = i_index*2 )
{
if( i_showflags & i_index )
{
{
case VLC_META_ENGINE_ARTIST:
strings.append( qtr( VLC_META_ARTIST ) );
- break;
+ break;
case VLC_META_ENGINE_TITLE:
strings.append( qtr( VLC_META_TITLE ) );
- break;
+ break;
case VLC_META_ENGINE_DESCRIPTION:
strings.append( qtr( VLC_META_DESCRIPTION ) );
- break;
+ break;
case VLC_META_ENGINE_DURATION:
strings.append( qtr( "Duration" ) );
- break;
+ break;
case VLC_META_ENGINE_GENRE:
strings.append( qtr( VLC_META_GENRE ) );
break;
{
char psz_duration[MSTRTIME_MAX_SIZE];
assert( p_item->p_input->i_id == i_input_id );
- strings.clear();
type = p_item->p_input->i_type;
current = iscurrent;
- if( current && p_item->p_input->p_meta &&
- p_item->p_input->p_meta->psz_arturl &&
- !strncmp( p_item->p_input->p_meta->psz_arturl, "file://", 7 ) )
- model->sendArt( qfu( p_item->p_input->p_meta->psz_arturl ) );
+ char *psz_arturl = input_item_GetArtURL( p_item->p_input );
+ if( ( current && psz_arturl ) &&
+ !strncmp( psz_arturl, "file://", 7 ) )
+ model->sendArt( qfu( psz_arturl ) ) ;
else if( current )
model->removeArt();
+ free( psz_arturl );
+
+ strings.clear();
if( model->i_depth == 1 ) //left window for playlist etc.
{
- strings.append( p_item->p_input->psz_name );
+ strings.append( qfu( p_item->p_input->psz_name ) );
return;
- }
-
+ }
-#define ADD_META( meta ) { \
- if( p_item->p_input->p_meta ) \
- strings.append( qfu( meta ) ); \
- else \
- strings.append( qtr( "" ) ); }
+ char *psz_meta;
+#define ADD_META( item, meta ) \
+ psz_meta = input_item_Get ## meta ( item->p_input ); \
+ strings.append( qfu( psz_meta ) ); \
+ free( psz_meta );
- for( int i_index=1; i_index <= VLC_META_ENGINE_MB_TRM_ID; i_index = i_index * 2 )
+ for( int i_index=1; i_index <= VLC_META_ENGINE_ART_URL; i_index = i_index * 2 )
{
if( parentItem->i_showflags & i_index )
{
switch( i_index )
{
case VLC_META_ENGINE_ARTIST:
- ADD_META( p_item->p_input->p_meta->psz_artist );
- break;
+ ADD_META( p_item, Artist );
+ break;
case VLC_META_ENGINE_TITLE:
- if( p_item->p_input->p_meta && p_item->p_input->p_meta->psz_title )
+ char *psz_title, *psz_name;
+ psz_title = input_item_GetTitle( p_item->p_input );
+ psz_name = input_item_GetName( p_item->p_input );
+ if( psz_title )
{
- ADD_META( p_item->p_input->p_meta->psz_title );
+ ADD_META( p_item, Title );
} else {
- ADD_META( p_item->p_input->psz_name );
+ strings.append( qfu( psz_name ) );
}
- break;
+ free( psz_title );
+ free( psz_name );
+ break;
case VLC_META_ENGINE_DESCRIPTION:
- ADD_META( p_item->p_input->p_meta->psz_description );
- break;
+ ADD_META( p_item, Description );
+ break;
case VLC_META_ENGINE_DURATION:
- secstotimestr( psz_duration, p_item->p_input->i_duration / 1000000 );
+ secstotimestr( psz_duration,
+ input_item_GetDuration( p_item->p_input ) / 1000000 );
strings.append( QString( psz_duration ) );
- break;
+ break;
case VLC_META_ENGINE_GENRE:
- ADD_META( p_item->p_input->p_meta->psz_genre );
+ ADD_META( p_item, Genre );
break;
case VLC_META_ENGINE_COLLECTION:
- ADD_META( p_item->p_input->p_meta->psz_album );
+ ADD_META( p_item, Album );
break;
case VLC_META_ENGINE_SEQ_NUM:
- ADD_META( p_item->p_input->p_meta->psz_tracknum);
+ ADD_META( p_item, TrackNum );
break;
case VLC_META_ENGINE_RATING:
- ADD_META( p_item->p_input->p_meta->psz_rating );
+ ADD_META( p_item, Rating );
default:
break;
- }
+ }
}
}
#undef ADD_META
-
}
/*************************************************************************
*************************************************************************/
PLModel::PLModel( playlist_t *_p_playlist, intf_thread_t *_p_intf,
- playlist_item_t * p_root, int _i_depth, QObject *parent)
+ playlist_item_t * p_root, int _i_depth, QObject *parent)
: QAbstractItemModel(parent)
{
i_depth = _i_depth;
#define ADD_ICON(type, x) icons[ITEM_TYPE_##type] = QIcon( QPixmap( type_##x##_xpm ) );
ADD_ICON( UNKNOWN , unknown );
- ADD_ICON( AFILE,afile );
- ADD_ICON( VFILE, vfile );
+ ADD_ICON( FILE, file );
ADD_ICON( DIRECTORY, directory );
ADD_ICON( DISC, disc );
ADD_ICON( CDDA, cdda );
rebuild( p_root );
}
-
PLModel::~PLModel()
{
delCallbacks();
int PLModel::columnCount( const QModelIndex &i) const
{
- if( i_depth == 1 ) return 1;
return rootItem->strings.count();
}
/* Clear the tree */
if( rootItem )
{
- beginRemoveRows( index( rootItem, 0 ), 0,
- rootItem->children.size() -1 );
- qDeleteAll( rootItem->children );
- rootItem->children.clear();
- endRemoveRows();
+ if( rootItem->children.size() )
+ {
+ beginRemoveRows( index( rootItem, 0 ), 0,
+ rootItem->children.size() -1 );
+ qDeleteAll( rootItem->children );
+ rootItem->children.clear();
+ endRemoveRows();
+ }
}
if( p_root )
{
menu->addAction( qfu(I_POP_SORT), this, SLOT( popupSort() ) );
menu->addAction( qfu(I_POP_ADD), this, SLOT( popupAdd() ) );
}
+#ifdef WIN32
menu->addSeparator();
-
- ContextUpdateMapper = new QSignalMapper(this);
-
-#define ADD_META_ACTION( meta ) { \
- QAction* option = menu->addAction( qfu(VLC_META_##meta) ); \
- option->setCheckable( true ); \
- option->setChecked( rootItem->i_showflags & VLC_META_ENGINE_##meta ); \
- ContextUpdateMapper->setMapping( option, VLC_META_ENGINE_##meta ); \
- CONNECT( option, triggered(), ContextUpdateMapper, map() ); \
- }
- CONNECT(ContextUpdateMapper, mapped( int ), this, viewchanged( int ) );
-
- ADD_META_ACTION( TITLE );
- ADD_META_ACTION( ARTIST );
- ADD_META_ACTION( DURATION );
- ADD_META_ACTION( COLLECTION );
- ADD_META_ACTION( GENRE );
- ADD_META_ACTION( SEQ_NUM );
- ADD_META_ACTION( RATING );
- ADD_META_ACTION( DESCRIPTION );
-
-#undef ADD_META_ACTION
-
+ menu->addAction( qfu( I_POP_EXPLORE ), this, SLOT( popupExplore() ) );
+#endif
menu->popup( point );
}
else
fprintf( stderr, "Save not implemented\n" );
}
+#ifdef WIN32
+#include <shellapi.h>
+void PLModel::popupExplore()
+{
+ ShellExecuteW(NULL, L"explore", L"C:\\", NULL, NULL, SW_SHOWNORMAL );
+}
+#endif
+
/**********************************************************************
* Playlist callbacks
**********************************************************************/