mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-09 07:36:48 +02:00
* Fix some Drag n Drop bugs in Playlist- / TrackModel code.
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
<widget class="QLabel" name="sourceLabel">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>22</pointsize>
|
||||
<pointsize>20</pointsize>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
|
@@ -213,7 +213,7 @@ PlaylistModel::dropMimeData( const QMimeData* data, Qt::DropAction action, int r
|
||||
Tomahawk::query_ptr* query = reinterpret_cast<Tomahawk::query_ptr*>(qptr);
|
||||
if ( query && !query->isNull() )
|
||||
{
|
||||
qDebug() << "Dropped query item:" << query->data()->artist() << "-" << query->data()->track();
|
||||
qDebug() << "Dropped query item:" << query->data()->artist() << "-" << query->data()->track() << action;
|
||||
queries << *query;
|
||||
}
|
||||
}
|
||||
@@ -239,6 +239,11 @@ PlaylistModel::dropMimeData( const QMimeData* data, Qt::DropAction action, int r
|
||||
connect( plitem, SIGNAL( dataChanged() ), SLOT( onDataChanged() ) );
|
||||
}
|
||||
emit endInsertRows();
|
||||
|
||||
if ( action == Qt::CopyAction )
|
||||
{
|
||||
onPlaylistChanged();
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -246,7 +251,7 @@ PlaylistModel::dropMimeData( const QMimeData* data, Qt::DropAction action, int r
|
||||
|
||||
|
||||
void
|
||||
PlaylistModel::onPlaylistChanged()
|
||||
PlaylistModel::onPlaylistChanged( bool waitForUpdate )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
|
||||
@@ -254,14 +259,13 @@ PlaylistModel::onPlaylistChanged()
|
||||
return;
|
||||
|
||||
QList<plentry_ptr> l = playlistEntries();
|
||||
if ( !l.count() )
|
||||
return;
|
||||
|
||||
foreach( const plentry_ptr& ple, l )
|
||||
{
|
||||
qDebug() << "updateinternal:" << ple->query()->toString();
|
||||
}
|
||||
|
||||
m_waitForUpdate = waitForUpdate;
|
||||
QString newrev = uuid();
|
||||
m_playlist->createNewRevision( newrev, m_playlist->currentrevision(), l );
|
||||
}
|
||||
@@ -287,16 +291,15 @@ PlaylistModel::playlistEntries() const
|
||||
|
||||
|
||||
void
|
||||
PlaylistModel::removeIndex( const QModelIndex& index )
|
||||
PlaylistModel::removeIndex( const QModelIndex& index, bool moreToCome )
|
||||
{
|
||||
if ( isReadOnly() )
|
||||
return;
|
||||
|
||||
TrackModel::removeIndex( index );
|
||||
|
||||
if ( !m_playlist.isNull() )
|
||||
if ( !moreToCome && !m_playlist.isNull() )
|
||||
{
|
||||
m_waitForUpdate = true;
|
||||
onPlaylistChanged();
|
||||
}
|
||||
}
|
||||
|
@@ -35,7 +35,7 @@ public:
|
||||
|
||||
void appendTrack( const Tomahawk::query_ptr& query );
|
||||
|
||||
virtual void removeIndex( const QModelIndex& index );
|
||||
virtual void removeIndex( const QModelIndex& index, bool moreToCome = false );
|
||||
|
||||
signals:
|
||||
void repeatModeChanged( PlaylistInterface::RepeatMode mode );
|
||||
@@ -50,7 +50,7 @@ private slots:
|
||||
void onDataChanged();
|
||||
|
||||
void onRevisionLoaded( Tomahawk::PlaylistRevision revision );
|
||||
void onPlaylistChanged();
|
||||
void onPlaylistChanged( bool waitForUpdate = true );
|
||||
|
||||
void onTracksAdded( const QList<Tomahawk::query_ptr>& tracks, const Tomahawk::collection_ptr& collection = Tomahawk::collection_ptr() );
|
||||
|
||||
|
@@ -273,14 +273,15 @@ TrackModel::mimeData( const QModelIndexList &indexes ) const
|
||||
|
||||
|
||||
void
|
||||
TrackModel::removeIndex( const QModelIndex& index )
|
||||
TrackModel::removeIndex( const QModelIndex& index, bool moreToCome )
|
||||
{
|
||||
if ( QThread::currentThread() != thread() )
|
||||
{
|
||||
qDebug() << "Reinvoking in correct thread:" << Q_FUNC_INFO;
|
||||
QMetaObject::invokeMethod( this, "removeIndex",
|
||||
Qt::QueuedConnection,
|
||||
Q_ARG(const QModelIndex, index)
|
||||
Q_ARG(const QModelIndex, index),
|
||||
Q_ARG(bool, moreToCome)
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
@@ -39,8 +39,6 @@ public:
|
||||
virtual QVariant data( const QModelIndex& index, int role = Qt::DisplayRole ) const;
|
||||
virtual QVariant headerData( int section, Qt::Orientation orientation, int role ) const;
|
||||
|
||||
virtual void removeIndexes( const QList<QModelIndex>& indexes );
|
||||
|
||||
virtual Tomahawk::result_ptr siblingItem( int direction ) { return Tomahawk::result_ptr(); }
|
||||
|
||||
virtual QMimeData* mimeData( const QModelIndexList& indexes ) const;
|
||||
@@ -68,7 +66,8 @@ signals:
|
||||
public slots:
|
||||
virtual void setCurrentItem( const QModelIndex& index );
|
||||
|
||||
virtual void removeIndex( const QModelIndex& index );
|
||||
virtual void removeIndex( const QModelIndex& index, bool moreToCome = false );
|
||||
virtual void removeIndexes( const QList<QModelIndex>& indexes );
|
||||
|
||||
virtual void setRepeatMode( PlaylistInterface::RepeatMode mode ) {}
|
||||
virtual void setShuffled( bool shuffled ) {}
|
||||
|
@@ -176,8 +176,20 @@ TrackProxyModel::removeIndexes( const QList<QModelIndex>& indexes )
|
||||
if ( !sourceModel() )
|
||||
return;
|
||||
|
||||
QList<QPersistentModelIndex> pil;
|
||||
foreach( const QModelIndex& idx, indexes )
|
||||
{
|
||||
removeIndex( idx );
|
||||
if ( idx.isValid() && idx.column() == 0 )
|
||||
pil << mapToSource( idx );
|
||||
}
|
||||
|
||||
bool b = true;
|
||||
foreach( const QPersistentModelIndex& idx, pil )
|
||||
{
|
||||
if ( idx == pil.last() )
|
||||
b = false;
|
||||
|
||||
qDebug() << "b is:" << b;
|
||||
sourceModel()->removeIndex( idx, b );
|
||||
}
|
||||
}
|
||||
|
@@ -274,21 +274,28 @@ TrackView::dragMoveEvent( QDragMoveEvent* event )
|
||||
void
|
||||
TrackView::dropEvent( QDropEvent* event )
|
||||
{
|
||||
/* const QPoint pos = event->pos();
|
||||
const QModelIndex index = indexAt( pos );
|
||||
QTreeView::dropEvent( event );
|
||||
|
||||
if ( event->isAccepted() )
|
||||
{
|
||||
qDebug() << "Ignoring accepted event!";
|
||||
return;
|
||||
}
|
||||
|
||||
if ( event->mimeData()->hasFormat( "application/tomahawk.query.list" ) )
|
||||
{
|
||||
const QPoint pos = event->pos();
|
||||
const QModelIndex index = indexAt( pos );
|
||||
|
||||
if ( index.isValid() )
|
||||
{
|
||||
event->acceptProposedAction();
|
||||
}
|
||||
}*/
|
||||
qDebug() << "Drop Event accepted at row:" << index.row();
|
||||
event->acceptProposedAction();
|
||||
|
||||
if ( !model()->isReadOnly() )
|
||||
{
|
||||
model()->dropMimeData( event->mimeData(), event->proposedAction(), index.row(), 0, index.parent() );
|
||||
}
|
||||
}
|
||||
|
||||
QTreeView::dropEvent( event );
|
||||
m_dragging = false;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user