void tableTemplateWidget::deleteTemplate(void) { if (templateId == 0) return; QMessageBox delTmp(QMessageBox::Question, tr("Deleting template!"), tr("Do you want delete template ?"), QMessageBox::Yes | QMessageBox::No); int code = delTmp.exec(); if (code == QMessageBox::No) return; QSqlQuery query; QSqlError le; query.prepare("DELETE FROM crossword.private_data WHERE _template = ?;"); query.addBindValue(QVariant(templateId)); query.exec(); le = query.lastError(); if (le.type() != QSqlError::NoError) qDebug() << "1. deleteTemplate: " << le.text(); query.prepare("DELETE FROM crossword.grids WHERE _template = ?;"); query.addBindValue(QVariant(templateId)); query.exec(); le = query.lastError(); if (le.type() != QSqlError::NoError) qDebug() << "2. deleteTemplate: " << le.text(); query.prepare("DELETE FROM crossword.templates WHERE _id = ?;"); query.addBindValue(QVariant(templateId)); query.exec(); le = query.lastError(); if (le.type() != QSqlError::NoError) qDebug() << "3. deleteTemplate: " << le.text(); for (int i = 0; i < numCol; i++) removeColumn(0); setRowCount(0); sb->showMessage(tr("Template deleted"), 2000); // need for templateListWidget emit deletedFromDB(templateId); numCol = numRow = 0; templateId = 0; countWords = 0; wi.clear(); }
void Execute(VMachine *vm) { int ip; VM_Stack* stack = newStack(); int ipc; int i,j,k; ip=0; while(ip < vm->ninstr) { ipc = 1; switch (vm->instr[ip].opcode) { case OP_NOP: break; case OP_PUSH : Push(&stack,newTmpCopyI(vm,vm->instr[ip].operand)); break; case OP_GETTOP : Assign(&(vm->str[vm->instr[ip].operand]),vm->str[stack->llstart->data]->s); break; case OP_DISCARD : delTmp(vm,Pop(&stack)); break; case OP_PRINT : i = Pop(&stack); Print(vm->str[i]); delTmp(vm,i); break; case OP_INPUT : Input(&(vm->str[vm->instr[ip].operand])); break; case OP_JMP : ipc = vm->instr[ip].operand; break; case OP_JMPF : i = Pop(&stack); if (i == ST_FALSE) ipc = vm->instr[ip].operand; break; case OP_STR_EQUAL : i = Pop(&stack); j = Pop(&stack); if(strcmp(vm->str[i]->s,vm->str[j]->s) == 0) k = ST_TRUE; else k = ST_FALSE ; delTmp(vm,i);delTmp(vm,j); Push(&stack,k); break; case OP_BOOL_EQUAL : i = Pop(&stack); j = Pop(&stack); if (i == j) k = ST_TRUE ; else k = ST_FALSE; Push(&stack,k); break; case OP_BOOL2STR : i = Pop(&stack); if (i == ST_FALSE) i = newTmpCopyS(vm,"false"); else i = newTmpCopyS(vm,"true"); Push(&stack,i); break; case OP_CONCAT : i = Pop(&stack); j = Pop(&stack); k = newTmpCopyI(vm,j); Concat(vm->str[k],vm->str[i]); delTmp(vm,i);delTmp(vm,j); Push(&stack,k); break; } ip += ipc; } }