void CGRequestRepairHandler::execute (CGRequestRepair* pPacket , Player* pPlayer) throw(ProtocolException , Error) { __BEGIN_TRY __BEGIN_DEBUG_EX #ifdef __GAME_SERVER__ Assert(pPacket != NULL); Assert(pPlayer != NULL); ObjectID_t ITEMOID = pPacket->getObjectID(); GamePlayer* pGamePlayer = dynamic_cast<GamePlayer*>(pPlayer); Creature* pPC = pGamePlayer->getCreature(); bool bSlayer = false; bool bVampire = false; bool bOusters = false; Item* pItem = NULL; // 플레이어가 슬레이어인지 뱀파이어인지 구분. if (pPC->isSlayer()) bSlayer = true; else if (pPC->isVampire()) bVampire = true; else if (pPC->isOusters()) bOusters = true; else throw ProtocolException("CGRequestRepairHandler::execute() : Unknown player creature!"); if (ITEMOID == 0) { // ObjectID가 0이라면 모든 아이템을 수리하고자 하는 것이다. executeAll(pPacket, pPlayer); } else { if (bSlayer) pItem = (dynamic_cast<Slayer*>(pPC))->findItemOID(ITEMOID); else if (bVampire) pItem = (dynamic_cast<Vampire*>(pPC))->findItemOID(ITEMOID); else if (bOusters) pItem = (dynamic_cast<Ousters*>(pPC))->findItemOID(ITEMOID); // 플레이어가 아이템을 가지고 있다면 if (pItem != NULL) { // 그 아이템이 모터 사이클 키라면... if (pItem->getItemClass() == Item::ITEM_CLASS_KEY && pItem->getItemType() == 2) { executeMotorcycle(pPacket, pPlayer); return; } else executeNormal(pPacket, pPlayer); } else { // 아이템이 없으니, 당연히 수리할 수 없다. GCNPCResponse response; response.setCode(NPC_RESPONSE_REPAIR_FAIL_ITEM_NOT_EXIST); pPlayer->sendPacket(&response); } } #endif __END_DEBUG_EX __END_CATCH }
/** * Execute the current selection from the editor. */ void ScriptFileInterpreter::executeSelection(const Script::ExecutionMode mode) { if ((m_editor->hasSelectedText() && (!m_editor->selectedText().isEmpty()))) { int firstLineOffset(0), unused(0); m_editor->getSelection(&firstLineOffset, &unused, &unused, &unused); executeCode(ScriptCode(m_editor->selectedText(), firstLineOffset), mode); } else { executeAll(mode); } }
ScriptEdit::ScriptEdit(ScriptingEnv *env, QWidget *parent, QString name) : QTextEdit(parent, name), scripted(env), d_error(false), d_changing_fmt(false) { myScript = scriptEnv->newScript("", this, name); connect(myScript, SIGNAL(error(const QString &, const QString &, int)), this, SLOT(insertErrorMsg(const QString &))); connect(myScript, SIGNAL(print(const QString &)), this, SLOT(scriptPrint(const QString &))); setLineWrapMode(NoWrap); setTextFormat(Qt::PlainText); setAcceptRichText(false); setFamily("Monospace"); new SyntaxHighlighter(document()); d_fmt_default.setBackground(palette().brush(QPalette::Base)); d_fmt_success.setBackground(QBrush(QColor(128, 255, 128))); d_fmt_failure.setBackground(QBrush(QColor(255, 128, 128))); printCursor = textCursor(); actionExecute = new QAction(tr("E&xecute"), this); actionExecute->setShortcut(tr("Ctrl+J")); connect(actionExecute, SIGNAL(activated()), this, SLOT(execute())); actionExecuteAll = new QAction(tr("Execute &All"), this); actionExecuteAll->setShortcut(tr("Ctrl+Shift+J")); connect(actionExecuteAll, SIGNAL(activated()), this, SLOT(executeAll())); actionEval = new QAction(tr("&Evaluate Expression"), this); actionEval->setShortcut(tr("Ctrl+Return")); connect(actionEval, SIGNAL(activated()), this, SLOT(evaluate())); actionPrint = new QAction(IconLoader::load("edit-print", IconLoader::LightDark), tr("&Print"), this); connect(actionPrint, SIGNAL(activated()), this, SLOT(print())); actionImport = new QAction(tr("&Import"), this); connect(actionImport, SIGNAL(activated()), this, SLOT(importASCII())); actionExport = new QAction(tr("&Export"), this); connect(actionExport, SIGNAL(activated()), this, SLOT(exportASCII())); functionsMenu = new QMenu(this); Q_CHECK_PTR(functionsMenu); connect(functionsMenu, SIGNAL(triggered(QAction *)), this, SLOT(insertFunction(QAction *))); connect(document(), SIGNAL(contentsChange(int, int, int)), this, SLOT(handleContentsChange(int, int, int))); }
void CorrespondenceEvaluate::generateInbetween(double t) { auto scheduler = QSharedPointer<Scheduler>(new Scheduler); auto blender = QSharedPointer<TopoBlender>(new TopoBlender(GraphCorr, scheduler.data())); auto synthManager = QSharedPointer<SynthesisManager>(new SynthesisManager(GraphCorr, scheduler.data(), blender.data(), 1000)); synthManager->genSynData(); scheduler->timeStep = 1.0 / 100.0; scheduler->defaultSchedule(); scheduler->executeAll(); auto blendedModel = scheduler->allGraphs[t * (scheduler->allGraphs.size() - 1)]; synthManager->renderGraph(*blendedModel, "test", false, 5); }
/** * Show custom context menu event */ void ScriptFileInterpreter::showContextMenu(const QPoint &clickPoint) { QMenu context(this); context.addAction("&Save", m_editor, SLOT(saveToCurrentFile())); auto *copyAction = context.addAction("&Copy", m_editor, SLOT(copy())); context.insertSeparator(copyAction); context.addAction("C&ut", m_editor, SLOT(cut())); context.addAction("P&aste", m_editor, SLOT(paste())); auto *execAction = context.addAction("E&xecute Selection", this, SLOT(executeSelection())); context.insertSeparator(execAction); context.addAction("Execute &All", this, SLOT(executeAll())); context.exec(this->mapToGlobal(clickPoint)); }
void AutoBlend::doBlend() { auto selected = gallery->getSelected(); if (selected.size() < 2) return; for(auto t : results->items) t->deleteLater(); results->items.clear(); ((GraphicsScene*)scene())->showPopup("Please wait.."); for(int shapeI = 0; shapeI < selected.size(); shapeI++) { for(int shapeJ = shapeI + 1; shapeJ < selected.size(); shapeJ++) { //auto sourceName = selected.front()->data["targetName"].toString(); //auto targetName = selected.back()->data["targetName"].toString(); auto sourceName = selected[shapeI]->data.value("targetName").toString(); auto targetName = selected[shapeJ]->data.value("targetName").toString(); auto cacheSource = document->cacheModel(sourceName); auto cacheTarget = document->cacheModel(targetName); if(cacheSource == nullptr || cacheTarget == nullptr) continue; auto source = QSharedPointer<Structure::Graph>(cacheSource->cloneAsShapeGraph()); auto target = QSharedPointer<Structure::Graph>(cacheTarget->cloneAsShapeGraph()); auto gcorr = QSharedPointer<GraphCorresponder>(new GraphCorresponder(source.data(), target.data())); // Apply computed correspondence //if (false) // enable/disable auto correspondence { QVector<QPair<QString, QString> > all_pairs; for(auto n : source->nodes) { if (!document->datasetCorr[sourceName][n->id][targetName].empty()) { for(auto nj : document->datasetCorr[sourceName][n->id][targetName]) { all_pairs << qMakePair(n->id, nj); } } } ResolveCorrespondence(source.data(), target.data(), all_pairs, gcorr.data()); } gcorr->computeCorrespondences(); // Schedule blending sequence auto scheduler = QSharedPointer<Scheduler>(new Scheduler); auto blender = QSharedPointer<TopoBlender>(new TopoBlender(gcorr.data(), scheduler.data())); // Sample geometries int numSamples = 100; int reconLevel = 4; int LOD = widget->levelDetails->currentIndex(); switch (LOD){ case 0: numSamples = 100; reconLevel = 4; break; case 1: numSamples = 1000; reconLevel = 5; break; case 2: numSamples = 10000; reconLevel = 7; break; } /// Visualize schedule: if (false) { blender->parentWidget = new QMainWindow(); blender->parentWidget->show(); blender->setupUI(); QStringList corr; for(auto n : scheduler->activeGraph->nodes){ corr << QString("%1-%2").arg(n->id, n->property["correspond"].toString()); } QMessageBox::information(blender->parentWidget, "Correspondence", corr.join("\n")); } auto synthManager = QSharedPointer<SynthesisManager>(new SynthesisManager(gcorr.data(), scheduler.data(), blender.data(), numSamples)); synthManager->genSynData(); // Compute blending scheduler->timeStep = 1.0 / 100.0; scheduler->defaultSchedule(); scheduler->executeAll(); int numResults = widget->count->value(); for (int i = 0; i < numResults; i++) { double a = ((double(i) / (numResults - 1)) * 0.9) + 0.05; auto blendedModel = scheduler->allGraphs[a * (scheduler->allGraphs.size() - 1)]; synthManager->renderGraph(*blendedModel, "", false, reconLevel ); auto t = results->addTextItem(""); t->setCamera(cameraPos, cameraMatrix); QVariantMap data; data["name"] = QString("%1_%2").arg(sourceName).arg(targetName); t->setData(data); // Add parts of target shape for (auto n : blendedModel->nodes){ t->addAuxMesh(toBasicMesh(blendedModel->getMesh(n->id), n->vis_property["color"].value<QColor>())); } } } } ((GraphicsScene*)scene())->hidePopup(); }
int NDBT_TestSuite::execute(int argc, const char** argv){ int res = NDBT_FAILED; /* Arguments: Run only a subset of tests -n testname Which test to run Recommendations to test functions: --records Number of records to use(default: 10000) --loops Number of loops to execute in the test(default: 100) Other parameters should: * be calculated from the above two parameters * be divided into different test cases, ex. one testcase runs with FragmentType = Single and another perfoms the same test with FragmentType = Large * let the test case iterate over all/subset of appropriate parameters ex. iterate over FragmentType = Single to FragmentType = AllLarge Remeber that the intention is that it should be _easy_ to run a complete test suite without any greater knowledge of what should be tested ie. keep arguments at a minimum */ char **_argv= (char **)argv; if (!my_progname) my_progname= _argv[0]; ndb_opt_set_usage_funcs(short_usage_sub, usage); ndb_load_defaults(NULL, load_default_groups,&argc,&_argv); // Save pointer to memory allocated by 'ndb_load_defaults' char** defaults_argv= _argv; int ho_error; #ifndef DBUG_OFF opt_debug= "d:t:i:F:L"; #endif if ((ho_error=handle_options(&argc, &_argv, my_long_options, ndb_std_get_one_option))) { usage(); ndb_free_defaults(defaults_argv); return NDBT_ProgramExit(NDBT_WRONGARGS); } if (opt_verbose) setOutputLevel(2); // Show g_info else setOutputLevel(0); // Show only g_err ? records = opt_records; loops = opt_loops; timer = opt_timer; if (opt_nologging) setLogging(false); temporaryTables = opt_temporary; m_noddl = opt_noddl; m_forceShort = opt_forceShort; if (opt_seed == 0) { opt_seed = (unsigned)NdbTick_CurrentMillisecond(); } ndbout_c("random seed: %u", opt_seed); srand(opt_seed); srandom(opt_seed); global_flag_skip_invalidate_cache = 1; int num_tables= argc; if (argc == 0) num_tables = NDBT_Tables::getNumTables(); for(int i = 0; i<num_tables; i++) { if (argc == 0) m_tables_in_test.push_back(NDBT_Tables::getTable(i)->getName()); else m_tables_in_test.push_back(_argv[i]); } if (m_createTable) { for (unsigned t = 0; t < tests.size(); t++) { const char* createFuncName= NULL; NDBT_TESTFUNC* createFunc= NULL; const char* dropFuncName= NULL; NDBT_TESTFUNC* dropFunc= NULL; if (!m_noddl) { createFuncName= m_createAll ? "runCreateTable" : "runCreateTable"; createFunc= m_createAll ? &runCreateTables : &runCreateTable; dropFuncName= m_createAll ? "runDropTables" : "runDropTable"; dropFunc= m_createAll ? &runDropTables : &runDropTable; } else { /* No DDL allowed, so we substitute 'do nothing' variants * of the create + drop table test procs */ createFuncName= "runCheckTableExists"; createFunc= &runCheckTableExists; dropFuncName= "runEmptyDropTable"; dropFunc= &runEmptyDropTable; } NDBT_TestCaseImpl1* pt= (NDBT_TestCaseImpl1*)tests[t]; NDBT_Initializer* pti = new NDBT_Initializer(pt, createFuncName, *createFunc); pt->addInitializer(pti, true); NDBT_Finalizer* ptf = new NDBT_Finalizer(pt, dropFuncName, *dropFunc); pt->addFinalizer(ptf); } for (unsigned t = 0; t < explicitTests.size(); t++) { const char* createFuncName= NULL; NDBT_TESTFUNC* createFunc= NULL; const char* dropFuncName= NULL; NDBT_TESTFUNC* dropFunc= NULL; if (!m_noddl) { createFuncName= m_createAll ? "runCreateTable" : "runCreateTable"; createFunc= m_createAll ? &runCreateTables : &runCreateTable; dropFuncName= m_createAll ? "runDropTables" : "runDropTable"; dropFunc= m_createAll ? &runDropTables : &runDropTable; } else { /* No DDL allowed, so we substitute 'do nothing' variants * of the create + drop table test procs */ createFuncName= "runCheckTableExists"; createFunc= &runCheckTableExists; dropFuncName= "runEmptyDropTable"; dropFunc= &runEmptyDropTable; } NDBT_TestCaseImpl1* pt= (NDBT_TestCaseImpl1*)explicitTests[t]; NDBT_Initializer* pti = new NDBT_Initializer(pt, createFuncName, *createFunc); pt->addInitializer(pti, true); NDBT_Finalizer* ptf = new NDBT_Finalizer(pt, dropFuncName, *dropFunc); pt->addFinalizer(ptf); } } if (opt_print == true){ printExecutionTree(); ndb_free_defaults(defaults_argv); return 0; } if (opt_print_html == true){ printExecutionTreeHTML(); ndb_free_defaults(defaults_argv); return 0; } if (opt_print_cases == true){ printCases(); ndb_free_defaults(defaults_argv); return 0; } Ndb_cluster_connection con(opt_ndb_connectstring, opt_ndb_nodeid); if(m_connect_cluster && con.connect(12, 5, 1)) { ndb_free_defaults(defaults_argv); return NDBT_ProgramExit(NDBT_FAILED); } if(argc == 0){ // No table specified res = executeAll(con, opt_testname); } else { testSuiteTimer.doStart(); for(int i = 0; i<argc; i++){ executeOne(con, _argv[i], opt_testname); } testSuiteTimer.doStop(); res = report(opt_testname); } ndb_free_defaults(defaults_argv); return NDBT_ProgramExit(res); }
ScriptEdit::ScriptEdit(ScriptingEnv *env, QWidget *parent, const char *name) : QTextEdit(parent, name), scripted(env), d_error(false), d_completer(0), d_file_name(QString::null), d_search_string(QString::null) { myScript = scriptEnv->newScript("", this, name); connect(myScript, SIGNAL(error(const QString&, const QString&, int)), this, SLOT(insertErrorMsg(const QString&))); connect(myScript, SIGNAL(print(const QString&)), this, SLOT(scriptPrint(const QString&))); setLineWrapMode(NoWrap); setUndoRedoEnabled(true); setTextFormat(Qt::PlainText); setAcceptRichText (false); #ifdef SCRIPTING_PYTHON if (scriptEnv->name() == QString("Python")) d_highlighter = new PythonSyntaxHighlighter(this); else d_highlighter = NULL; #endif d_fmt_default.setBackground(palette().brush(QPalette::Base)); printCursor = textCursor(); scriptsDirPath = qApp->applicationDirPath(); actionExecute = new QAction(tr("E&xecute"), this); actionExecute->setShortcut( tr("Ctrl+J") ); connect(actionExecute, SIGNAL(activated()), this, SLOT(execute())); actionExecuteAll = new QAction(tr("Execute &All"), this); actionExecuteAll->setShortcut( tr("Ctrl+Shift+J") ); connect(actionExecuteAll, SIGNAL(activated()), this, SLOT(executeAll())); actionEval = new QAction(tr("&Evaluate Expression"), this); actionEval->setShortcut( tr("Ctrl+Return") ); connect(actionEval, SIGNAL(activated()), this, SLOT(evaluate())); actionPrint = new QAction(QPixmap(fileprint_xpm), tr("&Print"), this); connect(actionPrint, SIGNAL(activated()), this, SLOT(print())); actionImport = new QAction(tr("&Import..."), this); actionImport->setShortcut(QKeySequence(Qt::CTRL+Qt::ALT+Qt::Key_O)); connect(actionImport, SIGNAL(activated()), this, SLOT(importASCII())); QShortcut *accelImport = new QShortcut(actionImport->shortcut(), this); connect(accelImport, SIGNAL(activated()), this, SLOT(importASCII())); actionSave = new QAction(QPixmap(filesave_xpm), tr("&Save"), this); actionSave->setShortcut(QKeySequence(Qt::CTRL+Qt::ALT+Qt::Key_S)); connect(actionSave, SIGNAL(activated()), this, SLOT(save())); QShortcut *accelSave = new QShortcut(actionSave->shortcut(), this); connect(accelSave, SIGNAL(activated()), this, SLOT(save())); actionExport = new QAction(QIcon(QPixmap(filesaveas_xpm)), tr("Sa&ve as..."), this); connect(actionExport, SIGNAL(activated()), this, SLOT(exportASCII())); actionFind = new QAction(QPixmap(find_xpm), tr("&Find..."), this); actionFind->setShortcut(QKeySequence(Qt::CTRL+Qt::ALT+Qt::Key_F)); connect(actionFind, SIGNAL(activated()), this, SLOT(showFindDialog())); QShortcut *accelFind = new QShortcut(actionFind->shortcut(), this); connect(accelFind, SIGNAL(activated()), this, SLOT(showFindDialog())); actionReplace = new QAction(tr("&Replace..."), this); actionReplace->setShortcut(QKeySequence(Qt::CTRL+Qt::ALT+Qt::Key_R)); connect(actionReplace, SIGNAL(activated()), this, SLOT(replace())); QShortcut *accelReplace = new QShortcut(actionReplace->shortcut(), this); connect(accelReplace, SIGNAL(activated()), this, SLOT(replace())); actionFindNext = new QAction(tr("&Find next"), this); actionFindNext->setShortcut(QKeySequence(Qt::Key_F3)); connect(actionFindNext, SIGNAL(activated()), this, SLOT(findNext())); QShortcut *accelFindNext = new QShortcut(actionFindNext->shortcut(), this); connect(accelFindNext, SIGNAL(activated()), this, SLOT(findNext())); actionFindPrevious = new QAction(tr("&Find previous"), this); actionFindPrevious->setShortcut(QKeySequence(Qt::Key_F4)); connect(actionFindPrevious, SIGNAL(activated()), this, SLOT(findPrevious())); QShortcut *accelFindPrevious = new QShortcut(actionFindPrevious->shortcut(), this); connect(accelFindPrevious, SIGNAL(activated()), this, SLOT(findPrevious())); functionsMenu = new QMenu(this); Q_CHECK_PTR(functionsMenu); connect(functionsMenu, SIGNAL(triggered(QAction *)), this, SLOT(insertFunction(QAction *))); }
void ScriptWindow::initActions() { actionNew = new QAction(QPixmap(new_xpm), tr("&New"), this); actionNew->setShortcut( tr("Ctrl+N") ); connect(actionNew, SIGNAL(activated()), this, SLOT(newScript())); file->addAction(actionNew); actionOpen = new QAction(QPixmap(fileopen_xpm), tr("&Open..."), this); actionOpen->setShortcut( tr("Ctrl+O") ); connect(actionOpen, SIGNAL(activated()), this, SLOT(open())); file->addAction(actionOpen); actionSave = new QAction(QPixmap(filesave_xpm), tr("&Save"), this); actionSave->setShortcut( tr("Ctrl+S") ); connect(actionSave, SIGNAL(activated()), this, SLOT(save())); file->addAction(actionSave); actionSaveAs = new QAction(tr("Save &As..."), this); connect(actionSaveAs, SIGNAL(activated()), this, SLOT(saveAs())); file->addAction(actionSaveAs); actionPrint = new QAction(QPixmap(fileprint_xpm), tr("&Print"), this); actionPrint->setShortcut( tr("Ctrl+P") ); connect(actionPrint, SIGNAL(activated()), te, SLOT(print())); file->addAction(actionPrint); actionUndo = new QAction(QPixmap(undo_xpm), tr("&Undo"), this); actionUndo->setShortcut( tr("Ctrl+Z") ); connect(actionUndo, SIGNAL(activated()), te, SLOT(undo())); edit->addAction(actionUndo); actionUndo->setEnabled(false); actionRedo = new QAction(QPixmap(redo_xpm), tr("&Redo"), this); actionRedo->setShortcut( tr("Ctrl+Y") ); connect(actionRedo, SIGNAL(activated()), te, SLOT(redo())); edit->addAction(actionRedo); actionRedo->setEnabled(false); edit->insertSeparator(); actionCut = new QAction(QPixmap(cut_xpm), tr("&Cut"), this); actionCut->setShortcut( tr("Ctrl+x") ); connect(actionCut, SIGNAL(activated()), te, SLOT(cut())); edit->addAction(actionCut); actionCut->setEnabled(false); actionCopy = new QAction(QPixmap(copy_xpm), tr("&Copy"), this); actionCopy->setShortcut( tr("Ctrl+C") ); connect(actionCopy, SIGNAL(activated()), te, SLOT(copy())); edit->addAction(actionCopy); actionCopy->setEnabled(false); actionPaste = new QAction(QPixmap(paste_xpm), tr("&Paste"), this); actionPaste->setShortcut( tr("Ctrl+V") ); connect(actionPaste, SIGNAL(activated()), te, SLOT(paste())); edit->addAction(actionPaste); edit->insertSeparator(); actionShowLineNumbers = new QAction(tr("Show &Line Numbers"), this); actionShowLineNumbers->setCheckable(true); actionShowLineNumbers->setChecked(d_app->d_note_line_numbers); connect(actionShowLineNumbers, SIGNAL(toggled(bool)), d_line_number, SLOT(setVisible(bool))); edit->addAction(actionShowLineNumbers); actionExecute = new QAction(tr("E&xecute"), this); actionExecute->setShortcut( tr("CTRL+J") ); connect(actionExecute, SIGNAL(activated()), te, SLOT(execute())); run->addAction(actionExecute); actionExecuteAll = new QAction(tr("Execute &All"), this); actionExecuteAll->setShortcut( tr("CTRL+SHIFT+J") ); connect(actionExecuteAll, SIGNAL(activated()), te, SLOT(executeAll())); run->addAction(actionExecuteAll); actionEval = new QAction(tr("&Evaluate Expression"), this); actionEval->setShortcut( tr("CTRL+Return") ); connect(actionEval, SIGNAL(activated()), te, SLOT(evaluate())); run->addAction(actionEval); actionAlwaysOnTop = new QAction(tr("Always on &Top"), this); actionAlwaysOnTop->setCheckable(true); if (d_app) actionAlwaysOnTop->setChecked (d_app->d_script_win_on_top); windowMenu->addAction(actionAlwaysOnTop); connect(actionAlwaysOnTop, SIGNAL(toggled(bool)), this, SLOT(setAlwaysOnTop(bool))); actionHide = new QAction(tr("&Hide"), this); connect(actionHide, SIGNAL(activated()), this, SLOT(close())); windowMenu->addAction(actionHide); connect(te, SIGNAL(copyAvailable(bool)), actionCut, SLOT(setEnabled(bool))); connect(te, SIGNAL(copyAvailable(bool)), actionCopy, SLOT(setEnabled(bool))); connect(te, SIGNAL(undoAvailable(bool)), actionUndo, SLOT(setEnabled(bool))); connect(te, SIGNAL(redoAvailable(bool)), actionRedo, SLOT(setEnabled(bool))); }
int NDBT_TestSuite::execute(int argc, const char** argv){ int res = NDBT_FAILED; /* Arguments: Run only a subset of tests -n testname Which test to run Recommendations to test functions: --records Number of records to use(default: 10000) --loops Number of loops to execute in the test(default: 100) Other parameters should: * be calculated from the above two parameters * be divided into different test cases, ex. one testcase runs with FragmentType = Single and another perfoms the same test with FragmentType = Large * let the test case iterate over all/subset of appropriate parameters ex. iterate over FragmentType = Single to FragmentType = AllLarge Remeber that the intention is that it should be _easy_ to run a complete test suite without any greater knowledge of what should be tested ie. keep arguments at a minimum */ char **_argv= (char **)argv; if (!my_progname) my_progname= _argv[0]; const char *load_default_groups[]= { "mysql_cluster",0 }; load_defaults("my",load_default_groups,&argc,&_argv); int ho_error; #ifndef DBUG_OFF opt_debug= "d:t:i:F:L"; #endif if ((ho_error=handle_options(&argc, &_argv, my_long_options, ndb_std_get_one_option))) { usage(); return NDBT_ProgramExit(NDBT_WRONGARGS); } if (opt_print == true){ printExecutionTree(); return 0; } if (opt_print_html == true){ printExecutionTreeHTML(); return 0; } if (opt_print_cases == true){ printCases(); return 0; } if (opt_verbose) setOutputLevel(2); // Show g_info else setOutputLevel(0); // Show only g_err ? remote_mgm = opt_remote_mgm; records = opt_records; loops = opt_loops; timer = opt_timer; Ndb_cluster_connection con; if(con.connect(12, 5, 1)) { return NDBT_ProgramExit(NDBT_FAILED); } if (opt_seed == 0) { opt_seed = NdbTick_CurrentMillisecond(); } ndbout_c("random seed: %u", opt_seed); srand(opt_seed); srandom(opt_seed); global_flag_skip_invalidate_cache = 1; { Ndb ndb(&con, "TEST_DB"); ndb.init(1024); if (ndb.waitUntilReady(500)){ g_err << "Ndb was not ready" << endl; return NDBT_ProgramExit(NDBT_FAILED); } NdbDictionary::Dictionary* pDict = ndb.getDictionary(); int num_tables= argc; if (argc == 0) num_tables = NDBT_Tables::getNumTables(); for(int i = 0; i<num_tables; i++) { if (argc == 0) m_tables_in_test.push_back(NDBT_Tables::getTable(i)->getName()); else m_tables_in_test.push_back(_argv[i]); if (createAllTables == true) { const char *tab_name= m_tables_in_test[i].c_str(); const NdbDictionary::Table* pTab = pDict->getTable(tab_name); if (pTab && pDict->dropTable(tab_name) != 0) { g_err << "ERROR0: Failed to drop table " << tab_name << pDict->getNdbError() << endl; return NDBT_ProgramExit(NDBT_FAILED); } if(NDBT_Tables::createTable(&ndb, tab_name) != 0) { g_err << "ERROR1: Failed to create table " << tab_name << pDict->getNdbError() << endl; return NDBT_ProgramExit(NDBT_FAILED); } } } } if(argc == 0){ // No table specified res = executeAll(con, opt_testname); } else { testSuiteTimer.doStart(); for(int i = 0; i<argc; i++){ executeOne(con, _argv[i], opt_testname); } testSuiteTimer.doStop(); res = report(opt_testname); } if (res == NDBT_OK && createAllTables == true) { Ndb ndb(&con, "TEST_DB"); ndb.init(1024); if (ndb.waitUntilReady(500)){ g_err << "Ndb was not ready" << endl; return NDBT_ProgramExit(NDBT_FAILED); } NdbDictionary::Dictionary* pDict = ndb.getDictionary(); for(unsigned i = 0; i<m_tables_in_test.size(); i++) { pDict->dropTable(m_tables_in_test[i].c_str()); } } return NDBT_ProgramExit(res); }
QueryPanel::QueryPanel(QWidget* parent) : QWidget(parent), model(nullptr) { QBoxLayout* layout = new QVBoxLayout(this); layout->setContentsMargins(0,0,0,0); layout->setSpacing(0); QSplitter* splitter = new QSplitter(this); splitter->setOrientation(Qt::Vertical); { // top half: query editor QWidget* top = new QWidget(splitter); QBoxLayout* editorLayout = new QVBoxLayout(top); editorLayout->setContentsMargins(0,0,0,0); editor = new QPlainTextEdit(this); QFont f; f.setStyleHint(QFont::Monospace); new SqlHighlighter(editor->document()); editor->setFont(f); editorLayout->addWidget(editor); error = new QLabel(this); error->setWordWrap(true); error->hide(); error->setStyleSheet("QLabel{color:red;}"); error->setContentsMargins(8,8,8,8); editorLayout->addWidget(error); QAction* runQueryAction = new QAction(this); QKeySequence ctrlEnter(Qt::CTRL + Qt::Key_Return); runQueryAction->setShortcut(ctrlEnter); addAction(runQueryAction); QAction* runAllAction = new QAction(this); QKeySequence ctrlShiftEnter(Qt::CTRL + Qt::SHIFT + Qt::Key_Return); runAllAction->setShortcut(ctrlShiftEnter); addAction(runAllAction); QBoxLayout* toolbar = new QHBoxLayout(); toolbar->addStretch(); QPushButton* run = new QPushButton("Execute statement under cursor (" + ctrlEnter.toString(QKeySequence::NativeText) + ")", this); toolbar->addWidget(run); QPushButton* runall = new QPushButton("Execute all (" + ctrlShiftEnter.toString(QKeySequence::NativeText) + ")", this); toolbar->addWidget(runall); editorLayout->addLayout(toolbar); splitter->addWidget(top); connect(editor, SIGNAL(textChanged()), error, SLOT(hide())); connect(runQueryAction, SIGNAL(triggered()), this, SLOT(executeQuery())); connect(run, SIGNAL(clicked()), runQueryAction, SIGNAL(triggered())); connect(runAllAction, SIGNAL(triggered()), this, SLOT(executeAll())); connect(runall, SIGNAL(clicked()), runAllAction, SIGNAL(triggered())); } { // bottom half: results table QWidget* bottom = new QWidget(splitter); QBoxLayout* v = new QVBoxLayout(bottom); v->setContentsMargins(0,0,0,0); v->setSpacing(0); results = new TableView(this); results->setModel(model); v->addWidget(results); status = new QLabel(bottom); status->hide(); v->addWidget(status); bottom->setLayout(v); splitter->addWidget(bottom); } layout->addWidget(splitter); }
ScriptEdit::ScriptEdit(ScriptingEnv *env, QWidget *parent, const char *name) : QTextEdit(parent, name), scripted(env), d_error(false), d_completer(0), d_highlighter(0), d_file_name(QString::null), d_search_string(QString::null), d_output_widget(NULL) { myScript = scriptEnv->newScript("", this, name); connect(myScript, SIGNAL(error(const QString&, const QString&, int)), this, SLOT(insertErrorMsg(const QString&))); connect(myScript, SIGNAL(print(const QString&)), this, SLOT(scriptPrint(const QString&))); connect(myScript, SIGNAL(error(const QString&, const QString&, int)), this, SIGNAL(error(const QString&, const QString&, int))); setLineWrapMode(NoWrap); setUndoRedoEnabled(true); setTextFormat(Qt::PlainText); setAcceptRichText (false); setFocusPolicy(Qt::StrongFocus); rehighlight(); d_fmt_default.setBackground(palette().brush(QPalette::Base)); //Init completer based on parser built-in functions QStringList functions = MyParser::functionNamesList(); functions.sort(); QCompleter *completer = new QCompleter(this); completer->setModelSorting(QCompleter::CaseSensitivelySortedModel); completer->setCompletionMode(QCompleter::PopupCompletion); completer->setModel(new QStringListModel(functions, completer)); setCompleter(completer); printCursor = textCursor(); scriptsDirPath = qApp->applicationDirPath(); actionExecute = new QAction(tr("E&xecute"), this); actionExecute->setShortcut( tr("Ctrl+J") ); connect(actionExecute, SIGNAL(activated()), this, SLOT(execute())); actionExecuteAll = new QAction(QIcon(":/play.png"), tr("Execute &All"), this); actionExecuteAll->setShortcut( tr("Ctrl+Shift+J") ); connect(actionExecuteAll, SIGNAL(activated()), this, SLOT(executeAll())); actionEval = new QAction(tr("&Evaluate Expression"), this); actionEval->setShortcut( tr("Ctrl+Return") ); connect(actionEval, SIGNAL(activated()), this, SLOT(evaluate())); actionPrint = new QAction(QIcon(":/fileprint.png"), tr("&Print"), this); connect(actionPrint, SIGNAL(activated()), this, SLOT(print())); actionImport = new QAction(QIcon(":/fileopen.png"), tr("&Import..."), this); actionImport->setShortcut(QKeySequence(Qt::CTRL+Qt::ALT+Qt::Key_O)); connect(actionImport, SIGNAL(activated()), this, SLOT(importASCII())); actionSave = new QAction(QIcon(":/filesave.png"), tr("&Save"), this); actionSave->setShortcut(QKeySequence(Qt::CTRL+Qt::ALT+Qt::Key_S)); connect(actionSave, SIGNAL(activated()), this, SLOT(save())); actionExport = new QAction(QIcon(":/filesaveas.png"), tr("Sa&ve as..."), this); connect(actionExport, SIGNAL(activated()), this, SLOT(exportASCII())); actionFind = new QAction(QIcon(":/find.png"), tr("&Find..."), this); actionFind->setShortcut(QKeySequence(Qt::CTRL+Qt::ALT+Qt::Key_F)); connect(actionFind, SIGNAL(activated()), this, SLOT(showFindDialog())); actionReplace = new QAction(QIcon(":/replace.png"), tr("&Replace..."), this); actionReplace->setShortcut(QKeySequence(Qt::CTRL+Qt::Key_R)); connect(actionReplace, SIGNAL(activated()), this, SLOT(replace())); actionFindNext = new QAction(QIcon(":/find_next.png"), tr("&Find next"), this); actionFindNext->setShortcut(QKeySequence(Qt::Key_F3)); connect(actionFindNext, SIGNAL(activated()), this, SLOT(findNext())); actionFindPrevious = new QAction(QIcon(":/find_previous.png"), tr("&Find previous"), this); actionFindPrevious->setShortcut(QKeySequence(Qt::Key_F4)); connect(actionFindPrevious, SIGNAL(activated()), this, SLOT(findPrevious())); functionsMenu = new QMenu(this); Q_CHECK_PTR(functionsMenu); connect(functionsMenu, SIGNAL(triggered(QAction *)), this, SLOT(insertFunction(QAction *))); connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(matchParentheses())); }