//-------------------------------------------------------------- void testApp::keyPressed(int key) { currentScreen->keyPressed(key); switch (key) { case 32: if (currentScreen == &menuScreen) { deleteSaves(); menuScreen.EXPLODING = true; } break; case OF_KEY_F1: gameScreen.ENABLE_EDITOR = true; currentScreen = &gameScreen; menuScreen.fxEngineLoop.stop(); break; } }
void savesWidget::showCollectionContextMenu(const QPoint & pnt)//test code { /*if(hack2==1) { hack2=0; return; } else { hack2++; }*/ QPoint globalPos = ui.savesTable->mapToGlobal(pnt); /* QModelIndex index=ui.collectionList->indexAt(pnt);//get model index int cacheid =index.sibling(index.row(), 8).data(Qt::DisplayRole).toUInt(); QString path; QSqlQuery query2(dbcollect); query2.prepare("SELECT path FROM cache WHERE id =?"); query2.addBindValue(cacheid); query2.exec(); if(query2.first()) { path=query2.value(0).toString(); }*/ QMenu contextmenu; // QItemSelectionModel *select= NULL; select = ui.savesTable->selectionModel(); QModelIndexList list=select->selectedRows(); if(list.size()==0) return; if(list.size()==1) { QMenu* m2=contextmenu.addMenu("Copy File to"); if(ui.sourceselectCombo->currentIndex()==1) { m2->addAction("Local Folder"); m2->addAction("JPCSP"); m2->addAction("PCSP"); m2->addAction("PSPE4ALL"); } if(ui.sourceselectCombo->currentIndex()==2) { m2->addAction("PSP Device"); m2->addAction("JPCSP"); m2->addAction("PCSP"); m2->addAction("PSPE4ALL"); } if(ui.sourceselectCombo->currentIndex()==3) { m2->addAction("PSP Device"); m2->addAction("Local Folder"); m2->addAction("PCSP"); m2->addAction("PSPE4ALL"); } if(ui.sourceselectCombo->currentIndex()==4) { m2->addAction("PSP Device"); m2->addAction("Local Folder"); m2->addAction("JPCSP"); m2->addAction("PSPE4ALL"); } if(ui.sourceselectCombo->currentIndex()==5) { m2->addAction("PSP Device"); m2->addAction("Local Folder"); m2->addAction("JPCSP"); m2->addAction("PCSP"); } contextmenu.addAction("Delete File"); } else { QMenu* m2=contextmenu.addMenu("Copy Files to"); if(ui.sourceselectCombo->currentIndex()==1) { m2->addAction("Local Folder"); m2->addAction("JPCSP"); m2->addAction("PCSP"); m2->addAction("PSPE4ALL"); } if(ui.sourceselectCombo->currentIndex()==2) { m2->addAction("PSP Device"); m2->addAction("JPCSP"); m2->addAction("PCSP"); m2->addAction("PSPE4ALL"); } if(ui.sourceselectCombo->currentIndex()==3) { m2->addAction("PSP Device"); m2->addAction("Local Folder"); m2->addAction("PCSP"); m2->addAction("PSPE4ALL"); } if(ui.sourceselectCombo->currentIndex()==4) { m2->addAction("PSP Device"); m2->addAction("Local Folder"); m2->addAction("JPCSP"); m2->addAction("PSPE4ALL"); } if(ui.sourceselectCombo->currentIndex()==5) { m2->addAction("PSP Device"); m2->addAction("Local Folder"); m2->addAction("JPCSP"); m2->addAction("PCSP"); } contextmenu.addAction("Delete Files"); } //contextmenu.addAction("Compress to cso"); /*if(path.endsWith("iso",Qt::CaseInsensitive)) { contextmenu.addAction("Compress to cso"); } else if(path.endsWith("cso",Qt::CaseInsensitive)) { contextmenu.addAction("Convert to iso"); }*/ QAction* selectedItem = contextmenu.exec(globalPos); if(selectedItem==NULL) return; if(selectedItem->text()=="Delete File") { if (askDelete(1)) { QList<QString> paths; QString cacheid =list[0].sibling(list[0].row(), 5).data(Qt::DisplayRole).toString(); paths.append(cacheid); deleteSaves(paths); } } if(selectedItem->text()=="Delete Files") { if (askDelete(2)) { QList<QString> paths; for(int i=0; i<list.size(); i++) { QString cacheid =list[i].sibling(list[i].row(), 5).data(Qt::DisplayRole).toString(); paths.append(cacheid); } deleteSaves(paths); } } if(selectedItem->text()=="PCSP") { QList<QString> paths; for(int i=0; i<list.size(); i++) { QString cacheid =list[i].sibling(list[i].row(), 5).data(Qt::DisplayRole).toString(); paths.append(cacheid); } copySaves(paths,"PCSP"); } if(selectedItem->text()=="JPCSP") { QList<QString> paths; for(int i=0; i<list.size(); i++) { QString cacheid =list[i].sibling(list[i].row(), 5).data(Qt::DisplayRole).toString(); paths.append(cacheid); } copySaves(paths,"JPCSP"); } if(selectedItem->text()=="PSPE4ALL") { QList<QString> paths; for(int i=0; i<list.size(); i++) { QString cacheid =list[i].sibling(list[i].row(), 5).data(Qt::DisplayRole).toString(); paths.append(cacheid); } copySaves(paths,"PSPE4ALL"); } if(selectedItem->text()=="Local Folder") { QList<QString> paths; for(int i=0; i<list.size(); i++) { QString cacheid =list[i].sibling(list[i].row(), 5).data(Qt::DisplayRole).toString(); paths.append(cacheid); } copySaves(paths,"Local Folder"); } if(selectedItem->text()=="PSP Device") { QList<QString> paths; for(int i=0; i<list.size(); i++) { QString cacheid =list[i].sibling(list[i].row(), 5).data(Qt::DisplayRole).toString(); paths.append(cacheid); } copySaves(paths,"PSP Device"); } }