Changeset View
Changeset View
Standalone View
Standalone View
src/browsers/filebrowser/FileView.cpp
Show First 20 Lines • Show All 66 Lines • ▼ Show 20 Line(s) | 66 | { | |||
---|---|---|---|---|---|
67 | setFrameStyle( QFrame::NoFrame ); | 67 | setFrameStyle( QFrame::NoFrame ); | ||
68 | setItemsExpandable( false ); | 68 | setItemsExpandable( false ); | ||
69 | setRootIsDecorated( false ); | 69 | setRootIsDecorated( false ); | ||
70 | setAlternatingRowColors( true ); | 70 | setAlternatingRowColors( true ); | ||
71 | setUniformRowHeights( true ); | 71 | setUniformRowHeights( true ); | ||
72 | setEditTriggers( EditKeyPressed ); | 72 | setEditTriggers( EditKeyPressed ); | ||
73 | 73 | | |||
74 | The::paletteHandler()->updateItemView( this ); | 74 | The::paletteHandler()->updateItemView( this ); | ||
75 | connect( The::paletteHandler(), SIGNAL(newPalette(QPalette)), | 75 | connect( The::paletteHandler(), &PaletteHandler::newPalette, | ||
76 | SLOT(newPalette(QPalette)) ); | 76 | this, &FileView::newPalette ); | ||
77 | } | 77 | } | ||
78 | 78 | | |||
79 | void | 79 | void | ||
80 | FileView::contextMenuEvent( QContextMenuEvent *e ) | 80 | FileView::contextMenuEvent( QContextMenuEvent *e ) | ||
81 | { | 81 | { | ||
82 | if( !model() ) | 82 | if( !model() ) | ||
83 | return; | 83 | return; | ||
84 | 84 | | |||
Show All 30 Lines | |||||
115 | } | 115 | } | ||
116 | if( !writableCollections.isEmpty() ) | 116 | if( !writableCollections.isEmpty() ) | ||
117 | { | 117 | { | ||
118 | QMenu *copyMenu = new QMenu( i18n( "Copy to Collection" ), &menu ); | 118 | QMenu *copyMenu = new QMenu( i18n( "Copy to Collection" ), &menu ); | ||
119 | copyMenu->setIcon( QIcon::fromTheme( "edit-copy" ) ); | 119 | copyMenu->setIcon( QIcon::fromTheme( "edit-copy" ) ); | ||
120 | foreach( Collections::Collection *coll, writableCollections ) | 120 | foreach( Collections::Collection *coll, writableCollections ) | ||
121 | { | 121 | { | ||
122 | CollectionAction *copyAction = new CollectionAction( coll, &menu ); | 122 | CollectionAction *copyAction = new CollectionAction( coll, &menu ); | ||
123 | connect( copyAction, SIGNAL(triggered()), this, SLOT(slotPrepareCopyTracks()) ); | 123 | connect( copyAction, &QAction::triggered, this, &FileView::slotPrepareCopyTracks ); | ||
124 | copyMenu->addAction( copyAction ); | 124 | copyMenu->addAction( copyAction ); | ||
125 | } | 125 | } | ||
126 | menu.addMenu( copyMenu ); | 126 | menu.addMenu( copyMenu ); | ||
127 | 127 | | |||
128 | QMenu *moveMenu = new QMenu( i18n( "Move to Collection" ), &menu ); | 128 | QMenu *moveMenu = new QMenu( i18n( "Move to Collection" ), &menu ); | ||
129 | moveMenu->setIcon( QIcon::fromTheme( "go-jump" ) ); | 129 | moveMenu->setIcon( QIcon::fromTheme( "go-jump" ) ); | ||
130 | foreach( Collections::Collection *coll, writableCollections ) | 130 | foreach( Collections::Collection *coll, writableCollections ) | ||
131 | { | 131 | { | ||
132 | CollectionAction *moveAction = new CollectionAction( coll, &menu ); | 132 | CollectionAction *moveAction = new CollectionAction( coll, &menu ); | ||
133 | connect( moveAction, SIGNAL(triggered()), this, SLOT(slotPrepareMoveTracks()) ); | 133 | connect( moveAction, &QAction::triggered, this, &FileView::slotPrepareMoveTracks ); | ||
134 | moveMenu->addAction( moveAction ); | 134 | moveMenu->addAction( moveAction ); | ||
135 | } | 135 | } | ||
136 | menu.addMenu( moveMenu ); | 136 | menu.addMenu( moveMenu ); | ||
137 | } | 137 | } | ||
138 | foreach( QAction *action, actionsForIndices( indices, OrganizeAction ) ) | 138 | foreach( QAction *action, actionsForIndices( indices, OrganizeAction ) ) | ||
139 | menu.addAction( action ); | 139 | menu.addAction( action ); | ||
140 | menu.addSeparator(); | 140 | menu.addSeparator(); | ||
141 | 141 | | |||
▲ Show 20 Lines • Show All 139 Lines • ▼ Show 20 Line(s) | 273 | { | |||
281 | m_moveDestinationCollection = action->collection(); | 281 | m_moveDestinationCollection = action->collection(); | ||
282 | 282 | | |||
283 | const KFileItemList list = selectedItems(); | 283 | const KFileItemList list = selectedItems(); | ||
284 | if( list.isEmpty() ) | 284 | if( list.isEmpty() ) | ||
285 | return; | 285 | return; | ||
286 | 286 | | |||
287 | // prevent bug 313003, require full metadata | 287 | // prevent bug 313003, require full metadata | ||
288 | TrackLoader* dl = new TrackLoader( TrackLoader::FullMetadataRequired ); // auto-deletes itself | 288 | TrackLoader* dl = new TrackLoader( TrackLoader::FullMetadataRequired ); // auto-deletes itself | ||
289 | connect( dl, SIGNAL(finished(Meta::TrackList)), SLOT(slotMoveTracks(Meta::TrackList)) ); | 289 | connect( dl, &TrackLoader::finished, this, &FileView::slotMoveTracks ); | ||
290 | dl->init( list.urlList() ); | 290 | dl->init( list.urlList() ); | ||
291 | } | 291 | } | ||
292 | 292 | | |||
293 | void | 293 | void | ||
294 | FileView::slotPrepareCopyTracks() | 294 | FileView::slotPrepareCopyTracks() | ||
295 | { | 295 | { | ||
296 | if( m_copyDestinationCollection ) | 296 | if( m_copyDestinationCollection ) | ||
297 | return; | 297 | return; | ||
298 | 298 | | |||
299 | CollectionAction *action = dynamic_cast<CollectionAction*>( sender() ); | 299 | CollectionAction *action = dynamic_cast<CollectionAction*>( sender() ); | ||
300 | if( !action ) | 300 | if( !action ) | ||
301 | return; | 301 | return; | ||
302 | 302 | | |||
303 | m_copyDestinationCollection = action->collection(); | 303 | m_copyDestinationCollection = action->collection(); | ||
304 | 304 | | |||
305 | const KFileItemList list = selectedItems(); | 305 | const KFileItemList list = selectedItems(); | ||
306 | if( list.isEmpty() ) | 306 | if( list.isEmpty() ) | ||
307 | return; | 307 | return; | ||
308 | 308 | | |||
309 | // prevent bug 313003, require full metadata | 309 | // prevent bug 313003, require full metadata | ||
310 | TrackLoader* dl = new TrackLoader( TrackLoader::FullMetadataRequired ); // auto-deletes itself | 310 | TrackLoader* dl = new TrackLoader( TrackLoader::FullMetadataRequired ); // auto-deletes itself | ||
311 | connect( dl, SIGNAL(finished(Meta::TrackList)), SLOT(slotCopyTracks(Meta::TrackList)) ); | 311 | connect( dl, &TrackLoader::finished, this, &FileView::slotMoveTracks ); | ||
312 | dl->init( list.urlList() ); | 312 | dl->init( list.urlList() ); | ||
313 | } | 313 | } | ||
314 | 314 | | |||
315 | void | 315 | void | ||
316 | FileView::slotCopyTracks( const Meta::TrackList& tracks ) | 316 | FileView::slotCopyTracks( const Meta::TrackList& tracks ) | ||
317 | { | 317 | { | ||
318 | if( !m_copyDestinationCollection ) | 318 | if( !m_copyDestinationCollection ) | ||
319 | return; | 319 | return; | ||
▲ Show 20 Lines • Show All 60 Lines • ▼ Show 20 Line(s) | 377 | { | |||
380 | if( indices.isEmpty() ) | 380 | if( indices.isEmpty() ) | ||
381 | return actions; // get out of here! | 381 | return actions; // get out of here! | ||
382 | 382 | | |||
383 | if( !m_appendAction ) | 383 | if( !m_appendAction ) | ||
384 | { | 384 | { | ||
385 | m_appendAction = new QAction( QIcon::fromTheme( "media-track-add-amarok" ), i18n( "&Add to Playlist" ), | 385 | m_appendAction = new QAction( QIcon::fromTheme( "media-track-add-amarok" ), i18n( "&Add to Playlist" ), | ||
386 | this ); | 386 | this ); | ||
387 | m_appendAction->setProperty( "popupdropper_svg_id", "append" ); | 387 | m_appendAction->setProperty( "popupdropper_svg_id", "append" ); | ||
388 | connect( m_appendAction, SIGNAL(triggered()), this, SLOT(slotAppendToPlaylist()) ); | 388 | connect( m_appendAction, &QAction::triggered, this, &FileView::slotAppendToPlaylist ); | ||
389 | } | 389 | } | ||
390 | if( type & PlaylistAction ) | 390 | if( type & PlaylistAction ) | ||
391 | actions.append( m_appendAction ); | 391 | actions.append( m_appendAction ); | ||
392 | 392 | | |||
393 | if( !m_loadAction ) | 393 | if( !m_loadAction ) | ||
394 | { | 394 | { | ||
395 | m_loadAction = new QAction( i18nc( "Replace the currently loaded tracks with these", | 395 | m_loadAction = new QAction( i18nc( "Replace the currently loaded tracks with these", | ||
396 | "&Replace Playlist" ), this ); | 396 | "&Replace Playlist" ), this ); | ||
397 | m_loadAction->setProperty( "popupdropper_svg_id", "load" ); | 397 | m_loadAction->setProperty( "popupdropper_svg_id", "load" ); | ||
398 | connect( m_loadAction, SIGNAL(triggered()), this, SLOT(slotReplacePlaylist()) ); | 398 | connect( m_loadAction, &QAction::triggered, this, &FileView::slotReplacePlaylist ); | ||
399 | } | 399 | } | ||
400 | if( type & PlaylistAction ) | 400 | if( type & PlaylistAction ) | ||
401 | actions.append( m_loadAction ); | 401 | actions.append( m_loadAction ); | ||
402 | 402 | | |||
403 | if( !m_moveToTrashAction ) | 403 | if( !m_moveToTrashAction ) | ||
404 | { | 404 | { | ||
405 | m_moveToTrashAction = new QAction( QIcon::fromTheme( "user-trash" ), i18n( "&Move to Trash" ), this ); | 405 | m_moveToTrashAction = new QAction( QIcon::fromTheme( "user-trash" ), i18n( "&Move to Trash" ), this ); | ||
406 | m_moveToTrashAction->setProperty( "popupdropper_svg_id", "delete_file" ); | 406 | m_moveToTrashAction->setProperty( "popupdropper_svg_id", "delete_file" ); | ||
407 | // key shortcut is only for display purposes here, actual one is determined by View in Model/View classes | 407 | // key shortcut is only for display purposes here, actual one is determined by View in Model/View classes | ||
408 | m_moveToTrashAction->setShortcut( Qt::Key_Delete ); | 408 | m_moveToTrashAction->setShortcut( Qt::Key_Delete ); | ||
409 | connect( m_moveToTrashAction, SIGNAL(triggered(Qt::MouseButtons,Qt::KeyboardModifiers)), | 409 | connect( m_moveToTrashAction, &QAction::triggered, this, &FileView::slotMoveToTrashWithoutModifiers ); | ||
410 | this, SLOT(slotMoveToTrash(Qt::MouseButtons,Qt::KeyboardModifiers)) ); | | |||
411 | } | 410 | } | ||
412 | if( type & OrganizeAction ) | 411 | if( type & OrganizeAction ) | ||
413 | actions.append( m_moveToTrashAction ); | 412 | actions.append( m_moveToTrashAction ); | ||
414 | 413 | | |||
415 | if( !m_deleteAction ) | 414 | if( !m_deleteAction ) | ||
416 | { | 415 | { | ||
417 | m_deleteAction = new QAction( QIcon::fromTheme( "remove-amarok" ), i18n( "&Delete" ), this ); | 416 | m_deleteAction = new QAction( QIcon::fromTheme( "remove-amarok" ), i18n( "&Delete" ), this ); | ||
418 | m_deleteAction->setProperty( "popupdropper_svg_id", "delete_file" ); | 417 | m_deleteAction->setProperty( "popupdropper_svg_id", "delete_file" ); | ||
419 | // key shortcut is only for display purposes here, actual one is determined by View in Model/View classes | 418 | // key shortcut is only for display purposes here, actual one is determined by View in Model/View classes | ||
420 | m_deleteAction->setShortcut( Qt::SHIFT + Qt::Key_Delete ); | 419 | m_deleteAction->setShortcut( Qt::SHIFT + Qt::Key_Delete ); | ||
421 | connect( m_deleteAction, SIGNAL(triggered(bool)), SLOT(slotDelete()) ); | 420 | connect( m_deleteAction, &QAction::triggered, this, &FileView::slotDelete ); | ||
422 | } | 421 | } | ||
423 | if( type & OrganizeAction ) | 422 | if( type & OrganizeAction ) | ||
424 | actions.append( m_deleteAction ); | 423 | actions.append( m_deleteAction ); | ||
425 | 424 | | |||
426 | if( !m_editAction ) | 425 | if( !m_editAction ) | ||
427 | { | 426 | { | ||
428 | m_editAction = new QAction( QIcon::fromTheme( "media-track-edit-amarok" ), | 427 | m_editAction = new QAction( QIcon::fromTheme( "media-track-edit-amarok" ), | ||
429 | i18n( "&Edit Track Details" ), this ); | 428 | i18n( "&Edit Track Details" ), this ); | ||
430 | m_editAction->setProperty( "popupdropper_svg_id", "edit" ); | 429 | m_editAction->setProperty( "popupdropper_svg_id", "edit" ); | ||
431 | connect( m_editAction, SIGNAL(triggered()), this, SLOT(slotEditTracks()) ); | 430 | connect( m_editAction, &QAction::triggered, this, &FileView::slotEditTracks ); | ||
432 | } | 431 | } | ||
433 | if( type & EditAction ) | 432 | if( type & EditAction ) | ||
434 | { | 433 | { | ||
435 | actions.append( m_editAction ); | 434 | actions.append( m_editAction ); | ||
436 | Meta::TrackList tracks = tracksForEdit(); | 435 | Meta::TrackList tracks = tracksForEdit(); | ||
437 | m_editAction->setVisible( !tracks.isEmpty() ); | 436 | m_editAction->setVisible( !tracks.isEmpty() ); | ||
438 | } | 437 | } | ||
439 | 438 | | |||
▲ Show 20 Lines • Show All 68 Lines • ▼ Show 20 Line(s) | 496 | { | |||
508 | 507 | | |||
509 | m_pd->show(); | 508 | m_pd->show(); | ||
510 | } | 509 | } | ||
511 | 510 | | |||
512 | QTreeView::startDrag( supportedActions ); | 511 | QTreeView::startDrag( supportedActions ); | ||
513 | 512 | | |||
514 | if( m_pd ) | 513 | if( m_pd ) | ||
515 | { | 514 | { | ||
516 | connect( m_pd, SIGNAL(fadeHideFinished()), m_pd, SLOT(clear()) ); | 515 | connect( m_pd, &PopupDropper::fadeHideFinished, m_pd, &PopupDropper::clear ); | ||
517 | m_pd->hide(); | 516 | m_pd->hide(); | ||
518 | } | 517 | } | ||
519 | 518 | | |||
520 | m_dragMutex.lock(); | 519 | m_dragMutex.lock(); | ||
521 | m_ongoingDrag = false; | 520 | m_ongoingDrag = false; | ||
522 | m_dragMutex.unlock(); | 521 | m_dragMutex.unlock(); | ||
523 | } | 522 | } | ||
524 | 523 | | |||
▲ Show 20 Lines • Show All 91 Lines • Show Last 20 Lines |