void ananasTreeView::ContextMenuAdd( QMenu* m ) { //--QLabel *caption = new QLabel( tr("<font color=darkblue><u><b>" "Context Menu</b></u></font>"), this ); //--caption->setAlignment( Qt::AlignCenter ); //--m->insertItem( caption ); //m->insertItem( tr("&Rename"), this, SLOT( itemRename() ), //Qt::CTRL+Qt::Key_R); QAction* rename = m->addAction(tr("&Rename")); rename->setShortcut(Qt::CTRL+Qt::Key_R); connect(rename,SIGNAL(triggered()),SLOT(itemRename())); //m->insertItem( tr("&Edit"), this, SLOT( itemEdit() ), //Qt::CTRL+Qt::Key_E ); QAction* edit = m->addAction(tr("&Edit")); edit->setShortcut(Qt::CTRL+Qt::Key_E); connect(edit,SIGNAL(triggered()),SLOT(itemEdit())); //m->insertItem( tr("&Delete"), this, SLOT( itemDelete() ), //Qt::CTRL+Qt::Key_D ); QAction* del = m->addAction(tr("&Delete")); del->setShortcut(Qt::CTRL+Qt::Key_D); connect(del,SIGNAL(triggered()),SLOT(itemDelete())); //m->insertItem( tr("&MoveUp"), this, SLOT( itemMoveUp() ), //Qt::CTRL+Qt::Key_U ); QAction* moveUp = m->addAction(tr("&MoveUp")); moveUp->setShortcut(Qt::CTRL+Qt::Key_U); connect(moveUp,SIGNAL(triggered()),SLOT(itemMoveUp())); //m->insertItem( tr("&MoveDown"), this, SLOT( itemMoveDown() ), //Qt::CTRL+Qt::Key_M ); QAction* moveDown = m->addAction(tr("&MoveDown")); moveDown->setShortcut(Qt::CTRL+Qt::Key_M); connect(moveDown,SIGNAL(triggered()),SLOT(itemMoveDown())); //m->insertItem( tr("&SaveItem"), this, SLOT( itemSave() ) ); QAction* saveItem = m->addAction(tr("&SaveItem")); connect(saveItem,SIGNAL(triggered()),SLOT(itemSave())); //m->insertItem( tr("&LoadItem"), this, SLOT( itemLoad() ) ); QAction* loadItem = m->addAction(tr("&LoadItem")); connect(loadItem,SIGNAL(triggered()),SLOT(itemLoad())); m->addSeparator(); };
void CoverArtScene::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) { CoverArtItem* item = (CoverArtItem*) this->itemAt(event->scenePos(), QTransform()); if (item) emit itemEdit(item->index()); }
void CoverArtScene::keyPressEvent(QKeyEvent *event) { if (event->key() == Qt::Key_Left) emit itemSelected(currentItem() - 1); if (event->key() == Qt::Key_Right) emit itemSelected(currentItem() + 1); if (event->key() == Qt::Key_End) emit itemSelected(-2); if (event->key() == Qt::Key_PageUp) emit itemSelected(currentItem() + 5); if (event->key() == Qt::Key_PageDown) emit itemSelected(currentItem() - 5); if (event->key() == Qt::Key_Home) emit itemSelected(-3); if (event->key() == Qt::Key_Enter) emit itemEdit(currentItem()); }