diff --git a/src/sourcetree/animationhelper.cpp b/src/sourcetree/animationhelper.cpp index b40f30c74..8efa25bf8 100644 --- a/src/sourcetree/animationhelper.cpp +++ b/src/sourcetree/animationhelper.cpp @@ -7,14 +7,13 @@ AnimationHelper::AnimationHelper( const QModelIndex& index, QObject *parent ) , m_index( index ) , m_fullyExpanded( false ) , m_expandAnimation( 0 ) - , m_forceClosing( false ) { m_expandTimer.setSingleShot( true ); - m_expandTimer.setInterval( 1000 ); + m_expandTimer.setInterval( 600 ); connect( &m_expandTimer, SIGNAL(timeout()), SLOT(expandTimeout())); m_collapseTimer.setSingleShot( true ); - m_collapseTimer.setInterval( 1000 ); + m_collapseTimer.setInterval( 600 ); connect( &m_collapseTimer, SIGNAL(timeout()), SLOT(collapseTimeout())); } @@ -70,7 +69,6 @@ void AnimationHelper::collapse( bool immediately ) if ( immediately ) { - m_forceClosing = true; m_fullyExpanded = false; m_collapseAnimation->start(); } @@ -80,9 +78,6 @@ void AnimationHelper::collapse( bool immediately ) bool AnimationHelper::partlyExpanded() { - if ( m_forceClosing ) - return false; - return m_size != m_startSize; // return m_fullyExpanded // || ( m_expandAnimation->state() == QPropertyAnimation::Running && m_expandAnimation->currentTime() > 250 ) diff --git a/src/sourcetree/animationhelper.h b/src/sourcetree/animationhelper.h index cc46013df..1e4998132 100644 --- a/src/sourcetree/animationhelper.h +++ b/src/sourcetree/animationhelper.h @@ -49,7 +49,6 @@ private: QTimer m_collapseTimer; bool m_fullyExpanded; - bool m_forceClosing; QPropertyAnimation *m_expandAnimation; QPropertyAnimation *m_collapseAnimation; diff --git a/src/sourcetree/sourcedelegate.cpp b/src/sourcetree/sourcedelegate.cpp index 0a2fbdfac..55b41dfc6 100644 --- a/src/sourcetree/sourcedelegate.cpp +++ b/src/sourcetree/sourcedelegate.cpp @@ -36,6 +36,13 @@ SourceDelegate::SourceDelegate( QAbstractItemView* parent ) m_dropTypeImageMap.insert( 2, QPixmap( ":/data/images/drop-all-songs.png" ).scaledToHeight( 32, Qt::SmoothTransformation ) ); m_dropTypeImageMap.insert( 3, QPixmap( ":/data/images/drop-local-songs.png" ).scaledToWidth( 32, Qt::SmoothTransformation ) ); m_dropTypeImageMap.insert( 4, QPixmap( ":/data/images/drop-top-songs.png" ).scaledToWidth( 32, Qt::SmoothTransformation ) ); + + m_dropMimeData = new QMimeData(); +} + +SourceDelegate::~SourceDelegate() +{ + delete m_dropMimeData; } QSize @@ -53,7 +60,7 @@ SourceDelegate::sizeHint( const QStyleOptionViewItem& option, const QModelIndex& qDebug() << "droptypecount is " << dropTypes; QSize originalSize = QStyledItemDelegate::sizeHint( option, index ); QSize targetSize = originalSize + QSize( 0, dropTypes == 0 ? 0 : 56 ); - m_expandedMap.value( index )->initialize( originalSize, targetSize, 500 ); + m_expandedMap.value( index )->initialize( originalSize, targetSize, 300 ); m_expandedMap.value( index )->expand(); } QMetaObject::invokeMethod( m_parent, "update", Qt::QueuedConnection, Q_ARG( QModelIndex, index ) ); @@ -380,7 +387,12 @@ SourceDelegate::hovered(const QModelIndex &index, const QMimeData *mimeData) } m_newDropHoverIndex = index; - m_dropMimeData = const_cast< QMimeData* >( mimeData ); + m_dropMimeData->clear(); + foreach ( const QString &mimeDataFormat, mimeData->formats() ) + { + m_dropMimeData->setData( mimeDataFormat, mimeData->data( mimeDataFormat ) ); + } + m_expandedMap.insert( m_newDropHoverIndex, new AnimationHelper( m_newDropHoverIndex ) ); connect( m_expandedMap.value( m_newDropHoverIndex ), SIGNAL( finished( QModelIndex ) ), SLOT( animationFinished( QModelIndex ) ) ); diff --git a/src/sourcetree/sourcedelegate.h b/src/sourcetree/sourcedelegate.h index 2c2313cb9..442c19a37 100644 --- a/src/sourcetree/sourcedelegate.h +++ b/src/sourcetree/sourcedelegate.h @@ -14,6 +14,7 @@ class SourceDelegate : public QStyledItemDelegate Q_OBJECT public: SourceDelegate( QAbstractItemView* parent = 0 ); + ~SourceDelegate(); void hovered( const QModelIndex &index, const QMimeData *mimeData ); void dragLeaveEvent();