extragear/multimedia/amarok/src/playlist/view/listview
Bart Cerneels
bart.cerneels at kde.org
Tue Dec 16 20:44:50 CET 2008
SVN commit 897767 by shanachie:
Use Ctrl+Right Click to quickly adjust the queue order in the Playlist.
This restores the basic functionality of the queue manager. It also uses the same key combo.
CCMAIL: amarok-devel at kde.org
M +45 -3 PrettyListView.cpp
--- trunk/extragear/multimedia/amarok/src/playlist/view/listview/PrettyListView.cpp #897766:897767
@@ -124,6 +124,14 @@
if ( !index.isValid() )
return;
+
+ Qt::KeyboardModifiers modifiers = event->modifiers();
+ const bool controlKeyPressed = modifiers & Qt::ControlModifier;
+ //Ctrl + Right Click is used for quick queue sorting
+ if ( controlKeyPressed )
+ {
+ return;
+ }
ViewCommon::trackMenu( this, &index, event->globalPos(), true );
event->accept();
@@ -217,7 +225,6 @@
{
if ( mouseEventInHeader( event ) && ( event->button() == Qt::LeftButton ) )
{
- //event->accept();
m_mousePressInHeader = true;
QModelIndex index = indexAt( event->pos() );
//only do this dance if header is not already selected
@@ -236,8 +243,43 @@
{
m_mousePressInHeader = false;
}
- QListView::mousePressEvent( event ); //this should always be forwarded, as it is used to determine the offset
- //relative to the mousr of the selection we are dragging!
+
+ //handle Ctrl + Right Click for quick queue sorting
+ Qt::KeyboardModifiers modifiers = event->modifiers();
+ const bool controlKeyPressed = modifiers & Qt::ControlModifier;
+ if ( ( event->button() == Qt::RightButton ) && controlKeyPressed )
+ {
+ QAbstractItemModel* plModel = model();
+
+ //move clicked items to row right after the last selected item.
+ int targetRow = selectedRows().isEmpty()
+ ? plModel->rowCount()
+ : selectedRows().last() + 1;
+ selectionModel()->clear();
+
+ event->accept();
+
+ QModelIndex index = indexAt( event->pos() );
+ QList<int> sr;
+ if( mouseEventInHeader( event ) )
+ {
+ int rows = index.data( GroupedTracksRole ).toInt();
+ for( int i = index.row(); i < index.row() + rows; i++ )
+ {
+ sr << i;
+ }
+ }
+ else
+ {
+ sr << index.row();
+ }
+ Controller::instance()->moveRows( sr, targetRow );
+ }
+ else
+ {
+ QListView::mousePressEvent( event ); //this should always be forwarded, as it is used to determine the offset
+ //relative to the mouse of the selection we are dragging!
+ }
}
void
More information about the Amarok-devel
mailing list