Commit 968dd88a authored by Jakob Leben's avatar Jakob Leben Committed by Rémi Denis-Courmont
Browse files

Qt4 Playlist: Disable dropping on non-container items



New protected field bool PLItem::b_is_node to have the data at hand.
Then only check this field in PLModel::flags().
Signed-off-by: Rémi Denis-Courmont's avatarRémi Denis-Courmont <remi@remlab.net>
parent 0ce4275a
......@@ -48,7 +48,7 @@
*/
void PLItem::init( int _i_id, int _i_input_id, PLItem *parent, PLModel *m, QSettings *settings )
void PLItem::init( int _i_id, int _i_input_id, bool _is_node, PLItem *parent, PLModel *m, QSettings *settings )
{
parentItem = parent; /* Can be NULL, but only for the rootItem */
i_id = _i_id; /* Playlist item specific id */
......@@ -56,6 +56,7 @@ void PLItem::init( int _i_id, int _i_input_id, PLItem *parent, PLModel *m, QSett
model = m; /* PLModel (QAbsmodel) */
i_type = -1; /* Item type - Avoid segfault */
b_current = false; /* Is the item the current Item or not */
b_is_node = _is_node;
assert( model ); /* We need a model */
......@@ -91,19 +92,21 @@ void PLItem::init( int _i_id, int _i_input_id, PLItem *parent, PLModel *m, QSett
Call the above function init
So far the first constructor isn't used...
*/
PLItem::PLItem( int _i_id, int _i_input_id, PLItem *parent, PLModel *m )
PLItem::PLItem( int _i_id, int _i_input_id, bool _is_node, PLItem *parent, PLModel *m )
{
init( _i_id, _i_input_id, parent, m, NULL );
init( _i_id, _i_input_id, _is_node, parent, m, NULL );
}
PLItem::PLItem( playlist_item_t * p_item, PLItem *parent, PLModel *m )
{
init( p_item->i_id, p_item->p_input->i_id, parent, m, NULL );
init( p_item->i_id, p_item->p_input->i_id, p_item->i_children > -1,
parent, m, NULL );
}
PLItem::PLItem( playlist_item_t * p_item, QSettings *settings, PLModel *m )
{
init( p_item->i_id, p_item->p_input->i_id, NULL, m, settings );
init( p_item->i_id, p_item->p_input->i_id, p_item->i_children > -1,
NULL, m, settings );
}
PLItem::~PLItem()
......@@ -174,6 +177,7 @@ void PLItem::update( playlist_item_t *p_item, bool iscurrent )
/* Useful for the model */
i_type = p_item->p_input->i_type;
b_current = iscurrent;
b_is_node = p_item->i_children > -1;
item_col_strings.clear();
......
......@@ -40,7 +40,7 @@ class PLItem
{
friend class PLModel;
public:
PLItem( int, int, PLItem *parent , PLModel * );
PLItem( int, int, bool, PLItem *parent , PLModel * );
PLItem( playlist_item_t *, PLItem *parent, PLModel * );
PLItem( playlist_item_t *, QSettings *, PLModel * );
~PLItem();
......@@ -72,9 +72,10 @@ protected:
int i_id;
int i_input_id;
int i_showflags;
bool b_is_node;
private:
void init( int, int, PLItem *, PLModel *, QSettings * );
void init( int, int, bool, PLItem *, PLModel *, QSettings * );
void updateColumnHeaders();
PLItem *parentItem;
PLModel *model;
......
......@@ -117,7 +117,12 @@ Qt::ItemFlags PLModel::flags( const QModelIndex &index ) const
{
Qt::ItemFlags defaultFlags = QAbstractItemModel::flags( index );
if( index.isValid() )
return Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled | defaultFlags;
{
PLItem *item = static_cast<PLItem*>( index.internalPointer() );
if ( item->b_is_node )
defaultFlags |= Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled;
else defaultFlags |= Qt::ItemIsDragEnabled;
}
else if ( rootItem->i_id != p_playlist->p_root_onelevel->i_id
&& rootItem->i_id != p_playlist->p_root_category->i_id )
defaultFlags |= Qt::ItemIsDropEnabled;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment