Commit 40b1e87c authored by Matěj Laitl's avatar Matěj Laitl
Browse files

{CollectionTree,PlaylistBrowser}View: fix doubleclick behaviour

Commit 2310a193 made it impossible to add an item to playlist
by double click in double click mode. This patch restores and tweaks
the original algorithm. (to keep bug 279513 fixed)

Used ideas from a patch by Yichao Yu, but implemented differently.

P.S.: Ralf, event heard about QRect::contains()? :-)

REVIEW: 109162
CCBUG: 279513
parent 9c0e08a2
......@@ -330,16 +330,14 @@ CollectionTreeView::mouseDoubleClickEvent( QMouseEvent *event )
return;
}
// that was a double click on the item itself or the expander clicked? (BR: 279513)
// code copied in src/browser/playlistbrowser/PlaylistBrowserView.cpp
bool reverse = isRightToLeft();
QRect rect = visualRect( index );
if( KGlobalSettings::singleClick() &&
event->button() == Qt::LeftButton &&
// code copied in PlaylistBrowserView::mouseDoubleClickEvent(), keep in sync
// mind bug 279513
bool isExpandable = model()->hasChildren( index );
bool wouldExpand = !visualRect( index ).contains( event->pos() ) || // clicked outside item, perhaps on expander icon
( isExpandable && !KGlobalSettings::singleClick() ); // we're in doubleClick
if( event->button() == Qt::LeftButton &&
event->modifiers() == Qt::NoModifier &&
( ( reverse && event->pos().x() < rect.right() ) ||
( !reverse && event->pos().x() > rect.left() ) ) )
!wouldExpand )
{
CollectionTreeItem *item = getItemFromIndex( index );
playChildTracks( item, Playlist::AppendAndPlay );
......@@ -347,7 +345,7 @@ CollectionTreeView::mouseDoubleClickEvent( QMouseEvent *event )
return;
}
Amarok::PrettyTreeView::mouseDoubleClickEvent( event );
PrettyTreeView::mouseDoubleClickEvent( event );
}
void
......
......@@ -185,9 +185,11 @@ PlaylistBrowserNS::PlaylistBrowserView::mouseDoubleClickEvent( QMouseEvent *even
return;
}
// code copied in src/browser/CollectionTreeView.cpp
// code copied in CollectionTreeView::mouseDoubleClickEvent(), keep in sync
// mind bug 279513
bool isExpandable = model()->hasChildren( index );
bool wouldExpand = isExpandable && !KGlobalSettings::singleClick(); // we're in doubleClick
bool wouldExpand = !visualRect( index ).contains( event->pos() ) || // clicked outside item, perhaps on expander icon
( isExpandable && !KGlobalSettings::singleClick() ); // we're in doubleClick
if( event->button() == Qt::LeftButton &&
event->modifiers() == Qt::NoModifier &&
!wouldExpand )
......@@ -196,7 +198,8 @@ PlaylistBrowserNS::PlaylistBrowserView::mouseDoubleClickEvent( QMouseEvent *even
event->accept();
return;
}
Amarok::PrettyTreeView::mouseDoubleClickEvent( event );
PrettyTreeView::mouseDoubleClickEvent( event );
}
void PlaylistBrowserNS::PlaylistBrowserView::contextMenuEvent( QContextMenuEvent *event )
......
Supports Markdown
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