void TableWidget::contextMenu(const QPoint &p, bool init ){ /* QModelIndex index = this->indexAt(p); int col = index.column(); //int row = index.row(); QString str = "file"; ColumnType t = ORIGIN; if(col==TRACK || col==TITLE){ str = "result"; t = RESULT; } */ QMenu *c = new QMenu(this); QAction* selectAction = new QAction("Check selected rows", this); selectAction->setData(true); connect(selectAction, SIGNAL(triggered()), this, SLOT(checkRows())); QAction* deselectAction = new QAction("Uncheck selected rows", this); deselectAction->setData(false); connect(deselectAction, SIGNAL(triggered()), this, SLOT(checkRows())); //move up/down actions for this QAction* moveResultUpAction = new QAction("Move result up", this); moveResultUpAction->setData(RESULT); moveResultUpAction->setShortcut(tr("Ctrl+U")); connect(moveResultUpAction, SIGNAL(triggered()), this, SLOT(moveRowUp())); QAction* moveResultDownAction = new QAction("Move result down", this); moveResultDownAction->setData(RESULT); moveResultDownAction->setShortcut(tr("Ctrl+D")); connect(moveResultDownAction, SIGNAL(triggered()), this, SLOT(moveRowDown())); QAction* moveResultToAction = new QAction("Move result to...", this); moveResultToAction->setData(RESULT); moveResultToAction->setShortcut(tr("Ctrl+T")); connect(moveResultToAction, SIGNAL(triggered()), this, SLOT(moveRowTo())); QAction* moveOriginUpAction = new QAction("Move file up", this); moveOriginUpAction->setData(ORIGIN); moveOriginUpAction->setShortcut(tr("Ctrl+Alt+U")); connect(moveOriginUpAction, SIGNAL(triggered()), this, SLOT(moveRowUp())); QAction* moveOriginDownAction = new QAction("Move file down", this); moveOriginDownAction->setData(ORIGIN); moveOriginDownAction->setShortcut(tr("Ctrl+Alt+D")); connect(moveOriginDownAction, SIGNAL(triggered()), this, SLOT(moveRowDown())); QAction* moveOriginToAction = new QAction("Move file to...", this); moveOriginToAction->setData(ORIGIN); moveOriginToAction->setShortcut(tr("Ctrl+Alt+T")); connect(moveOriginToAction, SIGNAL(triggered()), this, SLOT(moveRowTo())); QAction* sortEnabledAction = new QAction(tr("Sorting enabled"), this); sortEnabledAction->setCheckable(true); sortEnabledAction->setChecked( this->isSortingEnabled() ); connect(sortEnabledAction, SIGNAL(toggled(bool)), this, SLOT(enableSorting(bool))); resizeColumnAction->setShortcut(tr("Ctrl+R")); connect(resizeColumnAction, SIGNAL(toggled(bool)), this, SLOT(resizeColumns(bool))); connect(resizeRowAction, SIGNAL(toggled(bool)), this, SLOT(resizeRows(bool))); QAction* deleteAction = new QAction(tr("Delete selected cells"), this); deleteAction->setShortcut(tr("Ctrl+Del")); connect(deleteAction, SIGNAL(triggered()), this, SLOT(deleteCells())); QAction* insertBlankFileAction = new QAction("Insert empty file", this); insertBlankFileAction->setData(ORIGIN); connect(insertBlankFileAction, SIGNAL(triggered()), this, SLOT(insertBlankRow())); QAction* insertBlankResultAction = new QAction("Insert empty result", this); insertBlankResultAction->setData(RESULT); connect(insertBlankResultAction, SIGNAL(triggered()), this, SLOT(insertBlankRow())); QAction* copyAction = new QAction(tr("Copy"), this); copyAction->setShortcut(tr("Ctrl+C")); connect(copyAction, SIGNAL(triggered()), this, SLOT(copyCells())); QAction* pasteAction = new QAction(tr("Paste"), this); pasteAction->setShortcut(tr("Ctrl+V")); connect(pasteAction, SIGNAL(triggered()), this, SLOT(paste())); QAction* resetAction = new QAction(tr("Reset"), this); connect(resetAction, SIGNAL(triggered()), this, SLOT(resetTable())); QMenu* matchByMenu = new QMenu(tr("Match results by..."), this); connect(matchByTrackAction, SIGNAL(triggered(bool)), this, SLOT(matchBy(bool))); connect(matchByTitleAction, SIGNAL(triggered(bool)), this, SLOT(matchBy(bool))); connect(dontMatchAction, SIGNAL(triggered(bool)), this, SLOT(matchBy(bool))); connect(matchByTrackTitleAction, SIGNAL(triggered(bool)), this, SLOT(matchBy(bool))); connect(matchByTitleTrackAction, SIGNAL(triggered(bool)), this, SLOT(matchBy(bool))); connect(matchByFileNameAction, SIGNAL(triggered(bool)), this, SLOT(matchBy(bool))); matchByMenu->addAction( dontMatchAction ); matchByMenu->addAction( matchByTitleAction ); matchByMenu->addAction( matchByTrackAction ); matchByMenu->addAction( matchByTrackTitleAction ); matchByMenu->addAction( matchByTitleTrackAction ); matchByMenu->addAction( matchByFileNameAction ); c->addMenu(matchByMenu); c->addSeparator(); //if(col==FILE_NAME){ c->addAction(deselectAction); c->addAction(selectAction); c->addSeparator(); //} c->addAction(moveResultUpAction); c->addAction(moveResultDownAction); c->addAction(moveResultToAction); c->addAction(moveOriginUpAction); c->addAction(moveOriginDownAction); c->addAction(moveOriginToAction); c->addSeparator(); c->addAction(resizeColumnAction); c->addAction(resizeRowAction); c->addAction(sortEnabledAction); c->addSeparator(); c->addAction(copyAction); c->addAction(pasteAction); c->addAction(deleteAction); c->addSeparator(); c->addAction(insertBlankFileAction); c->addAction(insertBlankResultAction); c->addSeparator(); c->addAction(resetAction); QPoint globalPos = this->mapToGlobal(p); //menu->exec( globalPos ); if(!init){ c->exec(globalPos); }else{ this->addAction( dontMatchAction ); this->addAction( matchByTitleAction ); this->addAction( matchByTrackAction ); this->addAction( matchByTrackTitleAction ); this->addAction( matchByTitleTrackAction ); this->addAction( matchByFileNameAction ); this->addAction(deselectAction); this->addAction(selectAction); this->addAction(moveResultUpAction); this->addAction(moveResultDownAction); this->addAction(moveResultToAction); this->addAction(moveOriginUpAction); this->addAction(moveOriginDownAction); this->addAction(moveOriginToAction); this->addAction(resizeColumnAction); this->addAction(resizeRowAction); this->addAction(sortEnabledAction); this->addAction(copyAction); this->addAction(pasteAction); this->addAction(deleteAction); this->addAction(insertBlankFileAction); this->addAction(insertBlankResultAction); } }
// if return true: the card is played and added on the tbale successfully // return false: the suit of the card goes weird //constructor Table::Table(){ resetTable(); }