rebuild( p_root );
CONNECT( THEMIM->getIM(), metaChanged( input_item_t *),
- this, ProcessInputItemUpdate( input_item_t *) );
+ this, processInputItemUpdate( input_item_t *) );
CONNECT( THEMIM, inputChanged( input_thread_t * ),
- this, ProcessInputItemUpdate( input_thread_t* ) );
+ this, processInputItemUpdate( input_thread_t* ) );
}
PLModel::~PLModel()
ids.append( item->i_id );
model_items.append( item );
- TakeItem( item );
+ takeItem( item );
}
int count = ids.size();
if( count )
new_pos );
PL_UNLOCK;
- InsertChildren( target, model_items, model_pos );
+ insertChildren( target, model_items, model_pos );
}
}
/* remove item with its id */
void PLModel::removeItem( int i_id )
{
- PLItem *item = FindById( rootItem, i_id );
- RemoveItem( item );
+ PLItem *item = findById( rootItem, i_id );
+ removeItem( item );
}
/* callbacks and slots */
return columnCount;
}
-int PLModel::childrenCount( const QModelIndex &parent ) const
-{
- return rowCount( parent );
-}
-
int PLModel::rowCount( const QModelIndex &parent ) const
{
PLItem *parentItem = parent.isValid() ? getItem( parent ) : rootItem;
/************************* Lookups *****************************/
-PLItem *PLModel::FindById( PLItem *root, int i_id )
+PLItem *PLModel::findById( PLItem *root, int i_id )
{
- return FindInner( root, i_id, false );
+ return findInner( root, i_id, false );
}
-PLItem *PLModel::FindByInput( PLItem *root, int i_id )
+PLItem *PLModel::findByInput( PLItem *root, int i_id )
{
- PLItem *result = FindInner( root, i_id, true );
+ PLItem *result = findInner( root, i_id, true );
return result;
}
#define CACHE( i, p ) { i_cached_id = i; p_cached_item = p; }
#define ICACHE( i, p ) { i_cached_input_id = i; p_cached_item_bi = p; }
-PLItem * PLModel::FindInner( PLItem *root, int i_id, bool b_input )
+PLItem * PLModel::findInner( PLItem *root, int i_id, bool b_input )
{
if( ( !b_input && i_cached_id == i_id) ||
( b_input && i_cached_input_id ==i_id ) )
}
if( (*it)->children.size() )
{
- PLItem *childFound = FindInner( (*it), i_id, b_input );
+ PLItem *childFound = findInner( (*it), i_id, b_input );
if( childFound )
{
if( b_input )
PLEvent *ple = static_cast<PLEvent *>(event);
if( type == ItemAppend_Type )
- ProcessItemAppend( &ple->add );
+ processItemAppend( &ple->add );
else if( type == ItemDelete_Type )
- ProcessItemRemoval( ple->i_id );
+ processItemRemoval( ple->i_id );
else
rebuild();
}
/**** Events processing ****/
-void PLModel::ProcessInputItemUpdate( input_thread_t *p_input )
+void PLModel::processInputItemUpdate( input_thread_t *p_input )
{
if( !p_input ) return;
- ProcessInputItemUpdate( input_GetItem( p_input ) );
+ processInputItemUpdate( input_GetItem( p_input ) );
if( p_input && !( p_input->b_dead || !vlc_object_alive( p_input ) ) )
{
- PLItem *item = FindByInput( rootItem, input_GetItem( p_input )->i_id );
+ PLItem *item = findByInput( rootItem, input_GetItem( p_input )->i_id );
currentItem = item;
emit currentChanged( index( item, 0 ) );
}
currentItem = NULL;
}
}
-void PLModel::ProcessInputItemUpdate( input_item_t *p_item )
+void PLModel::processInputItemUpdate( input_item_t *p_item )
{
if( !p_item || p_item->i_id <= 0 ) return;
- PLItem *item = FindByInput( rootItem, p_item->i_id );
+ PLItem *item = findByInput( rootItem, p_item->i_id );
if( item )
- UpdateTreeItem( item, true, true);
+ updateTreeItem( item, true, true);
}
-void PLModel::ProcessItemRemoval( int i_id )
+void PLModel::processItemRemoval( int i_id )
{
if( i_id <= 0 ) return;
if( i_id == i_cached_id ) i_cached_id = -1;
removeItem( i_id );
}
-void PLModel::ProcessItemAppend( const playlist_add_t *p_add )
+void PLModel::processItemAppend( const playlist_add_t *p_add )
{
playlist_item_t *p_item = NULL;
PLItem *newItem = NULL;
- PLItem *nodeItem = FindById( rootItem, p_add->i_node );
+ PLItem *nodeItem = findById( rootItem, p_add->i_node );
if( !nodeItem ) return;
PL_LOCK;
beginInsertRows( index( nodeItem, 0 ), nodeItem->childCount(), nodeItem->childCount() );
nodeItem->appendChild( newItem );
endInsertRows();
- UpdateTreeItem( newItem, true );
+ updateTreeItem( newItem, true );
return;
end:
PL_UNLOCK;
}
assert( rootItem );
/* Recreate from root */
- UpdateChildren( rootItem );
+ updateChildren( rootItem );
if( (p_item = playlist_CurrentPlayingItem(p_playlist)) )
- currentItem = FindByInput( rootItem, p_item->p_input->i_id );
+ currentItem = findByInput( rootItem, p_item->p_input->i_id );
else
currentItem = NULL;
PL_UNLOCK;
addCallbacks();
}
-void PLModel::TakeItem( PLItem *item )
+void PLModel::takeItem( PLItem *item )
{
assert( item );
PLItem *parent = item->parentItem;
endRemoveRows();
}
-void PLModel::InsertChildren( PLItem *node, QList<PLItem*>& items, int i_pos )
+void PLModel::insertChildren( PLItem *node, QList<PLItem*>& items, int i_pos )
{
assert( node );
int count = items.size();
endInsertRows();
}
-void PLModel::RemoveItem( PLItem *item )
+void PLModel::removeItem( PLItem *item )
{
if( !item ) return;
if( currentItem == item )
}
/* This function must be entered WITH the playlist lock */
-void PLModel::UpdateChildren( PLItem *root )
+void PLModel::updateChildren( PLItem *root )
{
playlist_item_t *p_node = playlist_ItemGetById( p_playlist, root->i_id );
- UpdateChildren( p_node, root );
+ updateChildren( p_node, root );
}
/* This function must be entered WITH the playlist lock */
-void PLModel::UpdateChildren( playlist_item_t *p_node, PLItem *root )
+void PLModel::updateChildren( playlist_item_t *p_node, PLItem *root )
{
playlist_item_t *p_item = playlist_CurrentPlayingItem(p_playlist);
for( int i = 0; i < p_node->i_children ; i++ )
emit currentChanged( index( currentItem, 0 ) );
}
if( i_depth == DEPTH_PL && p_node->pp_children[i]->i_children != -1 )
- UpdateChildren( p_node->pp_children[i], newItem );
+ updateChildren( p_node->pp_children[i], newItem );
}
}
/* Function doesn't need playlist-lock, as we don't touch playlist_item_t stuff here*/
-void PLModel::UpdateTreeItem( PLItem *item, bool signal, bool force )
+void PLModel::updateTreeItem( PLItem *item, bool signal, bool force )
{
if ( !item || !item->p_input )
return;
/* And finally, remove it from the tree */
int itemIndex = item->parentItem->children.indexOf( item );
beginRemoveRows( index( item->parentItem, 0), itemIndex, itemIndex );
- RemoveItem( item );
+ removeItem( item );
endRemoveRows();
}
}
}
- PLItem *item = FindById( rootItem, i_root_id );
+ PLItem *item = findById( rootItem, i_root_id );
if( !item ) return;
QModelIndex qIndex = index( item, 0 );
int count = item->children.size();
if( count )
{
beginInsertRows( qIndex, 0, count - 1 );
- UpdateChildren( item );
+ updateChildren( item );
endInsertRows( );
}
PL_UNLOCK;
playlist_item_t *, int, QObject *parent = 0 );
~PLModel();
- /* All types of lookups / QModel stuff */
+ /*** QModel subclassing ***/
+
+ /* Data structure */
QVariant data( const QModelIndex &index, int role ) const;
- Qt::ItemFlags flags( const QModelIndex &index ) const;
QVariant headerData( int section, Qt::Orientation orientation,
int role = Qt::DisplayRole ) const;
- QModelIndex index( int r, int c, const QModelIndex &parent ) const;
- QModelIndex index( PLItem *, int c ) const;
- QModelIndex currentIndex( ) { return index( currentItem, 0 ); };
- int itemId( const QModelIndex &index ) const;
- bool isCurrent( const QModelIndex &index ) const;
- QModelIndex parent( const QModelIndex &index ) const;
- int childrenCount( const QModelIndex &parent = QModelIndex() ) const;
int rowCount( const QModelIndex &parent = QModelIndex() ) const;
int columnCount( const QModelIndex &parent = QModelIndex() ) const;
+ Qt::ItemFlags flags( const QModelIndex &index ) const;
+ QModelIndex index( int r, int c, const QModelIndex &parent ) const;
+ QModelIndex parent( const QModelIndex &index ) const;
- /* Get current selection */
- QStringList selectedURIs();
+ /* Drag and Drop */
+ Qt::DropActions supportedDropActions() const;
+ QMimeData* mimeData( const QModelIndexList &indexes ) const;
+ bool dropMimeData( const QMimeData *data, Qt::DropAction action,
+ int row, int column, const QModelIndex &target );
+ QStringList mimeTypes() const;
- void rebuild(); void rebuild( playlist_item_t * );
+ /**** Custom ****/
+
+ /* Lookups */
+ QStringList selectedURIs();
bool hasRandom(); bool hasLoop(); bool hasRepeat();
+ int shownFlags() { return i_showflags; }
+ QModelIndex index( PLItem *, int c ) const;
+ QModelIndex currentIndex( ) { return index( currentItem, 0 ); };
+ bool isCurrent( const QModelIndex &index ) const;
+ int itemId( const QModelIndex &index ) const;
- /* Actions made by the views */
+ /* Actions */
void popup( QModelIndex & index, QPoint &point, QModelIndexList list );
void doDelete( QModelIndexList selected );
void search( const QString& search_text );
void sort( int column, Qt::SortOrder order );
void sort( int i_root_id, int column, Qt::SortOrder order );
void removeItem( int );
-
- /* DnD handling */
- Qt::DropActions supportedDropActions() const;
- QMimeData* mimeData( const QModelIndexList &indexes ) const;
- bool dropMimeData( const QMimeData *data, Qt::DropAction action,
- int row, int column, const QModelIndex &target );
- QStringList mimeTypes() const;
-
- int shownFlags() { return i_showflags; }
+ void rebuild(); void rebuild( playlist_item_t * );
private:
- void addCallbacks();
- void delCallbacks();
- void customEvent( QEvent * );
+ /* General */
PLItem *rootItem;
PLItem *currentItem;
static QIcon icons[ITEM_TYPE_NUMBER];
- /* Update processing */
- void ProcessItemRemoval( int i_id );
- void ProcessItemAppend( const playlist_add_t *p_add );
+ /* Callbacks related */
+ void addCallbacks();
+ void delCallbacks();
+ void customEvent( QEvent * );
+ void processItemRemoval( int i_id );
+ void processItemAppend( const playlist_add_t *p_add );
/* Actions */
void recurseDelete( QList<PLItem*> children, QModelIndexList *fullList );
void doDeleteItem( PLItem *item, QModelIndexList *fullList );
- void UpdateTreeItem( PLItem *, bool, bool force = false );
+ void updateTreeItem( PLItem *, bool, bool force = false );
+ void takeItem( PLItem * ); //will not delete item
+ void insertChildren( PLItem *node, QList<PLItem*>& items, int i_pos );
void dropAppendCopy( QByteArray& data, PLItem *target );
void dropMove( QByteArray& data, PLItem *target, int new_pos );
- void TakeItem( PLItem * );
- void InsertChildren( PLItem *node, QList<PLItem*>& items, int i_pos );
/* The following actions will not signal the view! */
- void RemoveItem ( PLItem * );
- void UpdateChildren( PLItem * );
- void UpdateChildren( playlist_item_t *, PLItem * );
+ void removeItem ( PLItem * );
+ void updateChildren( PLItem * );
+ void updateChildren( playlist_item_t *, PLItem * );
/* Popup */
int i_popup_item, i_popup_parent, i_popup_column;
QSignalMapper *ContextUpdateMapper;
/* Lookups */
- PLItem *FindById( PLItem *, int );
- PLItem *FindByInput( PLItem *, int );
- PLItem *FindInner( PLItem *, int , bool );
+ PLItem *findById( PLItem *, int );
+ PLItem *findByInput( PLItem *, int );
+ PLItem *findInner( PLItem *, int , bool );
static inline PLItem *getItem( QModelIndex index );
int metaColumn ( int column ) const;
PLItem *p_cached_item;
PLItem *p_cached_item_bi;
int i_cached_id;
int i_cached_input_id;
+
signals:
void shouldRemove( int );
void currentChanged( const QModelIndex& );
void popupSortAsc();
void popupSortDesc();
void viewchanged( int );
- void ProcessInputItemUpdate( input_item_t *);
- void ProcessInputItemUpdate( input_thread_t* p_input );
+ void processInputItemUpdate( input_item_t *);
+ void processInputItemUpdate( input_thread_t* p_input );
};
#endif