void FileView::contextMenuEvent( QContextMenuEvent *e ) { if( !model() ) return; //trying to do fancy stuff while showing places only leads to tears! if( model()->objectName() == "PLACESMODEL" ) { e->accept(); return; } QModelIndexList indices = selectedIndexes(); // Abort if nothing is selected if( indices.isEmpty() ) return; KMenu* menu = new KMenu( this ); QList<QAction *> actions = actionsForIndices( indices ); foreach( QAction * action, actions ) menu->addAction( action ); // Create Copy/Move to menu items // ported from old filebrowser QList<Collections::Collection*> writableCollections; QHash<Collections::Collection*, CollectionManager::CollectionStatus> hash = CollectionManager::instance()->collections(); QHash<Collections::Collection*, CollectionManager::CollectionStatus>::const_iterator it = hash.constBegin(); while( it != hash.constEnd() ) { Collections::Collection *coll = it.key(); if( coll && coll->isWritable() ) writableCollections.append( coll ); ++it; } if( !writableCollections.isEmpty() ) { QMenu *moveMenu = new QMenu( i18n( "Move to Collection" ), this ); foreach( Collections::Collection *coll, writableCollections ) { CollectionAction *moveAction = new CollectionAction( coll, this ); connect( moveAction, SIGNAL( triggered() ), this, SLOT( slotPrepareMoveTracks() ) ); moveMenu->addAction( moveAction ); }
foreach( Collections::Collection *coll, writableCollections ) { CollectionAction *moveAction = new CollectionAction( coll, &menu ); connect( moveAction, SIGNAL(triggered()), this, SLOT(slotPrepareMoveTracks()) ); moveMenu->addAction( moveAction ); }