#endif
#include "qt4.hpp"
+#include "dialogs_provider.hpp"
#include "components/playlist/playlist_model.hpp"
#include "dialogs/mediainfo.hpp"
+#include "dialogs/playlist.hpp"
#include <vlc_intf_strings.h>
#include "pixmaps/types/type_unknown.xpm"
QByteArray encodedData;
QDataStream stream( &encodedData, QIODevice::WriteOnly );
- foreach( QModelIndex index, indexes ) {
+ foreach( const QModelIndex &index, indexes ) {
if( index.isValid() && index.column() == 0 )
stream << itemId( index );
}
if( action == Qt::IgnoreAction )
return true;
- PLItem *targetItem;
- if( target.isValid() )
- targetItem = static_cast<PLItem*>( target.internalPointer() );
- else
- targetItem = rootItem;
+ if( !target.isValid() )
+ /* We don't want to move on an invalid position */
+ return true;
+
+ PLItem *targetItem = static_cast<PLItem*>( target.internalPointer() );
QByteArray encodedData = data->data( "vlc/playlist-item-id" );
QDataStream stream( &encodedData, QIODevice::ReadOnly );
}
for( i = 0 ; i< p_parent->i_children ; i++ )
if( p_parent->pp_children[i] == p_target ) break;
- playlist_TreeMove( p_playlist, p_src, p_parent, i );
+ // Move the item to the element after i
+ playlist_TreeMove( p_playlist, p_src, p_parent, i + 1 );
newParentItem = parentItem;
}
else
i = 0;
newParentItem = targetItem;
}
- /* Remove from source */
- PLItem *srcItem = FindById( rootItem, p_src->i_id );
- // We dropped on the source selector. Ask the dialog to forward
- // to the main view
- if( !srcItem )
- {
- emit shouldRemove( p_src->i_id );
- }
- else
- srcItem->remove( srcItem );
-
- /* Display at new destination */
- PLItem *newItem = new PLItem( p_src, newParentItem, this );
- newParentItem->insertChild( newItem, i, true );
- UpdateTreeItem( p_src, newItem, true );
- if( p_src->i_children != -1 )
- UpdateNodeChildren( newItem );
PL_UNLOCK;
}
+ /*TODO: That's not a good idea to rebuild the playlist */
+ rebuild();
}
return true;
}
return parentItem->childCount();
}
+QStringList PLModel::selectedURIs()
+{
+ QStringList lst;
+ for( int i = 0; i < current_selection.size(); i++ )
+ {
+ PL_LOCK;
+ PLItem *item = static_cast<PLItem*>
+ (current_selection[i].internalPointer());
+ if( !item )
+ continue;
+
+ input_item_t *p_item = NULL;
+ if( !p_item )
+ continue;
+
+ char *psz = input_item_GetURI( p_item );
+ if( !psz )
+ continue;
+ else
+ {
+ lst.append( QString( psz ) );
+ free( psz );
+ }
+ PL_UNLOCK;
+ }
+ return lst;
+}
+
/************************* General playlist status ***********************/
bool PLModel::hasRandom()
void PLModel::rebuild( playlist_item_t *p_root )
{
+ playlist_item_t* p_item;
/* Remove callbacks before locking to avoid deadlocks */
delCallbacks();
/* Invalidate cache */
assert( rootItem );
/* Recreate from root */
UpdateNodeChildren( rootItem );
- if( p_playlist->status.p_item )
+ if( (p_item = playlist_CurrentPlayingItem(p_playlist)) )
{
PLItem *currentItem = FindByInput( rootItem,
- p_playlist->status.p_item->p_input->i_id );
+ p_item->p_input->i_id );
if( currentItem )
{
- UpdateTreeItem( p_playlist->status.p_item, currentItem,
+ UpdateTreeItem( p_item, currentItem,
true, false );
}
}
if( !force && i_depth == DEPTH_SEL && p_item->p_parent &&
p_item->p_parent->i_id != rootItem->i_id )
return;
- item->update( p_item, p_item == p_playlist->status.p_item );
+ item->update( p_item, p_item == playlist_CurrentPlayingItem( p_playlist ) );
if( signal )
emit dataChanged( index( item, 0 ) , index( item, 1 ) );
}
int i_index = -1;
int i_flag = 0;
- // FIXME: Disable sorting on startup by ignoring
- // first call of sorting caused by showing dialog
- // see: standardpanel.cpp:65
- static bool b_first_time = true;
- if( b_first_time )
+ int i_column = 1;
+ for( i_column = 1; i_column != COLUMN_END; i_column<<=1 )
{
- b_first_time = false;
- return;
+ if( ( shownFlags() & i_column ) )
+ i_index++;
+ if( column == i_index )
+ {
+ i_flag = i_column;
+ goto next;
+ }
}
-#define CHECK_COLUMN( meta ) \
-{ \
- if( ( shownFlags() & meta ) ) \
- i_index++; \
- if( column == i_index ) \
- { \
- i_flag = meta; \
- goto next; \
- } \
-}
-
- CHECK_COLUMN( COLUMN_NUMBER );
- CHECK_COLUMN( COLUMN_TITLE );
- CHECK_COLUMN( COLUMN_DURATION );
- CHECK_COLUMN( COLUMN_ARTIST );
- CHECK_COLUMN( COLUMN_GENRE );
- CHECK_COLUMN( COLUMN_ALBUM );
- CHECK_COLUMN( COLUMN_TRACK_NUMBER );
- CHECK_COLUMN( COLUMN_DESCRIPTION );
-
-#undef CHECK_COLUMN
next:
PL_LOCK;
i_column_sorting( i_flag ),
order == Qt::AscendingOrder ?
ORDER_NORMAL : ORDER_REVERSE );
- p_playlist->b_reset_currently_playing = true;
}
}
PL_UNLOCK;
PL_UNLOCK;
current_selection = list;
QMenu *menu = new QMenu;
- menu->addAction( qfu(I_POP_PLAY), this, SLOT( popupPlay() ) );
- menu->addAction( qfu(I_POP_DEL), this, SLOT( popupDel() ) );
+ menu->addAction( qtr(I_POP_PLAY), this, SLOT( popupPlay() ) );
+ menu->addAction( qtr(I_POP_DEL), this, SLOT( popupDel() ) );
menu->addSeparator();
- menu->addAction( qfu(I_POP_STREAM), this, SLOT( popupStream() ) );
- menu->addAction( qfu(I_POP_SAVE), this, SLOT( popupSave() ) );
+ menu->addAction( qtr(I_POP_STREAM), this, SLOT( popupStream() ) );
+ menu->addAction( qtr(I_POP_SAVE), this, SLOT( popupSave() ) );
menu->addSeparator();
- menu->addAction( qfu(I_POP_INFO), this, SLOT( popupInfo() ) );
+ menu->addAction( qtr(I_POP_INFO), this, SLOT( popupInfo() ) );
if( p_item->i_children > -1 )
{
menu->addSeparator();
- menu->addAction( qfu(I_POP_SORT), this, SLOT( popupSort() ) );
- menu->addAction( qfu(I_POP_ADD), this, SLOT( popupAdd() ) );
+ menu->addAction( qtr(I_POP_SORT), this, SLOT( popupSort() ) );
+ menu->addAction( qtr(I_POP_ADD), this, SLOT( popupAdd() ) );
}
menu->addSeparator();
- menu->addAction( qfu( I_POP_EXPLORE ), this, SLOT( popupExplore() ) );
+ menu->addAction( qtr( I_POP_EXPLORE ), this, SLOT( popupExplore() ) );
menu->popup( point );
}
else
{
beginRemoveColumns( parent, index, index+1 );
rootItem->i_showflags &= ~( meta );
+ getSettings()->setValue( "qt-pl-showflags", rootItem->i_showflags );
rootItem->updateColumnHeaders();
endRemoveColumns();
}
/* Adding columns */
beginInsertColumns( parent, index, index+1 );
rootItem->i_showflags |= meta;
+ getSettings()->setValue( "qt-pl-showflags", rootItem->i_showflags );
rootItem->updateColumnHeaders();
endInsertColumns();
}
{
doDelete( current_selection );
}
+
void PLModel::popupPlay()
{
PL_LOCK;
if( p_item )
{
MediaInfoDialog *mid = new MediaInfoDialog( p_intf, p_item->p_input );
+ mid->setParent( PlaylistDialog::getInstance( p_intf ),
+ Qt::Dialog );
mid->show();
}
}
void PLModel::popupStream()
{
- msg_Err( p_playlist, "Stream not implemented" );
+ QStringList mrls = selectedURIs();
+ if( !mrls.isEmpty() )
+ THEDP->streamingDialog( NULL, mrls[0], false );
+
}
void PLModel::popupSave()
{
- msg_Err( p_playlist, "Save not implemented" );
+ QStringList mrls = selectedURIs();
+ if( !mrls.isEmpty() )
+ THEDP->streamingDialog( NULL, mrls[0], true );
}
#include <QUrl>
char *psz_meta = input_item_GetURI( p_input );
if( psz_meta )
{
- /* FIXME add a MRLSplit like function */
- QFileInfo info( qfu( psz_meta ) );
- QDesktopServices::openUrl( QUrl::fromLocalFile( info.absolutePath() ) );
+ const char *psz_access;
+ const char *psz_demux;
+ char *psz_path;
+ input_SplitMRL( &psz_access, &psz_demux, &psz_path, psz_meta );
+
+ if( EMPTY_STR( psz_access ) ||
+ !strncasecmp( psz_access, "file", 4 ) ||
+ !strncasecmp( psz_access, "dire", 4 ) )
+ {
+ QFileInfo info( qfu( psz_meta ) );
+ QDesktopServices::openUrl(
+ QUrl::fromLocalFile( info.absolutePath() ) );
+ }
free( psz_meta );
}
}
{
PLModel *p_model = (PLModel *) param;
PLEvent *event = new PLEvent( PLUpdate_Type, 0 );
- QApplication::postEvent( p_model, static_cast<QEvent*>(event) );
+ QApplication::postEvent( p_model, event );
return VLC_SUCCESS;
}
{
PLModel *p_model = (PLModel *) param;
PLEvent *event = new PLEvent( ItemUpdate_Type, oval.i_int );
- QApplication::postEvent( p_model, static_cast<QEvent*>(event) );
+ QApplication::postEvent( p_model, event );
event = new PLEvent( ItemUpdate_Type, nval.i_int );
- QApplication::postEvent( p_model, static_cast<QEvent*>(event) );
+ QApplication::postEvent( p_model, event );
return VLC_SUCCESS;
}
{
PLModel *p_model = (PLModel *) param;
PLEvent *event = new PLEvent( ItemUpdate_Type, nval.i_int );
- QApplication::postEvent( p_model, static_cast<QEvent*>(event) );
+ QApplication::postEvent( p_model, event );
return VLC_SUCCESS;
}
{
PLModel *p_model = (PLModel *) param;
PLEvent *event = new PLEvent( ItemDelete_Type, nval.i_int );
- QApplication::postEvent( p_model, static_cast<QEvent*>(event) );
+ QApplication::postEvent( p_model, event );
return VLC_SUCCESS;
}
playlist_add_t *p_add = (playlist_add_t *)malloc( sizeof( playlist_add_t));
memcpy( p_add, nval.p_address, sizeof( playlist_add_t ) );
- PLEvent *event = new PLEvent( p_add );
- QApplication::postEvent( p_model, static_cast<QEvent*>(event) );
+ PLEvent *event = new PLEvent( p_add );
+ QApplication::postEvent( p_model, event );
return VLC_SUCCESS;
}