1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-04-14 04:51:53 +02:00

Draw proper drop index, since on some platforms (OS X :( ) visualRect() and indexAt() aren't commutative...

This commit is contained in:
Leo Franchi 2011-08-05 11:44:45 -04:00
parent 0c4746430b
commit 7feb9d5249
2 changed files with 7 additions and 2 deletions

View File

@ -435,6 +435,7 @@ SourceTreeView::dragEnterEvent( QDragEnterEvent* event )
{
m_dragging = true;
m_dropRect = QRect();
m_dropIndex = QPersistentModelIndex();
qDebug() << "Accepting Drag Event";
event->setDropAction( Qt::CopyAction );
@ -450,6 +451,8 @@ SourceTreeView::dragLeaveEvent( QDragLeaveEvent* event )
m_dragging = false;
setDirtyRegion( m_dropRect );
m_dropIndex = QPersistentModelIndex();
}
@ -464,6 +467,7 @@ SourceTreeView::dragMoveEvent( QDragMoveEvent* event )
setDirtyRegion( m_dropRect );
const QPoint pos = event->pos();
const QModelIndex index = indexAt( pos );
m_dropIndex = QPersistentModelIndex( index );
if ( index.isValid() )
{
@ -497,6 +501,7 @@ SourceTreeView::dropEvent( QDropEvent* event )
{
QTreeView::dropEvent( event );
m_dragging = false;
m_dropIndex = QPersistentModelIndex();
}
@ -527,8 +532,7 @@ SourceTreeView::paintEvent( QPaintEvent* event )
if ( m_dragging && !m_dropRect.isEmpty() )
{
QPainter painter( viewport() );
const QModelIndex index = indexAt( m_dropRect.topLeft() );
const QRect itemRect = visualRect( index );
const QRect itemRect = visualRect( m_dropIndex );
QStyleOptionViewItemV4 opt;
opt.initFrom( this );

View File

@ -94,6 +94,7 @@ private:
bool m_dragging;
QRect m_dropRect;
QPersistentModelIndex m_dropIndex;
};
#endif // SOURCETREEVIEW_H